diff --git a/0001-Add-support-for-Linux-EFI-stub-loading.patch b/0001-Add-support-for-Linux-EFI-stub-loading.patch index 88fae3cdc2c17a763affb8a37ec8e7b3038800ff..e839b15b9ebc9ab91a1eb8c1b7ebef68b26927de 100644 --- a/0001-Add-support-for-Linux-EFI-stub-loading.patch +++ b/0001-Add-support-for-Linux-EFI-stub-loading.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From a66a5e1ff5e4ad4df490754bfe41839a43cad1d5 Mon Sep 17 00:00:00 2001 From: Matthew Garrett -Date: Tue, 10 Jul 2012 11:58:52 -0400 -Subject: [PATCH] Add support for Linux EFI stub loading. +Date: Fri, 5 Jul 2019 18:36:44 +0200 +Subject: [PATCH 001/220] Add support for Linux EFI stub loading. Also: @@ -29,7 +29,7 @@ moves the check into grub_dl_load_file. grub-core/kern/dl.c | 21 +++ grub-core/kern/efi/efi.c | 28 ++++ grub-core/kern/efi/mm.c | 32 ++++ - grub-core/loader/arm64/linux.c | 118 +++++++------- + grub-core/loader/arm64/linux.c | 112 +++++++------ grub-core/loader/arm64/xen_boot.c | 1 - grub-core/loader/efi/linux.c | 70 ++++++++ grub-core/loader/i386/efi/linux.c | 335 ++++++++++++++++++++++++++++++++++++++ @@ -38,17 +38,16 @@ moves the check into grub_dl_load_file. include/grub/arm64/linux.h | 10 ++ include/grub/efi/efi.h | 7 +- include/grub/efi/linux.h | 31 ++++ - include/grub/i386/linux.h | 1 + - 14 files changed, 620 insertions(+), 69 deletions(-) + 13 files changed, 616 insertions(+), 66 deletions(-) create mode 100644 grub-core/loader/efi/linux.c create mode 100644 grub-core/loader/i386/efi/linux.c create mode 100644 include/grub/efi/linux.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 9590e87d9c0..0b4b0c2122d 100644 +index 474a63e..581d9df 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -1626,13 +1626,6 @@ module = { +@@ -1709,13 +1709,6 @@ module = { enable = i386_pc; }; @@ -62,7 +61,7 @@ index 9590e87d9c0..0b4b0c2122d 100644 module = { name = ntldr; i386_pc = loader/i386/pc/ntldr.c; -@@ -1685,7 +1678,9 @@ module = { +@@ -1771,7 +1764,9 @@ module = { module = { name = linux; @@ -70,13 +69,13 @@ index 9590e87d9c0..0b4b0c2122d 100644 + i386_pc = loader/i386/pc/linux.c; + x86_64_efi = loader/i386/efi/linux.c; + i386_efi = loader/i386/efi/linux.c; + i386_xen_pvh = loader/i386/linux.c; xen = loader/i386/xen.c; i386_pc = lib/i386/pc/vesa_modes_table.c; - mips = loader/mips/linux.c; -@@ -1696,9 +1691,14 @@ module = { - arm_efi = loader/arm64/linux.c; - arm_uboot = loader/arm/linux.c; +@@ -1786,9 +1781,14 @@ module = { arm64 = loader/arm64/linux.c; + riscv32 = loader/riscv/linux.c; + riscv64 = loader/riscv/linux.c; + emu = loader/emu/linux.c; + fdt = lib/fdt.c; + @@ -89,7 +88,7 @@ index 9590e87d9c0..0b4b0c2122d 100644 module = { diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index e394cd96f8c..04e804d1668 100644 +index 48eb5e7..896bebf 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -38,6 +38,14 @@ @@ -126,9 +125,9 @@ index e394cd96f8c..04e804d1668 100644 + grub_boot_time ("Loading module %s", filename); - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE); diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 708581fcbde..c8a9d8307c0 100644 +index 6e1ceb9..a0faa40 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -273,6 +273,34 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, @@ -167,7 +166,7 @@ index 708581fcbde..c8a9d8307c0 100644 /* Search the mods section from the PE32/PE32+ image. This code uses diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index 42ad7c570a5..5cdf6c943f2 100644 +index b02fab1..a9e3710 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -113,6 +113,38 @@ grub_efi_drop_alloc (grub_efi_physical_address_t address, @@ -210,7 +209,7 @@ index 42ad7c570a5..5cdf6c943f2 100644 void * grub_efi_allocate_pages_real (grub_efi_physical_address_t address, diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index 1f86229f86b..6c00af98dce 100644 +index ef3e9f9..a312c66 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -29,6 +29,7 @@ @@ -221,7 +220,7 @@ index 1f86229f86b..6c00af98dce 100644 #include #include #include -@@ -40,6 +41,7 @@ static int loaded; +@@ -41,6 +42,7 @@ static int loaded; static void *kernel_addr; static grub_uint64_t kernel_size; @@ -229,7 +228,7 @@ index 1f86229f86b..6c00af98dce 100644 static char *linux_args; static grub_uint32_t cmdline_size; -@@ -66,7 +68,8 @@ grub_armxx_efi_linux_check_image (struct linux_armxx_kernel_header * lh) +@@ -67,7 +69,8 @@ grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh) static grub_err_t finalize_params_linux (void) { @@ -239,20 +238,41 @@ index 1f86229f86b..6c00af98dce 100644 void *fdt; -@@ -101,79 +104,70 @@ finalize_params_linux (void) +@@ -102,6 +105,25 @@ finalize_params_linux (void) if (grub_fdt_install() != GRUB_ERR_NONE) goto failure; -- return GRUB_ERR_NONE; -- --failure: -- grub_fdt_unload(); -- return grub_error(GRUB_ERR_BAD_OS, "failed to install/update FDT"); --} -- ++ 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: +@@ -109,72 +131,44 @@ failure: + return grub_error(GRUB_ERR_BAD_OS, "failed to install/update FDT"); + } + -grub_err_t --grub_armxx_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args) --{ +-grub_arch_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args) ++static void ++free_params (void) + { - grub_efi_memory_mapped_device_path_t *mempath; - grub_efi_handle_t image_handle; - grub_efi_boot_services_t *b; @@ -270,7 +290,8 @@ index 1f86229f86b..6c00af98dce 100644 - mempath[0].memory_type = GRUB_EFI_LOADER_DATA; - mempath[0].start_address = addr; - mempath[0].end_address = addr + size; -- ++ grub_efi_loaded_image_t *loaded_image = NULL; + - 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); @@ -281,74 +302,49 @@ index 1f86229f86b..6c00af98dce 100644 - (void *) addr, size, &image_handle); - if (status != GRUB_EFI_SUCCESS) - return grub_error (GRUB_ERR_BAD_OS, "cannot load image"); -- -- grub_dprintf ("linux", "linux command line: '%s'\n", args); -+ grub_dprintf ("linux", "Installed/updated FDT configuration table @ %p\n", -+ fdt); - - /* Convert command line to UCS-2 */ -- loaded_image = grub_efi_get_loaded_image (image_handle); -+ loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); -+ if (!loaded_image) -+ goto failure; -+ - loaded_image->load_options_size = len = -- (grub_strlen (args) + 1) * sizeof (grub_efi_char16_t); -+ (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_errno; -+ 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 *) args, len, NULL); -+ (grub_uint8_t *) linux_args, len, NULL); - -- grub_dprintf ("linux", "starting image %p\n", image_handle); -- status = b->start_image (image_handle, 0, NULL); -+ return GRUB_ERR_NONE; - -- /* 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)); -+failure: -+ grub_fdt_unload(); -+ return grub_error(GRUB_ERR_BAD_OS, "failed to install/update FDT"); -+} - -- return grub_errno; -+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)); ++ 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_dprintf ("linux", "linux command line: '%s'\n", args); +grub_err_t -+grub_armxx_efi_linux_boot_image (grub_addr_t addr, char *args) ++grub_arch_efi_linux_boot_image (grub_addr_t addr, char *args) +{ + grub_err_t retval; -+ + +- /* 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) + retval = finalize_params_linux (); + if (retval != GRUB_ERR_NONE) -+ return grub_errno; -+ + return grub_errno; + +- loaded_image->load_options_size = +- 2 * grub_utf8_to_utf16 (loaded_image->load_options, len, +- (grub_uint8_t *) args, len, NULL); +- +- grub_dprintf ("linux", "starting image %p\n", image_handle); +- status = b->start_image (image_handle, 0, NULL); + grub_dprintf ("linux", "linux command line: '%s'\n", args); -+ + +- /* 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 *)addr, handover_offset, (void *)addr); -+ + +- return grub_errno; + /* Never reached... */ + free_params(); + return retval; @@ -360,21 +356,21 @@ index 1f86229f86b..6c00af98dce 100644 - if (finalize_params_linux () != GRUB_ERR_NONE) - return grub_errno; - -- return (grub_armxx_efi_linux_boot_image((grub_addr_t)kernel_addr, +- return (grub_arch_efi_linux_boot_image((grub_addr_t)kernel_addr, - kernel_size, linux_args)); -+ return grub_armxx_efi_linux_boot_image((grub_addr_t)kernel_addr, linux_args); ++ return (grub_arch_efi_linux_boot_image((grub_addr_t)kernel_addr, linux_args)); } static grub_err_t -@@ -287,6 +281,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -288,6 +282,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), { grub_file_t file = 0; - struct linux_armxx_kernel_header lh; + struct linux_arch_kernel_header lh; + struct grub_armxx_linux_pe_header *pe; + grub_err_t err; grub_dl_ref (my_mod); - -@@ -331,6 +326,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -333,6 +328,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); @@ -391,20 +387,20 @@ index 1f86229f86b..6c00af98dce 100644 linux_args = grub_malloc (cmdline_size); if (!linux_args) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c -index 1003a0b9997..f35b16caa92 100644 +index 22cc25e..d9b7a9b 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -266,7 +266,6 @@ xen_boot (void) return err; - return grub_armxx_efi_linux_boot_image (xen_hypervisor->start, + return grub_arch_efi_linux_boot_image (xen_hypervisor->start, - xen_hypervisor->size, xen_hypervisor->cmdline); } diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c new file mode 100644 -index 00000000000..c24202a5dd1 +index 0000000..c24202a --- /dev/null +++ b/grub-core/loader/efi/linux.c @@ -0,0 +1,70 @@ @@ -480,7 +476,7 @@ index 00000000000..c24202a5dd1 +#pragma GCC diagnostic pop diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c new file mode 100644 -index 00000000000..3db82e782df +index 0000000..bb2616a --- /dev/null +++ b/grub-core/loader/i386/efi/linux.c @@ -0,0 +1,335 @@ @@ -589,8 +585,7 @@ index 00000000000..3db82e782df + + for (i = 0; i < argc; i++) + { -+ grub_file_filter_disable_compression (); -+ files[i] = grub_file_open (argv[i]); ++ files[i] = grub_file_open (argv[i], GRUB_FILE_TYPE_LINUX_INITRD | GRUB_FILE_TYPE_NO_DECOMPRESS); + if (! files[i]) + goto fail; + nfiles++; @@ -643,7 +638,7 @@ index 00000000000..3db82e782df + int argc, char *argv[]) +{ + grub_file_t file = 0; -+ struct linux_kernel_header lh; ++ struct linux_i386_kernel_header lh; + grub_ssize_t len, start, filelen; + void *kernel = NULL; + @@ -655,7 +650,7 @@ index 00000000000..3db82e782df + goto fail; + } + -+ file = grub_file_open (argv[0]); ++ file = grub_file_open (argv[0], GRUB_FILE_TYPE_LINUX_KERNEL); + if (! file) + goto fail; + @@ -731,7 +726,8 @@ index 00000000000..3db82e782df + grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE)); + grub_create_loader_cmdline (argc, argv, + linux_cmdline + sizeof (LINUX_IMAGE) - 1, -+ lh.cmdline_size - (sizeof (LINUX_IMAGE) - 1)); ++ lh.cmdline_size - (sizeof (LINUX_IMAGE) - 1), ++ GRUB_VERIFY_KERNEL_CMDLINE); + + lh.cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline; + @@ -820,10 +816,10 @@ index 00000000000..3db82e782df + grub_unregister_command (cmd_initrdefi); +} diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index b69cb7a3a7f..a3c87cf2fc2 100644 +index 47ea294..eea25ea 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c -@@ -468,14 +468,20 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), +@@ -470,14 +470,20 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), return grub_errno; } @@ -845,7 +841,7 @@ index b69cb7a3a7f..a3c87cf2fc2 100644 grub_register_command ("initrd16", grub_cmd_initrd, 0, N_("Load initrd.")); my_mod = mod; -@@ -484,5 +490,7 @@ GRUB_MOD_INIT(linux16) +@@ -486,5 +492,7 @@ GRUB_MOD_INIT(linux16) GRUB_MOD_FINI(linux16) { grub_unregister_command (cmd_linux); @@ -854,7 +850,7 @@ index b69cb7a3a7f..a3c87cf2fc2 100644 + grub_unregister_command (cmd_initrd16); } diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h -index 712ba17b9ba..5900fc8a40c 100644 +index 2e98a66..775297d 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -20,6 +20,7 @@ @@ -878,13 +874,13 @@ index 712ba17b9ba..5900fc8a40c 100644 + #if defined(__arm__) # define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM_MAGIC_SIGNATURE - # define linux_armxx_kernel_header linux_arm_kernel_header + # define linux_arch_kernel_header linux_arm_kernel_header +# define grub_armxx_linux_pe_header grub_arm_linux_pe_header #endif #if defined GRUB_MACHINE_UBOOT diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h -index 8655067e039..7b533b57139 100644 +index 4269adc..a3be9dd 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -19,6 +19,8 @@ @@ -909,13 +905,13 @@ index 8655067e039..7b533b57139 100644 + #if defined(__aarch64__) # define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM64_MAGIC_SIGNATURE - # define linux_armxx_kernel_header linux_arm64_kernel_header + # define linux_arch_kernel_header linux_arm64_kernel_header +# define grub_armxx_linux_pe_header grub_arm64_linux_pe_header #endif #endif /* ! GRUB_ARM64_LINUX_HEADER */ diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 2c6648d46fc..1061aee9726 100644 +index e90e00d..6840bfe 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -47,6 +47,9 @@ EXPORT_FUNC(grub_efi_allocate_fixed) (grub_efi_physical_address_t address, @@ -939,16 +935,16 @@ index 2c6648d46fc..1061aee9726 100644 @@ -95,8 +99,7 @@ void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); #include - grub_err_t grub_armxx_efi_linux_check_image(struct linux_armxx_kernel_header *lh); --grub_err_t grub_armxx_efi_linux_boot_image(grub_addr_t addr, grub_size_t size, + grub_err_t grub_arch_efi_linux_check_image(struct linux_arch_kernel_header *lh); +-grub_err_t grub_arch_efi_linux_boot_image(grub_addr_t addr, grub_size_t size, - char *args); -+grub_err_t grub_armxx_efi_linux_boot_image(grub_addr_t addr, char *args); ++grub_err_t grub_arch_efi_linux_boot_image(grub_addr_t addr, char *args); #endif grub_addr_t grub_efi_modules_addr (void); diff --git a/include/grub/efi/linux.h b/include/grub/efi/linux.h new file mode 100644 -index 00000000000..d9ede36773b +index 0000000..d9ede36 --- /dev/null +++ b/include/grub/efi/linux.h @@ -0,0 +1,31 @@ @@ -983,15 +979,6 @@ index 00000000000..d9ede36773b + void *kernel_param); + +#endif /* ! GRUB_EFI_LINUX_HEADER */ -diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h -index 60c7c3b5e66..bb19dbd5a77 100644 ---- a/include/grub/i386/linux.h -+++ b/include/grub/i386/linux.h -@@ -142,6 +142,7 @@ struct linux_i386_kernel_header - grub_uint64_t setup_data; - grub_uint64_t pref_address; - grub_uint32_t init_size; -+ grub_uint32_t handover_offset; - } GRUB_PACKED; - - /* Boot parameters for Linux based on 2.6.12. This is used by the setup +-- +1.8.3.1 + diff --git a/0002-Rework-linux-command.patch b/0002-Rework-linux-command.patch index 485541ffa69d6c7540ca1a46ceccb99de5bcdb53..07ee4c4dee4392baec0ceebd55913ab69b97b9ee 100644 --- a/0002-Rework-linux-command.patch +++ b/0002-Rework-linux-command.patch @@ -1,20 +1,20 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 6dd706679d6a784317929140bdc7bb11c90ab622 Mon Sep 17 00:00:00 2001 From: Matthew Garrett -Date: Sun, 9 Aug 2015 16:12:39 -0700 -Subject: [PATCH] Rework linux command +Date: Fri, 5 Jul 2019 20:54:51 +0200 +Subject: [PATCH 002/220] Rework linux command We want a single buffer that contains the entire kernel image in order to perform a TPM measurement. Allocate one and copy the entire kernel into it before pulling out the individual blocks later on. --- - grub-core/loader/i386/linux.c | 37 ++++++++++++++++++++++++------------- - 1 file changed, 24 insertions(+), 13 deletions(-) + grub-core/loader/i386/linux.c | 36 +++++++++++++++++++++++------------- + 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index 9b53d3168f9..f7186be4002 100644 +index d0501e2..b255c95 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c -@@ -685,13 +685,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -641,13 +641,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), { grub_file_t file = 0; struct linux_i386_kernel_header lh; @@ -31,7 +31,7 @@ index 9b53d3168f9..f7186be4002 100644 grub_dl_ref (my_mod); -@@ -705,7 +707,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -661,7 +663,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (! file) goto fail; @@ -48,7 +48,7 @@ index 9b53d3168f9..f7186be4002 100644 { if (!grub_errno) grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -@@ -713,6 +723,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -669,6 +679,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } @@ -58,7 +58,7 @@ index 9b53d3168f9..f7186be4002 100644 if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) { grub_error (GRUB_ERR_BAD_OS, "invalid magic number"); -@@ -804,6 +817,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -760,6 +773,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), preferred_address)) goto fail; @@ -66,10 +66,10 @@ index 9b53d3168f9..f7186be4002 100644 grub_memset (&linux_params, 0, sizeof (linux_params)); grub_memcpy (&linux_params.setup_sects, &lh.setup_sects, sizeof (lh) - 0x1F1); -@@ -812,13 +826,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - linux_params.ps_mouse = linux_params.padding10 = 0; +@@ -782,13 +796,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + /* We've already read lh so there is no need to read it second time. */ + len -= sizeof(lh); - len = sizeof (linux_params) - sizeof (lh); - if (grub_file_read (file, (char *) &linux_params + sizeof (lh), len) != len) - { - if (!grub_errno) @@ -77,14 +77,13 @@ index 9b53d3168f9..f7186be4002 100644 - argv[0]); - goto fail; - } -+ + linux_params_ptr = (void *)&linux_params; + grub_memcpy (linux_params_ptr + sizeof (lh), kernel + kernel_offset, len); + kernel_offset += len; linux_params.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE; -@@ -877,7 +888,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -847,7 +857,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), /* The other parameters are filled when booting. */ @@ -93,8 +92,8 @@ index 9b53d3168f9..f7186be4002 100644 grub_dprintf ("linux", "bzImage, setup=0x%x, size=0x%x\n", (unsigned) real_size, (unsigned) prot_size); -@@ -1025,9 +1036,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - (sizeof (LINUX_IMAGE) - 1)); +@@ -1001,9 +1011,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + } len = prot_file_size; - if (grub_file_read (file, prot_mode_mem, len) != len && !grub_errno) @@ -104,7 +103,7 @@ index 9b53d3168f9..f7186be4002 100644 if (grub_errno == GRUB_ERR_NONE) { -@@ -1038,6 +1047,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -1014,6 +1022,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), fail: @@ -113,3 +112,6 @@ index 9b53d3168f9..f7186be4002 100644 if (file) grub_file_close (file); +-- +1.8.3.1 + diff --git a/0003-Rework-linux16-command.patch b/0003-Rework-linux16-command.patch index 99d6e7c21a232db5b1db51485a5bf862cc2b4e13..287343aac512128d3d2ab0e08b5fbaaf472082fa 100644 --- a/0003-Rework-linux16-command.patch +++ b/0003-Rework-linux16-command.patch @@ -1,17 +1,17 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 84d1fbf3d3a427c168b57f83e8e29a7ae22e7192 Mon Sep 17 00:00:00 2001 From: Matthew Garrett -Date: Sun, 9 Aug 2015 16:20:58 -0700 -Subject: [PATCH] Rework linux16 command +Date: Fri, 5 Jul 2019 21:12:00 +0200 +Subject: [PATCH 003/220] Rework linux16 command We want a single buffer that contains the entire kernel image in order to perform a TPM measurement. Allocate one and copy the entire kernel int it before pulling out the individual blocks later on. --- - grub-core/loader/i386/pc/linux.c | 34 +++++++++++++++++++++------------- - 1 file changed, 21 insertions(+), 13 deletions(-) + grub-core/loader/i386/pc/linux.c | 33 +++++++++++++++++++++------------ + 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index a3c87cf2fc2..caa76bee8af 100644 +index eea25ea..73fb91e 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -123,13 +123,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), @@ -74,12 +74,11 @@ index a3c87cf2fc2..caa76bee8af 100644 if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0200) -@@ -355,10 +363,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -358,9 +366,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), } len = grub_linux16_prot_size; -- if (grub_file_read (file, grub_linux_prot_chunk, grub_linux16_prot_size) -- != (grub_ssize_t) grub_linux16_prot_size && !grub_errno) +- if (grub_file_read (file, grub_linux_prot_chunk, len) != len && !grub_errno) - grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), - argv[0]); + grub_memcpy (grub_linux_prot_chunk, kernel + kernel_offset, len); @@ -87,7 +86,7 @@ index a3c87cf2fc2..caa76bee8af 100644 if (grub_errno == GRUB_ERR_NONE) { -@@ -368,6 +374,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -370,6 +377,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), fail: @@ -96,3 +95,6 @@ index a3c87cf2fc2..caa76bee8af 100644 if (file) grub_file_close (file); +-- +1.8.3.1 + diff --git a/0004-Add-secureboot-support-on-efi-chainloader.patch b/0004-Add-secureboot-support-on-efi-chainloader.patch index 6a347d8a6548617e661dd23fe9a906e0985ffe11..b1d0a33d3887261f99649a68b022ebecc6cfef34 100644 --- a/0004-Add-secureboot-support-on-efi-chainloader.patch +++ b/0004-Add-secureboot-support-on-efi-chainloader.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 703e2ddcf768f52f46d02a59627b91280822c293 Mon Sep 17 00:00:00 2001 From: Raymund Will -Date: Fri, 10 Apr 2015 01:45:02 -0400 -Subject: [PATCH] Add secureboot support on efi chainloader +Date: Mon, 8 Jul 2019 11:55:18 +0200 +Subject: [PATCH 004/220] Add secureboot support on efi chainloader Expand the chainloader to be able to verify the image by means of shim lock protocol. The PE/COFF image is loaded and relocated by the @@ -175,7 +175,7 @@ Signed-off-by: Laszlo Ersek 7 files changed, 840 insertions(+), 91 deletions(-) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index c8a9d8307c0..91129e33566 100644 +index a0faa40..3487b06 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -283,14 +283,20 @@ grub_efi_secure_boot (void) @@ -204,18 +204,18 @@ index c8a9d8307c0..91129e33566 100644 if (*secure_boot && !*setup_mode) ret = 1; diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index 6c00af98dce..a1ac7a38867 100644 +index a312c66..04994d5 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c -@@ -282,6 +282,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - grub_file_t file = 0; - struct linux_armxx_kernel_header lh; +@@ -284,6 +284,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + struct linux_arch_kernel_header lh; struct grub_armxx_linux_pe_header *pe; + grub_err_t err; + int rc; grub_dl_ref (my_mod); -@@ -326,7 +327,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -328,7 +329,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); @@ -226,7 +226,7 @@ index 6c00af98dce..a1ac7a38867 100644 grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), argv[0]); goto fail; diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index adc85636633..af2189619a3 100644 +index cd92ea3..ef87b06 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -32,6 +32,8 @@ @@ -261,7 +261,7 @@ index adc85636633..af2189619a3 100644 grub_dl_unref (my_mod); return GRUB_ERR_NONE; -@@ -173,7 +181,6 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) +@@ -179,7 +187,6 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) /* Fill the file path for the directory. */ d = (grub_efi_device_path_t *) ((char *) file_path + ((char *) d - (char *) dp)); @@ -269,7 +269,7 @@ index adc85636633..af2189619a3 100644 copy_file_path ((grub_efi_file_path_device_path_t *) d, dir_start, dir_end - dir_start); -@@ -191,20 +198,690 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) +@@ -197,20 +204,690 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) return file_path; } @@ -963,7 +963,7 @@ index adc85636633..af2189619a3 100644 if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -@@ -216,15 +893,45 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -222,15 +899,45 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), address = 0; image_handle = 0; file_path = 0; @@ -997,7 +997,7 @@ index adc85636633..af2189619a3 100644 + *(--p16) = 0; + } + - file = grub_file_open (filename); + file = grub_file_open (filename, GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE); if (! file) goto fail; @@ -1011,7 +1011,7 @@ index adc85636633..af2189619a3 100644 if (! dev) goto fail; -@@ -261,17 +968,14 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -267,17 +974,14 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), if (! file_path) goto fail; @@ -1032,7 +1032,7 @@ index adc85636633..af2189619a3 100644 status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ANY_PAGES, GRUB_EFI_LOADER_CODE, -@@ -285,7 +989,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -291,7 +995,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), } boot_image = (void *) ((grub_addr_t) address); @@ -1041,7 +1041,7 @@ index adc85636633..af2189619a3 100644 { if (grub_errno == GRUB_ERR_NONE) grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -@@ -295,7 +999,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -301,7 +1005,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), } #if defined (__i386__) || defined (__x86_64__) @@ -1050,7 +1050,7 @@ index adc85636633..af2189619a3 100644 { struct grub_macho_fat_header *head = boot_image; if (head->magic -@@ -304,6 +1008,14 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -310,6 +1014,14 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), grub_uint32_t i; struct grub_macho_fat_arch *archs = (struct grub_macho_fat_arch *) (head + 1); @@ -1065,7 +1065,7 @@ index adc85636633..af2189619a3 100644 for (i = 0; i < grub_cpu_to_le32 (head->nfat_arch); i++) { if (GRUB_MACHO_CPUTYPE_IS_HOST_CURRENT (archs[i].cputype)) -@@ -318,79 +1030,39 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -324,79 +1036,39 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), > ~grub_cpu_to_le32 (archs[i].size) || grub_cpu_to_le32 (archs[i].offset) + grub_cpu_to_le32 (archs[i].size) @@ -1097,27 +1097,27 @@ index adc85636633..af2189619a3 100644 - grub_error (GRUB_ERR_BAD_OS, "cannot load image"); - - goto fail; -+ grub_file_close (file); -+ grub_device_close (dev); -+ grub_loader_set (grub_secureboot_chainloader_boot, -+ grub_secureboot_chainloader_unload, 0); -+ return 0; - } +- } - - /* LoadImage does not set a device handler when the image is - loaded from memory, so it is necessary to set it explicitly here. - This is a mess. */ - loaded_image = grub_efi_get_loaded_image (image_handle); - if (! loaded_image) -+ else if (rc == 0) - { +- { - grub_error (GRUB_ERR_BAD_OS, "no loaded image available"); - goto fail; -- } ++ grub_file_close (file); ++ grub_device_close (dev); ++ grub_loader_set (grub_secureboot_chainloader_boot, ++ grub_secureboot_chainloader_unload, 0); ++ return 0; + } - loaded_image->device_handle = dev_handle; - - if (argc > 1) -- { ++ else if (rc == 0) + { - int i, len; - grub_efi_char16_t *p16; - @@ -1128,11 +1128,7 @@ index adc85636633..af2189619a3 100644 - cmdline = p16 = grub_malloc (len); - if (! cmdline) - goto fail; -+ grub_load_and_start_image(boot_image); -+ grub_file_close (file); -+ grub_device_close (dev); -+ grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); - +- - for (i = 1; i < argc; i++) - { - char *p8; @@ -1144,7 +1140,11 @@ index adc85636633..af2189619a3 100644 - *(p16++) = ' '; - } - *(--p16) = 0; -- ++ grub_load_and_start_image(boot_image); ++ grub_file_close (file); ++ grub_device_close (dev); ++ grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); + - loaded_image->load_options = cmdline; - loaded_image->load_options_size = len; + return 0; @@ -1162,7 +1162,7 @@ index adc85636633..af2189619a3 100644 if (dev) grub_device_close (dev); -@@ -402,6 +1074,9 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -408,6 +1080,9 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), if (address) efi_call_2 (b->free_pages, address, pages); @@ -1173,7 +1173,7 @@ index adc85636633..af2189619a3 100644 return grub_errno; diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index c24202a5dd1..c8ecce6dfd0 100644 +index c24202a..c8ecce6 100644 --- a/grub-core/loader/efi/linux.c +++ b/grub-core/loader/efi/linux.c @@ -33,21 +33,34 @@ struct grub_efi_shim_lock @@ -1197,9 +1197,7 @@ index c24202a5dd1..c8ecce6dfd0 100644 + grub_dprintf ("secureboot", "shim not available\n"); + return 0; + } - -- if (shim_lock->verify(data, size) == GRUB_EFI_SUCCESS) -- return 1; ++ + grub_dprintf ("secureboot", "Asking shim to verify kernel signature\n"); + status = shim_lock->verify (data, size); + grub_dprintf ("secureboot", "shim_lock->verify(): %ld\n", (long int)status); @@ -1209,19 +1207,21 @@ index c24202a5dd1..c8ecce6dfd0 100644 + return 1; + } -- return 0; +- if (shim_lock->verify(data, size) == GRUB_EFI_SUCCESS) +- return 1; + grub_dprintf ("secureboot", "Kernel signature verification failed (0x%lx)\n", + (unsigned long) status); -+ + +- return 0; + return -1; } #pragma GCC diagnostic push diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 3db82e782df..8db228c5bf5 100644 +index bb2616a..6b24cbb 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c -@@ -118,6 +118,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), +@@ -117,6 +117,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; } @@ -1230,15 +1230,15 @@ index 3db82e782df..8db228c5bf5 100644 params->ramdisk_size = size; params->ramdisk_image = (grub_uint32_t)(grub_addr_t) initrd_mem; -@@ -160,6 +162,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - struct linux_kernel_header lh; +@@ -159,6 +161,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + struct linux_i386_kernel_header lh; grub_ssize_t len, start, filelen; void *kernel = NULL; + int rc; grub_dl_ref (my_mod); -@@ -185,11 +188,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -184,11 +187,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, kernel, filelen) != filelen) { @@ -1254,7 +1254,7 @@ index 3db82e782df..8db228c5bf5 100644 { grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), argv[0]); -@@ -204,6 +209,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -203,6 +208,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } @@ -1263,7 +1263,7 @@ index 3db82e782df..8db228c5bf5 100644 grub_memset (params, 0, 16384); grub_memcpy (&lh, kernel, sizeof (lh)); -@@ -242,6 +249,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -241,6 +248,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } @@ -1286,7 +1286,7 @@ index 3db82e782df..8db228c5bf5 100644 grub_file_close (file); diff --git a/include/grub/efi/linux.h b/include/grub/efi/linux.h -index d9ede36773b..0033d9305a9 100644 +index d9ede36..0033d93 100644 --- a/include/grub/efi/linux.h +++ b/include/grub/efi/linux.h @@ -22,7 +22,7 @@ @@ -1299,10 +1299,10 @@ index d9ede36773b..0033d9305a9 100644 grub_err_t EXPORT_FUNC(grub_efi_linux_boot) (void *kernel_address, grub_off_t offset, diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h -index 7d44732d2c3..c03cc599f63 100644 +index 0ed8781..a43adf2 100644 --- a/include/grub/efi/pe32.h +++ b/include/grub/efi/pe32.h -@@ -214,7 +214,11 @@ struct grub_pe64_optional_header +@@ -223,7 +223,11 @@ struct grub_pe64_optional_header struct grub_pe32_section_table { char name[8]; @@ -1315,7 +1315,7 @@ index 7d44732d2c3..c03cc599f63 100644 grub_uint32_t virtual_address; grub_uint32_t raw_data_size; grub_uint32_t raw_data_offset; -@@ -225,12 +229,18 @@ struct grub_pe32_section_table +@@ -234,12 +238,18 @@ struct grub_pe32_section_table grub_uint32_t characteristics; }; @@ -1338,7 +1338,7 @@ index 7d44732d2c3..c03cc599f63 100644 #define GRUB_PE32_SCN_ALIGN_1BYTES 0x00100000 #define GRUB_PE32_SCN_ALIGN_2BYTES 0x00200000 -@@ -239,10 +249,28 @@ struct grub_pe32_section_table +@@ -248,10 +258,28 @@ struct grub_pe32_section_table #define GRUB_PE32_SCN_ALIGN_16BYTES 0x00500000 #define GRUB_PE32_SCN_ALIGN_32BYTES 0x00600000 #define GRUB_PE32_SCN_ALIGN_64BYTES 0x00700000 @@ -1367,7 +1367,7 @@ index 7d44732d2c3..c03cc599f63 100644 #define GRUB_PE32_SIGNATURE_SIZE 4 struct grub_pe32_header -@@ -265,6 +293,20 @@ struct grub_pe32_header +@@ -274,6 +302,20 @@ struct grub_pe32_header #endif }; @@ -1388,3 +1388,6 @@ index 7d44732d2c3..c03cc599f63 100644 struct grub_pe32_fixup_block { grub_uint32_t page_rva; +-- +1.8.3.1 + diff --git a/0005-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch b/0005-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch index 3c86beec2ce54a7222b0346871edc5277c7f1c66..d553562320898bceb960410e335995a3a8f727c0 100644 --- a/0005-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch +++ b/0005-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch @@ -1,14 +1,15 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From a5d1b0391c2875677f3d7a6d762b3fadaa3ecf85 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 6 Oct 2015 16:09:25 -0400 -Subject: [PATCH] Make any of the loaders that link in efi mode honor secure - boot. +Subject: [PATCH 005/220] Make any of the loaders that link in efi mode honor + secure boot. And in this case "honor" means "even if somebody does link this in, they won't register commands if SB is enabled." Signed-off-by: Peter Jones --- + grub-core/Makefile.am | 1 + grub-core/Makefile.core.def | 1 + grub-core/commands/iorw.c | 7 +++++ grub-core/commands/memrw.c | 7 +++++ @@ -28,7 +29,6 @@ Signed-off-by: Peter Jones include/grub/mips/linux.h | 0 include/grub/powerpc/linux.h | 0 include/grub/sparc64/linux.h | 0 - grub-core/Makefile.am | 1 + 20 files changed, 153 insertions(+), 35 deletions(-) create mode 100644 grub-core/kern/efi/sb.c create mode 100644 include/grub/efi/sb.h @@ -37,11 +37,23 @@ Signed-off-by: Peter Jones create mode 100644 include/grub/powerpc/linux.h create mode 100644 include/grub/sparc64/linux.h +diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am +index 3ea8e7f..c6ba5b2 100644 +--- a/grub-core/Makefile.am ++++ b/grub-core/Makefile.am +@@ -71,6 +71,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/device.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/disk.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/dl.h ++KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/sb.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env_private.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/err.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 0b4b0c2122d..e92a7ef322f 100644 +index 581d9df..eb1088f 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -195,6 +195,7 @@ kernel = { +@@ -207,6 +207,7 @@ kernel = { i386_multiboot = kern/i386/pc/acpi.c; i386_coreboot = kern/acpi.c; i386_multiboot = kern/acpi.c; @@ -50,7 +62,7 @@ index 0b4b0c2122d..e92a7ef322f 100644 x86 = kern/i386/tsc.c; x86 = kern/i386/tsc_pit.c; diff --git a/grub-core/commands/iorw.c b/grub-core/commands/iorw.c -index a0c164e54f0..41a7f3f0466 100644 +index a0c164e..41a7f3f 100644 --- a/grub-core/commands/iorw.c +++ b/grub-core/commands/iorw.c @@ -23,6 +23,7 @@ @@ -82,7 +94,7 @@ index a0c164e54f0..41a7f3f0466 100644 grub_unregister_extcmd (cmd_read_word); grub_unregister_extcmd (cmd_read_dword); diff --git a/grub-core/commands/memrw.c b/grub-core/commands/memrw.c -index 98769eadb34..088cbe9e2bc 100644 +index 98769ea..088cbe9 100644 --- a/grub-core/commands/memrw.c +++ b/grub-core/commands/memrw.c @@ -22,6 +22,7 @@ @@ -114,7 +126,7 @@ index 98769eadb34..088cbe9e2bc 100644 grub_unregister_extcmd (cmd_read_word); grub_unregister_extcmd (cmd_read_dword); diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 04e804d1668..621070918d4 100644 +index 896bebf..d7718d2 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -32,6 +32,7 @@ @@ -126,7 +138,7 @@ index 04e804d1668..621070918d4 100644 /* Platforms where modules are in a readonly area of memory. */ #if defined(GRUB_MACHINE_QEMU) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 91129e33566..708581fcbde 100644 +index 3487b06..6e1ceb9 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -273,40 +273,6 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, @@ -172,7 +184,7 @@ index 91129e33566..708581fcbde 100644 /* Search the mods section from the PE32/PE32+ image. This code uses diff --git a/grub-core/kern/efi/sb.c b/grub-core/kern/efi/sb.c new file mode 100644 -index 00000000000..d74778b0cac +index 0000000..d74778b --- /dev/null +++ b/grub-core/kern/efi/sb.c @@ -0,0 +1,64 @@ @@ -241,7 +253,7 @@ index 00000000000..d74778b0cac +#endif +} diff --git a/grub-core/loader/efi/appleloader.c b/grub-core/loader/efi/appleloader.c -index 74888c463ba..69c2a10d351 100644 +index 74888c4..69c2a10 100644 --- a/grub-core/loader/efi/appleloader.c +++ b/grub-core/loader/efi/appleloader.c @@ -24,6 +24,7 @@ @@ -272,7 +284,7 @@ index 74888c463ba..69c2a10d351 100644 grub_unregister_command (cmd); } diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index af2189619a3..5cd9b6e08a8 100644 +index ef87b06..5aa3a5d 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -34,6 +34,7 @@ @@ -284,10 +296,10 @@ index af2189619a3..5cd9b6e08a8 100644 #include #include diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c -index 7f96515da65..87709aa23e8 100644 +index 3730ed3..5b9b92d 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c -@@ -38,6 +38,7 @@ +@@ -39,6 +39,7 @@ #ifdef GRUB_MACHINE_PCBIOS #include #endif @@ -295,7 +307,7 @@ index 7f96515da65..87709aa23e8 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -2124,6 +2125,9 @@ static grub_command_t cmd_netbsd_module_elf, cmd_openbsd_ramdisk; +@@ -2130,6 +2131,9 @@ static grub_command_t cmd_netbsd_module_elf, cmd_openbsd_ramdisk; GRUB_MOD_INIT (bsd) { @@ -305,7 +317,7 @@ index 7f96515da65..87709aa23e8 100644 /* Net and OpenBSD kernels are often compressed. */ grub_dl_load ("gzio"); -@@ -2163,6 +2167,9 @@ GRUB_MOD_INIT (bsd) +@@ -2169,6 +2173,9 @@ GRUB_MOD_INIT (bsd) GRUB_MOD_FINI (bsd) { @@ -316,18 +328,18 @@ index 7f96515da65..87709aa23e8 100644 grub_unregister_extcmd (cmd_openbsd); grub_unregister_extcmd (cmd_netbsd); diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index f7186be4002..c84747ea857 100644 +index b255c95..376c726 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c -@@ -35,6 +35,7 @@ - #include +@@ -36,6 +36,7 @@ #include #include + #include +#include GRUB_MOD_LICENSE ("GPLv3+"); -@@ -1156,6 +1157,9 @@ static grub_command_t cmd_linux, cmd_initrd; +@@ -1131,6 +1132,9 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { @@ -337,7 +349,7 @@ index f7186be4002..c84747ea857 100644 cmd_linux = grub_register_command ("linux", grub_cmd_linux, 0, N_("Load Linux.")); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, -@@ -1165,6 +1169,9 @@ GRUB_MOD_INIT(linux) +@@ -1140,6 +1144,9 @@ GRUB_MOD_INIT(linux) GRUB_MOD_FINI(linux) { @@ -348,7 +360,7 @@ index f7186be4002..c84747ea857 100644 grub_unregister_command (cmd_initrd); } diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index caa76bee8af..783a3cd93bc 100644 +index 73fb91e..fe3e1d4 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -35,6 +35,7 @@ @@ -359,7 +371,7 @@ index caa76bee8af..783a3cd93bc 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -480,6 +481,9 @@ static grub_command_t cmd_linux, cmd_linux16, cmd_initrd, cmd_initrd16; +@@ -483,6 +484,9 @@ static grub_command_t cmd_linux, cmd_linux16, cmd_initrd, cmd_initrd16; GRUB_MOD_INIT(linux16) { @@ -369,7 +381,7 @@ index caa76bee8af..783a3cd93bc 100644 cmd_linux = grub_register_command ("linux", grub_cmd_linux, 0, N_("Load Linux.")); -@@ -497,6 +501,9 @@ GRUB_MOD_INIT(linux16) +@@ -500,6 +504,9 @@ GRUB_MOD_INIT(linux16) GRUB_MOD_FINI(linux16) { @@ -380,7 +392,7 @@ index caa76bee8af..783a3cd93bc 100644 grub_unregister_command (cmd_linux16); grub_unregister_command (cmd_initrd); diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c -index 40c67e82489..26df46a4161 100644 +index 4a98d70..3e6ad16 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -50,6 +50,7 @@ @@ -391,7 +403,7 @@ index 40c67e82489..26df46a4161 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -446,6 +447,9 @@ static grub_command_t cmd_multiboot, cmd_module; +@@ -444,6 +445,9 @@ static grub_command_t cmd_multiboot, cmd_module; GRUB_MOD_INIT(multiboot) { @@ -401,7 +413,7 @@ index 40c67e82489..26df46a4161 100644 cmd_multiboot = #ifdef GRUB_USE_MULTIBOOT2 grub_register_command ("multiboot2", grub_cmd_multiboot, -@@ -466,6 +470,9 @@ GRUB_MOD_INIT(multiboot) +@@ -464,6 +468,9 @@ GRUB_MOD_INIT(multiboot) GRUB_MOD_FINI(multiboot) { @@ -412,18 +424,18 @@ index 40c67e82489..26df46a4161 100644 grub_unregister_command (cmd_module); } diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c -index c9885b1bcd7..df8dfdb4ba0 100644 +index 7f74d1d..e0f47e7 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c -@@ -33,6 +33,7 @@ - #include +@@ -34,6 +34,7 @@ #include #include + #include +#include GRUB_MOD_LICENSE ("GPLv3+"); -@@ -1469,6 +1470,9 @@ static grub_extcmd_t cmd_splash; +@@ -1478,6 +1479,9 @@ static grub_extcmd_t cmd_splash; GRUB_MOD_INIT(xnu) { @@ -433,7 +445,7 @@ index c9885b1bcd7..df8dfdb4ba0 100644 cmd_kernel = grub_register_command ("xnu_kernel", grub_cmd_xnu_kernel, 0, N_("Load XNU image.")); cmd_kernel64 = grub_register_command ("xnu_kernel64", grub_cmd_xnu_kernel64, -@@ -1509,6 +1513,9 @@ GRUB_MOD_INIT(xnu) +@@ -1518,6 +1522,9 @@ GRUB_MOD_INIT(xnu) GRUB_MOD_FINI(xnu) { @@ -444,7 +456,7 @@ index c9885b1bcd7..df8dfdb4ba0 100644 grub_unregister_command (cmd_resume); #endif diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 1061aee9726..39480b38674 100644 +index 6840bfe..090c862 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -85,7 +85,6 @@ EXPORT_FUNC (grub_efi_set_variable) (const char *var, @@ -457,7 +469,7 @@ index 1061aee9726..39480b38674 100644 const grub_efi_device_path_t *dp2); diff --git a/include/grub/efi/sb.h b/include/grub/efi/sb.h new file mode 100644 -index 00000000000..9629fbb0f9e +index 0000000..9629fbb --- /dev/null +++ b/include/grub/efi/sb.h @@ -0,0 +1,29 @@ @@ -492,25 +504,16 @@ index 00000000000..9629fbb0f9e +#endif /* ! GRUB_EFI_SB_HEADER */ diff --git a/include/grub/ia64/linux.h b/include/grub/ia64/linux.h new file mode 100644 -index 00000000000..e69de29bb2d +index 0000000..e69de29 diff --git a/include/grub/mips/linux.h b/include/grub/mips/linux.h new file mode 100644 -index 00000000000..e69de29bb2d +index 0000000..e69de29 diff --git a/include/grub/powerpc/linux.h b/include/grub/powerpc/linux.h new file mode 100644 -index 00000000000..e69de29bb2d +index 0000000..e69de29 diff --git a/include/grub/sparc64/linux.h b/include/grub/sparc64/linux.h new file mode 100644 -index 00000000000..e69de29bb2d -diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am -index f4ff62b769a..9c69aa88626 100644 ---- a/grub-core/Makefile.am -+++ b/grub-core/Makefile.am -@@ -71,6 +71,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/device.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/disk.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/dl.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/sb.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env_private.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/err.h +index 0000000..e69de29 +-- +1.8.3.1 + diff --git a/0006-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch b/0006-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch index 76b1183d347a58b5688187b988f23114b3efb1b7..ba6eae35950a0bc52c65c12c01fc90e73420df76 100644 --- a/0006-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch +++ b/0006-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch @@ -1,19 +1,19 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 6290701c8bd7183fef478afd5c27053bf9691639 Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Tue, 14 Feb 2017 16:18:54 -0500 -Subject: [PATCH] Handle multi-arch (64-on-32) boot in linuxefi loader. +Date: Mon, 8 Jul 2019 12:32:37 +0200 +Subject: [PATCH 006/220] Handle multi-arch (64-on-32) boot in linuxefi loader. Allow booting 64-bit kernels on 32-bit EFI on x86. Signed-off-by: Peter Jones --- - grub-core/loader/efi/linux.c | 9 +++- - grub-core/loader/i386/efi/linux.c | 110 ++++++++++++++++++++++++++------------ + grub-core/loader/efi/linux.c | 9 ++- + grub-core/loader/i386/efi/linux.c | 114 ++++++++++++++++++++++++++------------ include/grub/i386/linux.h | 7 ++- - 3 files changed, 89 insertions(+), 37 deletions(-) + 3 files changed, 91 insertions(+), 39 deletions(-) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index c8ecce6dfd0..0622dfa48d4 100644 +index c8ecce6..0622dfa 100644 --- a/grub-core/loader/efi/linux.c +++ b/grub-core/loader/efi/linux.c @@ -69,12 +69,17 @@ grub_linuxefi_secure_validate (void *data, grub_uint32_t size) @@ -37,7 +37,7 @@ index c8ecce6dfd0..0622dfa48d4 100644 return GRUB_ERR_BUG; diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 8db228c5bf5..800c3e54022 100644 +index 6b24cbb..3017d0f 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -44,14 +44,10 @@ static char *linux_cmdline; @@ -57,12 +57,12 @@ index 8db228c5bf5..800c3e54022 100644 params); } -@@ -154,14 +150,20 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), +@@ -153,14 +149,20 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), return grub_errno; } +#define MIN(a, b) \ -+ ({ typeof (a) _a = (a); \ ++ ({ typeof (a) _a = (a); \ + typeof (b) _b = (b); \ + _a < _b ? _a : _b; }) + @@ -71,7 +71,7 @@ index 8db228c5bf5..800c3e54022 100644 int argc, char *argv[]) { grub_file_t file = 0; -- struct linux_kernel_header lh; +- struct linux_i386_kernel_header lh; - grub_ssize_t len, start, filelen; + struct linux_i386_kernel_header *lh = NULL; + grub_ssize_t start, filelen; @@ -80,7 +80,7 @@ index 8db228c5bf5..800c3e54022 100644 int rc; grub_dl_ref (my_mod); -@@ -201,48 +203,79 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -200,48 +202,79 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } @@ -95,14 +95,16 @@ index 8db228c5bf5..800c3e54022 100644 } - grub_dprintf ("linux", "params = %lx\n", (unsigned long) params); -+ grub_dprintf ("linux", "params = %p\n", params); - +- - grub_memset (params, 0, 16384); -+ grub_memset (params, 0, sizeof(*params)); - +- - grub_memcpy (&lh, kernel, sizeof (lh)); - - if (lh.boot_flag != grub_cpu_to_le16 (0xaa55)) ++ grub_dprintf ("linux", "params = %p\n", params); ++ ++ grub_memset (params, 0, sizeof(*params)); ++ + setup_header_end_offset = *((grub_uint8_t *)kernel + 0x201); + grub_dprintf ("linux", "copying %lu bytes from %p to %p\n", + MIN((grub_size_t)0x202+setup_header_end_offset, @@ -172,12 +174,13 @@ index 8db228c5bf5..800c3e54022 100644 if (!linux_cmdline) { grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate cmdline")); -@@ -255,21 +288,23 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -254,22 +287,24 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE)); grub_create_loader_cmdline (argc, argv, linux_cmdline + sizeof (LINUX_IMAGE) - 1, -- lh.cmdline_size - (sizeof (LINUX_IMAGE) - 1)); -+ lh->cmdline_size - (sizeof (LINUX_IMAGE) - 1)); +- lh.cmdline_size - (sizeof (LINUX_IMAGE) - 1), ++ lh->cmdline_size - (sizeof (LINUX_IMAGE) - 1), + GRUB_VERIFY_KERNEL_CMDLINE); - lh.cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline; + grub_dprintf ("linux", "cmdline:%s\n", linux_cmdline); @@ -215,15 +218,15 @@ index 8db228c5bf5..800c3e54022 100644 loaded=1; + grub_dprintf ("linux", "setting lh->code32_start to %p\n", kernel_mem); + lh->code32_start = (grub_uint32_t)(grub_addr_t) kernel_mem; ++ ++ grub_memcpy (kernel_mem, (char *)kernel + start, filelen - start); - lh.code32_start = (grub_uint32_t)(grub_uint64_t) kernel_mem; - grub_memcpy (params, &lh, 2 * 512); -+ grub_memcpy (kernel_mem, (char *)kernel + start, filelen - start); - -- params->type_of_loader = 0x21; + grub_dprintf ("linux", "setting lh->type_of_loader\n"); + lh->type_of_loader = 0x6; -+ + +- params->type_of_loader = 0x21; + grub_dprintf ("linux", "setting lh->ext_loader_{type,ver}\n"); + params->ext_loader_type = 0; + params->ext_loader_ver = 2; @@ -244,10 +247,10 @@ index 8db228c5bf5..800c3e54022 100644 if (kernel_mem && !loaded) grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h -index bb19dbd5a77..8474a857ed2 100644 +index ce30e7f..a093679 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h -@@ -133,7 +133,12 @@ struct linux_i386_kernel_header +@@ -136,7 +136,12 @@ struct linux_i386_kernel_header grub_uint32_t kernel_alignment; grub_uint8_t relocatable; grub_uint8_t min_alignment; @@ -261,3 +264,6 @@ index bb19dbd5a77..8474a857ed2 100644 grub_uint32_t cmdline_size; grub_uint32_t hardware_subarch; grub_uint64_t hardware_subarch_data; +-- +1.8.3.1 + diff --git a/0007-re-write-.gitignore.patch b/0007-re-write-.gitignore.patch index 34deea7276f18845bec6592cd059f33d86b5abfa..7e3c6b1f4e3f70bf5433e62518d9505491373eb8 100644 --- a/0007-re-write-.gitignore.patch +++ b/0007-re-write-.gitignore.patch @@ -1,33 +1,42 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 22e9b5b6f0e2031bc68d1c3cb0e8e1f33cc68c93 Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Tue, 8 Aug 2017 12:48:04 -0400 -Subject: [PATCH] re-write .gitignore +Date: Mon, 8 Jul 2019 12:55:29 +0200 +Subject: [PATCH 007/220] re-write .gitignore --- - .gitignore | 357 +++++++++++++------------------------- - build-aux/.gitignore | 9 + - docs/.gitignore | 4 + - grub-core/.gitignore | 15 ++ - grub-core/gnulib/.gitignore | 22 +++ + .gitignore | 366 +++++++++++++++----------------------- + docs/.gitignore | 5 + + grub-core/.gitignore | 16 ++ grub-core/lib/.gitignore | 1 + include/grub/gcrypt/.gitignore | 2 + - po/.gitignore | 4 + - util/bash-completion.d/.gitignore | 1 + - 9 files changed, 175 insertions(+), 240 deletions(-) - create mode 100644 build-aux/.gitignore + po/.gitignore | 5 + + util/bash-completion.d/.gitignore | 2 + + 7 files changed, 171 insertions(+), 226 deletions(-) create mode 100644 docs/.gitignore create mode 100644 grub-core/.gitignore - create mode 100644 grub-core/gnulib/.gitignore create mode 100644 grub-core/lib/.gitignore create mode 100644 include/grub/gcrypt/.gitignore create mode 100644 po/.gitignore create mode 100644 util/bash-completion.d/.gitignore diff --git a/.gitignore b/.gitignore -index eca17bec9b8..43f04d47277 100644 +index 819cd18..b45a633 100644 --- a/.gitignore +++ b/.gitignore -@@ -1,249 +1,126 @@ +@@ -1,237 +1,151 @@ ++# things ./autogen.sh will create ++/Makefile.utilgcry.def ++/ABOUT-NLS ++/aclocal.m4 ++/autom4te.cache ++/build-aux ++/configure ++/gnulib ++/grub-core/lib/gnulib/ ++/Makefile ++ ++# things very common editors create that we never want + *~ -00_header -10_* -20_linux_xen @@ -36,11 +45,13 @@ index eca17bec9b8..43f04d47277 100644 -41_custom -*.1 -*.8 +-ABOUT-NLS -aclocal.m4 -ahci_test -ascii.bitmaps -ascii.h -autom4te.cache +-build-aux -build-grub-gen-asciih -build-grub-gen-widthspec -build-grub-mkfont @@ -64,26 +75,18 @@ index eca17bec9b8..43f04d47277 100644 -example_grub_script_test -example_scripted_test -example_unit_test -+# things ./autogen.sh will create -+/Makefile.utilgcry.def -+/aclocal.m4 -+/autom4te.cache -+/configure -+Makefile -+# we want to enable building in a subdirectory, but we don't want to exclude -+# /build-aux so explicitly don't ignore it. -+/build*/ -+!/build-aux/ -+ -+# things very common editors create that we never want -+*~ +.*.sw? +*.patch + ++# stuff you're likely to make while building test trees ++grub.cfg ++/build*/ ++ +# built objects across the whole tree +Makefile.in +*.a +*.am ++*.efi *.exec -*.exec.exe -fddboot_test @@ -92,6 +95,7 @@ index eca17bec9b8..43f04d47277 100644 -gentrigtables -gentrigtables.exe -gettext_strings_test +-/gnulib -grub-bin2h -/grub-bios-setup -/grub-bios-setup.exe @@ -184,6 +188,7 @@ index eca17bec9b8..43f04d47277 100644 -*.image.exe -include/grub/cpu -include/grub/machine +-INSTALL.grub -install-sh -lib/libgcrypt-grub -libgrub_a_init.c @@ -194,6 +199,7 @@ index eca17bec9b8..43f04d47277 100644 -lzocompress_test *.marker -Makefile + /m4 *.mod -mod-*.c -missing @@ -208,7 +214,11 @@ index eca17bec9b8..43f04d47277 100644 -*.pp -po/*.mo -po/grub.pot +-po/Makefile.in.in +-po/Makevars +-po/Makevars.template -po/POTFILES +-po/Rules-quot -po/stamp-po -printf_test -priority_queue_unit_test @@ -259,25 +269,7 @@ index eca17bec9b8..43f04d47277 100644 -grub-core/*.pp -grub-core/kernel.img.bin -util/bash-completion.d/grub --grub-core/gnulib/alloca.h --grub-core/gnulib/arg-nonnull.h --grub-core/gnulib/c++defs.h --grub-core/gnulib/charset.alias --grub-core/gnulib/configmake.h --grub-core/gnulib/float.h --grub-core/gnulib/getopt.h --grub-core/gnulib/langinfo.h --grub-core/gnulib/ref-add.sed --grub-core/gnulib/ref-del.sed --grub-core/gnulib/stdio.h --grub-core/gnulib/stdlib.h --grub-core/gnulib/string.h --grub-core/gnulib/strings.h --grub-core/gnulib/sys --grub-core/gnulib/unistd.h --grub-core/gnulib/warn-on-use.h --grub-core/gnulib/wchar.h --grub-core/gnulib/wctype.h +-grub-core/lib/gnulib -grub-core/rs_decoder.h -widthspec.bin -widthspec.h @@ -296,10 +288,6 @@ index eca17bec9b8..43f04d47277 100644 -/grub-render-label -/grub-glue-efi.exe -/grub-render-label.exe --grub-core/gnulib/locale.h --grub-core/gnulib/unitypes.h --grub-core/gnulib/uniwidth.h --build-aux/test-driver + +# next are things you get if you do ./configure in the topdir (for e.g. +# "make dist" invocation. @@ -307,9 +295,16 @@ index eca17bec9b8..43f04d47277 100644 +/config.h +/include/grub/cpu +/include/grub/machine ++/INSTALL ++/INSTALL.grub ++/po/Makefile.in.in ++/po/Makevars ++/po/Makevars.template +/po/POTFILES ++/po/Rules-quot +/stamp-h +/stamp-h1 ++bootstrap.log +config.log +config.status + @@ -338,6 +333,8 @@ index eca17bec9b8..43f04d47277 100644 +/grub*-fs-tester +/grub*-fstest +/grub*-fstest.1 ++/grub*-get-kernel-settings ++/grub*-get-kernel-settings.3 +/grub*-glue-efi +/grub*-glue-efi.1 +/grub*-install @@ -348,6 +345,8 @@ index eca17bec9b8..43f04d47277 100644 +/grub*-macbless.8 +/grub*-menulst2cfg +/grub*-menulst2cfg.1 ++/grub*-mount ++/grub*-mount.1 +/grub*-mkconfig +/grub*-mkconfig.8 +/grub*-mkconfig_lib @@ -375,16 +374,24 @@ index eca17bec9b8..43f04d47277 100644 +/grub*-reboot.8 +/grub*-render-label +/grub*-render-label.1 ++/grub*-rpm-sort ++/grub*-rpm-sort.8 +/grub*-script-check +/grub*-script-check.1 ++/grub*-set-bootflag ++/grub*-set-bootflag.1 +/grub*-set-default +/grub*-set-default.8 ++/grub*-set-password ++/grub*-set-password.8 +/grub*-shell +/grub*-shell-tester +/grub*-sparc64-setup +/grub*-sparc64-setup.8 +/grub*-syslinux2cfg +/grub*-syslinux2cfg.1 ++/grub*-switch-to-blscfg ++/grub*-switch-to-blscfg.8 +/grub_fstest.pp +/grub_fstest_init.c +/grub_fstest_init.lst @@ -394,38 +401,25 @@ index eca17bec9b8..43f04d47277 100644 +/libgrub_a_init.lst +/stamp-h.in +/widthspec.h -diff --git a/build-aux/.gitignore b/build-aux/.gitignore -new file mode 100644 -index 00000000000..f2f17aab9ff ---- /dev/null -+++ b/build-aux/.gitignore -@@ -0,0 +1,9 @@ -+/compile -+/config.guess -+/config.sub -+/depcomp -+/install-sh -+/mdate-sh -+/missing -+/test-driver -+/texinfo.tex diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 -index 00000000000..91aee84d3e9 +index 0000000..e1d849e --- /dev/null +++ b/docs/.gitignore -@@ -0,0 +1,4 @@ +@@ -0,0 +1,5 @@ +/*.in ++/Makefile +/stamp-1 +/stamp-vti +/version*.texi diff --git a/grub-core/.gitignore b/grub-core/.gitignore new file mode 100644 -index 00000000000..c738ac6c649 +index 0000000..2acce28 --- /dev/null +++ b/grub-core/.gitignore -@@ -0,0 +1,15 @@ +@@ -0,0 +1,16 @@ +/*.lst ++/Makefile +/Makefile.gcry.def +/unidata.c +/build-grub-module-verifier @@ -440,44 +434,16 @@ index 00000000000..c738ac6c649 +/symlist.c +/symlist.h +/trigtables.c -diff --git a/grub-core/gnulib/.gitignore b/grub-core/gnulib/.gitignore -new file mode 100644 -index 00000000000..29e199c2db4 ---- /dev/null -+++ b/grub-core/gnulib/.gitignore -@@ -0,0 +1,22 @@ -+/alloca.h -+/arg-nonnull.h -+/c++defs.h -+/charset.alias -+/configmake.h -+/getopt.h -+/langinfo.h -+/libgnu.a -+/locale.h -+/ref-add.sed -+/ref-del.sed -+/stdio.h -+/stdlib.h -+/string.h -+/strings.h -+/sys/ -+/unistd.h -+/unitypes.h -+/uniwidth.h -+/warn-on-use.h -+/wchar.h -+/wctype.h diff --git a/grub-core/lib/.gitignore b/grub-core/lib/.gitignore new file mode 100644 -index 00000000000..68154591404 +index 0000000..6815459 --- /dev/null +++ b/grub-core/lib/.gitignore @@ -0,0 +1 @@ +/libgcrypt-grub/ diff --git a/include/grub/gcrypt/.gitignore b/include/grub/gcrypt/.gitignore new file mode 100644 -index 00000000000..8fbf5646246 +index 0000000..8fbf564 --- /dev/null +++ b/include/grub/gcrypt/.gitignore @@ -0,0 +1,2 @@ @@ -485,18 +451,23 @@ index 00000000000..8fbf5646246 +gcrypt.h diff --git a/po/.gitignore b/po/.gitignore new file mode 100644 -index 00000000000..97b679c3138 +index 0000000..f507e77 --- /dev/null +++ b/po/.gitignore -@@ -0,0 +1,4 @@ +@@ -0,0 +1,5 @@ ++/Makefile +/POTFILES*.in +/grub.pot +/remove-potcdate.sed +/stamp-po diff --git a/util/bash-completion.d/.gitignore b/util/bash-completion.d/.gitignore new file mode 100644 -index 00000000000..b7e1eb12428 +index 0000000..6813a52 --- /dev/null +++ b/util/bash-completion.d/.gitignore -@@ -0,0 +1 @@ +@@ -0,0 +1,2 @@ ++Makefile +grub +-- +1.8.3.1 + diff --git a/0008-IBM-client-architecture-CAS-reboot-support.patch b/0008-IBM-client-architecture-CAS-reboot-support.patch index 0dcaa0ad62b4a5ae0792298d626f3f1479785e79..6bf74105c9ab01053783133d4266980454e51314 100644 --- a/0008-IBM-client-architecture-CAS-reboot-support.patch +++ b/0008-IBM-client-architecture-CAS-reboot-support.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 3b4c970a7123c3c29415f41bebee761524597b25 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Thu, 20 Sep 2012 18:07:39 -0300 -Subject: [PATCH] IBM client architecture (CAS) reboot support +Subject: [PATCH 008/220] IBM client architecture (CAS) reboot support This is an implementation of IBM client architecture (CAS) reboot for GRUB. @@ -25,10 +25,10 @@ parameters 4 files changed, 91 insertions(+) diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c -index 62929d983bf..2d53c0e8608 100644 +index 4d493ab..3a6689a 100644 --- a/grub-core/kern/ieee1275/openfw.c +++ b/grub-core/kern/ieee1275/openfw.c -@@ -588,3 +588,66 @@ grub_ieee1275_get_boot_dev (void) +@@ -591,3 +591,66 @@ grub_ieee1275_get_boot_dev (void) return bootpath; } @@ -96,7 +96,7 @@ index 62929d983bf..2d53c0e8608 100644 + return 0; +} diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 78a70a8bf47..249e19bc788 100644 +index 1b03dfd..222e239 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -33,6 +33,9 @@ @@ -133,20 +133,20 @@ index 78a70a8bf47..249e19bc788 100644 grub_errno = GRUB_ERR_NONE; } diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index a8502d90711..ab78ca87f90 100644 +index ee299fd..0d05d6b 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c -@@ -27,6 +27,9 @@ - #include +@@ -28,6 +28,9 @@ #include #include + #include +#ifdef GRUB_MACHINE_IEEE1275 +#include +#endif /* Max digits for a char is 3 (0xFF is 255), similarly for an int it is sizeof (int) * 3, and one extra for a possible -ve sign. */ -@@ -877,6 +880,10 @@ grub_script_execute_sourcecode (const char *source) +@@ -878,6 +881,10 @@ grub_script_execute_sourcecode (const char *source) grub_err_t ret = 0; struct grub_script *parsed_script; @@ -158,10 +158,10 @@ index a8502d90711..ab78ca87f90 100644 { char *line; diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h -index 8868f3a756f..2310f33dbc2 100644 +index 73e2f46..0a59960 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h -@@ -252,6 +252,8 @@ int EXPORT_FUNC(grub_ieee1275_devalias_next) (struct grub_ieee1275_devalias *ali +@@ -254,6 +254,8 @@ int EXPORT_FUNC(grub_ieee1275_devalias_next) (struct grub_ieee1275_devalias *ali void EXPORT_FUNC(grub_ieee1275_children_peer) (struct grub_ieee1275_devalias *alias); void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath, struct grub_ieee1275_devalias *alias); @@ -170,3 +170,6 @@ index 8868f3a756f..2310f33dbc2 100644 char *EXPORT_FUNC(grub_ieee1275_get_boot_dev) (void); +-- +1.8.3.1 + diff --git a/0009-for-ppc-reset-console-display-attr-when-clear-screen.patch b/0009-for-ppc-reset-console-display-attr-when-clear-screen.patch index ac6745314313e7632d903ff59ee76d628090973b..9a6ca8e721f5763879871d9366050ba9c2b102c6 100644 --- a/0009-for-ppc-reset-console-display-attr-when-clear-screen.patch +++ b/0009-for-ppc-reset-console-display-attr-when-clear-screen.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 8213eaa16384c332659e2655a7f5f01d09d5b27d Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Wed, 24 Apr 2013 10:51:48 -0300 -Subject: [PATCH] for ppc, reset console display attr when clear screen +Subject: [PATCH 009/220] for ppc, reset console display attr when clear screen v2: Also use \x0c instead of a literal ^L to make future patches less awkward. @@ -15,7 +15,7 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c -index d317efa368d..29df35e6d20 100644 +index d317efa..29df35e 100644 --- a/grub-core/term/terminfo.c +++ b/grub-core/term/terminfo.c @@ -151,7 +151,7 @@ grub_terminfo_set_current (struct grub_term_output *term, @@ -27,3 +27,6 @@ index d317efa368d..29df35e6d20 100644 data->reverse_video_on = grub_strdup ("\e[7m"); data->reverse_video_off = grub_strdup ("\e[m"); if (grub_strcmp ("ieee1275", str) == 0) +-- +1.8.3.1 + diff --git a/0010-Disable-GRUB-video-support-for-IBM-power-machines.patch b/0010-Disable-GRUB-video-support-for-IBM-power-machines.patch index ab411af34037a0e519706622f781ee6348104d42..83d7c486f4a21efee70614eaf7282e42af601bed 100644 --- a/0010-Disable-GRUB-video-support-for-IBM-power-machines.patch +++ b/0010-Disable-GRUB-video-support-for-IBM-power-machines.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 0a3d7e634bfa38143cdbe1c53aae681ea4432547 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Tue, 11 Jun 2013 15:14:05 -0300 -Subject: [PATCH] Disable GRUB video support for IBM power machines +Subject: [PATCH 010/220] Disable GRUB video support for IBM power machines Should fix the problem in bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=973205 @@ -12,7 +12,7 @@ https://bugzilla.redhat.com/show_bug.cgi?id=973205 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c -index 3e12e6b24e1..3e14f539368 100644 +index 20cbbd7..04df9d2 100644 --- a/grub-core/kern/ieee1275/cmain.c +++ b/grub-core/kern/ieee1275/cmain.c @@ -90,7 +90,10 @@ grub_ieee1275_find_options (void) @@ -28,7 +28,7 @@ index 3e12e6b24e1..3e14f539368 100644 /* Old Macs have no key repeat, newer ones have fully working one. The ones inbetween when repeated key generates an escaoe sequence diff --git a/grub-core/video/ieee1275.c b/grub-core/video/ieee1275.c -index 17a3dbbb575..b8e4b3feb32 100644 +index 17a3dbb..b8e4b3f 100644 --- a/grub-core/video/ieee1275.c +++ b/grub-core/video/ieee1275.c @@ -352,9 +352,12 @@ static struct grub_video_adapter grub_video_ieee1275_adapter = @@ -48,15 +48,18 @@ index 17a3dbbb575..b8e4b3feb32 100644 GRUB_MOD_FINI(ieee1275_fb) diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h -index 2310f33dbc2..ca08bd96681 100644 +index 0a59960..b5a1d49 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h -@@ -146,6 +146,8 @@ enum grub_ieee1275_flag - GRUB_IEEE1275_FLAG_BROKEN_REPEAT, - +@@ -148,6 +148,8 @@ enum grub_ieee1275_flag GRUB_IEEE1275_FLAG_CURSORONOFF_ANSI_BROKEN, -+ + + GRUB_IEEE1275_FLAG_RAW_DEVNAMES, ++ + GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT }; extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); +-- +1.8.3.1 + diff --git a/0011-Honor-a-symlink-when-generating-configuration-by-gru.patch b/0011-Honor-a-symlink-when-generating-configuration-by-gru.patch index 1ea476c33013af7718670ea063e60da20bc85985..473aeb18c794b4fc821808cfe0431caded31c201 100644 --- a/0011-Honor-a-symlink-when-generating-configuration-by-gru.patch +++ b/0011-Honor-a-symlink-when-generating-configuration-by-gru.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 100f123a544bc54034cf61646f03f988fc876435 Mon Sep 17 00:00:00 2001 From: Marcel Kolaja Date: Tue, 21 Jan 2014 10:57:08 -0500 -Subject: [PATCH] Honor a symlink when generating configuration by +Subject: [PATCH 011/220] Honor a symlink when generating configuration by grub2-mkconfig Honor a symlink when generating configuration by grub2-mkconfig, so that @@ -11,7 +11,7 @@ the -o option follows it rather than overwriting it with a regular file. 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 33332360eec..bc5a3f17541 100644 +index 9f477ff..523d4e0 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -287,7 +287,8 @@ and /etc/grub.d/* files or please file a bug report with @@ -24,3 +24,6 @@ index 33332360eec..bc5a3f17541 100644 fi fi +-- +1.8.3.1 + diff --git a/0012-Move-bash-completion-script-922997.patch b/0012-Move-bash-completion-script-922997.patch index 6c3c773c76e7d4a6a77a8aa2cffa434753971f52..6e46b61249d89d65b6577b67eda19fd0d3e651e1 100644 --- a/0012-Move-bash-completion-script-922997.patch +++ b/0012-Move-bash-completion-script-922997.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 11d400b4b4f1475cf1a75e7f216524a903e7df7c Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 3 Apr 2013 14:35:34 -0400 -Subject: [PATCH] Move bash completion script (#922997) +Subject: [PATCH 012/220] Move bash completion script (#922997) Apparently these go in a new place now. --- @@ -10,10 +10,10 @@ Apparently these go in a new place now. 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac -index c7888e40f66..783118ccdcd 100644 +index 7656f24..d283af6 100644 --- a/configure.ac +++ b/configure.ac -@@ -289,6 +289,14 @@ AC_SUBST(grubdirname) +@@ -305,6 +305,14 @@ AC_SUBST(grubdirname) AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname", [Default grub directory name]) @@ -28,7 +28,7 @@ index c7888e40f66..783118ccdcd 100644 # # Checks for build programs. # -@@ -498,6 +506,9 @@ HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags" +@@ -516,6 +524,9 @@ HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags" # Check for target programs. # @@ -39,7 +39,7 @@ index c7888e40f66..783118ccdcd 100644 if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then tmp_ac_tool_prefix="$ac_tool_prefix" diff --git a/util/bash-completion.d/Makefile.am b/util/bash-completion.d/Makefile.am -index 136287cf1bf..61108f05429 100644 +index 136287c..61108f0 100644 --- a/util/bash-completion.d/Makefile.am +++ b/util/bash-completion.d/Makefile.am @@ -6,7 +6,6 @@ EXTRA_DIST = $(bash_completion_source) @@ -50,3 +50,6 @@ index 136287cf1bf..61108f05429 100644 bashcompletion_DATA = $(bash_completion_script) $(bash_completion_script): $(bash_completion_source) $(top_builddir)/config.status +-- +1.8.3.1 + diff --git a/0013-Update-to-minilzo-2.08.patch b/0013-Update-to-minilzo-2.08.patch index a71c501e8faaf04fd4aa6ef8e2e4a66b2308df6f..9d2759754a88736bfa5a890a4a4034f7550a7311 100644 --- a/0013-Update-to-minilzo-2.08.patch +++ b/0013-Update-to-minilzo-2.08.patch @@ -1,22 +1,22 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From f2619e8e299f13ea8ade1ee9f69334f2c1c71219 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 4 Dec 2014 15:36:09 -0500 -Subject: [PATCH] Update to minilzo-2.08 +Subject: [PATCH 013/220] Update to minilzo-2.08 This fixes CVE-2014-4607 - lzo: lzo1x_decompress_safe() integer overflow Signed-off-by: Peter Jones --- - grub-core/lib/minilzo/minilzo.c | 3801 +++++++++++++++++++++++++++------------ grub-core/lib/minilzo/lzoconf.h | 216 ++- - grub-core/lib/minilzo/lzodefs.h | 2320 ++++++++++++++++++------ + grub-core/lib/minilzo/lzodefs.h | 2450 +++++++++++++++++------- + grub-core/lib/minilzo/minilzo.c | 3953 +++++++++++++++++++++++++++------------ grub-core/lib/minilzo/minilzo.h | 21 +- - 4 files changed, 4489 insertions(+), 1869 deletions(-) + 4 files changed, 4630 insertions(+), 2010 deletions(-) -diff --git a/grub-core/lib/minilzo/minilzo.c b/grub-core/lib/minilzo/minilzo.c -index 25a1f68b3b5..ab2be5f4fd0 100644 ---- a/grub-core/lib/minilzo/minilzo.c -+++ b/grub-core/lib/minilzo/minilzo.c +diff --git a/grub-core/lib/minilzo/lzoconf.h b/grub-core/lib/minilzo/lzoconf.h +index 1d0fe14..61be29c 100644 +--- a/grub-core/lib/minilzo/lzoconf.h ++++ b/grub-core/lib/minilzo/lzoconf.h @@ -2,22 +2,7 @@ This file is part of the LZO real-time data compression library. @@ -41,84 +41,423 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 All Rights Reserved. The LZO library is free software; you can redistribute it and/or -@@ -67,12 +52,6 @@ - #if defined(__CYGWIN32__) && !defined(__CYGWIN__) - # define __CYGWIN__ __CYGWIN32__ +@@ -44,9 +29,9 @@ + #ifndef __LZOCONF_H_INCLUDED + #define __LZOCONF_H_INCLUDED 1 + +-#define LZO_VERSION 0x2050 +-#define LZO_VERSION_STRING "2.05" +-#define LZO_VERSION_DATE "Apr 23 2011" ++#define LZO_VERSION 0x2080 ++#define LZO_VERSION_STRING "2.08" ++#define LZO_VERSION_DATE "Jun 29 2014" + + /* internal Autoconf configuration file - only used when building LZO */ + #if defined(LZO_HAVE_CONFIG_H) +@@ -63,7 +48,7 @@ + #if !defined(CHAR_BIT) || (CHAR_BIT != 8) + # error "invalid CHAR_BIT" #endif --#if defined(__IBMCPP__) && !defined(__IBMC__) --# define __IBMC__ __IBMCPP__ --#endif --#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) --# define __INTEL_COMPILER __ICL --#endif - #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) - # define _ALL_SOURCE 1 +-#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) ++#if !defined(UCHAR_MAX) || !defined(USHRT_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) + # error "check your compiler installation" #endif -@@ -81,19 +60,30 @@ - # define __LONG_MAX__ 9223372036854775807L + #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1) +@@ -85,14 +70,6 @@ extern "C" { + // some core defines + ************************************************************************/ + +-#if !defined(LZO_UINT32_C) +-# if (UINT_MAX < LZO_0xffffffffL) +-# define LZO_UINT32_C(c) c ## UL +-# else +-# define LZO_UINT32_C(c) ((c) + 0U) +-# endif +-#endif +- + /* memory checkers */ + #if !defined(__LZO_CHECKER) + # if defined(__BOUNDS_CHECKING_ON) +@@ -111,28 +88,31 @@ extern "C" { + // integral and pointer types + ************************************************************************/ + +-/* lzo_uint should match size_t */ ++/* lzo_uint must match size_t */ + #if !defined(LZO_UINT_MAX) +-# if defined(LZO_ABI_LLP64) /* WIN64 */ +-# if defined(LZO_OS_WIN64) ++# if (LZO_ABI_LLP64) ++# if (LZO_OS_WIN64) + typedef unsigned __int64 lzo_uint; + typedef __int64 lzo_int; + # else +- typedef unsigned long long lzo_uint; +- typedef long long lzo_int; ++ typedef lzo_ullong_t lzo_uint; ++ typedef lzo_llong_t lzo_int; + # endif ++# define LZO_SIZEOF_LZO_UINT 8 + # define LZO_UINT_MAX 0xffffffffffffffffull + # define LZO_INT_MAX 9223372036854775807LL + # define LZO_INT_MIN (-1LL - LZO_INT_MAX) +-# elif defined(LZO_ABI_IP32L64) /* MIPS R5900 */ ++# elif (LZO_ABI_IP32L64) /* MIPS R5900 */ + typedef unsigned int lzo_uint; + typedef int lzo_int; ++# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_INT + # define LZO_UINT_MAX UINT_MAX + # define LZO_INT_MAX INT_MAX + # define LZO_INT_MIN INT_MIN + # elif (ULONG_MAX >= LZO_0xffffffffL) + typedef unsigned long lzo_uint; + typedef long lzo_int; ++# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_LONG + # define LZO_UINT_MAX ULONG_MAX + # define LZO_INT_MAX LONG_MAX + # define LZO_INT_MIN LONG_MIN +@@ -141,63 +121,22 @@ extern "C" { # endif #endif --#if defined(__INTEL_COMPILER) && defined(__linux__) -+#if !defined(LZO_CFG_NO_DISABLE_WUNDEF) -+#if defined(__ARMCC_VERSION) -+# pragma diag_suppress 193 -+#elif defined(__clang__) && defined(__clang_minor__) -+# pragma clang diagnostic ignored "-Wundef" -+#elif defined(__INTEL_COMPILER) - # pragma warning(disable: 193) + +-/* Integral types with 32 bits or more. */ +-#if !defined(LZO_UINT32_MAX) +-# if (UINT_MAX >= LZO_0xffffffffL) +- typedef unsigned int lzo_uint32; +- typedef int lzo_int32; +-# define LZO_UINT32_MAX UINT_MAX +-# define LZO_INT32_MAX INT_MAX +-# define LZO_INT32_MIN INT_MIN +-# elif (ULONG_MAX >= LZO_0xffffffffL) +- typedef unsigned long lzo_uint32; +- typedef long lzo_int32; +-# define LZO_UINT32_MAX ULONG_MAX +-# define LZO_INT32_MAX LONG_MAX +-# define LZO_INT32_MIN LONG_MIN +-# else +-# error "lzo_uint32" +-# endif -#endif --#if defined(__KEIL__) && defined(__C166__) -+#elif defined(__KEIL__) && defined(__C166__) - # pragma warning disable = 322 --#elif 0 && defined(__C251__) --# pragma warning disable = 322 +- +-/* Integral types with exactly 64 bits. */ +-#if !defined(LZO_UINT64_MAX) +-# if (LZO_UINT_MAX >= LZO_0xffffffffL) +-# if ((((LZO_UINT_MAX) >> 31) >> 31) == 3) +-# define lzo_uint64 lzo_uint +-# define lzo_int64 lzo_int +-# define LZO_UINT64_MAX LZO_UINT_MAX +-# define LZO_INT64_MAX LZO_INT_MAX +-# define LZO_INT64_MIN LZO_INT_MIN +-# endif +-# elif (ULONG_MAX >= LZO_0xffffffffL) +-# if ((((ULONG_MAX) >> 31) >> 31) == 3) +- typedef unsigned long lzo_uint64; +- typedef long lzo_int64; +-# define LZO_UINT64_MAX ULONG_MAX +-# define LZO_INT64_MAX LONG_MAX +-# define LZO_INT64_MIN LONG_MIN +-# endif +-# endif -#endif --#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) --# if (_MSC_VER >= 1300) -+#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) -+# if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) -+# pragma GCC diagnostic ignored "-Wundef" -+# endif -+#elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) -+# if ((_MSC_VER-0) >= 1300) - # pragma warning(disable: 4668) - # endif +- +-/* The larger type of lzo_uint and lzo_uint32. */ +-#if (LZO_UINT_MAX >= LZO_UINT32_MAX) ++/* The larger type of lzo_uint and lzo_uint32_t. */ ++#if (LZO_SIZEOF_LZO_UINT >= 4) + # define lzo_xint lzo_uint + #else +-# define lzo_xint lzo_uint32 ++# define lzo_xint lzo_uint32_t #endif -+#endif -+#if 0 && defined(__POCC__) && defined(_WIN32) -+# if (__POCC__ >= 400) -+# pragma warn(disable: 2216) -+# endif -+#endif - #if 0 && defined(__WATCOMC__) - # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) - # pragma warning 203 9 -@@ -102,13 +92,29 @@ - #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) - # pragma option -h + +-/* Memory model that allows to access memory at offsets of lzo_uint. */ +-#if !defined(__LZO_MMODEL) +-# if (LZO_UINT_MAX <= UINT_MAX) +-# define __LZO_MMODEL /*empty*/ +-# elif defined(LZO_HAVE_MM_HUGE_PTR) +-# define __LZO_MMODEL_HUGE 1 +-# define __LZO_MMODEL __huge +-# else +-# define __LZO_MMODEL /*empty*/ +-# endif ++typedef int lzo_bool; ++ ++/* sanity checks */ ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == LZO_SIZEOF_LZO_UINT) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint32_t)) ++ ++#ifndef __LZO_MMODEL ++#define __LZO_MMODEL /*empty*/ #endif -+#if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) -+#ifndef _CRT_NONSTDC_NO_DEPRECATE -+#define _CRT_NONSTDC_NO_DEPRECATE 1 + + /* no typedef here because of const-pointer issues */ +@@ -206,21 +145,52 @@ extern "C" { + #define lzo_voidp void __LZO_MMODEL * + #define lzo_shortp short __LZO_MMODEL * + #define lzo_ushortp unsigned short __LZO_MMODEL * +-#define lzo_uint32p lzo_uint32 __LZO_MMODEL * +-#define lzo_int32p lzo_int32 __LZO_MMODEL * +-#if defined(LZO_UINT64_MAX) +-#define lzo_uint64p lzo_uint64 __LZO_MMODEL * +-#define lzo_int64p lzo_int64 __LZO_MMODEL * +-#endif +-#define lzo_uintp lzo_uint __LZO_MMODEL * + #define lzo_intp lzo_int __LZO_MMODEL * ++#define lzo_uintp lzo_uint __LZO_MMODEL * + #define lzo_xintp lzo_xint __LZO_MMODEL * + #define lzo_voidpp lzo_voidp __LZO_MMODEL * + #define lzo_bytepp lzo_bytep __LZO_MMODEL * +-/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ +-#define lzo_byte unsigned char __LZO_MMODEL + +-typedef int lzo_bool; ++#define lzo_int8_tp lzo_int8_t __LZO_MMODEL * ++#define lzo_uint8_tp lzo_uint8_t __LZO_MMODEL * ++#define lzo_int16_tp lzo_int16_t __LZO_MMODEL * ++#define lzo_uint16_tp lzo_uint16_t __LZO_MMODEL * ++#define lzo_int32_tp lzo_int32_t __LZO_MMODEL * ++#define lzo_uint32_tp lzo_uint32_t __LZO_MMODEL * ++#if defined(lzo_int64_t) ++#define lzo_int64_tp lzo_int64_t __LZO_MMODEL * ++#define lzo_uint64_tp lzo_uint64_t __LZO_MMODEL * +#endif -+#ifndef _CRT_NONSTDC_NO_WARNINGS -+#define _CRT_NONSTDC_NO_WARNINGS 1 ++ ++/* Older LZO versions used to support ancient systems and memory models ++ * like 16-bit MSDOS with __huge pointers and Cray PVP, but these ++ * obsolete configurations are not supported any longer. ++ */ ++#if defined(__LZO_MMODEL_HUGE) ++#error "__LZO_MMODEL_HUGE is unsupported" +#endif -+#ifndef _CRT_SECURE_NO_DEPRECATE -+#define _CRT_SECURE_NO_DEPRECATE 1 ++#if (LZO_MM_PVP) ++#error "LZO_MM_PVP is unsupported" +#endif -+#ifndef _CRT_SECURE_NO_WARNINGS -+#define _CRT_SECURE_NO_WARNINGS 1 ++#if (LZO_SIZEOF_INT < 4) ++#error "LZO_SIZEOF_INT < 4 is unsupported" +#endif ++#if (__LZO_UINTPTR_T_IS_POINTER) ++#error "__LZO_UINTPTR_T_IS_POINTER is unsupported" +#endif - #if 0 --#define LZO_0xffffL 0xfffful --#define LZO_0xffffffffL 0xfffffffful -+#define LZO_0xffffUL 0xfffful -+#define LZO_0xffffffffUL 0xfffffffful - #else --#define LZO_0xffffL 65535ul --#define LZO_0xffffffffL 4294967295ul ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) >= 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) >= 4) ++/* Strange configurations where sizeof(lzo_uint) != sizeof(size_t) should ++ * work but have not received much testing lately, so be strict here. ++ */ ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp)) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep)) + + + /*********************************************************************** +@@ -315,7 +285,7 @@ struct lzo_callback_t + /* a progress indicator callback function (set to 0 to disable) */ + lzo_progress_func_t nprogress; + +- /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress ++ /* INFO: the first parameter "self" of the nalloc/nfree/nprogress + * callbacks points back to this struct, so you are free to store + * some extra info in the following variables. */ + lzo_voidp user1; +@@ -343,6 +313,9 @@ struct lzo_callback_t + #define LZO_E_INPUT_NOT_CONSUMED (-8) + #define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ + #define LZO_E_INVALID_ARGUMENT (-10) ++#define LZO_E_INVALID_ALIGNMENT (-11) /* pointer argument is not properly aligned */ ++#define LZO_E_OUTPUT_NOT_CONSUMED (-12) ++#define LZO_E_INTERNAL_ERROR (-99) + + + #ifndef lzo_sizeof_dict_t +@@ -356,7 +329,7 @@ struct lzo_callback_t + * compiler's view of various types are consistent. + */ + #define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ +- (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ ++ (int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\ + (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ + (int)sizeof(lzo_callback_t)) + LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int); +@@ -379,18 +352,22 @@ LZO_EXTERN(lzo_voidp) + lzo_memset(lzo_voidp buf, int c, lzo_uint len); + + /* checksum functions */ +-LZO_EXTERN(lzo_uint32) +- lzo_adler32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); +-LZO_EXTERN(lzo_uint32) +- lzo_crc32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); +-LZO_EXTERN(const lzo_uint32p) ++LZO_EXTERN(lzo_uint32_t) ++ lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); ++LZO_EXTERN(lzo_uint32_t) ++ lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); ++LZO_EXTERN(const lzo_uint32_tp) + lzo_get_crc32_table(void); + + /* misc. */ + LZO_EXTERN(int) _lzo_config_check(void); +-typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; +-typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; +-typedef union { void *vp; lzo_bytep bp; lzo_uint u; lzo_uint32 u32; unsigned long l; } lzo_align_t; ++typedef union { ++ lzo_voidp a00; lzo_bytep a01; lzo_uint a02; lzo_xint a03; lzo_uintptr_t a04; ++ void *a05; unsigned char *a06; unsigned long a07; size_t a08; ptrdiff_t a09; ++#if defined(lzo_int64_t) ++ lzo_uint64_t a10; ++#endif ++} lzo_align_t; + + /* align a char pointer on a boundary that is a multiple of 'size' */ + LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); +@@ -399,9 +376,30 @@ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); + + + /*********************************************************************** +-// deprecated macros - only for backward compatibility with LZO v1.xx ++// deprecated macros - only for backward compatibility + ************************************************************************/ + ++/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ ++#define lzo_byte unsigned char ++/* deprecated type names */ ++#define lzo_int32 lzo_int32_t ++#define lzo_uint32 lzo_uint32_t ++#define lzo_int32p lzo_int32_t __LZO_MMODEL * ++#define lzo_uint32p lzo_uint32_t __LZO_MMODEL * ++#define LZO_INT32_MAX LZO_INT32_C(2147483647) ++#define LZO_UINT32_MAX LZO_UINT32_C(4294967295) ++#if defined(lzo_int64_t) ++#define lzo_int64 lzo_int64_t ++#define lzo_uint64 lzo_uint64_t ++#define lzo_int64p lzo_int64_t __LZO_MMODEL * ++#define lzo_uint64p lzo_uint64_t __LZO_MMODEL * ++#define LZO_INT64_MAX LZO_INT64_C(9223372036854775807) ++#define LZO_UINT64_MAX LZO_UINT64_C(18446744073709551615) ++#endif ++/* deprecated types */ ++typedef union { lzo_bytep a; lzo_uint b; } __lzo_pu_u; ++typedef union { lzo_bytep a; lzo_uint32_t b; } __lzo_pu32_u; ++ + #if defined(LZO_CFG_COMPAT) + + #define __LZOCONF_H 1 +@@ -443,4 +441,4 @@ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); + #endif /* already included */ + + +-/* vim:set ts=4 et: */ ++/* vim:set ts=4 sw=4 et: */ +diff --git a/grub-core/lib/minilzo/lzodefs.h b/grub-core/lib/minilzo/lzodefs.h +index 0e40e33..f4ae948 100644 +--- a/grub-core/lib/minilzo/lzodefs.h ++++ b/grub-core/lib/minilzo/lzodefs.h +@@ -2,22 +2,7 @@ + + This file is part of the LZO real-time data compression library. + +- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer ++ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + The LZO library is free software; you can redistribute it and/or +@@ -47,12 +32,6 @@ + #if defined(__CYGWIN32__) && !defined(__CYGWIN__) + # define __CYGWIN__ __CYGWIN32__ + #endif +-#if defined(__IBMCPP__) && !defined(__IBMC__) +-# define __IBMC__ __IBMCPP__ +-#endif +-#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) +-# define __INTEL_COMPILER __ICL +-#endif + #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) + # define _ALL_SOURCE 1 + #endif +@@ -61,19 +40,30 @@ + # define __LONG_MAX__ 9223372036854775807L + # endif + #endif +-#if defined(__INTEL_COMPILER) && defined(__linux__) ++#if !defined(LZO_CFG_NO_DISABLE_WUNDEF) ++#if defined(__ARMCC_VERSION) ++# pragma diag_suppress 193 ++#elif defined(__clang__) && defined(__clang_minor__) ++# pragma clang diagnostic ignored "-Wundef" ++#elif defined(__INTEL_COMPILER) + # pragma warning(disable: 193) +-#endif +-#if defined(__KEIL__) && defined(__C166__) +-# pragma warning disable = 322 +-#elif 0 && defined(__C251__) ++#elif defined(__KEIL__) && defined(__C166__) + # pragma warning disable = 322 +-#endif +-#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) +-# if (_MSC_VER >= 1300) ++#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) ++# if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) ++# pragma GCC diagnostic ignored "-Wundef" ++# endif ++#elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) ++# if ((_MSC_VER-0) >= 1300) + # pragma warning(disable: 4668) + # endif + #endif ++#endif ++#if 0 && defined(__POCC__) && defined(_WIN32) ++# if (__POCC__ >= 400) ++# pragma warn(disable: 2216) ++# endif ++#endif + #if 0 && defined(__WATCOMC__) + # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) + # pragma warning 203 9 +@@ -82,13 +72,29 @@ + #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) + # pragma option -h + #endif ++#if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) ++#ifndef _CRT_NONSTDC_NO_DEPRECATE ++#define _CRT_NONSTDC_NO_DEPRECATE 1 ++#endif ++#ifndef _CRT_NONSTDC_NO_WARNINGS ++#define _CRT_NONSTDC_NO_WARNINGS 1 ++#endif ++#ifndef _CRT_SECURE_NO_DEPRECATE ++#define _CRT_SECURE_NO_DEPRECATE 1 ++#endif ++#ifndef _CRT_SECURE_NO_WARNINGS ++#define _CRT_SECURE_NO_WARNINGS 1 ++#endif ++#endif + #if 0 +-#define LZO_0xffffL 0xfffful +-#define LZO_0xffffffffL 0xfffffffful ++#define LZO_0xffffUL 0xfffful ++#define LZO_0xffffffffUL 0xfffffffful + #else +-#define LZO_0xffffL 65535ul +-#define LZO_0xffffffffL 4294967295ul +#define LZO_0xffffUL 65535ul +#define LZO_0xffffffffUL 4294967295ul #endif @@ -127,7 +466,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #if (LZO_0xffffL == LZO_0xffffffffL) # error "your preprocessor is broken 1" #endif -@@ -123,6 +129,13 @@ +@@ -103,6 +109,13 @@ # error "your preprocessor is broken 4" #endif #endif @@ -141,7 +480,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #if (UINT_MAX == LZO_0xffffL) #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) # if !defined(MSDOS) -@@ -253,14 +266,31 @@ +@@ -233,14 +246,31 @@ #endif #define LZO_PP_STRINGIZE(x) #x #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) @@ -173,7 +512,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #if 1 #define LZO_CPP_STRINGIZE(x) #x #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) -@@ -268,12 +298,16 @@ +@@ -248,12 +278,16 @@ #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e @@ -191,7 +530,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #if 1 && defined(__cplusplus) # if !defined(__STDC_CONSTANT_MACROS) # define __STDC_CONSTANT_MACROS 1 -@@ -283,9 +317,13 @@ +@@ -263,9 +297,13 @@ # endif #endif #if defined(__cplusplus) @@ -207,7 +546,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #endif #if !defined(__LZO_OS_OVERRIDE) #if (LZO_OS_FREESTANDING) -@@ -386,12 +424,12 @@ +@@ -366,12 +404,12 @@ #elif defined(__VMS) # define LZO_OS_VMS 1 # define LZO_INFO_OS "vms" @@ -222,7 +561,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 # define LZO_OS_CONSOLE 1 # define LZO_OS_CONSOLE_PSP 1 # define LZO_INFO_OS "console" -@@ -419,9 +457,18 @@ +@@ -399,9 +437,18 @@ # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) # define LZO_OS_POSIX_LINUX 1 # define LZO_INFO_OS_POSIX "linux" @@ -244,7 +583,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 # elif defined(__minix__) || defined(__minix) # define LZO_OS_POSIX_MINIX 1 # define LZO_INFO_OS_POSIX "minix" -@@ -456,18 +503,18 @@ +@@ -436,18 +483,18 @@ #endif #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # if (UINT_MAX != LZO_0xffffL) @@ -267,7 +606,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 # endif #endif #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) -@@ -483,59 +530,65 @@ +@@ -463,59 +510,65 @@ # define LZO_INFO_CC "sdcc" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) @@ -358,7 +697,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #elif defined(__AZTEC_C__) # define LZO_CC_AZTECC 1 # define LZO_INFO_CC "Aztec C" -@@ -560,10 +613,23 @@ +@@ -540,10 +593,23 @@ # define LZO_CC_DECC 1 # define LZO_INFO_CC "DEC C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) @@ -382,7 +721,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #elif defined(__IAR_SYSTEMS_ICC__) # define LZO_CC_IARC 1 # define LZO_INFO_CC "IAR C" -@@ -572,10 +638,14 @@ +@@ -552,10 +618,14 @@ # else # define LZO_INFO_CCVER "unknown" # endif @@ -399,7 +738,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #elif defined(__KEIL__) && defined(__C166__) # define LZO_CC_KEILC 1 # define LZO_INFO_CC "Keil C" -@@ -592,16 +662,8 @@ +@@ -572,16 +642,8 @@ # else # define LZO_INFO_CCVER "unknown" # endif @@ -418,7 +757,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 # define LZO_INFO_CC "Metrowerks C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) -@@ -612,6 +674,15 @@ +@@ -592,6 +654,15 @@ # define LZO_CC_PACIFICC 1 # define LZO_INFO_CC "Pacific C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) @@ -434,7 +773,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) # define LZO_CC_PGI 1 # define LZO_INFO_CC "Portland Group PGI C" -@@ -626,7 +697,7 @@ +@@ -606,7 +677,7 @@ # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) #elif defined(__SUNPRO_C) # define LZO_INFO_CC "SunPro C" @@ -443,7 +782,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 # define LZO_CC_SUNPROC __SUNPRO_C # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) # else -@@ -635,7 +706,7 @@ +@@ -615,7 +686,7 @@ # endif #elif defined(__SUNPRO_CC) # define LZO_INFO_CC "SunPro C" @@ -452,7 +791,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 # define LZO_CC_SUNPROC __SUNPRO_CC # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) # else -@@ -661,16 +732,46 @@ +@@ -641,16 +712,46 @@ #elif defined(__ZTC__) # define LZO_CC_ZORTECHC 1 # define LZO_INFO_CC "Zortech C" @@ -500,7 +839,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" #endif -@@ -688,8 +789,10 @@ +@@ -668,8 +769,10 @@ # define LZO_INFO_ARCH "generic" #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # define LZO_ARCH_I086 1 @@ -512,7 +851,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) # define LZO_ARCH_ALPHA 1 # define LZO_INFO_ARCH "alpha" -@@ -705,10 +808,10 @@ +@@ -685,10 +788,10 @@ # define LZO_INFO_ARCH "arm_thumb" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) # define LZO_ARCH_ARM 1 @@ -525,7 +864,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 # define LZO_INFO_ARCH "arm" # else # define LZO_INFO_ARCH "arm" -@@ -826,53 +929,147 @@ +@@ -806,53 +909,147 @@ # error "FIXME - missing define for CPU architecture" #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) @@ -555,9 +894,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# define LZO_ARCH_X64 1 +#elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE) +# define LZO_ARCH_AMD64 1 - #endif --#if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086) --# error "this should not happen" ++#endif +#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) +# define LZO_ARCH_AARCH64 1 +#elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE) @@ -585,7 +922,9 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +#endif +#if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB) +# error "unexpected configuration - check your compiler defines" -+#endif + #endif +-#if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086) +-# error "this should not happen" +#if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2) +# error "unexpected configuration - check your compiler defines" +#endif @@ -614,9 +953,8 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 # if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" +# error "unexpected configuration - check your compiler defines" - # endif - #endif --#if !defined(__LZO_MM_OVERRIDE) ++# endif ++#endif +#if (LZO_ARCH_AMD64 || LZO_ARCH_I386) +# if !defined(LZO_TARGET_FEATURE_SSE2) +# if defined(__SSE2__) @@ -679,8 +1017,9 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# if 1 +# define LZO_TARGET_FEATURE_NEON 1 +# endif -+# endif -+#endif + # endif + #endif +-#if !defined(__LZO_MM_OVERRIDE) +#if 0 +#elif !defined(__LZO_MM_OVERRIDE) #if (LZO_ARCH_I086) @@ -690,7 +1029,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #endif #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) # define LZO_MM_TINY 1 -@@ -899,7 +1096,7 @@ +@@ -879,7 +1076,7 @@ #elif (LZO_CC_ZORTECHC && defined(__VCM__)) # define LZO_MM_LARGE 1 #else @@ -699,7 +1038,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #endif #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) #define LZO_HAVE_MM_HUGE_PTR 1 -@@ -922,10 +1119,10 @@ +@@ -902,10 +1099,10 @@ #endif #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) # if (LZO_OS_DOS16) @@ -712,7 +1051,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 # endif #endif #ifdef __cplusplus -@@ -957,7 +1154,7 @@ extern "C" { +@@ -937,7 +1134,7 @@ extern "C" { #endif #elif (LZO_ARCH_C166) #if !defined(__MODEL__) @@ -721,7 +1060,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #elif ((__MODEL__) == 0) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 1) -@@ -971,11 +1168,11 @@ extern "C" { +@@ -951,11 +1148,11 @@ extern "C" { #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else @@ -735,7 +1074,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #elif ((__MODEL__) == 0) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) -@@ -987,11 +1184,11 @@ extern "C" { +@@ -967,11 +1164,11 @@ extern "C" { #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else @@ -749,7 +1088,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #elif ((__MODEL__) == 1) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) -@@ -1003,7 +1200,7 @@ extern "C" { +@@ -983,7 +1180,7 @@ extern "C" { #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else @@ -758,10 +1097,12 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #endif #elif (LZO_ARCH_CRAY_PVP) # define LZO_MM_PVP 1 -@@ -1030,35 +1227,818 @@ extern "C" { +@@ -1010,462 +1207,270 @@ extern "C" { # error "unknown memory model" #endif #endif +-#if defined(SIZEOF_SHORT) +-# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) +#if !defined(__lzo_gnuc_extension__) +#if (LZO_CC_GNUC >= 0x020800ul) +# define __lzo_gnuc_extension__ __extension__ @@ -770,11 +1111,17 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +#elif (LZO_CC_IBMC >= 600) +# define __lzo_gnuc_extension__ __extension__ +#else -+#endif -+#endif + #endif +-#if defined(SIZEOF_INT) +-# define LZO_SIZEOF_INT (SIZEOF_INT) + #endif +-#if defined(SIZEOF_LONG) +-# define LZO_SIZEOF_LONG (SIZEOF_LONG) +#if !defined(__lzo_gnuc_extension__) +# define __lzo_gnuc_extension__ /*empty*/ -+#endif + #endif +-#if defined(SIZEOF_LONG_LONG) +-# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) +#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0 +# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) +# define LZO_CFG_USE_NEW_STYLE_CASTS 0 @@ -783,35 +1130,85 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# else +# define LZO_CFG_USE_NEW_STYLE_CASTS 1 +# endif -+#endif + #endif +-#if defined(SIZEOF___INT16) +-# define LZO_SIZEOF___INT16 (SIZEOF___INT16) +#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+#endif + #endif +-#if defined(SIZEOF___INT32) +-# define LZO_SIZEOF___INT32 (SIZEOF___INT32) +#if !defined(__cplusplus) +# if defined(LZO_CFG_USE_NEW_STYLE_CASTS) +# undef LZO_CFG_USE_NEW_STYLE_CASTS +# endif +# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+#endif + #endif +-#if defined(SIZEOF___INT64) +-# define LZO_SIZEOF___INT64 (SIZEOF___INT64) +#if !defined(LZO_REINTERPRET_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast (e)) +# endif -+#endif + #endif +-#if defined(SIZEOF_VOID_P) +-# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) +#if !defined(LZO_REINTERPRET_CAST) +# define LZO_REINTERPRET_CAST(t,e) ((t) (e)) -+#endif + #endif +-#if defined(SIZEOF_SIZE_T) +-# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) +#if !defined(LZO_STATIC_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_STATIC_CAST(t,e) (static_cast (e)) +# endif -+#endif + #endif +-#if defined(SIZEOF_PTRDIFF_T) +-# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) +#if !defined(LZO_STATIC_CAST) +# define LZO_STATIC_CAST(t,e) ((t) (e)) -+#endif + #endif +-#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) +-#if !defined(LZO_SIZEOF_SHORT) +-# if (LZO_ARCH_CRAY_PVP) +-# define LZO_SIZEOF_SHORT 8 +-# elif (USHRT_MAX == LZO_0xffffL) +-# define LZO_SIZEOF_SHORT 2 +-# elif (__LZO_LSR(USHRT_MAX,7) == 1) +-# define LZO_SIZEOF_SHORT 1 +-# elif (__LZO_LSR(USHRT_MAX,15) == 1) +-# define LZO_SIZEOF_SHORT 2 +-# elif (__LZO_LSR(USHRT_MAX,31) == 1) +-# define LZO_SIZEOF_SHORT 4 +-# elif (__LZO_LSR(USHRT_MAX,63) == 1) +-# define LZO_SIZEOF_SHORT 8 +-# elif (__LZO_LSR(USHRT_MAX,127) == 1) +-# define LZO_SIZEOF_SHORT 16 +-# else +-# error "LZO_SIZEOF_SHORT" +-# endif +#if !defined(LZO_STATIC_CAST2) +# define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e)) -+#endif + #endif +-#if !defined(LZO_SIZEOF_INT) +-# if (LZO_ARCH_CRAY_PVP) +-# define LZO_SIZEOF_INT 8 +-# elif (UINT_MAX == LZO_0xffffL) +-# define LZO_SIZEOF_INT 2 +-# elif (UINT_MAX == LZO_0xffffffffL) +-# define LZO_SIZEOF_INT 4 +-# elif (__LZO_LSR(UINT_MAX,7) == 1) +-# define LZO_SIZEOF_INT 1 +-# elif (__LZO_LSR(UINT_MAX,15) == 1) +-# define LZO_SIZEOF_INT 2 +-# elif (__LZO_LSR(UINT_MAX,31) == 1) +-# define LZO_SIZEOF_INT 4 +-# elif (__LZO_LSR(UINT_MAX,63) == 1) +-# define LZO_SIZEOF_INT 8 +-# elif (__LZO_LSR(UINT_MAX,127) == 1) +-# define LZO_SIZEOF_INT 16 +-# else +-# error "LZO_SIZEOF_INT" +#if !defined(LZO_UNCONST_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_UNCONST_CAST(t,e) (const_cast (e)) @@ -819,8 +1216,23 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# define LZO_UNCONST_CAST(t,e) ((t) (e)) +# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e))))) -+# endif -+#endif + # endif + #endif +-#if !defined(LZO_SIZEOF_LONG) +-# if (ULONG_MAX == LZO_0xffffffffL) +-# define LZO_SIZEOF_LONG 4 +-# elif (__LZO_LSR(ULONG_MAX,7) == 1) +-# define LZO_SIZEOF_LONG 1 +-# elif (__LZO_LSR(ULONG_MAX,15) == 1) +-# define LZO_SIZEOF_LONG 2 +-# elif (__LZO_LSR(ULONG_MAX,31) == 1) +-# define LZO_SIZEOF_LONG 4 +-# elif (__LZO_LSR(ULONG_MAX,63) == 1) +-# define LZO_SIZEOF_LONG 8 +-# elif (__LZO_LSR(ULONG_MAX,127) == 1) +-# define LZO_SIZEOF_LONG 16 +-# else +-# error "LZO_SIZEOF_LONG" +#if !defined(LZO_UNCONST_CAST) +# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e)))) +#endif @@ -831,8 +1243,18 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e)) +# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) -+# endif -+#endif + # endif + #endif +-#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) +-#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) +-# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) +-# if (LZO_CC_GNUC >= 0x030300ul) +-# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) +-# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG +-# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) +-# define LZO_SIZEOF_LONG_LONG 4 +-# endif +-# endif +#if !defined(LZO_UNCONST_VOLATILE_CAST) +# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e)))) +#endif @@ -843,11 +1265,47 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# define LZO_UNVOLATILE_CAST(t,e) ((t) (e)) +# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e))))) -+# endif -+#endif + # endif + #endif +#if !defined(LZO_UNVOLATILE_CAST) +# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e)))) -+#endif + #endif +-#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) +-#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) +-#if (LZO_ARCH_I086 && LZO_CC_DMC) +-#elif (LZO_CC_CILLY) && defined(__GNUC__) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_OS_WIN64 || defined(_WIN64)) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) +-# define LZO_SIZEOF___INT64 8 +-#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) +-#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +-# define LZO_SIZEOF_LONG_LONG 8 +#if !defined(LZO_UNVOLATILE_CONST_CAST) +# if (LZO_CFG_USE_NEW_STYLE_CASTS) +# define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast (e)) @@ -856,26 +1314,40 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) +# endif -+#endif + #endif +#if !defined(LZO_UNVOLATILE_CONST_CAST) +# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e)))) -+#endif + #endif +#if !defined(LZO_PCAST) +# if (LZO_HAVE_MM_HUGE_PTR) +# define LZO_PCAST(t,e) ((t) (e)) +# endif -+#endif + #endif +-#if defined(__cplusplus) && (LZO_CC_GNUC) +-# if (LZO_CC_GNUC < 0x020800ul) +-# undef LZO_SIZEOF_LONG_LONG +#if !defined(LZO_PCAST) +# define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e)) +#endif +#if !defined(LZO_CCAST) +# if (LZO_HAVE_MM_HUGE_PTR) +# define LZO_CCAST(t,e) ((t) (e)) -+# endif -+#endif + # endif + #endif +-#if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) +-# undef LZO_SIZEOF_LONG_LONG +#if !defined(LZO_CCAST) +# define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e)) -+#endif + #endif +-#if !defined(LZO_SIZEOF_VOID_P) +-#if (LZO_ARCH_I086) +-# define __LZO_WORDSIZE 2 +-# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) +-# define LZO_SIZEOF_VOID_P 2 +-# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) +-# define LZO_SIZEOF_VOID_P 4 +-# else +-# error "LZO_MM" +#if !defined(LZO_ICONV) +# define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e) +#endif @@ -890,11 +1362,67 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# define __lzo_cte(e) ((void)0,(e)) +# elif 1 +# define __lzo_cte(e) ((void)0,(e)) -+# endif -+#endif + # endif +-#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) +-# define __LZO_WORDSIZE 1 +-# define LZO_SIZEOF_VOID_P 2 +-#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) +-# define LZO_SIZEOF_VOID_P 2 +-#elif (LZO_ARCH_H8300) +-# if defined(__NORMAL_MODE__) +-# define __LZO_WORDSIZE 4 +-# define LZO_SIZEOF_VOID_P 2 +-# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) +-# define __LZO_WORDSIZE 4 +-# define LZO_SIZEOF_VOID_P 4 +-# else +-# define __LZO_WORDSIZE 2 +-# define LZO_SIZEOF_VOID_P 2 +-# endif +-# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT +-# endif +-#elif (LZO_ARCH_M16C) +-# define __LZO_WORDSIZE 2 +-# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) +-# define LZO_SIZEOF_VOID_P 4 +-# else +-# define LZO_SIZEOF_VOID_P 2 +-# endif +-#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) +-# define __LZO_WORDSIZE 8 +-# define LZO_SIZEOF_VOID_P 4 +-#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) +-# define __LZO_WORDSIZE 8 +-# define LZO_SIZEOF_VOID_P 8 +-#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) +-# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +-#elif (LZO_OS_OS400 || defined(__OS400__)) +-# define __LZO_WORDSIZE LZO_SIZEOF_LONG +-# define LZO_SIZEOF_VOID_P 16 +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +-#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +-# define LZO_SIZEOF_VOID_P 8 +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +-#elif (LZO_ARCH_SPU) +-# if 0 +-# define __LZO_WORDSIZE 16 +-# endif +-# define LZO_SIZEOF_VOID_P 4 +-#else +-# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG + #endif +#if !defined(__lzo_cte) +# define __lzo_cte(e) (e) -+#endif + #endif +-#if !defined(LZO_WORDSIZE) +-# if defined(__LZO_WORDSIZE) +-# define LZO_WORDSIZE __LZO_WORDSIZE +#if !defined(LZO_BLOCK_BEGIN) +# define LZO_BLOCK_BEGIN do { +# define LZO_BLOCK_END } while __lzo_cte(0) @@ -916,10 +1444,28 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# define LZO_UNUSED(var) ((void) sizeof(var)) +# elif (LZO_CC_WATCOMC) && defined(__cplusplus) +# define LZO_UNUSED(var) ((void) var) -+# else + # else +-# define LZO_WORDSIZE LZO_SIZEOF_VOID_P +# define LZO_UNUSED(var) ((void) &var) -+# endif -+#endif + # endif + #endif +-#if !defined(LZO_SIZEOF_SIZE_T) +-#if (LZO_ARCH_I086 || LZO_ARCH_M16C) +-# define LZO_SIZEOF_SIZE_T 2 +-#else +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P +-#endif +-#endif +-#if !defined(LZO_SIZEOF_PTRDIFF_T) +-#if (LZO_ARCH_I086) +-# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P +-# elif (LZO_MM_COMPACT || LZO_MM_LARGE) +-# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) +-# define LZO_SIZEOF_PTRDIFF_T 4 +-# else +-# define LZO_SIZEOF_PTRDIFF_T 2 +-# endif +#if !defined(LZO_UNUSED_FUNC) +# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) +# define LZO_UNUSED_FUNC(func) ((void) func) @@ -933,131 +1479,322 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# define LZO_UNUSED_FUNC(func) ((void) &func) +# elif (LZO_CC_KEILC || LZO_CC_PELLESC) +# define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];} -+# else + # else +-# error "LZO_MM" +# define LZO_UNUSED_FUNC(func) ((void) func) -+# endif -+#endif + # endif +-#else +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T +-#endif + #endif +-#if (LZO_ABI_NEUTRAL_ENDIAN) +-# undef LZO_ABI_BIG_ENDIAN +-# undef LZO_ABI_LITTLE_ENDIAN +-#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) +-#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) +-# if (__LITTLE_ENDIAN__ == 1) +-# define LZO_ABI_LITTLE_ENDIAN 1 +#if !defined(LZO_UNUSED_LABEL) +# if (LZO_CC_CLANG >= 0x020800ul) +# define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l))) +# elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) +# define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l -+# else + # else +-# define LZO_ABI_BIG_ENDIAN 1 +# define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l -+# endif -+#endif + # endif +-#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#endif +-#endif +-#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) +-# error "this should not happen" +-#endif +-#if (LZO_ABI_BIG_ENDIAN) +-# define LZO_INFO_ABI_ENDIAN "be" +-#elif (LZO_ABI_LITTLE_ENDIAN) +-# define LZO_INFO_ABI_ENDIAN "le" +-#elif (LZO_ABI_NEUTRAL_ENDIAN) +-# define LZO_INFO_ABI_ENDIAN "neutral" +-#endif +-#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) +-# define LZO_ABI_I8LP16 1 +-# define LZO_INFO_ABI_PM "i8lp16" +-#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) +-# define LZO_ABI_ILP16 1 +-# define LZO_INFO_ABI_PM "ilp16" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) +-# define LZO_ABI_ILP32 1 +-# define LZO_INFO_ABI_PM "ilp32" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) +-# define LZO_ABI_LLP64 1 +-# define LZO_INFO_ABI_PM "llp64" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) +-# define LZO_ABI_LP64 1 +-# define LZO_INFO_ABI_PM "lp64" +-#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) +-# define LZO_ABI_ILP64 1 +-# define LZO_INFO_ABI_PM "ilp64" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) +-# define LZO_ABI_IP32L64 1 +-# define LZO_INFO_ABI_PM "ip32l64" + #endif +-#if !defined(__LZO_LIBC_OVERRIDE) +-#if (LZO_LIBC_NAKED) +-# define LZO_INFO_LIBC "naked" +-#elif (LZO_LIBC_FREESTANDING) +-# define LZO_INFO_LIBC "freestanding" +-#elif (LZO_LIBC_MOSTLY_FREESTANDING) +-# define LZO_INFO_LIBC "mfreestanding" +-#elif (LZO_LIBC_ISOC90) +-# define LZO_INFO_LIBC "isoc90" +-#elif (LZO_LIBC_ISOC99) +-# define LZO_INFO_LIBC "isoc99" +-#elif defined(__dietlibc__) +-# define LZO_LIBC_DIETLIBC 1 +-# define LZO_INFO_LIBC "dietlibc" +-#elif defined(_NEWLIB_VERSION) +-# define LZO_LIBC_NEWLIB 1 +-# define LZO_INFO_LIBC "newlib" +-#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) +-# if defined(__UCLIBC_SUBLEVEL__) +-# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) +#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) +# if 0 +# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var +# elif 0 && (LZO_CC_GNUC) +# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var -+# else + # else +-# define LZO_LIBC_UCLIBC 0x00090bL +# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init -+# endif -+#endif -+#if !defined(__lzo_inline) -+#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) -+#elif defined(__cplusplus) -+# define __lzo_inline inline + # endif +-# define LZO_INFO_LIBC "uclibc" +-#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) +-# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) +-# define LZO_INFO_LIBC "glibc" +-#elif (LZO_CC_MWERKS) && defined(__MSL__) +-# define LZO_LIBC_MSL __MSL__ +-# define LZO_INFO_LIBC "msl" +-#elif 1 && defined(__IAR_SYSTEMS_ICC__) +-# define LZO_LIBC_ISOC90 1 +-# define LZO_INFO_LIBC "isoc90" +-#else +-# define LZO_LIBC_DEFAULT 1 +-# define LZO_INFO_LIBC "default" +-#endif +-#endif +-#if !defined(__lzo_gnuc_extension__) +-#if (LZO_CC_GNUC >= 0x020800ul) +-# define __lzo_gnuc_extension__ __extension__ +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_gnuc_extension__ __extension__ +-#else +-# define __lzo_gnuc_extension__ /*empty*/ +-#endif +-#endif +-#if !defined(__lzo_ua_volatile) +-# define __lzo_ua_volatile volatile +-#endif +-#if !defined(__lzo_alignof) +-#if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +-# define __lzo_alignof(e) __alignof__(e) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) +-# define __lzo_alignof(e) __alignof__(e) +-#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) +-# define __lzo_alignof(e) __alignof(e) +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) +-# define __lzo_alignof(e) __alignof__(e) +-#endif +-#endif +-#if defined(__lzo_alignof) +-# define __lzo_HAVE_alignof 1 +-#endif +-#if !defined(__lzo_constructor) +-#if (LZO_CC_GNUC >= 0x030400ul) +-# define __lzo_constructor __attribute__((__constructor__,__used__)) +-#elif (LZO_CC_GNUC >= 0x020700ul) +-# define __lzo_constructor __attribute__((__constructor__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_constructor __attribute__((__constructor__)) +-#endif +-#endif +-#if defined(__lzo_constructor) +-# define __lzo_HAVE_constructor 1 +-#endif +-#if !defined(__lzo_destructor) +-#if (LZO_CC_GNUC >= 0x030400ul) +-# define __lzo_destructor __attribute__((__destructor__,__used__)) +-#elif (LZO_CC_GNUC >= 0x020700ul) +-# define __lzo_destructor __attribute__((__destructor__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_destructor __attribute__((__destructor__)) +-#endif +-#endif +-#if defined(__lzo_destructor) +-# define __lzo_HAVE_destructor 1 +-#endif +-#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) +-# error "this should not happen" + #endif + #if !defined(__lzo_inline) + #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) + #elif defined(__cplusplus) + # define __lzo_inline inline +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) +# define __lzo_inline inline -+#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) -+# define __lzo_inline __inline + #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) + # define __lzo_inline __inline +-#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+# define __lzo_inline __inline__ -+#elif (LZO_CC_DMC) -+# define __lzo_inline __inline + # define __lzo_inline __inline__ + #elif (LZO_CC_DMC) + # define __lzo_inline __inline +#elif (LZO_CC_GHS) +# define __lzo_inline __inline__ +#elif (LZO_CC_IBMC >= 600) +# define __lzo_inline __inline__ -+#elif (LZO_CC_INTELC) -+# define __lzo_inline __inline -+#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) -+# define __lzo_inline __inline -+#elif (LZO_CC_MSC && (_MSC_VER >= 900)) -+# define __lzo_inline __inline + #elif (LZO_CC_INTELC) + # define __lzo_inline __inline + #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) + # define __lzo_inline __inline + #elif (LZO_CC_MSC && (_MSC_VER >= 900)) + # define __lzo_inline __inline +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) +#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_inline __inline__ -+#endif -+#endif -+#if defined(__lzo_inline) + # define __lzo_inline __inline__ +-#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +-# define __lzo_inline inline + #endif + #endif + #if defined(__lzo_inline) +# ifndef __lzo_HAVE_inline -+# define __lzo_HAVE_inline 1 + # define __lzo_HAVE_inline 1 +# endif -+#else -+# define __lzo_inline /*empty*/ -+#endif -+#if !defined(__lzo_forceinline) -+#if (LZO_CC_GNUC >= 0x030200ul) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) + #else + # define __lzo_inline /*empty*/ + #endif + #if !defined(__lzo_forceinline) + #if (LZO_CC_GNUC >= 0x030200ul) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) +#elif (LZO_CC_IBMC >= 700) +# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) -+# define __lzo_forceinline __forceinline + # define __lzo_forceinline __forceinline +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -+# define __lzo_forceinline __forceinline + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) + #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) + # define __lzo_forceinline __forceinline +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) +#elif (LZO_CC_PGI >= 0x0d0a00ul) +# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#endif -+#endif -+#if defined(__lzo_forceinline) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) + #endif + #endif + #if defined(__lzo_forceinline) +# ifndef __lzo_HAVE_forceinline -+# define __lzo_HAVE_forceinline 1 + # define __lzo_HAVE_forceinline 1 +# endif -+#else + #else +-# define __lzo_forceinline /*empty*/ +# define __lzo_forceinline __lzo_inline -+#endif -+#if !defined(__lzo_noinline) -+#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) -+# define __lzo_noinline __attribute__((__noinline__,__used__)) -+#elif (LZO_CC_GNUC >= 0x030200ul) -+# define __lzo_noinline __attribute__((__noinline__)) + #endif + #if !defined(__lzo_noinline) + #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) + # define __lzo_noinline __attribute__((__noinline__,__used__)) + #elif (LZO_CC_GNUC >= 0x030200ul) + # define __lzo_noinline __attribute__((__noinline__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) +#elif (LZO_CC_IBMC >= 700) +# define __lzo_noinline __attribute__((__noinline__)) +#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) -+# define __lzo_noinline __declspec(noinline) + # define __lzo_noinline __declspec(noinline) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_noinline __attribute__((__noinline__)) + # define __lzo_noinline __attribute__((__noinline__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_noinline __declspec(noinline) -+#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) -+# if defined(__cplusplus) -+# else -+# define __lzo_noinline __declspec(noinline) -+# endif + # define __lzo_noinline __attribute__((__noinline__)) + #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) + # define __lzo_noinline __declspec(noinline) +@@ -1474,179 +1479,409 @@ extern "C" { + # else + # define __lzo_noinline __declspec(noinline) + # endif +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) +#elif (LZO_CC_PGI >= 0x0d0a00ul) +# define __lzo_noinline __attribute__((__noinline__)) +#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_noinline __attribute__((__noinline__)) -+#endif -+#endif -+#if defined(__lzo_noinline) + # define __lzo_noinline __attribute__((__noinline__)) + #endif + #endif + #if defined(__lzo_noinline) +# ifndef __lzo_HAVE_noinline -+# define __lzo_HAVE_noinline 1 + # define __lzo_HAVE_noinline 1 +# endif -+#else -+# define __lzo_noinline /*empty*/ -+#endif -+#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) + #else + # define __lzo_noinline /*empty*/ + #endif + #if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) +-# error "this should not happen" +# error "unexpected configuration - check your compiler defines" -+#endif + #endif +-#if !defined(__lzo_noreturn) +-#if (LZO_CC_GNUC >= 0x020700ul) +-# define __lzo_noreturn __attribute__((__noreturn__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) +-# define __lzo_noreturn __declspec(noreturn) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) +-# define __lzo_noreturn __attribute__((__noreturn__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_noreturn __attribute__((__noreturn__)) +-#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) +-# define __lzo_noreturn __declspec(noreturn) +#if !defined(__lzo_static_inline) +#if (LZO_CC_IBMC) +# define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline -+#endif -+#endif + #endif + #endif +-#if defined(__lzo_noreturn) +-# define __lzo_HAVE_noreturn 1 +-#else +-# define __lzo_noreturn /*empty*/ +#if !defined(__lzo_static_inline) +# define __lzo_static_inline static __lzo_inline -+#endif + #endif +-#if !defined(__lzo_nothrow) +-#if (LZO_CC_GNUC >= 0x030300ul) +-# define __lzo_nothrow __attribute__((__nothrow__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) +-# define __lzo_nothrow __declspec(nothrow) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC) +-# define __lzo_nothrow __attribute__((__nothrow__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_nothrow __attribute__((__nothrow__)) +-#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) +#if !defined(__lzo_static_forceinline) +#if (LZO_CC_IBMC) +# define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline @@ -1145,41 +1882,43 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +# define __lzo_nothrow __attribute__((__nothrow__)) +#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) -+# define __lzo_nothrow __declspec(nothrow) -+#endif -+#endif -+#if defined(__lzo_nothrow) + # define __lzo_nothrow __declspec(nothrow) + #endif + #endif + #if defined(__lzo_nothrow) +# ifndef __lzo_HAVE_nothrow -+# define __lzo_HAVE_nothrow 1 + # define __lzo_HAVE_nothrow 1 +# endif -+#else -+# define __lzo_nothrow /*empty*/ -+#endif -+#if !defined(__lzo_restrict) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_restrict __restrict__ + #else + # define __lzo_nothrow /*empty*/ + #endif + #if !defined(__lzo_restrict) + #if (LZO_CC_GNUC >= 0x030400ul) + # define __lzo_restrict __restrict__ +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) +#elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus) -+# define __lzo_restrict __restrict__ + # define __lzo_restrict __restrict__ +-#elif (LZO_CC_CLANG || LZO_CC_LLVM) +#elif (LZO_CC_IBMC >= 1210) +# define __lzo_restrict __restrict__ +#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) +# define __lzo_restrict __restrict__ +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) -+# define __lzo_restrict __restrict + # define __lzo_restrict __restrict__ + #elif (LZO_CC_MSC && (_MSC_VER >= 1400)) + # define __lzo_restrict __restrict +#elif (LZO_CC_PGI >= 0x0d0a00ul) +# define __lzo_restrict __restrict__ -+#endif -+#endif -+#if defined(__lzo_restrict) + #endif + #endif + #if defined(__lzo_restrict) +# ifndef __lzo_HAVE_restrict -+# define __lzo_HAVE_restrict 1 + # define __lzo_HAVE_restrict 1 +# endif -+#else -+# define __lzo_restrict /*empty*/ -+#endif + #else + # define __lzo_restrict /*empty*/ + #endif +#if !defined(__lzo_alignof) +#if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +# define __lzo_alignof(e) __alignof__(e) @@ -1328,49 +2067,88 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) +# error "unexpected configuration - check your compiler defines" +#endif -+#if !defined(__lzo_likely) && !defined(__lzo_unlikely) -+#if (LZO_CC_GNUC >= 0x030200ul) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) + #if !defined(__lzo_likely) && !defined(__lzo_unlikely) + #if (LZO_CC_GNUC >= 0x030200ul) + # define __lzo_likely(e) (__builtin_expect(!!(e),1)) + # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +#elif (LZO_CC_IBMC >= 1010) +# define __lzo_likely(e) (__builtin_expect(!!(e),1)) +# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) + #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) + # define __lzo_likely(e) (__builtin_expect(!!(e),1)) + # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#endif -+#endif -+#if defined(__lzo_likely) + # define __lzo_likely(e) (__builtin_expect(!!(e),1)) + # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) + #endif + #endif + #if defined(__lzo_likely) +# ifndef __lzo_HAVE_likely -+# define __lzo_HAVE_likely 1 + # define __lzo_HAVE_likely 1 +# endif -+#else -+# define __lzo_likely(e) (e) -+#endif -+#if defined(__lzo_unlikely) + #else + # define __lzo_likely(e) (e) + #endif + #if defined(__lzo_unlikely) +# ifndef __lzo_HAVE_unlikely -+# define __lzo_HAVE_unlikely 1 + # define __lzo_HAVE_unlikely 1 +# endif -+#else -+# define __lzo_unlikely(e) (e) -+#endif + #else + # define __lzo_unlikely(e) (e) + #endif +-#if !defined(LZO_UNUSED) +-# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) +-# define LZO_UNUSED(var) ((void) &var) +-# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) +-# define LZO_UNUSED(var) if (&var) ; else +-# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define LZO_UNUSED(var) ((void) var) +-# elif (LZO_CC_MSC && (_MSC_VER < 900)) +-# define LZO_UNUSED(var) if (&var) ; else +-# elif (LZO_CC_KEILC) +-# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} +-# elif (LZO_CC_PACIFICC) +-# define LZO_UNUSED(var) ((void) sizeof(var)) +-# elif (LZO_CC_WATCOMC) && defined(__cplusplus) +-# define LZO_UNUSED(var) ((void) var) +#if !defined(__lzo_static_unused_void_func) +# if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +# define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void) -+# else + # else +-# define LZO_UNUSED(var) ((void) &var) +# define __lzo_static_unused_void_func(f) static __lzo_inline void f(void) -+# endif -+#endif + # endif + #endif +-#if !defined(LZO_UNUSED_FUNC) +-# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) +-# define LZO_UNUSED_FUNC(func) ((void) func) +-# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) +-# define LZO_UNUSED_FUNC(func) if (func) ; else +-# elif (LZO_CC_CLANG || LZO_CC_LLVM) +-# define LZO_UNUSED_FUNC(func) ((void) &func) +-# elif (LZO_CC_MSC && (_MSC_VER < 900)) +-# define LZO_UNUSED_FUNC(func) if (func) ; else +-# elif (LZO_CC_MSC) +-# define LZO_UNUSED_FUNC(func) ((void) &func) +-# elif (LZO_CC_KEILC || LZO_CC_PELLESC) +-# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} +#if !defined(__lzo_loop_forever) +# if (LZO_CC_IBMC) +# define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END -+# else + # else +-# define LZO_UNUSED_FUNC(func) ((void) func) +# define __lzo_loop_forever() do { ; } while __lzo_cte(1) -+# endif -+#endif + # endif + #endif +-#if !defined(LZO_UNUSED_LABEL) +-# if (LZO_CC_WATCOMC) && defined(__cplusplus) +-# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l +-# elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) +-# define LZO_UNUSED_LABEL(l) if (0) goto l +-# else +-# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l +-# endif +#if !defined(__lzo_unreachable) +#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) +# define __lzo_unreachable() __builtin_unreachable(); @@ -1378,99 +2156,92 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# define __lzo_unreachable() __builtin_unreachable(); +#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1 +# define __lzo_unreachable() __builtin_unreachable(); -+#endif + #endif +-#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) +#endif +#if defined(__lzo_unreachable) +# ifndef __lzo_HAVE_unreachable +# define __lzo_HAVE_unreachable 1 +# endif +#else -+# if 0 + # if 0 +-# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var +-# elif 0 && (LZO_CC_GNUC) +-# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var +# define __lzo_unreachable() ((void)0); -+# else + # else +-# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init +# define __lzo_unreachable() __lzo_loop_forever(); -+# endif -+#endif + # endif + #endif +-#if !defined(LZO_UNCONST_CAST) +-# if 0 && defined(__cplusplus) +-# define LZO_UNCONST_CAST(t,e) (const_cast (e)) +-# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e)))))) +-# else +-# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) +-# endif +#ifndef __LZO_CTA_NAME +#if (LZO_CFG_USE_COUNTER) +# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__) +#else +# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__) +#endif -+#endif -+#if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) -+# if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) + #endif + #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) + # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END -+# elif (LZO_CC_DMC || LZO_CC_SYMANTECC) + # elif (LZO_CC_DMC || LZO_CC_SYMANTECC) +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END -+# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) + # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END +# elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus) +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END +# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END -+# else + # else +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; +# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END -+# endif -+#endif -+#if !defined(LZO_COMPILE_TIME_ASSERT) -+# if (LZO_CC_AZTECC) + # endif + #endif + #if !defined(LZO_COMPILE_TIME_ASSERT) + # if (LZO_CC_AZTECC) +-# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} +# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];} -+# elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) -+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; + # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) + # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; +# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) +# define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));} +# elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus) +# define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));} +# elif (LZO_CC_GNUC >= 0x040700ul) +# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} -+# elif (LZO_CC_MSC && (_MSC_VER < 900)) -+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -+# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) -+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -+# else + # elif (LZO_CC_MSC && (_MSC_VER < 900)) + # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; + # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) + # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; + # else +-# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} +# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];} -+# endif -+#endif + # endif + #endif +LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1) +#if defined(__cplusplus) +extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) } +#endif +LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3) -+#if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) -+# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) -+# elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) -+# define __lzo_cdecl __cdecl -+# define __lzo_cdecl_atexit /*empty*/ -+# define __lzo_cdecl_main __cdecl -+# if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) -+# define __lzo_cdecl_qsort __pascal -+# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) -+# define __lzo_cdecl_qsort _stdcall -+# else -+# define __lzo_cdecl_qsort __cdecl -+# endif -+# elif (LZO_CC_WATCOMC) -+# define __lzo_cdecl __cdecl -+# else -+# define __lzo_cdecl __cdecl -+# define __lzo_cdecl_atexit __cdecl -+# define __lzo_cdecl_main __cdecl -+# define __lzo_cdecl_qsort __cdecl -+# endif -+# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) -+# elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) -+# define __lzo_cdecl_sighandler __pascal -+# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) -+# define __lzo_cdecl_sighandler _stdcall -+# elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) -+# define __lzo_cdecl_sighandler __clrcall -+# elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) -+# if defined(_DLL) -+# define __lzo_cdecl_sighandler _far _cdecl _loadds -+# elif defined(_MT) -+# define __lzo_cdecl_sighandler _far _cdecl -+# else + #if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) + # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) + # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) +@@ -1681,99 +1916,654 @@ extern "C" { + # elif defined(_MT) + # define __lzo_cdecl_sighandler _far _cdecl + # else +-# define __lzo_cdecl_sighandler _cdecl +# define __lzo_cdecl_sighandler _cdecl +# endif +# else @@ -1512,154 +2283,198 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +#endif +#endif +#ifndef LZO_SIZEOF_SHORT - #if defined(SIZEOF_SHORT) - # define LZO_SIZEOF_SHORT (SIZEOF_SHORT) ++#if defined(SIZEOF_SHORT) ++# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) +#elif defined(__SIZEOF_SHORT__) +# define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__) - #endif ++#endif +#endif +#ifndef LZO_SIZEOF_INT - #if defined(SIZEOF_INT) - # define LZO_SIZEOF_INT (SIZEOF_INT) ++#if defined(SIZEOF_INT) ++# define LZO_SIZEOF_INT (SIZEOF_INT) +#elif defined(__SIZEOF_INT__) +# define LZO_SIZEOF_INT (__SIZEOF_INT__) - #endif ++#endif +#endif +#ifndef LZO_SIZEOF_LONG - #if defined(SIZEOF_LONG) - # define LZO_SIZEOF_LONG (SIZEOF_LONG) ++#if defined(SIZEOF_LONG) ++# define LZO_SIZEOF_LONG (SIZEOF_LONG) +#elif defined(__SIZEOF_LONG__) +# define LZO_SIZEOF_LONG (__SIZEOF_LONG__) - #endif ++#endif +#endif +#ifndef LZO_SIZEOF_LONG_LONG - #if defined(SIZEOF_LONG_LONG) - # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) ++#if defined(SIZEOF_LONG_LONG) ++# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) +#elif defined(__SIZEOF_LONG_LONG__) +# define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__) - #endif ++#endif +#endif +#ifndef LZO_SIZEOF___INT16 - #if defined(SIZEOF___INT16) - # define LZO_SIZEOF___INT16 (SIZEOF___INT16) - #endif ++#if defined(SIZEOF___INT16) ++# define LZO_SIZEOF___INT16 (SIZEOF___INT16) ++#endif +#endif +#ifndef LZO_SIZEOF___INT32 - #if defined(SIZEOF___INT32) - # define LZO_SIZEOF___INT32 (SIZEOF___INT32) - #endif ++#if defined(SIZEOF___INT32) ++# define LZO_SIZEOF___INT32 (SIZEOF___INT32) ++#endif +#endif +#ifndef LZO_SIZEOF___INT64 - #if defined(SIZEOF___INT64) - # define LZO_SIZEOF___INT64 (SIZEOF___INT64) - #endif ++#if defined(SIZEOF___INT64) ++# define LZO_SIZEOF___INT64 (SIZEOF___INT64) ++#endif +#endif +#ifndef LZO_SIZEOF_VOID_P - #if defined(SIZEOF_VOID_P) - # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) ++#if defined(SIZEOF_VOID_P) ++# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) +#elif defined(__SIZEOF_POINTER__) +# define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__) - #endif ++#endif +#endif +#ifndef LZO_SIZEOF_SIZE_T - #if defined(SIZEOF_SIZE_T) - # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) ++#if defined(SIZEOF_SIZE_T) ++# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) +#elif defined(__SIZEOF_SIZE_T__) +# define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__) - #endif ++#endif +#endif +#ifndef LZO_SIZEOF_PTRDIFF_T - #if defined(SIZEOF_PTRDIFF_T) - # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) ++#if defined(SIZEOF_PTRDIFF_T) ++# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) +#elif defined(__SIZEOF_PTRDIFF_T__) +# define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__) +#endif - #endif - #define __LZO_LSR(x,b) (((x)+0ul) >> (b)) - #if !defined(LZO_SIZEOF_SHORT) -@@ -1080,6 +2060,7 @@ extern "C" { - # error "LZO_SIZEOF_SHORT" - # endif - #endif ++#endif ++#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) ++#if !defined(LZO_SIZEOF_SHORT) ++# if (LZO_ARCH_CRAY_PVP) ++# define LZO_SIZEOF_SHORT 8 ++# elif (USHRT_MAX == LZO_0xffffL) ++# define LZO_SIZEOF_SHORT 2 ++# elif (__LZO_LSR(USHRT_MAX,7) == 1) ++# define LZO_SIZEOF_SHORT 1 ++# elif (__LZO_LSR(USHRT_MAX,15) == 1) ++# define LZO_SIZEOF_SHORT 2 ++# elif (__LZO_LSR(USHRT_MAX,31) == 1) ++# define LZO_SIZEOF_SHORT 4 ++# elif (__LZO_LSR(USHRT_MAX,63) == 1) ++# define LZO_SIZEOF_SHORT 8 ++# elif (__LZO_LSR(USHRT_MAX,127) == 1) ++# define LZO_SIZEOF_SHORT 16 ++# else ++# error "LZO_SIZEOF_SHORT" ++# endif ++#endif +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short)) - #if !defined(LZO_SIZEOF_INT) - # if (LZO_ARCH_CRAY_PVP) - # define LZO_SIZEOF_INT 8 -@@ -1101,6 +2082,7 @@ extern "C" { - # error "LZO_SIZEOF_INT" - # endif - #endif ++#if !defined(LZO_SIZEOF_INT) ++# if (LZO_ARCH_CRAY_PVP) ++# define LZO_SIZEOF_INT 8 ++# elif (UINT_MAX == LZO_0xffffL) ++# define LZO_SIZEOF_INT 2 ++# elif (UINT_MAX == LZO_0xffffffffL) ++# define LZO_SIZEOF_INT 4 ++# elif (__LZO_LSR(UINT_MAX,7) == 1) ++# define LZO_SIZEOF_INT 1 ++# elif (__LZO_LSR(UINT_MAX,15) == 1) ++# define LZO_SIZEOF_INT 2 ++# elif (__LZO_LSR(UINT_MAX,31) == 1) ++# define LZO_SIZEOF_INT 4 ++# elif (__LZO_LSR(UINT_MAX,63) == 1) ++# define LZO_SIZEOF_INT 8 ++# elif (__LZO_LSR(UINT_MAX,127) == 1) ++# define LZO_SIZEOF_INT 16 ++# else ++# error "LZO_SIZEOF_INT" ++# endif ++#endif +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int)) - #if !defined(LZO_SIZEOF_LONG) - # if (ULONG_MAX == LZO_0xffffffffL) - # define LZO_SIZEOF_LONG 4 -@@ -1110,6 +2092,8 @@ extern "C" { - # define LZO_SIZEOF_LONG 2 - # elif (__LZO_LSR(ULONG_MAX,31) == 1) - # define LZO_SIZEOF_LONG 4 ++#if !defined(LZO_SIZEOF_LONG) ++# if (ULONG_MAX == LZO_0xffffffffL) ++# define LZO_SIZEOF_LONG 4 ++# elif (__LZO_LSR(ULONG_MAX,7) == 1) ++# define LZO_SIZEOF_LONG 1 ++# elif (__LZO_LSR(ULONG_MAX,15) == 1) ++# define LZO_SIZEOF_LONG 2 ++# elif (__LZO_LSR(ULONG_MAX,31) == 1) ++# define LZO_SIZEOF_LONG 4 +# elif (__LZO_LSR(ULONG_MAX,39) == 1) +# define LZO_SIZEOF_LONG 5 - # elif (__LZO_LSR(ULONG_MAX,63) == 1) - # define LZO_SIZEOF_LONG 8 - # elif (__LZO_LSR(ULONG_MAX,127) == 1) -@@ -1118,11 +2102,12 @@ extern "C" { - # error "LZO_SIZEOF_LONG" - # endif - #endif ++# elif (__LZO_LSR(ULONG_MAX,63) == 1) ++# define LZO_SIZEOF_LONG 8 ++# elif (__LZO_LSR(ULONG_MAX,127) == 1) ++# define LZO_SIZEOF_LONG 16 ++# else ++# error "LZO_SIZEOF_LONG" ++# endif ++#endif +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long)) - #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) - #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) - # if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) - # if (LZO_CC_GNUC >= 0x030300ul) --# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) ++#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) ++#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) ++# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) ++# if (LZO_CC_GNUC >= 0x030300ul) +# if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0)) - # define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG - # elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) - # define LZO_SIZEOF_LONG_LONG 4 -@@ -1136,7 +2121,7 @@ extern "C" { - #if (LZO_ARCH_I086 && LZO_CC_DMC) - #elif (LZO_CC_CILLY) && defined(__GNUC__) - # define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG ++# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) ++# define LZO_SIZEOF_LONG_LONG 4 ++# endif ++# endif ++# endif ++#endif ++#endif ++#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) ++#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) ++#if (LZO_ARCH_I086 && LZO_CC_DMC) ++#elif (LZO_CC_CILLY) && defined(__GNUC__) ++# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) - # define LZO_SIZEOF_LONG_LONG 8 - #elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) - # define LZO_SIZEOF_LONG_LONG 8 -@@ -1158,11 +2143,13 @@ extern "C" { - # define LZO_SIZEOF___INT64 8 - #elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) - # define LZO_SIZEOF___INT64 8 --#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_OS_WIN64 || defined(_WIN64)) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) ++# define LZO_SIZEOF___INT64 8 ++#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) ++# define LZO_SIZEOF___INT64 8 +#elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64)) +# define LZO_SIZEOF_LONG_LONG 8 +#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64)) - # define LZO_SIZEOF___INT64 8 - #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) - # define LZO_SIZEOF_LONG_LONG 8 --#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) ++# define LZO_SIZEOF_LONG_LONG 8 +#elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64) - # define LZO_SIZEOF_LONG_LONG 8 - #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) - #elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -@@ -1175,87 +2162,127 @@ extern "C" { - # undef LZO_SIZEOF_LONG_LONG - # endif - #endif --#if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) ++#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) ++# define LZO_SIZEOF_LONG_LONG 8 ++#endif ++#endif ++#endif ++#if defined(__cplusplus) && (LZO_CC_GNUC) ++# if (LZO_CC_GNUC < 0x020800ul) ++# undef LZO_SIZEOF_LONG_LONG ++# endif ++#endif +#if (LZO_CFG_NO_LONG_LONG) +# undef LZO_SIZEOF_LONG_LONG +#elif defined(__NO_LONG_LONG) +# undef LZO_SIZEOF_LONG_LONG +#elif defined(_NO_LONGLONG) - # undef LZO_SIZEOF_LONG_LONG - #endif --#if !defined(LZO_SIZEOF_VOID_P) --#if (LZO_ARCH_I086) --# define __LZO_WORDSIZE 2 --# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) --# define LZO_SIZEOF_VOID_P 2 --# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) --# define LZO_SIZEOF_VOID_P 4 ++# undef LZO_SIZEOF_LONG_LONG ++#endif +#if !defined(LZO_WORDSIZE) +#if (LZO_ARCH_ALPHA) +# define LZO_WORDSIZE 8 @@ -1672,12 +2487,9 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# define LZO_WORDSIZE 4 +# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) +# define LZO_WORDSIZE 4 - # else --# error "LZO_MM" ++# else +# define LZO_WORDSIZE 2 - # endif --#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) --# define __LZO_WORDSIZE 1 ++# endif +#elif (LZO_ARCH_I086) +# define LZO_WORDSIZE 2 +#elif (LZO_ARCH_IA64) @@ -1712,24 +2524,21 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) +# define LZO_SIZEOF_VOID_P 8 +#elif (LZO_ARCH_AVR) - # define LZO_SIZEOF_VOID_P 2 - #elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) - # define LZO_SIZEOF_VOID_P 2 - #elif (LZO_ARCH_H8300) - # if defined(__NORMAL_MODE__) --# define __LZO_WORDSIZE 4 - # define LZO_SIZEOF_VOID_P 2 - # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) --# define __LZO_WORDSIZE 4 - # define LZO_SIZEOF_VOID_P 4 - # else --# define __LZO_WORDSIZE 2 - # define LZO_SIZEOF_VOID_P 2 - # endif - # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) - # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT - # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT - # endif ++# define LZO_SIZEOF_VOID_P 2 ++#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) ++# define LZO_SIZEOF_VOID_P 2 ++#elif (LZO_ARCH_H8300) ++# if defined(__NORMAL_MODE__) ++# define LZO_SIZEOF_VOID_P 2 ++# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) ++# define LZO_SIZEOF_VOID_P 4 ++# else ++# define LZO_SIZEOF_VOID_P 2 ++# endif ++# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT ++# endif +#elif (LZO_ARCH_I086) +# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) +# define LZO_SIZEOF_VOID_P 2 @@ -1738,116 +2547,114 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# else +# error "invalid LZO_ARCH_I086 memory model" +# endif - #elif (LZO_ARCH_M16C) --# define __LZO_WORDSIZE 2 - # if defined(__m32c_cpu__) || defined(__m32cm_cpu__) - # define LZO_SIZEOF_VOID_P 4 - # else - # define LZO_SIZEOF_VOID_P 2 - # endif ++#elif (LZO_ARCH_M16C) ++# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) ++# define LZO_SIZEOF_VOID_P 4 ++# else ++# define LZO_SIZEOF_VOID_P 2 ++# endif +#elif (LZO_ARCH_SPU) +# define LZO_SIZEOF_VOID_P 4 +#elif (LZO_ARCH_Z80) +# define LZO_SIZEOF_VOID_P 2 - #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) --# define __LZO_WORDSIZE 8 - # define LZO_SIZEOF_VOID_P 4 --#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) --# define __LZO_WORDSIZE 8 --# define LZO_SIZEOF_VOID_P 8 --#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) --# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - #elif (LZO_OS_OS400 || defined(__OS400__)) --# define __LZO_WORDSIZE LZO_SIZEOF_LONG --# define LZO_SIZEOF_VOID_P 16 --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG --#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) --# define LZO_SIZEOF_VOID_P 8 --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG --#elif (LZO_ARCH_SPU) --# if 0 --# define __LZO_WORDSIZE 16 --# endif --# define LZO_SIZEOF_VOID_P 4 --#else --# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG --#endif --#endif --#if !defined(LZO_WORDSIZE) --# if defined(__LZO_WORDSIZE) --# define LZO_WORDSIZE __LZO_WORDSIZE ++#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) ++# define LZO_SIZEOF_VOID_P 4 ++#elif (LZO_OS_OS400 || defined(__OS400__)) +# if defined(__LLP64_IFC__) +# define LZO_SIZEOF_VOID_P 8 +# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - # else --# define LZO_WORDSIZE LZO_SIZEOF_VOID_P ++# else +# define LZO_SIZEOF_VOID_P 16 +# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - # endif ++# endif +#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +# define LZO_SIZEOF_VOID_P 8 +# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - #endif ++#endif +#endif +#if !defined(LZO_SIZEOF_VOID_P) +# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG +#endif +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) - #if !defined(LZO_SIZEOF_SIZE_T) - #if (LZO_ARCH_I086 || LZO_ARCH_M16C) - # define LZO_SIZEOF_SIZE_T 2 --#else ++#if !defined(LZO_SIZEOF_SIZE_T) ++#if (LZO_ARCH_I086 || LZO_ARCH_M16C) ++# define LZO_SIZEOF_SIZE_T 2 +#endif +#endif +#if !defined(LZO_SIZEOF_SIZE_T) - # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P - #endif ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P ++#endif +#if defined(offsetof) +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t)) - #endif - #if !defined(LZO_SIZEOF_PTRDIFF_T) - #if (LZO_ARCH_I086) -@@ -1268,11 +2295,18 @@ extern "C" { - # define LZO_SIZEOF_PTRDIFF_T 2 ++#endif ++#if !defined(LZO_SIZEOF_PTRDIFF_T) ++#if (LZO_ARCH_I086) ++# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P ++# elif (LZO_MM_COMPACT || LZO_MM_LARGE) ++# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) ++# define LZO_SIZEOF_PTRDIFF_T 4 ++# else ++# define LZO_SIZEOF_PTRDIFF_T 2 # endif # else --# error "LZO_MM" +-# define __lzo_cdecl_sighandler __cdecl +# error "invalid LZO_ARCH_I086 memory model" # endif --#else -+#endif -+#endif +-#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) +-# define __lzo_cdecl __cdecl +-#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) +-# define __lzo_cdecl cdecl + #endif +-#if !defined(__lzo_cdecl) +-# define __lzo_cdecl /*empty*/ + #endif +-#if !defined(__lzo_cdecl_atexit) +-# define __lzo_cdecl_atexit /*empty*/ +#if !defined(LZO_SIZEOF_PTRDIFF_T) - # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T #endif +-#if !defined(__lzo_cdecl_main) +-# define __lzo_cdecl_main /*empty*/ +#if defined(offsetof) +LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)) -+#endif + #endif +-#if !defined(__lzo_cdecl_qsort) +-# define __lzo_cdecl_qsort /*empty*/ +#if !defined(LZO_WORDSIZE) +# define LZO_WORDSIZE LZO_SIZEOF_VOID_P #endif - #if (LZO_ABI_NEUTRAL_ENDIAN) - # undef LZO_ABI_BIG_ENDIAN -@@ -1284,7 +2318,7 @@ extern "C" { - # define LZO_ABI_LITTLE_ENDIAN 1 - #elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) - # define LZO_ABI_LITTLE_ENDIAN 1 --#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390) +-#if !defined(__lzo_cdecl_sighandler) +-# define __lzo_cdecl_sighandler /*empty*/ ++#if (LZO_ABI_NEUTRAL_ENDIAN) ++# undef LZO_ABI_BIG_ENDIAN ++# undef LZO_ABI_LITTLE_ENDIAN ++#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) ++#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) ++# define LZO_ABI_LITTLE_ENDIAN 1 +#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU) - # define LZO_ABI_BIG_ENDIAN 1 - #elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) - # if (__LITTLE_ENDIAN__ == 1) -@@ -1300,6 +2334,19 @@ extern "C" { - # define LZO_ABI_BIG_ENDIAN 1 - #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) - # define LZO_ABI_LITTLE_ENDIAN 1 ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) ++# if (__LITTLE_ENDIAN__ == 1) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++# else ++# define LZO_ABI_BIG_ENDIAN 1 ++# endif ++#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) ++# define LZO_ABI_LITTLE_ENDIAN 1 +#elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC) +# if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) +# error "unexpected configuration - check your compiler defines" @@ -1861,457 +2668,124 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# define LZO_ABI_BIG_ENDIAN 1 +#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__) +# define LZO_ABI_LITTLE_ENDIAN 1 - #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) - # define LZO_ABI_BIG_ENDIAN 1 - #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) -@@ -1307,7 +2354,7 @@ extern "C" { ++#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) ++# define LZO_ABI_LITTLE_ENDIAN 1 #endif +-#if !defined(__lzo_cdecl_va) +-# define __lzo_cdecl_va __lzo_cdecl #endif - #if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) --# error "this should not happen" +-#if !(LZO_CFG_NO_WINDOWS_H) +-#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) +-# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) +-# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) +-# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) ++#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) +# error "unexpected configuration - check your compiler defines" - #endif - #if (LZO_ABI_BIG_ENDIAN) - # define LZO_INFO_ABI_ENDIAN "be" -@@ -1322,6 +2369,9 @@ extern "C" { - #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) - # define LZO_ABI_ILP16 1 - # define LZO_INFO_ABI_PM "ilp16" ++#endif ++#if (LZO_ABI_BIG_ENDIAN) ++# define LZO_INFO_ABI_ENDIAN "be" ++#elif (LZO_ABI_LITTLE_ENDIAN) ++# define LZO_INFO_ABI_ENDIAN "le" ++#elif (LZO_ABI_NEUTRAL_ENDIAN) ++# define LZO_INFO_ABI_ENDIAN "neutral" ++#endif ++#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) ++# define LZO_ABI_I8LP16 1 ++# define LZO_INFO_ABI_PM "i8lp16" ++#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) ++# define LZO_ABI_ILP16 1 ++# define LZO_INFO_ABI_PM "ilp16" +#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) +# define LZO_ABI_LP32 1 +# define LZO_INFO_ABI_PM "lp32" - #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) - # define LZO_ABI_ILP32 1 - # define LZO_INFO_ABI_PM "ilp32" -@@ -1338,7 +2388,8 @@ extern "C" { - # define LZO_ABI_IP32L64 1 - # define LZO_INFO_ABI_PM "ip32l64" - #endif --#if !defined(__LZO_LIBC_OVERRIDE) ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) ++# define LZO_ABI_ILP32 1 ++# define LZO_INFO_ABI_PM "ilp32" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) ++# define LZO_ABI_LLP64 1 ++# define LZO_INFO_ABI_PM "llp64" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) ++# define LZO_ABI_LP64 1 ++# define LZO_INFO_ABI_PM "lp64" ++#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) ++# define LZO_ABI_ILP64 1 ++# define LZO_INFO_ABI_PM "ilp64" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) ++# define LZO_ABI_IP32L64 1 ++# define LZO_INFO_ABI_PM "ip32l64" ++#endif +#if 0 +#elif !defined(__LZO_LIBC_OVERRIDE) - #if (LZO_LIBC_NAKED) - # define LZO_INFO_LIBC "naked" - #elif (LZO_LIBC_FREESTANDING) -@@ -1349,6 +2400,9 @@ extern "C" { - # define LZO_INFO_LIBC "isoc90" - #elif (LZO_LIBC_ISOC99) - # define LZO_INFO_LIBC "isoc99" ++#if (LZO_LIBC_NAKED) ++# define LZO_INFO_LIBC "naked" ++#elif (LZO_LIBC_FREESTANDING) ++# define LZO_INFO_LIBC "freestanding" ++#elif (LZO_LIBC_MOSTLY_FREESTANDING) ++# define LZO_INFO_LIBC "mfreestanding" ++#elif (LZO_LIBC_ISOC90) ++# define LZO_INFO_LIBC "isoc90" ++#elif (LZO_LIBC_ISOC99) ++# define LZO_INFO_LIBC "isoc99" +#elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION) +# define LZO_LIBC_ISOC90 1 +# define LZO_INFO_LIBC "isoc90" - #elif defined(__dietlibc__) - # define LZO_LIBC_DIETLIBC 1 - # define LZO_INFO_LIBC "dietlibc" -@@ -1357,13 +2411,13 @@ extern "C" { - # define LZO_INFO_LIBC "newlib" - #elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) - # if defined(__UCLIBC_SUBLEVEL__) --# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) ++#elif defined(__dietlibc__) ++# define LZO_LIBC_DIETLIBC 1 ++# define LZO_INFO_LIBC "dietlibc" ++#elif defined(_NEWLIB_VERSION) ++# define LZO_LIBC_NEWLIB 1 ++# define LZO_INFO_LIBC "newlib" ++#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) ++# if defined(__UCLIBC_SUBLEVEL__) +# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0)) # else - # define LZO_LIBC_UCLIBC 0x00090bL +-# define LZO_HAVE_WINDOWS_H 1 ++# define LZO_LIBC_UCLIBC 0x00090bL # endif --# define LZO_INFO_LIBC "uclibc" +# define LZO_INFO_LIBC "uc" "libc" - #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) --# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) ++#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) +# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100) - # define LZO_INFO_LIBC "glibc" - #elif (LZO_CC_MWERKS) && defined(__MSL__) - # define LZO_LIBC_MSL __MSL__ -@@ -1376,423 +2430,159 @@ extern "C" { - # define LZO_INFO_LIBC "default" - #endif - #endif --#if !defined(__lzo_gnuc_extension__) --#if (LZO_CC_GNUC >= 0x020800ul) --# define __lzo_gnuc_extension__ __extension__ --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_gnuc_extension__ __extension__ --#else --# define __lzo_gnuc_extension__ /*empty*/ --#endif --#endif --#if !defined(__lzo_ua_volatile) --# define __lzo_ua_volatile volatile --#endif --#if !defined(__lzo_alignof) --#if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) --# define __lzo_alignof(e) __alignof__(e) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) --# define __lzo_alignof(e) __alignof__(e) --#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) --# define __lzo_alignof(e) __alignof(e) --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_alignof(e) __alignof__(e) --#endif --#endif --#if defined(__lzo_alignof) --# define __lzo_HAVE_alignof 1 --#endif --#if !defined(__lzo_constructor) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_constructor __attribute__((__constructor__,__used__)) --#elif (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_constructor __attribute__((__constructor__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_constructor __attribute__((__constructor__)) --#endif --#endif --#if defined(__lzo_constructor) --# define __lzo_HAVE_constructor 1 --#endif --#if !defined(__lzo_destructor) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_destructor __attribute__((__destructor__,__used__)) --#elif (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_destructor __attribute__((__destructor__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_destructor __attribute__((__destructor__)) --#endif --#endif --#if defined(__lzo_destructor) --# define __lzo_HAVE_destructor 1 --#endif --#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) --# error "this should not happen" --#endif --#if !defined(__lzo_inline) --#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) --#elif defined(__cplusplus) --# define __lzo_inline inline --#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) --# define __lzo_inline __inline --#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) --# define __lzo_inline __inline__ --#elif (LZO_CC_DMC) --# define __lzo_inline __inline --#elif (LZO_CC_INTELC) --# define __lzo_inline __inline --#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) --# define __lzo_inline __inline --#elif (LZO_CC_MSC && (_MSC_VER >= 900)) --# define __lzo_inline __inline --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_inline __inline__ --#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) --# define __lzo_inline inline --#endif --#endif --#if defined(__lzo_inline) --# define __lzo_HAVE_inline 1 --#else --# define __lzo_inline /*empty*/ --#endif --#if !defined(__lzo_forceinline) --#if (LZO_CC_GNUC >= 0x030200ul) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) --# define __lzo_forceinline __forceinline --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) --# define __lzo_forceinline __forceinline --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#endif --#endif --#if defined(__lzo_forceinline) --# define __lzo_HAVE_forceinline 1 --#else --# define __lzo_forceinline /*empty*/ --#endif --#if !defined(__lzo_noinline) --#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) --# define __lzo_noinline __attribute__((__noinline__,__used__)) --#elif (LZO_CC_GNUC >= 0x030200ul) --# define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) --# define __lzo_noinline __declspec(noinline) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) --# define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) --# define __lzo_noinline __declspec(noinline) --#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) --# if defined(__cplusplus) --# else --# define __lzo_noinline __declspec(noinline) --# endif --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_noinline __attribute__((__noinline__)) --#endif --#endif --#if defined(__lzo_noinline) --# define __lzo_HAVE_noinline 1 --#else --# define __lzo_noinline /*empty*/ --#endif --#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) --# error "this should not happen" --#endif --#if !defined(__lzo_noreturn) --#if (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) --# define __lzo_noreturn __declspec(noreturn) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) --# define __lzo_noreturn __declspec(noreturn) --#endif --#endif --#if defined(__lzo_noreturn) --# define __lzo_HAVE_noreturn 1 --#else --# define __lzo_noreturn /*empty*/ --#endif --#if !defined(__lzo_nothrow) --#if (LZO_CC_GNUC >= 0x030300ul) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) --# define __lzo_nothrow __declspec(nothrow) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) --# define __lzo_nothrow __declspec(nothrow) --#endif --#endif --#if defined(__lzo_nothrow) --# define __lzo_HAVE_nothrow 1 --#else --# define __lzo_nothrow /*empty*/ --#endif --#if !defined(__lzo_restrict) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_restrict __restrict__ --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) --# define __lzo_restrict __restrict__ --#elif (LZO_CC_CLANG || LZO_CC_LLVM) --# define __lzo_restrict __restrict__ --#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) --# define __lzo_restrict __restrict --#endif --#endif --#if defined(__lzo_restrict) --# define __lzo_HAVE_restrict 1 --#else --# define __lzo_restrict /*empty*/ --#endif --#if !defined(__lzo_likely) && !defined(__lzo_unlikely) --#if (LZO_CC_GNUC >= 0x030200ul) --# define __lzo_likely(e) (__builtin_expect(!!(e),1)) --# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) --# define __lzo_likely(e) (__builtin_expect(!!(e),1)) --# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_likely(e) (__builtin_expect(!!(e),1)) --# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) --#endif --#endif --#if defined(__lzo_likely) --# define __lzo_HAVE_likely 1 --#else --# define __lzo_likely(e) (e) --#endif --#if defined(__lzo_unlikely) --# define __lzo_HAVE_unlikely 1 --#else --# define __lzo_unlikely(e) (e) --#endif --#if !defined(LZO_UNUSED) --# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) --# define LZO_UNUSED(var) ((void) &var) --# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) --# define LZO_UNUSED(var) if (&var) ; else --# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define LZO_UNUSED(var) ((void) var) --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_UNUSED(var) if (&var) ; else --# elif (LZO_CC_KEILC) --# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} --# elif (LZO_CC_PACIFICC) --# define LZO_UNUSED(var) ((void) sizeof(var)) --# elif (LZO_CC_WATCOMC) && defined(__cplusplus) --# define LZO_UNUSED(var) ((void) var) --# else --# define LZO_UNUSED(var) ((void) &var) --# endif --#endif --#if !defined(LZO_UNUSED_FUNC) --# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) --# define LZO_UNUSED_FUNC(func) ((void) func) --# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) --# define LZO_UNUSED_FUNC(func) if (func) ; else --# elif (LZO_CC_CLANG || LZO_CC_LLVM) --# define LZO_UNUSED_FUNC(func) ((void) &func) --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_UNUSED_FUNC(func) if (func) ; else --# elif (LZO_CC_MSC) --# define LZO_UNUSED_FUNC(func) ((void) &func) --# elif (LZO_CC_KEILC || LZO_CC_PELLESC) --# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} --# else --# define LZO_UNUSED_FUNC(func) ((void) func) --# endif --#endif --#if !defined(LZO_UNUSED_LABEL) --# if (LZO_CC_WATCOMC) && defined(__cplusplus) --# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l --# elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) --# define LZO_UNUSED_LABEL(l) if (0) goto l --# else --# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l --# endif --#endif --#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) --# if 0 --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var --# elif 0 && (LZO_CC_GNUC) --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var --# else --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init --# endif --#endif --#if !defined(LZO_UNCONST_CAST) --# if 0 && defined(__cplusplus) --# define LZO_UNCONST_CAST(t,e) (const_cast (e)) --# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e)))))) --# else --# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) --# endif --#endif --#if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) --# if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; --# elif (LZO_CC_DMC || LZO_CC_SYMANTECC) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; --# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; --# else --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; --# endif --#endif --#if !defined(LZO_COMPILE_TIME_ASSERT) --# if (LZO_CC_AZTECC) --# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} --# elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) --# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; --# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) --# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; --# else --# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} --# endif --#endif --#if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) --# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) --# elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) --# define __lzo_cdecl __cdecl --# define __lzo_cdecl_atexit /*empty*/ --# define __lzo_cdecl_main __cdecl --# if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) --# define __lzo_cdecl_qsort __pascal --# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) --# define __lzo_cdecl_qsort _stdcall --# else --# define __lzo_cdecl_qsort __cdecl --# endif --# elif (LZO_CC_WATCOMC) --# define __lzo_cdecl __cdecl --# else --# define __lzo_cdecl __cdecl --# define __lzo_cdecl_atexit __cdecl --# define __lzo_cdecl_main __cdecl --# define __lzo_cdecl_qsort __cdecl --# endif --# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) --# elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) --# define __lzo_cdecl_sighandler __pascal --# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) --# define __lzo_cdecl_sighandler _stdcall --# elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) --# define __lzo_cdecl_sighandler __clrcall --# elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) --# if defined(_DLL) --# define __lzo_cdecl_sighandler _far _cdecl _loadds --# elif defined(_MT) --# define __lzo_cdecl_sighandler _far _cdecl --# else --# define __lzo_cdecl_sighandler _cdecl --# endif --# else --# define __lzo_cdecl_sighandler __cdecl --# endif --#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) --# define __lzo_cdecl __cdecl --#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) --# define __lzo_cdecl cdecl --#endif --#if !defined(__lzo_cdecl) --# define __lzo_cdecl /*empty*/ --#endif --#if !defined(__lzo_cdecl_atexit) --# define __lzo_cdecl_atexit /*empty*/ --#endif --#if !defined(__lzo_cdecl_main) --# define __lzo_cdecl_main /*empty*/ --#endif --#if !defined(__lzo_cdecl_qsort) --# define __lzo_cdecl_qsort /*empty*/ --#endif --#if !defined(__lzo_cdecl_sighandler) --# define __lzo_cdecl_sighandler /*empty*/ --#endif --#if !defined(__lzo_cdecl_va) --# define __lzo_cdecl_va __lzo_cdecl --#endif --#if !(LZO_CFG_NO_WINDOWS_H) --#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) --# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) --# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) --# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) --# else --# define LZO_HAVE_WINDOWS_H 1 --# endif -+#if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -+# define LZO_ASM_SYNTAX_MSC 1 -+#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -+#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) -+#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#elif (LZO_CC_GNUC) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#endif -+#if (LZO_ASM_SYNTAX_GNUC) -+#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) -+# define __LZO_ASM_CLOBBER "ax" -+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) -+# define __LZO_ASM_CLOBBER "memory" -+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ -+#else -+# define __LZO_ASM_CLOBBER "cc", "memory" -+# define __LZO_ASM_CLOBBER_LIST_CC : "cc" -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ ++# define LZO_INFO_LIBC "glibc" ++#elif (LZO_CC_MWERKS) && defined(__MSL__) ++# define LZO_LIBC_MSL __MSL__ ++# define LZO_INFO_LIBC "msl" ++#elif 1 && defined(__IAR_SYSTEMS_ICC__) ++# define LZO_LIBC_ISOC90 1 ++# define LZO_INFO_LIBC "isoc90" ++#else ++# define LZO_LIBC_DEFAULT 1 ++# define LZO_INFO_LIBC "default" ++#endif ++#endif ++#if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) ++# define LZO_ASM_SYNTAX_MSC 1 ++#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) ++#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) ++#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) ++# define LZO_ASM_SYNTAX_GNUC 1 ++#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) ++# define LZO_ASM_SYNTAX_GNUC 1 ++#elif (LZO_CC_GNUC) ++# define LZO_ASM_SYNTAX_GNUC 1 ++#endif ++#if (LZO_ASM_SYNTAX_GNUC) ++#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) ++# define __LZO_ASM_CLOBBER "ax" ++# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ ++# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ ++# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ ++#elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) ++# define __LZO_ASM_CLOBBER "memory" ++# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ ++# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" ++# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ ++#else ++# define __LZO_ASM_CLOBBER "cc", "memory" ++# define __LZO_ASM_CLOBBER_LIST_CC : "cc" ++# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" ++# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ #endif #endif #if (LZO_ARCH_ALPHA) @@ -2460,10 +2934,10 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #ifndef LZO_CFG_NO_INLINE_ASM -#if (LZO_CC_LLVM) +#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) - # define LZO_CFG_NO_INLINE_ASM 1 -+#elif (LZO_CC_LLVM) +# define LZO_CFG_NO_INLINE_ASM 1 -+#endif ++#elif (LZO_CC_LLVM) + # define LZO_CFG_NO_INLINE_ASM 1 + #endif #endif +#if (LZO_CFG_NO_INLINE_ASM) +# undef LZO_ASM_SYNTAX_MSC @@ -2472,10 +2946,11 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +# undef __LZO_ASM_CLOBBER_LIST_CC +# undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY +# undef __LZO_ASM_CLOBBER_LIST_EMPTY - #endif ++#endif #ifndef LZO_CFG_NO_UNALIGNED #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) -@@ -1804,25 +2594,6 @@ extern "C" { + # define LZO_CFG_NO_UNALIGNED 1 +@@ -1784,25 +2574,6 @@ extern "C" { # undef LZO_OPT_UNALIGNED32 # undef LZO_OPT_UNALIGNED64 #endif @@ -2501,7 +2976,7 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 #if defined(__LZO_INFOSTR_MM) #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) # define __LZO_INFOSTR_MM "" -@@ -1866,6 +2637,381 @@ extern "C" { +@@ -1846,7 +2617,382 @@ extern "C" { #define LZO_INFO_STRING \ LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER @@ -2881,5588 +3356,5391 @@ index 25a1f68b3b5..ab2be5f4fd0 100644 +#endif +#endif - #endif + #endif /* already included */ -@@ -1874,7 +3020,7 @@ extern "C" { - #undef LZO_HAVE_CONFIG_H - #include "minilzo.h" +-/* vim:set ts=4 et: */ ++/* vim:set ts=4 sw=4 et: */ +diff --git a/grub-core/lib/minilzo/minilzo.c b/grub-core/lib/minilzo/minilzo.c +index 25a1f68..ab2be5f 100644 +--- a/grub-core/lib/minilzo/minilzo.c ++++ b/grub-core/lib/minilzo/minilzo.c +@@ -2,22 +2,7 @@ --#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2050) -+#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2080) - # error "version mismatch in miniLZO source files" - #endif + This file is part of the LZO real-time data compression library. -@@ -1886,23 +3032,9 @@ extern "C" { - #define __LZO_CONF_H 1 +- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer +- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer ++ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. - #if !defined(__LZO_IN_MINILZO) --#if (LZO_CFG_FREESTANDING) -+#if defined(LZO_CFG_FREESTANDING) && (LZO_CFG_FREESTANDING) - # define LZO_LIBC_FREESTANDING 1 - # define LZO_OS_FREESTANDING 1 --# define ACC_LIBC_FREESTANDING 1 --# define ACC_OS_FREESTANDING 1 + The LZO library is free software; you can redistribute it and/or +@@ -67,12 +52,6 @@ + #if defined(__CYGWIN32__) && !defined(__CYGWIN__) + # define __CYGWIN__ __CYGWIN32__ + #endif +-#if defined(__IBMCPP__) && !defined(__IBMC__) +-# define __IBMC__ __IBMCPP__ -#endif --#if (LZO_CFG_NO_UNALIGNED) --# define ACC_CFG_NO_UNALIGNED 1 +-#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) +-# define __INTEL_COMPILER __ICL -#endif --#if (LZO_ARCH_GENERIC) --# define ACC_ARCH_GENERIC 1 + #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) + # define _ALL_SOURCE 1 + #endif +@@ -81,19 +60,30 @@ + # define __LONG_MAX__ 9223372036854775807L + # endif + #endif +-#if defined(__INTEL_COMPILER) && defined(__linux__) ++#if !defined(LZO_CFG_NO_DISABLE_WUNDEF) ++#if defined(__ARMCC_VERSION) ++# pragma diag_suppress 193 ++#elif defined(__clang__) && defined(__clang_minor__) ++# pragma clang diagnostic ignored "-Wundef" ++#elif defined(__INTEL_COMPILER) + # pragma warning(disable: 193) -#endif --#if (LZO_ABI_NEUTRAL_ENDIAN) --# define ACC_ABI_NEUTRAL_ENDIAN 1 +-#if defined(__KEIL__) && defined(__C166__) +-# pragma warning disable = 322 +-#elif 0 && defined(__C251__) ++#elif defined(__KEIL__) && defined(__C166__) + # pragma warning disable = 322 -#endif --#if (LZO_HAVE_CONFIG_H) --# define ACC_CONFIG_NO_HEADER 1 - #endif - #if defined(LZO_CFG_EXTRA_CONFIG_HEADER) - # include LZO_CFG_EXTRA_CONFIG_HEADER -@@ -1911,22 +3043,27 @@ extern "C" { - # error "include this file first" +-#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) +-# if (_MSC_VER >= 1300) ++#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) ++# if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) ++# pragma GCC diagnostic ignored "-Wundef" ++# endif ++#elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) ++# if ((_MSC_VER-0) >= 1300) + # pragma warning(disable: 4668) + # endif #endif - #include "lzo/lzoconf.h" -+#if defined(LZO_CFG_EXTRA_CONFIG_HEADER2) -+# include LZO_CFG_EXTRA_CONFIG_HEADER2 +#endif - #endif - --#if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED) -+#if (LZO_VERSION < 0x2080) || !defined(__LZOCONF_H_INCLUDED) - # error "version mismatch" - #endif - --#if (LZO_CC_BORLANDC && LZO_ARCH_I086) --# pragma option -h -+#if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1100)) -+# pragma warning(disable: 4702) - #endif -- - #if (LZO_CC_MSC && (_MSC_VER >= 1000)) - # pragma warning(disable: 4127 4701) -+# pragma warning(disable: 4514 4710 4711) - #endif - #if (LZO_CC_MSC && (_MSC_VER >= 1300)) - # pragma warning(disable: 4820) --# pragma warning(disable: 4514 4710 4711) ++#if 0 && defined(__POCC__) && defined(_WIN32) ++# if (__POCC__ >= 400) ++# pragma warn(disable: 2216) ++# endif +#endif -+#if (LZO_CC_MSC && (_MSC_VER >= 1800)) -+# pragma warning(disable: 4746) - #endif - - #if (LZO_CC_SUNPROC) -@@ -1937,49 +3074,16 @@ extern "C" { - #endif - #endif - --#if (__LZO_MMODEL_HUGE) && !(LZO_HAVE_MM_HUGE_PTR) --# error "this should not happen - check defines for __huge" --#endif -- --#if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING) --#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) --# define ACC_WANT_ACC_INCD_H 1 --# define ACC_WANT_ACC_INCE_H 1 --# define ACC_WANT_ACC_INCI_H 1 -+#if defined(__LZO_IN_MINILZO) || (LZO_CFG_FREESTANDING) - #elif 1 - # include - #else --# define ACC_WANT_ACC_INCD_H 1 -+# define LZO_WANT_ACC_INCD_H 1 - #endif -- --#if (LZO_ARCH_I086) --# define ACC_MM_AHSHIFT LZO_MM_AHSHIFT --# define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0]) --# define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1]) --# define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o))) -+#if defined(LZO_HAVE_CONFIG_H) -+# define LZO_CFG_NO_CONFIG_HEADER 1 - #endif - --#if !defined(lzo_uintptr_t) --# if defined(__LZO_MMODEL_HUGE) --# define lzo_uintptr_t unsigned long --# elif 1 && defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16) --# define __LZO_UINTPTR_T_IS_POINTER 1 -- typedef char* lzo_uintptr_t; --# define lzo_uintptr_t lzo_uintptr_t --# elif (LZO_SIZEOF_SIZE_T == LZO_SIZEOF_VOID_P) --# define lzo_uintptr_t size_t --# elif (LZO_SIZEOF_LONG == LZO_SIZEOF_VOID_P) --# define lzo_uintptr_t unsigned long --# elif (LZO_SIZEOF_INT == LZO_SIZEOF_VOID_P) --# define lzo_uintptr_t unsigned int --# elif (LZO_SIZEOF_LONG_LONG == LZO_SIZEOF_VOID_P) --# define lzo_uintptr_t unsigned long long --# else --# define lzo_uintptr_t size_t --# endif --#endif --LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) -- - #if 1 && !defined(LZO_CFG_FREESTANDING) - #if 1 && !defined(HAVE_STRING_H) - #define HAVE_STRING_H 1 -@@ -2002,6 +3106,23 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) - #include + #if 0 && defined(__WATCOMC__) + # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) + # pragma warning 203 9 +@@ -102,13 +92,29 @@ + #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) + # pragma option -h #endif - -+#if 1 || defined(lzo_int8_t) || defined(lzo_uint8_t) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint8_t) == 1) ++#if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) ++#ifndef _CRT_NONSTDC_NO_DEPRECATE ++#define _CRT_NONSTDC_NO_DEPRECATE 1 +#endif -+#if 1 || defined(lzo_int16_t) || defined(lzo_uint16_t) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint16_t) == 2) ++#ifndef _CRT_NONSTDC_NO_WARNINGS ++#define _CRT_NONSTDC_NO_WARNINGS 1 +#endif -+#if 1 || defined(lzo_int32_t) || defined(lzo_uint32_t) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32_t) == 4) ++#ifndef _CRT_SECURE_NO_DEPRECATE ++#define _CRT_SECURE_NO_DEPRECATE 1 +#endif -+#if defined(lzo_int64_t) || defined(lzo_uint64_t) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64_t) == 8) ++#ifndef _CRT_SECURE_NO_WARNINGS ++#define _CRT_SECURE_NO_WARNINGS 1 +#endif -+ - #if (LZO_CFG_FREESTANDING) - # undef HAVE_MEMCMP - # undef HAVE_MEMCPY -@@ -2012,28 +3133,28 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) - #if !(HAVE_MEMCMP) - # undef memcmp - # define memcmp(a,b,c) lzo_memcmp(a,b,c) --#elif !(__LZO_MMODEL_HUGE) -+#else - # undef lzo_memcmp - # define lzo_memcmp(a,b,c) memcmp(a,b,c) ++#endif + #if 0 +-#define LZO_0xffffL 0xfffful +-#define LZO_0xffffffffL 0xfffffffful ++#define LZO_0xffffUL 0xfffful ++#define LZO_0xffffffffUL 0xfffffffful + #else +-#define LZO_0xffffL 65535ul +-#define LZO_0xffffffffL 4294967295ul ++#define LZO_0xffffUL 65535ul ++#define LZO_0xffffffffUL 4294967295ul #endif - #if !(HAVE_MEMCPY) - # undef memcpy - # define memcpy(a,b,c) lzo_memcpy(a,b,c) --#elif !(__LZO_MMODEL_HUGE) -+#else - # undef lzo_memcpy - # define lzo_memcpy(a,b,c) memcpy(a,b,c) ++#define LZO_0xffffL LZO_0xffffUL ++#define LZO_0xffffffffL LZO_0xffffffffUL + #if (LZO_0xffffL == LZO_0xffffffffL) + # error "your preprocessor is broken 1" #endif - #if !(HAVE_MEMMOVE) - # undef memmove - # define memmove(a,b,c) lzo_memmove(a,b,c) --#elif !(__LZO_MMODEL_HUGE) -+#else - # undef lzo_memmove - # define lzo_memmove(a,b,c) memmove(a,b,c) +@@ -123,6 +129,13 @@ + # error "your preprocessor is broken 4" #endif - #if !(HAVE_MEMSET) - # undef memset - # define memset(a,b,c) lzo_memset(a,b,c) --#elif !(__LZO_MMODEL_HUGE) -+#else - # undef lzo_memset - # define lzo_memset(a,b,c) memset(a,b,c) #endif -@@ -2058,27 +3179,29 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) - # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) ++#if defined(__COUNTER__) ++# ifndef LZO_CFG_USE_COUNTER ++# define LZO_CFG_USE_COUNTER 1 ++# endif ++#else ++# undef LZO_CFG_USE_COUNTER ++#endif + #if (UINT_MAX == LZO_0xffffL) + #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) + # if !defined(MSDOS) +@@ -253,14 +266,31 @@ #endif - --#if !defined(__lzo_inline) --# define __lzo_inline /*empty*/ --#endif --#if !defined(__lzo_forceinline) --# define __lzo_forceinline /*empty*/ --#endif --#if !defined(__lzo_noinline) --# define __lzo_noinline /*empty*/ --#endif -- - #if (LZO_CFG_PGO) --# undef __acc_likely --# undef __acc_unlikely - # undef __lzo_likely - # undef __lzo_unlikely --# define __acc_likely(e) (e) --# define __acc_unlikely(e) (e) - # define __lzo_likely(e) (e) - # define __lzo_unlikely(e) (e) - #endif - -+#undef _ -+#undef __ -+#undef ___ -+#undef ____ -+#undef _p0 -+#undef _p1 -+#undef _p2 -+#undef _p3 -+#undef _p4 -+#undef _s0 -+#undef _s1 -+#undef _s2 -+#undef _s3 -+#undef _s4 -+#undef _ww -+ + #define LZO_PP_STRINGIZE(x) #x + #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) ++#define LZO_PP_CONCAT0() /*empty*/ ++#define LZO_PP_CONCAT1(a) a + #define LZO_PP_CONCAT2(a,b) a ## b + #define LZO_PP_CONCAT3(a,b,c) a ## b ## c + #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d + #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e ++#define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f ++#define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g ++#define LZO_PP_ECONCAT0() LZO_PP_CONCAT0() ++#define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a) + #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) + #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) + #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) + #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) ++#define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f) ++#define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g) ++#define LZO_PP_EMPTY /*empty*/ ++#define LZO_PP_EMPTY0() /*empty*/ ++#define LZO_PP_EMPTY1(a) /*empty*/ ++#define LZO_PP_EMPTY2(a,b) /*empty*/ ++#define LZO_PP_EMPTY3(a,b,c) /*empty*/ ++#define LZO_PP_EMPTY4(a,b,c,d) /*empty*/ ++#define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/ ++#define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/ ++#define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/ #if 1 - # define LZO_BYTE(x) ((unsigned char) (x)) - #else -@@ -2097,84 +3220,548 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) - #define LZO_SIZE(bits) (1u << (bits)) - #define LZO_MASK(bits) (LZO_SIZE(bits) - 1) - --#define LZO_LSIZE(bits) (1ul << (bits)) --#define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1) -- - #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) - #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) - - #if !defined(DMUL) - #if 0 - --# define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b))) -+# define DMUL(a,b) ((lzo_xint) ((lzo_uint32_t)(a) * (lzo_uint32_t)(b))) + #define LZO_CPP_STRINGIZE(x) #x + #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) +@@ -268,12 +298,16 @@ + #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c + #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d + #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e ++#define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f ++#define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g + #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) + #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) + #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) + #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) ++#define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f) ++#define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g) + #endif +-#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) ++#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b)) + #if 1 && defined(__cplusplus) + # if !defined(__STDC_CONSTANT_MACROS) + # define __STDC_CONSTANT_MACROS 1 +@@ -283,9 +317,13 @@ + # endif + #endif + #if defined(__cplusplus) +-# define LZO_EXTERN_C extern "C" ++# define LZO_EXTERN_C extern "C" ++# define LZO_EXTERN_C_BEGIN extern "C" { ++# define LZO_EXTERN_C_END } #else - # define DMUL(a,b) ((lzo_xint) ((a) * (b))) +-# define LZO_EXTERN_C extern ++# define LZO_EXTERN_C extern ++# define LZO_EXTERN_C_BEGIN /*empty*/ ++# define LZO_EXTERN_C_END /*empty*/ + #endif + #if !defined(__LZO_OS_OVERRIDE) + #if (LZO_OS_FREESTANDING) +@@ -386,12 +424,12 @@ + #elif defined(__VMS) + # define LZO_OS_VMS 1 + # define LZO_INFO_OS "vms" +-#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) ++#elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__) + # define LZO_OS_CONSOLE 1 + # define LZO_OS_CONSOLE_PS2 1 + # define LZO_INFO_OS "console" + # define LZO_INFO_OS_CONSOLE "ps2" +-#elif (defined(__mips__) && defined(__psp__)) ++#elif defined(__mips__) && defined(__psp__) + # define LZO_OS_CONSOLE 1 + # define LZO_OS_CONSOLE_PSP 1 + # define LZO_INFO_OS "console" +@@ -419,9 +457,18 @@ + # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) + # define LZO_OS_POSIX_LINUX 1 + # define LZO_INFO_OS_POSIX "linux" +-# elif defined(__APPLE__) || defined(__MACOS__) +-# define LZO_OS_POSIX_MACOSX 1 +-# define LZO_INFO_OS_POSIX "macosx" ++# elif defined(__APPLE__) && defined(__MACH__) ++# if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000) ++# define LZO_OS_POSIX_DARWIN 1040 ++# define LZO_INFO_OS_POSIX "darwin_iphone" ++# elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040) ++# define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ ++# define LZO_INFO_OS_POSIX "darwin" ++# else ++# define LZO_OS_POSIX_DARWIN 1 ++# define LZO_INFO_OS_POSIX "darwin" ++# endif ++# define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN + # elif defined(__minix__) || defined(__minix) + # define LZO_OS_POSIX_MINIX 1 + # define LZO_INFO_OS_POSIX "minix" +@@ -456,18 +503,18 @@ #endif + #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) + # if (UINT_MAX != LZO_0xffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (ULONG_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif #endif - --#if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386 || LZO_ARCH_POWERPC) --# if (LZO_SIZEOF_SHORT == 2) --# define LZO_UNALIGNED_OK_2 1 --# endif --# if (LZO_SIZEOF_INT == 4) --# define LZO_UNALIGNED_OK_4 1 --# endif --#endif --#if 1 && (LZO_ARCH_AMD64) --# if defined(LZO_UINT64_MAX) --# define LZO_UNALIGNED_OK_8 1 --# endif --#endif --#if (LZO_CFG_NO_UNALIGNED) --# undef LZO_UNALIGNED_OK_2 --# undef LZO_UNALIGNED_OK_4 --# undef LZO_UNALIGNED_OK_8 --#endif -- --#undef UA_GET16 --#undef UA_SET16 --#undef UA_COPY16 --#undef UA_GET32 --#undef UA_SET32 --#undef UA_COPY32 --#undef UA_GET64 --#undef UA_SET64 --#undef UA_COPY64 --#if defined(LZO_UNALIGNED_OK_2) -- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(unsigned short) == 2) --# if 1 && defined(ACC_UA_COPY16) --# define UA_GET16 ACC_UA_GET16 --# define UA_SET16 ACC_UA_SET16 --# define UA_COPY16 ACC_UA_COPY16 --# else --# define UA_GET16(p) (* (__lzo_ua_volatile const lzo_ushortp) (__lzo_ua_volatile const lzo_voidp) (p)) --# define UA_SET16(p,v) ((* (__lzo_ua_volatile lzo_ushortp) (__lzo_ua_volatile lzo_voidp) (p)) = (unsigned short) (v)) --# define UA_COPY16(d,s) UA_SET16(d, UA_GET16(s)) --# endif --#endif --#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) -- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4) --# if 1 && defined(ACC_UA_COPY32) --# define UA_GET32 ACC_UA_GET32 --# define UA_SET32 ACC_UA_SET32 --# define UA_COPY32 ACC_UA_COPY32 --# else --# define UA_GET32(p) (* (__lzo_ua_volatile const lzo_uint32p) (__lzo_ua_volatile const lzo_voidp) (p)) --# define UA_SET32(p,v) ((* (__lzo_ua_volatile lzo_uint32p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint32) (v)) --# define UA_COPY32(d,s) UA_SET32(d, UA_GET32(s)) --# endif --#endif --#if defined(LZO_UNALIGNED_OK_8) -- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64) == 8) --# if 1 && defined(ACC_UA_COPY64) --# define UA_GET64 ACC_UA_GET64 --# define UA_SET64 ACC_UA_SET64 --# define UA_COPY64 ACC_UA_COPY64 + #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) + # if (UINT_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (ULONG_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + #endif + #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) +@@ -483,59 +530,65 @@ + # define LZO_INFO_CC "sdcc" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) + #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) +-# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) ++# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0)) + # define LZO_INFO_CC "Pathscale C" + # define LZO_INFO_CCVER __PATHSCALE__ +-#elif defined(__INTEL_COMPILER) +-# define LZO_CC_INTELC 1 ++# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++# define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) ++# endif ++#elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0) ++# define LZO_CC_INTELC __INTEL_COMPILER + # define LZO_INFO_CC "Intel C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) +-# if defined(_WIN32) || defined(_WIN64) +-# define LZO_CC_SYNTAX_MSC 1 -# else --# define UA_GET64(p) (* (__lzo_ua_volatile const lzo_uint64p) (__lzo_ua_volatile const lzo_voidp) (p)) --# define UA_SET64(p,v) ((* (__lzo_ua_volatile lzo_uint64p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint64) (v)) --# define UA_COPY64(d,s) UA_SET64(d, UA_GET64(s)) --# endif -+#ifndef __LZO_FUNC_H -+#define __LZO_FUNC_H 1 -+ -+#if !defined(LZO_BITOPS_USE_ASM_BITSCAN) && !defined(LZO_BITOPS_USE_GNUC_BITSCAN) && !defined(LZO_BITOPS_USE_MSC_BITSCAN) -+#if 1 && (LZO_ARCH_AMD64) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_ASM_SYNTAX_GNUC) -+#define LZO_BITOPS_USE_ASM_BITSCAN 1 -+#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul)))) -+#define LZO_BITOPS_USE_GNUC_BITSCAN 1 -+#elif (LZO_OS_WIN32 || LZO_OS_WIN64) && ((LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 1010)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) -+#define LZO_BITOPS_USE_MSC_BITSCAN 1 -+#if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+#include -+#endif -+#if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+#pragma intrinsic(_BitScanReverse) -+#pragma intrinsic(_BitScanForward) -+#endif -+#if (LZO_CC_MSC) && (LZO_ARCH_AMD64) -+#pragma intrinsic(_BitScanReverse64) -+#pragma intrinsic(_BitScanForward64) -+#endif -+#endif +-# define LZO_CC_SYNTAX_GNUC 1 ++# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) ++# define LZO_CC_INTELC_MSC _MSC_VER ++# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++# define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) + # endif + #elif defined(__POCC__) && defined(_WIN32) + # define LZO_CC_PELLESC 1 + # define LZO_INFO_CC "Pelles C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) +-#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++#elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) + # if defined(__GNUC_PATCHLEVEL__) +-# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) ++# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) + # else +-# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) ++# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) + # endif ++# define LZO_CC_ARMCC __ARMCC_VERSION ++# define LZO_INFO_CC "ARM C Compiler" ++# define LZO_INFO_CCVER __VERSION__ ++#elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__) + # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) +-# define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__) ++# define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0)) + # else +-# define LZO_CC_CLANG_CLANG 0x010000L ++# define LZO_CC_CLANG 0x010000L ++# endif ++# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) ++# define LZO_CC_CLANG_MSC _MSC_VER ++# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) + # endif +-# define LZO_CC_CLANG LZO_CC_CLANG_GNUC + # define LZO_INFO_CC "clang" + # define LZO_INFO_CCVER __VERSION__ + #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) + # if defined(__GNUC_PATCHLEVEL__) +-# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) ++# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) + # else +-# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) ++# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) + # endif + # define LZO_CC_LLVM LZO_CC_LLVM_GNUC + # define LZO_INFO_CC "llvm-gcc" + # define LZO_INFO_CCVER __VERSION__ +-#elif defined(__GNUC__) && defined(__VERSION__) +-# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) +-# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) +-# elif defined(__GNUC_MINOR__) +-# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) +-# else +-# define LZO_CC_GNUC (__GNUC__ * 0x10000L) +-# endif +-# define LZO_INFO_CC "gcc" +-# define LZO_INFO_CCVER __VERSION__ + #elif defined(__ACK__) && defined(_ACK) + # define LZO_CC_ACK 1 + # define LZO_INFO_CC "Amsterdam Compiler Kit C" + # define LZO_INFO_CCVER "unknown" ++#elif defined(__ARMCC_VERSION) && !defined(__GNUC__) ++# define LZO_CC_ARMCC __ARMCC_VERSION ++# define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION ++# define LZO_INFO_CC "ARM C Compiler" ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION) + #elif defined(__AZTEC_C__) + # define LZO_CC_AZTECC 1 + # define LZO_INFO_CC "Aztec C" +@@ -560,10 +613,23 @@ + # define LZO_CC_DECC 1 + # define LZO_INFO_CC "DEC C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) ++#elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0) ++# define LZO_CC_GHS 1 ++# define LZO_INFO_CC "Green Hills C" ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER) ++# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) ++# define LZO_CC_GHS_MSC _MSC_VER ++# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) ++# define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) ++# endif + #elif defined(__HIGHC__) + # define LZO_CC_HIGHC 1 + # define LZO_INFO_CC "MetaWare High C" + # define LZO_INFO_CCVER "unknown" ++#elif defined(__HP_aCC) && ((__HP_aCC-0) > 0) ++# define LZO_CC_HPACC __HP_aCC ++# define LZO_INFO_CC "HP aCC" ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC) + #elif defined(__IAR_SYSTEMS_ICC__) + # define LZO_CC_IARC 1 + # define LZO_INFO_CC "IAR C" +@@ -572,10 +638,14 @@ + # else + # define LZO_INFO_CCVER "unknown" + # endif +-#elif defined(__IBMC__) +-# define LZO_CC_IBMC 1 ++#elif defined(__IBMC__) && ((__IBMC__-0) > 0) ++# define LZO_CC_IBMC __IBMC__ + # define LZO_INFO_CC "IBM C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) ++#elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0) ++# define LZO_CC_IBMC __IBMCPP__ ++# define LZO_INFO_CC "IBM C" ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__) + #elif defined(__KEIL__) && defined(__C166__) + # define LZO_CC_KEILC 1 + # define LZO_INFO_CC "Keil C" +@@ -592,16 +662,8 @@ + # else + # define LZO_INFO_CCVER "unknown" + # endif +-#elif defined(_MSC_VER) +-# define LZO_CC_MSC 1 +-# define LZO_INFO_CC "Microsoft C" +-# if defined(_MSC_FULL_VER) +-# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) +-# else +-# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) +-# endif +-#elif defined(__MWERKS__) +-# define LZO_CC_MWERKS 1 ++#elif defined(__MWERKS__) && ((__MWERKS__-0) > 0) ++# define LZO_CC_MWERKS __MWERKS__ + # define LZO_INFO_CC "Metrowerks C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) + #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) +@@ -612,6 +674,15 @@ + # define LZO_CC_PACIFICC 1 + # define LZO_INFO_CC "Pacific C" + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) ++#elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) ++# if defined(__PGIC_PATCHLEVEL__) ++# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0)) ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__) ++# else ++# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100) ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0" ++# endif ++# define LZO_INFO_CC "Portland Group PGI C" + #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) + # define LZO_CC_PGI 1 + # define LZO_INFO_CC "Portland Group PGI C" +@@ -626,7 +697,7 @@ + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) + #elif defined(__SUNPRO_C) + # define LZO_INFO_CC "SunPro C" +-# if ((__SUNPRO_C)+0 > 0) ++# if ((__SUNPRO_C-0) > 0) + # define LZO_CC_SUNPROC __SUNPRO_C + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) + # else +@@ -635,7 +706,7 @@ + # endif + #elif defined(__SUNPRO_CC) + # define LZO_INFO_CC "SunPro C" +-# if ((__SUNPRO_CC)+0 > 0) ++# if ((__SUNPRO_CC-0) > 0) + # define LZO_CC_SUNPROC __SUNPRO_CC + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) + # else +@@ -661,16 +732,46 @@ + #elif defined(__ZTC__) + # define LZO_CC_ZORTECHC 1 + # define LZO_INFO_CC "Zortech C" +-# if (__ZTC__ == 0x310) ++# if ((__ZTC__-0) == 0x310) + # define LZO_INFO_CCVER "0x310" + # else + # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) + # endif ++#elif defined(__GNUC__) && defined(__VERSION__) ++# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) ++# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) ++# elif defined(__GNUC_MINOR__) ++# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) ++# else ++# define LZO_CC_GNUC (__GNUC__ * 0x10000L) ++# endif ++# define LZO_INFO_CC "gcc" ++# define LZO_INFO_CCVER __VERSION__ ++#elif defined(_MSC_VER) && ((_MSC_VER-0) > 0) ++# define LZO_CC_MSC _MSC_VER ++# define LZO_INFO_CC "Microsoft C" ++# if defined(_MSC_FULL_VER) ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) ++# else ++# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) ++# endif + #else + # define LZO_CC_UNKNOWN 1 + # define LZO_INFO_CC "unknown" + # define LZO_INFO_CCVER "unknown" + #endif ++#if (LZO_CC_GNUC) && defined(__OPEN64__) ++# if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__) ++# define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0)) ++# define LZO_CC_OPEN64_GNUC LZO_CC_GNUC ++# endif +#endif -+ -+__lzo_static_forceinline unsigned lzo_bitops_ctlz32_func(lzo_uint32_t v) -+{ -+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+ unsigned long r; (void) _BitScanReverse(&r, v); return (unsigned) r ^ 31; -+#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) -+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_uint32_t r; -+ __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); -+ return (unsigned) r ^ 31; -+#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT == 4) -+ unsigned r; r = (unsigned) __builtin_clz(v); return r; -+#define lzo_bitops_ctlz32(v) ((unsigned) __builtin_clz(v)) -+#else -+ LZO_UNUSED(v); return 0; ++#if (LZO_CC_GNUC) && defined(__PCC__) ++# if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__) ++# define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0)) ++# define LZO_CC_PCC_GNUC LZO_CC_GNUC ++# endif +#endif -+} -+ -+#if defined(lzo_uint64_t) -+__lzo_static_forceinline unsigned lzo_bitops_ctlz64_func(lzo_uint64_t v) -+{ -+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) -+ unsigned long r; (void) _BitScanReverse64(&r, v); return (unsigned) r ^ 63; -+#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) -+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_uint64_t r; -+ __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); -+ return (unsigned) r ^ 63; -+#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG == 8) && (LZO_WORDSIZE >= 8) -+ unsigned r; r = (unsigned) __builtin_clzl(v); return r; -+#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzl(v)) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG == 8) && (LZO_WORDSIZE >= 8) -+ unsigned r; r = (unsigned) __builtin_clzll(v); return r; -+#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzll(v)) -+#else -+ LZO_UNUSED(v); return 0; -+#endif -+} -+#endif -+ -+__lzo_static_forceinline unsigned lzo_bitops_cttz32_func(lzo_uint32_t v) -+{ -+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+ unsigned long r; (void) _BitScanForward(&r, v); return (unsigned) r; -+#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) -+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_uint32_t r; -+ __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); -+ return (unsigned) r; -+#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT >= 4) -+ unsigned r; r = (unsigned) __builtin_ctz(v); return r; -+#define lzo_bitops_cttz32(v) ((unsigned) __builtin_ctz(v)) -+#else -+ LZO_UNUSED(v); return 0; -+#endif -+} -+ -+#if defined(lzo_uint64_t) -+__lzo_static_forceinline unsigned lzo_bitops_cttz64_func(lzo_uint64_t v) -+{ -+#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) -+ unsigned long r; (void) _BitScanForward64(&r, v); return (unsigned) r; -+#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) -+#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_uint64_t r; -+ __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); -+ return (unsigned) r; -+#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG >= 8) && (LZO_WORDSIZE >= 8) -+ unsigned r; r = (unsigned) __builtin_ctzl(v); return r; -+#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzl(v)) -+#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG >= 8) && (LZO_WORDSIZE >= 8) -+ unsigned r; r = (unsigned) __builtin_ctzll(v); return r; -+#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzll(v)) -+#else -+ LZO_UNUSED(v); return 0; + #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) + # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" + #endif +@@ -688,8 +789,10 @@ + # define LZO_INFO_ARCH "generic" + #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) + # define LZO_ARCH_I086 1 +-# define LZO_ARCH_IA16 1 + # define LZO_INFO_ARCH "i086" ++#elif defined(__aarch64__) ++# define LZO_ARCH_ARM64 1 ++# define LZO_INFO_ARCH "arm64" + #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) + # define LZO_ARCH_ALPHA 1 + # define LZO_INFO_ARCH "alpha" +@@ -705,10 +808,10 @@ + # define LZO_INFO_ARCH "arm_thumb" + #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) + # define LZO_ARCH_ARM 1 +-# if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) ++# if defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 1) + # define LZO_ARCH_ARM_THUMB 1 + # define LZO_INFO_ARCH "arm_thumb" +-# elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) ++# elif defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 2) + # define LZO_INFO_ARCH "arm" + # else + # define LZO_INFO_ARCH "arm" +@@ -826,53 +929,147 @@ + # error "FIXME - missing define for CPU architecture" + #endif + #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) +-# error "FIXME - missing WIN32 define for CPU architecture" ++# error "FIXME - missing LZO_OS_WIN32 define for CPU architecture" + #endif + #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) +-# error "FIXME - missing WIN64 define for CPU architecture" ++# error "FIXME - missing LZO_OS_WIN64 define for CPU architecture" + #endif + #if (LZO_OS_OS216 || LZO_OS_WIN16) + # define LZO_ARCH_I086PM 1 +-# define LZO_ARCH_IA16PM 1 + #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) + # define LZO_ARCH_I086PM 1 +-# define LZO_ARCH_IA16PM 1 + #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) + # define LZO_ARCH_I086PM 1 +-# define LZO_ARCH_IA16PM 1 + #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) + # define LZO_ARCH_I086PM 1 +-# define LZO_ARCH_IA16PM 1 + #endif +-#if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM) +-# error "this should not happen" ++#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) ++# define LZO_ARCH_X64 1 ++#elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE) ++# define LZO_ARCH_AMD64 1 +#endif -+} ++#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) ++# define LZO_ARCH_AARCH64 1 ++#elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE) ++# define LZO_ARCH_ARM64 1 +#endif -+ -+#if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+static void __attribute__((__unused__)) -+#else -+__lzo_static_forceinline void ++#if (LZO_ARCH_I386 && !LZO_ARCH_X86) ++# define LZO_ARCH_X86 1 ++#elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE) ++# define LZO_ARCH_I386 1 +#endif -+lzo_bitops_unused_funcs(void) -+{ -+ LZO_UNUSED_FUNC(lzo_bitops_ctlz32_func); -+ LZO_UNUSED_FUNC(lzo_bitops_cttz32_func); -+#if defined(lzo_uint64_t) -+ LZO_UNUSED_FUNC(lzo_bitops_ctlz64_func); -+ LZO_UNUSED_FUNC(lzo_bitops_cttz64_func); ++#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64) ++# error "unexpected configuration - check your compiler defines" +#endif -+ LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); -+} -+ -+#if defined(__lzo_alignof) && !(LZO_CFG_NO_UNALIGNED) -+#ifndef __lzo_memops_tcheck -+#define __lzo_memops_tcheck(t,a,b) ((void)0, sizeof(t) == (a) && __lzo_alignof(t) == (b)) ++#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) ++# error "unexpected configuration - check your compiler defines" +#endif ++#if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86) ++# error "unexpected configuration - check your compiler defines" +#endif -+#ifndef lzo_memops_TU0p -+#define lzo_memops_TU0p void __LZO_MMODEL * ++#if (LZO_ARCH_ARM_THUMB && !LZO_ARCH_ARM) ++# error "unexpected configuration - check your compiler defines" +#endif -+#ifndef lzo_memops_TU1p -+#define lzo_memops_TU1p unsigned char __LZO_MMODEL * ++#if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM_THUMB) ++# error "unexpected configuration - check your compiler defines" +#endif -+#ifndef lzo_memops_TU2p -+#if (LZO_OPT_UNALIGNED16) -+typedef lzo_uint16_t __lzo_may_alias lzo_memops_TU2; -+#define lzo_memops_TU2p volatile lzo_memops_TU2 * -+#elif defined(__lzo_byte_struct) -+__lzo_byte_struct(lzo_memops_TU2_struct,2) -+typedef struct lzo_memops_TU2_struct lzo_memops_TU2; -+#else -+struct lzo_memops_TU2_struct { unsigned char a[2]; } __lzo_may_alias; -+typedef struct lzo_memops_TU2_struct lzo_memops_TU2; ++#if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB) ++# error "unexpected configuration - check your compiler defines" + #endif +-#if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086) +-# error "this should not happen" ++#if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2) ++# error "unexpected configuration - check your compiler defines" +#endif -+#ifndef lzo_memops_TU2p -+#define lzo_memops_TU2p lzo_memops_TU2 * ++#if (LZO_ARCH_I086PM && !LZO_ARCH_I086) ++# error "unexpected configuration - check your compiler defines" + #endif + #if (LZO_ARCH_I086) + # if (UINT_MAX != LZO_0xffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (ULONG_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + #endif + #if (LZO_ARCH_I386) + # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + # if (ULONG_MAX != LZO_0xffffffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" ++# endif +#endif ++#if (LZO_ARCH_AMD64 || LZO_ARCH_I386) ++# if !defined(LZO_TARGET_FEATURE_SSE2) ++# if defined(__SSE2__) ++# define LZO_TARGET_FEATURE_SSE2 1 ++# elif defined(_MSC_VER) && ((defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) || defined(_M_AMD64)) ++# define LZO_TARGET_FEATURE_SSE2 1 ++# endif ++# endif ++# if !defined(LZO_TARGET_FEATURE_SSSE3) ++# if (LZO_TARGET_FEATURE_SSE2) ++# if defined(__SSSE3__) ++# define LZO_TARGET_FEATURE_SSSE3 1 ++# elif defined(_MSC_VER) && defined(__AVX__) ++# define LZO_TARGET_FEATURE_SSSE3 1 ++# endif ++# endif ++# endif ++# if !defined(LZO_TARGET_FEATURE_SSE4_2) ++# if (LZO_TARGET_FEATURE_SSSE3) ++# if defined(__SSE4_2__) ++# define LZO_TARGET_FEATURE_SSE4_2 1 ++# endif ++# endif ++# endif ++# if !defined(LZO_TARGET_FEATURE_AVX) ++# if (LZO_TARGET_FEATURE_SSSE3) ++# if defined(__AVX__) ++# define LZO_TARGET_FEATURE_AVX 1 ++# endif ++# endif ++# endif ++# if !defined(LZO_TARGET_FEATURE_AVX2) ++# if (LZO_TARGET_FEATURE_AVX) ++# if defined(__AVX2__) ++# define LZO_TARGET_FEATURE_AVX2 1 ++# endif ++# endif ++# endif +#endif -+#ifndef lzo_memops_TU4p -+#if (LZO_OPT_UNALIGNED32) -+typedef lzo_uint32_t __lzo_may_alias lzo_memops_TU4; -+#define lzo_memops_TU4p volatile lzo_memops_TU4 __LZO_MMODEL * -+#elif defined(__lzo_byte_struct) -+__lzo_byte_struct(lzo_memops_TU4_struct,4) -+typedef struct lzo_memops_TU4_struct lzo_memops_TU4; -+#else -+struct lzo_memops_TU4_struct { unsigned char a[4]; } __lzo_may_alias; -+typedef struct lzo_memops_TU4_struct lzo_memops_TU4; ++#if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2)) ++# error "unexpected configuration - check your compiler defines" +#endif -+#ifndef lzo_memops_TU4p -+#define lzo_memops_TU4p lzo_memops_TU4 __LZO_MMODEL * ++#if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3)) ++# error "unexpected configuration - check your compiler defines" +#endif ++#if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3)) ++# error "unexpected configuration - check your compiler defines" +#endif -+#ifndef lzo_memops_TU8p -+#if (LZO_OPT_UNALIGNED64) -+typedef lzo_uint64_t __lzo_may_alias lzo_memops_TU8; -+#define lzo_memops_TU8p volatile lzo_memops_TU8 __LZO_MMODEL * -+#elif defined(__lzo_byte_struct) -+__lzo_byte_struct(lzo_memops_TU8_struct,8) -+typedef struct lzo_memops_TU8_struct lzo_memops_TU8; -+#else -+struct lzo_memops_TU8_struct { unsigned char a[8]; } __lzo_may_alias; -+typedef struct lzo_memops_TU8_struct lzo_memops_TU8; ++#if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX)) ++# error "unexpected configuration - check your compiler defines" +#endif -+#ifndef lzo_memops_TU8p -+#define lzo_memops_TU8p lzo_memops_TU8 __LZO_MMODEL * ++#if (LZO_ARCH_ARM) ++# if !defined(LZO_TARGET_FEATURE_NEON) ++# if defined(__ARM_NEON__) ++# define LZO_TARGET_FEATURE_NEON 1 ++# endif ++# endif ++#elif (LZO_ARCH_ARM64) ++# if !defined(LZO_TARGET_FEATURE_NEON) ++# if 1 ++# define LZO_TARGET_FEATURE_NEON 1 ++# endif + # endif + #endif +-#if !defined(__LZO_MM_OVERRIDE) ++#if 0 ++#elif !defined(__LZO_MM_OVERRIDE) + #if (LZO_ARCH_I086) + #if (UINT_MAX != LZO_0xffffL) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + #endif + #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) + # define LZO_MM_TINY 1 +@@ -899,7 +1096,7 @@ + #elif (LZO_CC_ZORTECHC && defined(__VCM__)) + # define LZO_MM_LARGE 1 + #else +-# error "unknown memory model" ++# error "unknown LZO_ARCH_I086 memory model" + #endif + #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) + #define LZO_HAVE_MM_HUGE_PTR 1 +@@ -922,10 +1119,10 @@ + #endif + #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) + # if (LZO_OS_DOS16) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # elif (LZO_CC_ZORTECHC) + # else +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" + # endif + #endif + #ifdef __cplusplus +@@ -957,7 +1154,7 @@ extern "C" { + #endif + #elif (LZO_ARCH_C166) + #if !defined(__MODEL__) +-# error "FIXME - C166 __MODEL__" ++# error "FIXME - LZO_ARCH_C166 __MODEL__" + #elif ((__MODEL__) == 0) + # define LZO_MM_SMALL 1 + #elif ((__MODEL__) == 1) +@@ -971,11 +1168,11 @@ extern "C" { + #elif ((__MODEL__) == 5) + # define LZO_MM_XSMALL 1 + #else +-# error "FIXME - C166 __MODEL__" ++# error "FIXME - LZO_ARCH_C166 __MODEL__" + #endif + #elif (LZO_ARCH_MCS251) + #if !defined(__MODEL__) +-# error "FIXME - MCS251 __MODEL__" ++# error "FIXME - LZO_ARCH_MCS251 __MODEL__" + #elif ((__MODEL__) == 0) + # define LZO_MM_SMALL 1 + #elif ((__MODEL__) == 2) +@@ -987,11 +1184,11 @@ extern "C" { + #elif ((__MODEL__) == 5) + # define LZO_MM_XSMALL 1 + #else +-# error "FIXME - MCS251 __MODEL__" ++# error "FIXME - LZO_ARCH_MCS251 __MODEL__" + #endif + #elif (LZO_ARCH_MCS51) + #if !defined(__MODEL__) +-# error "FIXME - MCS51 __MODEL__" ++# error "FIXME - LZO_ARCH_MCS51 __MODEL__" + #elif ((__MODEL__) == 1) + # define LZO_MM_SMALL 1 + #elif ((__MODEL__) == 2) +@@ -1003,7 +1200,7 @@ extern "C" { + #elif ((__MODEL__) == 5) + # define LZO_MM_XSMALL 1 + #else +-# error "FIXME - MCS51 __MODEL__" ++# error "FIXME - LZO_ARCH_MCS51 __MODEL__" + #endif + #elif (LZO_ARCH_CRAY_PVP) + # define LZO_MM_PVP 1 +@@ -1030,462 +1227,270 @@ extern "C" { + # error "unknown memory model" + #endif + #endif +-#if defined(SIZEOF_SHORT) +-# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) ++#if !defined(__lzo_gnuc_extension__) ++#if (LZO_CC_GNUC >= 0x020800ul) ++# define __lzo_gnuc_extension__ __extension__ ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_gnuc_extension__ __extension__ ++#elif (LZO_CC_IBMC >= 600) ++# define __lzo_gnuc_extension__ __extension__ ++#else + #endif +-#if defined(SIZEOF_INT) +-# define LZO_SIZEOF_INT (SIZEOF_INT) + #endif +-#if defined(SIZEOF_LONG) +-# define LZO_SIZEOF_LONG (SIZEOF_LONG) ++#if !defined(__lzo_gnuc_extension__) ++# define __lzo_gnuc_extension__ /*empty*/ + #endif +-#if defined(SIZEOF_LONG_LONG) +-# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) ++#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0 ++# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) ++# define LZO_CFG_USE_NEW_STYLE_CASTS 0 ++# elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200)) ++# define LZO_CFG_USE_NEW_STYLE_CASTS 0 ++# else ++# define LZO_CFG_USE_NEW_STYLE_CASTS 1 ++# endif + #endif +-#if defined(SIZEOF___INT16) +-# define LZO_SIZEOF___INT16 (SIZEOF___INT16) ++#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_CFG_USE_NEW_STYLE_CASTS 0 + #endif +-#if defined(SIZEOF___INT32) +-# define LZO_SIZEOF___INT32 (SIZEOF___INT32) ++#if !defined(__cplusplus) ++# if defined(LZO_CFG_USE_NEW_STYLE_CASTS) ++# undef LZO_CFG_USE_NEW_STYLE_CASTS ++# endif ++# define LZO_CFG_USE_NEW_STYLE_CASTS 0 + #endif +-#if defined(SIZEOF___INT64) +-# define LZO_SIZEOF___INT64 (SIZEOF___INT64) ++#if !defined(LZO_REINTERPRET_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast (e)) ++# endif + #endif +-#if defined(SIZEOF_VOID_P) +-# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) ++#if !defined(LZO_REINTERPRET_CAST) ++# define LZO_REINTERPRET_CAST(t,e) ((t) (e)) + #endif +-#if defined(SIZEOF_SIZE_T) +-# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) ++#if !defined(LZO_STATIC_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_STATIC_CAST(t,e) (static_cast (e)) ++# endif + #endif +-#if defined(SIZEOF_PTRDIFF_T) +-# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) ++#if !defined(LZO_STATIC_CAST) ++# define LZO_STATIC_CAST(t,e) ((t) (e)) + #endif +-#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) +-#if !defined(LZO_SIZEOF_SHORT) +-# if (LZO_ARCH_CRAY_PVP) +-# define LZO_SIZEOF_SHORT 8 +-# elif (USHRT_MAX == LZO_0xffffL) +-# define LZO_SIZEOF_SHORT 2 +-# elif (__LZO_LSR(USHRT_MAX,7) == 1) +-# define LZO_SIZEOF_SHORT 1 +-# elif (__LZO_LSR(USHRT_MAX,15) == 1) +-# define LZO_SIZEOF_SHORT 2 +-# elif (__LZO_LSR(USHRT_MAX,31) == 1) +-# define LZO_SIZEOF_SHORT 4 +-# elif (__LZO_LSR(USHRT_MAX,63) == 1) +-# define LZO_SIZEOF_SHORT 8 +-# elif (__LZO_LSR(USHRT_MAX,127) == 1) +-# define LZO_SIZEOF_SHORT 16 +-# else +-# error "LZO_SIZEOF_SHORT" +-# endif ++#if !defined(LZO_STATIC_CAST2) ++# define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e)) + #endif +-#if !defined(LZO_SIZEOF_INT) +-# if (LZO_ARCH_CRAY_PVP) +-# define LZO_SIZEOF_INT 8 +-# elif (UINT_MAX == LZO_0xffffL) +-# define LZO_SIZEOF_INT 2 +-# elif (UINT_MAX == LZO_0xffffffffL) +-# define LZO_SIZEOF_INT 4 +-# elif (__LZO_LSR(UINT_MAX,7) == 1) +-# define LZO_SIZEOF_INT 1 +-# elif (__LZO_LSR(UINT_MAX,15) == 1) +-# define LZO_SIZEOF_INT 2 +-# elif (__LZO_LSR(UINT_MAX,31) == 1) +-# define LZO_SIZEOF_INT 4 +-# elif (__LZO_LSR(UINT_MAX,63) == 1) +-# define LZO_SIZEOF_INT 8 +-# elif (__LZO_LSR(UINT_MAX,127) == 1) +-# define LZO_SIZEOF_INT 16 +-# else +-# error "LZO_SIZEOF_INT" ++#if !defined(LZO_UNCONST_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_UNCONST_CAST(t,e) (const_cast (e)) ++# elif (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_UNCONST_CAST(t,e) ((t) (e)) ++# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e))))) + # endif + #endif +-#if !defined(LZO_SIZEOF_LONG) +-# if (ULONG_MAX == LZO_0xffffffffL) +-# define LZO_SIZEOF_LONG 4 +-# elif (__LZO_LSR(ULONG_MAX,7) == 1) +-# define LZO_SIZEOF_LONG 1 +-# elif (__LZO_LSR(ULONG_MAX,15) == 1) +-# define LZO_SIZEOF_LONG 2 +-# elif (__LZO_LSR(ULONG_MAX,31) == 1) +-# define LZO_SIZEOF_LONG 4 +-# elif (__LZO_LSR(ULONG_MAX,63) == 1) +-# define LZO_SIZEOF_LONG 8 +-# elif (__LZO_LSR(ULONG_MAX,127) == 1) +-# define LZO_SIZEOF_LONG 16 +-# else +-# error "LZO_SIZEOF_LONG" ++#if !defined(LZO_UNCONST_CAST) ++# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e)))) +#endif ++#if !defined(LZO_UNCONST_VOLATILE_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast (e)) ++# elif (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e)) ++# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) + # endif + #endif +-#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) +-#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) +-# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) +-# if (LZO_CC_GNUC >= 0x030300ul) +-# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) +-# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG +-# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) +-# define LZO_SIZEOF_LONG_LONG 4 +-# endif +-# endif ++#if !defined(LZO_UNCONST_VOLATILE_CAST) ++# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e)))) +#endif -+#ifndef lzo_memops_set_TU1p -+#define lzo_memops_set_TU1p volatile lzo_memops_TU1p ++#if !defined(LZO_UNVOLATILE_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_UNVOLATILE_CAST(t,e) (const_cast (e)) ++# elif (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_UNVOLATILE_CAST(t,e) ((t) (e)) ++# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e))))) + # endif + #endif ++#if !defined(LZO_UNVOLATILE_CAST) ++# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e)))) + #endif +-#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) +-#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) +-#if (LZO_ARCH_I086 && LZO_CC_DMC) +-#elif (LZO_CC_CILLY) && defined(__GNUC__) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_OS_WIN64 || defined(_WIN64)) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) +-# define LZO_SIZEOF___INT64 8 +-#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) +-# define LZO_SIZEOF___INT64 8 +-#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +-# define LZO_SIZEOF_LONG_LONG 8 +-#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) +-#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +-# define LZO_SIZEOF_LONG_LONG 8 ++#if !defined(LZO_UNVOLATILE_CONST_CAST) ++# if (LZO_CFG_USE_NEW_STYLE_CASTS) ++# define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast (e)) ++# elif (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e)) ++# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) ++# endif + #endif ++#if !defined(LZO_UNVOLATILE_CONST_CAST) ++# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e)))) + #endif ++#if !defined(LZO_PCAST) ++# if (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_PCAST(t,e) ((t) (e)) ++# endif + #endif +-#if defined(__cplusplus) && (LZO_CC_GNUC) +-# if (LZO_CC_GNUC < 0x020800ul) +-# undef LZO_SIZEOF_LONG_LONG ++#if !defined(LZO_PCAST) ++# define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e)) +#endif -+#ifndef lzo_memops_move_TU1p -+#define lzo_memops_move_TU1p lzo_memops_TU1p ++#if !defined(LZO_CCAST) ++# if (LZO_HAVE_MM_HUGE_PTR) ++# define LZO_CCAST(t,e) ((t) (e)) + # endif + #endif +-#if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) +-# undef LZO_SIZEOF_LONG_LONG ++#if !defined(LZO_CCAST) ++# define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e)) + #endif +-#if !defined(LZO_SIZEOF_VOID_P) +-#if (LZO_ARCH_I086) +-# define __LZO_WORDSIZE 2 +-# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) +-# define LZO_SIZEOF_VOID_P 2 +-# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) +-# define LZO_SIZEOF_VOID_P 4 +-# else +-# error "LZO_MM" ++#if !defined(LZO_ICONV) ++# define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e) +#endif -+#define LZO_MEMOPS_SET1(dd,cc) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_set_TU1p d__1 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ -+ d__1[0] = LZO_BYTE(cc); \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_SET2(dd,cc) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_set_TU1p d__2 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ -+ d__2[0] = LZO_BYTE(cc); d__2[1] = LZO_BYTE(cc); \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_SET3(dd,cc) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_set_TU1p d__3 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ -+ d__3[0] = LZO_BYTE(cc); d__3[1] = LZO_BYTE(cc); d__3[2] = LZO_BYTE(cc); \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_SET4(dd,cc) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_set_TU1p d__4 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ -+ d__4[0] = LZO_BYTE(cc); d__4[1] = LZO_BYTE(cc); d__4[2] = LZO_BYTE(cc); d__4[3] = LZO_BYTE(cc); \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE1(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__1 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__1 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__1[0] = s__1[0]; \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE2(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__2 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__2 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__2[0] = s__2[0]; d__2[1] = s__2[1]; \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE3(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__3 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__3 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__3[0] = s__3[0]; d__3[1] = s__3[1]; d__3[2] = s__3[2]; \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE4(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__4 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__4 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__4[0] = s__4[0]; d__4[1] = s__4[1]; d__4[2] = s__4[2]; d__4[3] = s__4[3]; \ -+ LZO_BLOCK_END -+#define LZO_MEMOPS_MOVE8(dd,ss) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_move_TU1p d__8 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_move_TU1p s__8 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ -+ d__8[0] = s__8[0]; d__8[1] = s__8[1]; d__8[2] = s__8[2]; d__8[3] = s__8[3]; \ -+ d__8[4] = s__8[4]; d__8[5] = s__8[5]; d__8[6] = s__8[6]; d__8[7] = s__8[7]; \ -+ LZO_BLOCK_END -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU1p)0)==1) -+#define LZO_MEMOPS_COPY1(dd,ss) LZO_MEMOPS_MOVE1(dd,ss) -+#if (LZO_OPT_UNALIGNED16) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0)==2) -+#define LZO_MEMOPS_COPY2(dd,ss) \ -+ * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) -+#elif defined(__lzo_memops_tcheck) -+#define LZO_MEMOPS_COPY2(dd,ss) \ -+ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU2,2,1)) { \ -+ * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss); \ -+ } else { LZO_MEMOPS_MOVE2(dd,ss); } LZO_BLOCK_END -+#else -+#define LZO_MEMOPS_COPY2(dd,ss) LZO_MEMOPS_MOVE2(dd,ss) -+#endif -+#if (LZO_OPT_UNALIGNED32) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0)==4) -+#define LZO_MEMOPS_COPY4(dd,ss) \ -+ * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) -+#elif defined(__lzo_memops_tcheck) -+#define LZO_MEMOPS_COPY4(dd,ss) \ -+ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU4,4,1)) { \ -+ * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss); \ -+ } else { LZO_MEMOPS_MOVE4(dd,ss); } LZO_BLOCK_END -+#else -+#define LZO_MEMOPS_COPY4(dd,ss) LZO_MEMOPS_MOVE4(dd,ss) -+#endif -+#if (LZO_WORDSIZE != 8) -+#define LZO_MEMOPS_COPY8(dd,ss) \ -+ LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END -+#else -+#if (LZO_OPT_UNALIGNED64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8) -+#define LZO_MEMOPS_COPY8(dd,ss) \ -+ * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) -+#elif (LZO_OPT_UNALIGNED32) -+#define LZO_MEMOPS_COPY8(dd,ss) \ -+ LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END -+#elif defined(__lzo_memops_tcheck) -+#define LZO_MEMOPS_COPY8(dd,ss) \ -+ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU8,8,1)) { \ -+ * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss); \ -+ } else { LZO_MEMOPS_MOVE8(dd,ss); } LZO_BLOCK_END -+#else -+#define LZO_MEMOPS_COPY8(dd,ss) LZO_MEMOPS_MOVE8(dd,ss) -+#endif -+#endif -+#define LZO_MEMOPS_COPYN(dd,ss,nn) \ -+ LZO_BLOCK_BEGIN \ -+ lzo_memops_TU1p d__n = (lzo_memops_TU1p) (lzo_memops_TU0p) (dd); \ -+ const lzo_memops_TU1p s__n = (const lzo_memops_TU1p) (const lzo_memops_TU0p) (ss); \ -+ lzo_uint n__n = (nn); \ -+ while ((void)0, n__n >= 8) { LZO_MEMOPS_COPY8(d__n, s__n); d__n += 8; s__n += 8; n__n -= 8; } \ -+ if ((void)0, n__n >= 4) { LZO_MEMOPS_COPY4(d__n, s__n); d__n += 4; s__n += 4; n__n -= 4; } \ -+ if ((void)0, n__n > 0) do { *d__n++ = *s__n++; } while (--n__n > 0); \ -+ LZO_BLOCK_END -+ -+__lzo_static_forceinline lzo_uint16_t lzo_memops_get_le16(const lzo_voidp ss) -+{ -+ lzo_uint16_t v; -+#if (LZO_ABI_LITTLE_ENDIAN) -+ LZO_MEMOPS_COPY2(&v, ss); -+#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) -+ const lzo_memops_TU2p s = (const lzo_memops_TU2p) ss; -+ unsigned long vv; -+ __asm__("lhbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); -+ v = (lzo_uint16_t) vv; -+#else -+ const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; -+ v = (lzo_uint16_t) (((lzo_uint16_t)s[0]) | ((lzo_uint16_t)s[1] << 8)); -+#endif -+ return v; -+} -+#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_GET_LE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) -+#else -+#define LZO_MEMOPS_GET_LE16(ss) lzo_memops_get_le16(ss) -+#endif -+ -+__lzo_static_forceinline lzo_uint32_t lzo_memops_get_le32(const lzo_voidp ss) -+{ -+ lzo_uint32_t v; -+#if (LZO_ABI_LITTLE_ENDIAN) -+ LZO_MEMOPS_COPY4(&v, ss); -+#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) -+ const lzo_memops_TU4p s = (const lzo_memops_TU4p) ss; -+ unsigned long vv; -+ __asm__("lwbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); -+ v = (lzo_uint32_t) vv; -+#else -+ const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; -+ v = (lzo_uint32_t) (((lzo_uint32_t)s[0]) | ((lzo_uint32_t)s[1] << 8) | ((lzo_uint32_t)s[2] << 16) | ((lzo_uint32_t)s[3] << 24)); -+#endif -+ return v; -+} -+#if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_GET_LE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) -+#else -+#define LZO_MEMOPS_GET_LE32(ss) lzo_memops_get_le32(ss) -+#endif -+ -+#if (LZO_OPT_UNALIGNED64) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_GET_LE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) -+#endif -+ -+__lzo_static_forceinline lzo_uint16_t lzo_memops_get_ne16(const lzo_voidp ss) -+{ -+ lzo_uint16_t v; -+ LZO_MEMOPS_COPY2(&v, ss); -+ return v; -+} -+#if (LZO_OPT_UNALIGNED16) -+#define LZO_MEMOPS_GET_NE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) -+#else -+#define LZO_MEMOPS_GET_NE16(ss) lzo_memops_get_ne16(ss) -+#endif -+ -+__lzo_static_forceinline lzo_uint32_t lzo_memops_get_ne32(const lzo_voidp ss) -+{ -+ lzo_uint32_t v; -+ LZO_MEMOPS_COPY4(&v, ss); -+ return v; -+} -+#if (LZO_OPT_UNALIGNED32) -+#define LZO_MEMOPS_GET_NE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) -+#else -+#define LZO_MEMOPS_GET_NE32(ss) lzo_memops_get_ne32(ss) -+#endif -+ -+#if (LZO_OPT_UNALIGNED64) -+#define LZO_MEMOPS_GET_NE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) -+#endif -+ -+__lzo_static_forceinline void lzo_memops_put_le16(lzo_voidp dd, lzo_uint16_t vv) -+{ -+#if (LZO_ABI_LITTLE_ENDIAN) -+ LZO_MEMOPS_COPY2(dd, &vv); -+#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_memops_TU2p d = (lzo_memops_TU2p) dd; -+ unsigned long v = vv; -+ __asm__("sthbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); -+#else -+ lzo_memops_TU1p d = (lzo_memops_TU1p) dd; -+ d[0] = LZO_BYTE((vv ) & 0xff); -+ d[1] = LZO_BYTE((vv >> 8) & 0xff); -+#endif -+} -+#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_PUT_LE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv)) -+#else -+#define LZO_MEMOPS_PUT_LE16(dd,vv) lzo_memops_put_le16(dd,vv) ++#if !defined(LZO_ICAST) ++# define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e) +#endif -+ -+__lzo_static_forceinline void lzo_memops_put_le32(lzo_voidp dd, lzo_uint32_t vv) -+{ -+#if (LZO_ABI_LITTLE_ENDIAN) -+ LZO_MEMOPS_COPY4(dd, &vv); -+#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) -+ lzo_memops_TU4p d = (lzo_memops_TU4p) dd; -+ unsigned long v = vv; -+ __asm__("stwbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); -+#else -+ lzo_memops_TU1p d = (lzo_memops_TU1p) dd; -+ d[0] = LZO_BYTE((vv ) & 0xff); -+ d[1] = LZO_BYTE((vv >> 8) & 0xff); -+ d[2] = LZO_BYTE((vv >> 16) & 0xff); -+ d[3] = LZO_BYTE((vv >> 24) & 0xff); ++#if !defined(LZO_ITRUNC) ++# define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e) +#endif -+} -+#if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN) -+#define LZO_MEMOPS_PUT_LE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv)) -+#else -+#define LZO_MEMOPS_PUT_LE32(dd,vv) lzo_memops_put_le32(dd,vv) ++#if !defined(__lzo_cte) ++# if (LZO_CC_MSC || LZO_CC_WATCOMC) ++# define __lzo_cte(e) ((void)0,(e)) ++# elif 1 ++# define __lzo_cte(e) ((void)0,(e)) + # endif +-#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) +-# define __LZO_WORDSIZE 1 +-# define LZO_SIZEOF_VOID_P 2 +-#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) +-# define LZO_SIZEOF_VOID_P 2 +-#elif (LZO_ARCH_H8300) +-# if defined(__NORMAL_MODE__) +-# define __LZO_WORDSIZE 4 +-# define LZO_SIZEOF_VOID_P 2 +-# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) +-# define __LZO_WORDSIZE 4 +-# define LZO_SIZEOF_VOID_P 4 +-# else +-# define __LZO_WORDSIZE 2 +-# define LZO_SIZEOF_VOID_P 2 +-# endif +-# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT +-# endif +-#elif (LZO_ARCH_M16C) +-# define __LZO_WORDSIZE 2 +-# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) +-# define LZO_SIZEOF_VOID_P 4 +-# else +-# define LZO_SIZEOF_VOID_P 2 +-# endif +-#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) +-# define __LZO_WORDSIZE 8 +-# define LZO_SIZEOF_VOID_P 4 +-#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) +-# define __LZO_WORDSIZE 8 +-# define LZO_SIZEOF_VOID_P 8 +-#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) +-# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +-#elif (LZO_OS_OS400 || defined(__OS400__)) +-# define __LZO_WORDSIZE LZO_SIZEOF_LONG +-# define LZO_SIZEOF_VOID_P 16 +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +-#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) +-# define LZO_SIZEOF_VOID_P 8 +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +-#elif (LZO_ARCH_SPU) +-# if 0 +-# define __LZO_WORDSIZE 16 +-# endif +-# define LZO_SIZEOF_VOID_P 4 +-#else +-# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG + #endif ++#if !defined(__lzo_cte) ++# define __lzo_cte(e) (e) + #endif +-#if !defined(LZO_WORDSIZE) +-# if defined(__LZO_WORDSIZE) +-# define LZO_WORDSIZE __LZO_WORDSIZE ++#if !defined(LZO_BLOCK_BEGIN) ++# define LZO_BLOCK_BEGIN do { ++# define LZO_BLOCK_END } while __lzo_cte(0) +#endif -+ -+__lzo_static_forceinline void lzo_memops_put_ne16(lzo_voidp dd, lzo_uint16_t vv) -+{ -+ LZO_MEMOPS_COPY2(dd, &vv); -+} -+#if (LZO_OPT_UNALIGNED16) -+#define LZO_MEMOPS_PUT_NE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv)) -+#else -+#define LZO_MEMOPS_PUT_NE16(dd,vv) lzo_memops_put_ne16(dd,vv) -+#endif -+ -+__lzo_static_forceinline void lzo_memops_put_ne32(lzo_voidp dd, lzo_uint32_t vv) -+{ -+ LZO_MEMOPS_COPY4(dd, &vv); -+} -+#if (LZO_OPT_UNALIGNED32) -+#define LZO_MEMOPS_PUT_NE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv)) -+#else -+#define LZO_MEMOPS_PUT_NE32(dd,vv) lzo_memops_put_ne32(dd,vv) -+#endif -+ -+#if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+static void __attribute__((__unused__)) -+#else -+__lzo_static_forceinline void -+#endif -+lzo_memops_unused_funcs(void) -+{ -+ LZO_UNUSED_FUNC(lzo_memops_get_le16); -+ LZO_UNUSED_FUNC(lzo_memops_get_le32); -+ LZO_UNUSED_FUNC(lzo_memops_get_ne16); -+ LZO_UNUSED_FUNC(lzo_memops_get_ne32); -+ LZO_UNUSED_FUNC(lzo_memops_put_le16); -+ LZO_UNUSED_FUNC(lzo_memops_put_le32); -+ LZO_UNUSED_FUNC(lzo_memops_put_ne16); -+ LZO_UNUSED_FUNC(lzo_memops_put_ne32); -+ LZO_UNUSED_FUNC(lzo_memops_unused_funcs); -+} -+ -+#endif -+ -+#ifndef UA_SET1 -+#define UA_SET1 LZO_MEMOPS_SET1 -+#endif -+#ifndef UA_SET2 -+#define UA_SET2 LZO_MEMOPS_SET2 -+#endif -+#ifndef UA_SET3 -+#define UA_SET3 LZO_MEMOPS_SET3 -+#endif -+#ifndef UA_SET4 -+#define UA_SET4 LZO_MEMOPS_SET4 -+#endif -+#ifndef UA_MOVE1 -+#define UA_MOVE1 LZO_MEMOPS_MOVE1 -+#endif -+#ifndef UA_MOVE2 -+#define UA_MOVE2 LZO_MEMOPS_MOVE2 -+#endif -+#ifndef UA_MOVE3 -+#define UA_MOVE3 LZO_MEMOPS_MOVE3 -+#endif -+#ifndef UA_MOVE4 -+#define UA_MOVE4 LZO_MEMOPS_MOVE4 -+#endif -+#ifndef UA_MOVE8 -+#define UA_MOVE8 LZO_MEMOPS_MOVE8 -+#endif -+#ifndef UA_COPY1 -+#define UA_COPY1 LZO_MEMOPS_COPY1 -+#endif -+#ifndef UA_COPY2 -+#define UA_COPY2 LZO_MEMOPS_COPY2 -+#endif -+#ifndef UA_COPY3 -+#define UA_COPY3 LZO_MEMOPS_COPY3 -+#endif -+#ifndef UA_COPY4 -+#define UA_COPY4 LZO_MEMOPS_COPY4 -+#endif -+#ifndef UA_COPY8 -+#define UA_COPY8 LZO_MEMOPS_COPY8 -+#endif -+#ifndef UA_COPYN -+#define UA_COPYN LZO_MEMOPS_COPYN -+#endif -+#ifndef UA_COPYN_X -+#define UA_COPYN_X LZO_MEMOPS_COPYN -+#endif -+#ifndef UA_GET_LE16 -+#define UA_GET_LE16 LZO_MEMOPS_GET_LE16 -+#endif -+#ifndef UA_GET_LE32 -+#define UA_GET_LE32 LZO_MEMOPS_GET_LE32 -+#endif -+#ifdef LZO_MEMOPS_GET_LE64 -+#ifndef UA_GET_LE64 -+#define UA_GET_LE64 LZO_MEMOPS_GET_LE64 -+#endif -+#endif -+#ifndef UA_GET_NE16 -+#define UA_GET_NE16 LZO_MEMOPS_GET_NE16 -+#endif -+#ifndef UA_GET_NE32 -+#define UA_GET_NE32 LZO_MEMOPS_GET_NE32 -+#endif -+#ifdef LZO_MEMOPS_GET_NE64 -+#ifndef UA_GET_NE64 -+#define UA_GET_NE64 LZO_MEMOPS_GET_NE64 -+#endif -+#endif -+#ifndef UA_PUT_LE16 -+#define UA_PUT_LE16 LZO_MEMOPS_PUT_LE16 -+#endif -+#ifndef UA_PUT_LE32 -+#define UA_PUT_LE32 LZO_MEMOPS_PUT_LE32 -+#endif -+#ifndef UA_PUT_NE16 -+#define UA_PUT_NE16 LZO_MEMOPS_PUT_NE16 -+#endif -+#ifndef UA_PUT_NE32 -+#define UA_PUT_NE32 LZO_MEMOPS_PUT_NE32 - #endif - - #define MEMCPY8_DS(dest,src,len) \ -@@ -2195,25 +3782,10 @@ LZO_EXTERN(const lzo_bytep) lzo_copyright(void); - extern "C" { ++#if !defined(LZO_UNUSED) ++# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) ++# define LZO_UNUSED(var) ((void) &var) ++# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) ++# define LZO_UNUSED(var) if (&var) ; else ++# elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul)) ++# define LZO_UNUSED(var) ((void) &var) ++# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_UNUSED(var) ((void) var) ++# elif (LZO_CC_MSC && (_MSC_VER < 900)) ++# define LZO_UNUSED(var) if (&var) ; else ++# elif (LZO_CC_KEILC) ++# define LZO_UNUSED(var) {LZO_EXTERN_C int lzo_unused__[1-2*!(sizeof(var)>0)];} ++# elif (LZO_CC_PACIFICC) ++# define LZO_UNUSED(var) ((void) sizeof(var)) ++# elif (LZO_CC_WATCOMC) && defined(__cplusplus) ++# define LZO_UNUSED(var) ((void) var) + # else +-# define LZO_WORDSIZE LZO_SIZEOF_VOID_P ++# define LZO_UNUSED(var) ((void) &var) + # endif #endif - --#if !defined(lzo_uintptr_t) --# if (__LZO_MMODEL_HUGE) --# define lzo_uintptr_t unsigned long --# else --# define lzo_uintptr_t acc_uintptr_t --# ifdef __ACC_INTPTR_T_IS_POINTER --# define __LZO_UINTPTR_T_IS_POINTER 1 +-#if !defined(LZO_SIZEOF_SIZE_T) +-#if (LZO_ARCH_I086 || LZO_ARCH_M16C) +-# define LZO_SIZEOF_SIZE_T 2 +-#else +-# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P +-#endif +-#endif +-#if !defined(LZO_SIZEOF_PTRDIFF_T) +-#if (LZO_ARCH_I086) +-# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P +-# elif (LZO_MM_COMPACT || LZO_MM_LARGE) +-# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) +-# define LZO_SIZEOF_PTRDIFF_T 4 +-# else +-# define LZO_SIZEOF_PTRDIFF_T 2 -# endif --# endif ++#if !defined(LZO_UNUSED_FUNC) ++# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) ++# define LZO_UNUSED_FUNC(func) ((void) func) ++# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) ++# define LZO_UNUSED_FUNC(func) if (func) ; else ++# elif (LZO_CC_CLANG || LZO_CC_LLVM) ++# define LZO_UNUSED_FUNC(func) ((void) &func) ++# elif (LZO_CC_MSC && (_MSC_VER < 900)) ++# define LZO_UNUSED_FUNC(func) if (func) ; else ++# elif (LZO_CC_MSC) ++# define LZO_UNUSED_FUNC(func) ((void) &func) ++# elif (LZO_CC_KEILC || LZO_CC_PELLESC) ++# define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];} + # else +-# error "LZO_MM" ++# define LZO_UNUSED_FUNC(func) ((void) func) + # endif +-#else +-# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T -#endif -- - #if (LZO_ARCH_I086) --#define PTR(a) ((lzo_bytep) (a)) --#define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0) --#define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0) -+#error "LZO_ARCH_I086 is unsupported" - #elif (LZO_MM_PVP) --#define PTR(a) ((lzo_bytep) (a)) --#define PTR_ALIGNED_8(a) ((((lzo_uintptr_t)(a)) >> 61) == 0) --#define PTR_ALIGNED2_8(a,b) ((((lzo_uintptr_t)(a)|(lzo_uintptr_t)(b)) >> 61) == 0) -+#error "LZO_MM_PVP is unsupported" - #else - #define PTR(a) ((lzo_uintptr_t) (a)) - #define PTR_LINEAR(a) PTR(a) -@@ -2243,24 +3815,28 @@ typedef union - unsigned long a_ulong; - lzo_int a_lzo_int; - lzo_uint a_lzo_uint; -- lzo_int32 a_lzo_int32; -- lzo_uint32 a_lzo_uint32; --#if defined(LZO_UINT64_MAX) -- lzo_int64 a_lzo_int64; -- lzo_uint64 a_lzo_uint64; -+ lzo_xint a_lzo_xint; -+ lzo_int16_t a_lzo_int16_t; -+ lzo_uint16_t a_lzo_uint16_t; -+ lzo_int32_t a_lzo_int32_t; -+ lzo_uint32_t a_lzo_uint32_t; -+#if defined(lzo_uint64_t) -+ lzo_int64_t a_lzo_int64_t; -+ lzo_uint64_t a_lzo_uint64_t; #endif -+ size_t a_size_t; - ptrdiff_t a_ptrdiff_t; - lzo_uintptr_t a_lzo_uintptr_t; -- lzo_voidp a_lzo_voidp; - void * a_void_p; -- lzo_bytep a_lzo_bytep; -- lzo_bytepp a_lzo_bytepp; -- lzo_uintp a_lzo_uintp; -- lzo_uint * a_lzo_uint_p; -- lzo_uint32p a_lzo_uint32p; -- lzo_uint32 * a_lzo_uint32_p; -- unsigned char * a_uchar_p; - char * a_char_p; -+ unsigned char * a_uchar_p; -+ const void * a_c_void_p; -+ const char * a_c_char_p; -+ const unsigned char * a_c_uchar_p; -+ lzo_voidp a_lzo_voidp; -+ lzo_bytep a_lzo_bytep; -+ const lzo_voidp a_c_lzo_voidp; -+ const lzo_bytep a_c_lzo_bytep; - } - lzo_full_align_t; - -@@ -2276,18 +3852,14 @@ lzo_full_align_t; - - #ifndef LZO_DICT_USE_PTR - #define LZO_DICT_USE_PTR 1 --#if 0 && (LZO_ARCH_I086) --# undef LZO_DICT_USE_PTR --# define LZO_DICT_USE_PTR 0 +-#if (LZO_ABI_NEUTRAL_ENDIAN) +-# undef LZO_ABI_BIG_ENDIAN +-# undef LZO_ABI_LITTLE_ENDIAN +-#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) +-#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) +-# if (__LITTLE_ENDIAN__ == 1) +-# define LZO_ABI_LITTLE_ENDIAN 1 ++#if !defined(LZO_UNUSED_LABEL) ++# if (LZO_CC_CLANG >= 0x020800ul) ++# define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l))) ++# elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) ++# define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l + # else +-# define LZO_ABI_BIG_ENDIAN 1 ++# define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l + # endif +-#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) +-# define LZO_ABI_BIG_ENDIAN 1 +-#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) +-# define LZO_ABI_LITTLE_ENDIAN 1 +-#endif +-#endif +-#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) +-# error "this should not happen" -#endif +-#if (LZO_ABI_BIG_ENDIAN) +-# define LZO_INFO_ABI_ENDIAN "be" +-#elif (LZO_ABI_LITTLE_ENDIAN) +-# define LZO_INFO_ABI_ENDIAN "le" +-#elif (LZO_ABI_NEUTRAL_ENDIAN) +-# define LZO_INFO_ABI_ENDIAN "neutral" +-#endif +-#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) +-# define LZO_ABI_I8LP16 1 +-# define LZO_INFO_ABI_PM "i8lp16" +-#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) +-# define LZO_ABI_ILP16 1 +-# define LZO_INFO_ABI_PM "ilp16" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) +-# define LZO_ABI_ILP32 1 +-# define LZO_INFO_ABI_PM "ilp32" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) +-# define LZO_ABI_LLP64 1 +-# define LZO_INFO_ABI_PM "llp64" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) +-# define LZO_ABI_LP64 1 +-# define LZO_INFO_ABI_PM "lp64" +-#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) +-# define LZO_ABI_ILP64 1 +-# define LZO_INFO_ABI_PM "ilp64" +-#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) +-# define LZO_ABI_IP32L64 1 +-# define LZO_INFO_ABI_PM "ip32l64" #endif - - #if (LZO_DICT_USE_PTR) - # define lzo_dict_t const lzo_bytep --# define lzo_dict_p lzo_dict_t __LZO_MMODEL * -+# define lzo_dict_p lzo_dict_t * - #else - # define lzo_dict_t lzo_uint --# define lzo_dict_p lzo_dict_t __LZO_MMODEL * -+# define lzo_dict_p lzo_dict_t * +-#if !defined(__LZO_LIBC_OVERRIDE) +-#if (LZO_LIBC_NAKED) +-# define LZO_INFO_LIBC "naked" +-#elif (LZO_LIBC_FREESTANDING) +-# define LZO_INFO_LIBC "freestanding" +-#elif (LZO_LIBC_MOSTLY_FREESTANDING) +-# define LZO_INFO_LIBC "mfreestanding" +-#elif (LZO_LIBC_ISOC90) +-# define LZO_INFO_LIBC "isoc90" +-#elif (LZO_LIBC_ISOC99) +-# define LZO_INFO_LIBC "isoc99" +-#elif defined(__dietlibc__) +-# define LZO_LIBC_DIETLIBC 1 +-# define LZO_INFO_LIBC "dietlibc" +-#elif defined(_NEWLIB_VERSION) +-# define LZO_LIBC_NEWLIB 1 +-# define LZO_INFO_LIBC "newlib" +-#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) +-# if defined(__UCLIBC_SUBLEVEL__) +-# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) ++#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) ++# if 0 ++# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var ++# elif 0 && (LZO_CC_GNUC) ++# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var + # else +-# define LZO_LIBC_UCLIBC 0x00090bL ++# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init + # endif +-# define LZO_INFO_LIBC "uclibc" +-#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) +-# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) +-# define LZO_INFO_LIBC "glibc" +-#elif (LZO_CC_MWERKS) && defined(__MSL__) +-# define LZO_LIBC_MSL __MSL__ +-# define LZO_INFO_LIBC "msl" +-#elif 1 && defined(__IAR_SYSTEMS_ICC__) +-# define LZO_LIBC_ISOC90 1 +-# define LZO_INFO_LIBC "isoc90" +-#else +-# define LZO_LIBC_DEFAULT 1 +-# define LZO_INFO_LIBC "default" +-#endif +-#endif +-#if !defined(__lzo_gnuc_extension__) +-#if (LZO_CC_GNUC >= 0x020800ul) +-# define __lzo_gnuc_extension__ __extension__ +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_gnuc_extension__ __extension__ +-#else +-# define __lzo_gnuc_extension__ /*empty*/ +-#endif +-#endif +-#if !defined(__lzo_ua_volatile) +-# define __lzo_ua_volatile volatile +-#endif +-#if !defined(__lzo_alignof) +-#if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) +-# define __lzo_alignof(e) __alignof__(e) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) +-# define __lzo_alignof(e) __alignof__(e) +-#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) +-# define __lzo_alignof(e) __alignof(e) +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) +-# define __lzo_alignof(e) __alignof__(e) +-#endif +-#endif +-#if defined(__lzo_alignof) +-# define __lzo_HAVE_alignof 1 +-#endif +-#if !defined(__lzo_constructor) +-#if (LZO_CC_GNUC >= 0x030400ul) +-# define __lzo_constructor __attribute__((__constructor__,__used__)) +-#elif (LZO_CC_GNUC >= 0x020700ul) +-# define __lzo_constructor __attribute__((__constructor__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_constructor __attribute__((__constructor__)) +-#endif +-#endif +-#if defined(__lzo_constructor) +-# define __lzo_HAVE_constructor 1 +-#endif +-#if !defined(__lzo_destructor) +-#if (LZO_CC_GNUC >= 0x030400ul) +-# define __lzo_destructor __attribute__((__destructor__,__used__)) +-#elif (LZO_CC_GNUC >= 0x020700ul) +-# define __lzo_destructor __attribute__((__destructor__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_destructor __attribute__((__destructor__)) +-#endif +-#endif +-#if defined(__lzo_destructor) +-# define __lzo_HAVE_destructor 1 +-#endif +-#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) +-# error "this should not happen" #endif - + #if !defined(__lzo_inline) + #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) + #elif defined(__cplusplus) + # define __lzo_inline inline ++#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) ++# define __lzo_inline inline + #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) + # define __lzo_inline __inline +-#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) + # define __lzo_inline __inline__ + #elif (LZO_CC_DMC) + # define __lzo_inline __inline ++#elif (LZO_CC_GHS) ++# define __lzo_inline __inline__ ++#elif (LZO_CC_IBMC >= 600) ++# define __lzo_inline __inline__ + #elif (LZO_CC_INTELC) + # define __lzo_inline __inline + #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) + # define __lzo_inline __inline + #elif (LZO_CC_MSC && (_MSC_VER >= 900)) + # define __lzo_inline __inline +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) ++#elif (LZO_CC_SUNPROC >= 0x5100) + # define __lzo_inline __inline__ +-#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +-# define __lzo_inline inline #endif -@@ -2300,10 +3872,9 @@ __lzo_ptr_linear(const lzo_voidp ptr) - lzo_uintptr_t p; - - #if (LZO_ARCH_I086) -- p = (((lzo_uintptr_t)(ACC_PTR_FP_SEG(ptr))) << (16 - ACC_MM_AHSHIFT)) + (ACC_PTR_FP_OFF(ptr)); -+#error "LZO_ARCH_I086 is unsupported" - #elif (LZO_MM_PVP) -- p = (lzo_uintptr_t) (ptr); -- p = (p << 3) | (p >> 61); -+#error "LZO_MM_PVP is unsupported" - #else - p = (lzo_uintptr_t) PTR_LINEAR(ptr); #endif -@@ -2314,9 +3885,8 @@ __lzo_ptr_linear(const lzo_voidp ptr) - LZO_PUBLIC(unsigned) - __lzo_align_gap(const lzo_voidp ptr, lzo_uint size) - { --#if defined(__LZO_UINTPTR_T_IS_POINTER) -- size_t n = (size_t) ptr; -- n = (((n + size - 1) / size) * size) - n; -+#if (__LZO_UINTPTR_T_IS_POINTER) -+#error "__LZO_UINTPTR_T_IS_POINTER is unsupported" + #if defined(__lzo_inline) ++# ifndef __lzo_HAVE_inline + # define __lzo_HAVE_inline 1 ++# endif #else - lzo_uintptr_t p, n; - p = __lzo_ptr_linear(ptr); -@@ -2342,7 +3912,7 @@ static const char __lzo_copyright[] = + # define __lzo_inline /*empty*/ + #endif + #if !defined(__lzo_forceinline) + #if (LZO_CC_GNUC >= 0x030200ul) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) + # define __lzo_forceinline __forceinline +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) + #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) + # define __lzo_forceinline __forceinline +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) ++#elif (LZO_CC_PGI >= 0x0d0a00ul) ++# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) ++#elif (LZO_CC_SUNPROC >= 0x5100) + # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) + #endif + #endif + #if defined(__lzo_forceinline) ++# ifndef __lzo_HAVE_forceinline + # define __lzo_HAVE_forceinline 1 ++# endif #else - "\r\n\n" - "LZO data compression library.\n" -- "$Copyright: LZO Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\n" -+ "$Copyright: LZO Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\n" - "\n" - "http://www.oberhumer.com $\n\n" - "$Id: LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE " $\n" -@@ -2352,11 +3922,7 @@ static const char __lzo_copyright[] = - LZO_PUBLIC(const lzo_bytep) - lzo_copyright(void) - { --#if (LZO_OS_DOS16 && LZO_CC_TURBOC) -- return (lzo_voidp) __lzo_copyright; --#else - return (const lzo_bytep) __lzo_copyright; --#endif - } - - LZO_PUBLIC(unsigned) -@@ -2393,16 +3959,16 @@ _lzo_version_date(void) - #define LZO_NMAX 5552 - - #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1 --#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1); --#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2); --#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4); --#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8); -+#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1) -+#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2) -+#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4) -+#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8) - --LZO_PUBLIC(lzo_uint32) --lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len) -+LZO_PUBLIC(lzo_uint32_t) -+lzo_adler32(lzo_uint32_t adler, const lzo_bytep buf, lzo_uint len) - { -- lzo_uint32 s1 = adler & 0xffff; -- lzo_uint32 s2 = (adler >> 16) & 0xffff; -+ lzo_uint32_t s1 = adler & 0xffff; -+ lzo_uint32_t s2 = (adler >> 16) & 0xffff; - unsigned k; - - if (buf == NULL) -@@ -2459,8 +4025,8 @@ lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len) - LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo_hsize_t len) - { - #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP) -- const lzo_hbyte_p p1 = (const lzo_hbyte_p) s1; -- const lzo_hbyte_p p2 = (const lzo_hbyte_p) s2; -+ const lzo_hbyte_p p1 = LZO_STATIC_CAST(const lzo_hbyte_p, s1); -+ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, s2); - if __lzo_likely(len > 0) do - { - int d = *p1 - *p2; -@@ -2476,8 +4042,8 @@ LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo - LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) - { - #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY) -- lzo_hbyte_p p1 = (lzo_hbyte_p) dest; -- const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; -+ lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest); -+ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src); - if (!(len > 0) || p1 == p2) - return dest; - do -@@ -2491,8 +4057,8 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src - LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) - { - #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE) -- lzo_hbyte_p p1 = (lzo_hbyte_p) dest; -- const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; -+ lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest); -+ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src); - if (!(len > 0) || p1 == p2) - return dest; - if (p1 < p2) -@@ -2514,16 +4080,17 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p sr - return memmove(dest, src, len); +-# define __lzo_forceinline /*empty*/ ++# define __lzo_forceinline __lzo_inline #endif - } --LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len) -+LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int cc, lzo_hsize_t len) - { - #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET) -- lzo_hbyte_p p = (lzo_hbyte_p) s; -+ lzo_hbyte_p p = LZO_STATIC_CAST(lzo_hbyte_p, s); -+ unsigned char c = LZO_ITRUNC(unsigned char, cc); - if __lzo_likely(len > 0) do -- *p++ = (unsigned char) c; -+ *p++ = c; - while __lzo_likely(--len > 0); - return s; + #if !defined(__lzo_noinline) + #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) + # define __lzo_noinline __attribute__((__noinline__,__used__)) + #elif (LZO_CC_GNUC >= 0x030200ul) + # define __lzo_noinline __attribute__((__noinline__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_noinline __attribute__((__noinline__)) ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) + # define __lzo_noinline __declspec(noinline) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) + # define __lzo_noinline __attribute__((__noinline__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) + # define __lzo_noinline __attribute__((__noinline__)) + #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) + # define __lzo_noinline __declspec(noinline) +@@ -1494,179 +1499,409 @@ extern "C" { + # else + # define __lzo_noinline __declspec(noinline) + # endif +-#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) ++#elif (LZO_CC_PGI >= 0x0d0a00ul) ++# define __lzo_noinline __attribute__((__noinline__)) ++#elif (LZO_CC_SUNPROC >= 0x5100) + # define __lzo_noinline __attribute__((__noinline__)) + #endif + #endif + #if defined(__lzo_noinline) ++# ifndef __lzo_HAVE_noinline + # define __lzo_HAVE_noinline 1 ++# endif #else -- return memset(s, c, len); -+ return memset(s, cc, len); + # define __lzo_noinline /*empty*/ #endif - } - #undef LZOLIB_PUBLIC -@@ -2532,105 +4099,28 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len) - - #if !defined(__LZO_IN_MINILZO) - --#define ACC_WANT_ACC_CHK_CH 1 --#undef ACCCHK_ASSERT -+#define LZO_WANT_ACC_CHK_CH 1 -+#undef LZOCHK_ASSERT - -- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int) -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) -- -- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int32) -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32) -- ACCCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) -- ACCCHK_ASSERT(sizeof(lzo_uint32) >= 4) --#if defined(LZO_UINT64_MAX) -- ACCCHK_ASSERT(sizeof(lzo_uint64) == 8) -- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int64) -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint64) -+ LZOCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) -+ LZOCHK_ASSERT_IS_SIGNED_T(lzo_int) -+ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) -+#if !(__LZO_UINTPTR_T_IS_POINTER) -+ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) - #endif -+ LZOCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) -+ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) - --#if !defined(__LZO_UINTPTR_T_IS_POINTER) -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) - #endif -- ACCCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) -- -- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) -- ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint32)) -- ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint)) -- ACCCHK_ASSERT(sizeof(lzo_xint) == sizeof(lzo_uint32) || sizeof(lzo_xint) == sizeof(lzo_uint)) -+#undef LZOCHK_ASSERT - -+union lzo_config_check_union { -+ lzo_uint a[2]; -+ unsigned char b[2*LZO_MAX(8,sizeof(lzo_uint))]; -+#if defined(lzo_uint64_t) -+ lzo_uint64_t c[2]; + #if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) +-# error "this should not happen" ++# error "unexpected configuration - check your compiler defines" #endif --#undef ACCCHK_ASSERT -- --#if 0 --#define WANT_lzo_bitops_clz32 1 --#define WANT_lzo_bitops_clz64 1 --#endif --#define WANT_lzo_bitops_ctz32 1 --#define WANT_lzo_bitops_ctz64 1 -- --#if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) --#include --#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0 --#pragma intrinsic(_BitScanReverse) --static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v) --{ -- unsigned long r; -- (void) _BitScanReverse(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_clz32 lzo_bitops_clz32 --#endif --#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0 --#pragma intrinsic(_BitScanReverse64) --static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v) --{ -- unsigned long r; -- (void) _BitScanReverse64(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_clz64 lzo_bitops_clz64 --#endif --#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) --#pragma intrinsic(_BitScanForward) --static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v) --{ -- unsigned long r; -- (void) _BitScanForward(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_ctz32 lzo_bitops_ctz32 --#endif --#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) --#pragma intrinsic(_BitScanForward64) --static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v) --{ -- unsigned long r; -- (void) _BitScanForward64(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_ctz64 lzo_bitops_ctz64 --#endif -- --#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM) --#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) --#define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v)) --#endif --#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v)) --#endif --#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) --#define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v)) --#endif --#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v)) --#endif --#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32) --#define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v)) --#endif --#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v)) --#endif --#endif -+}; - - #if 0 - #define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off))) -@@ -2644,73 +4134,101 @@ static __lzo_noinline lzo_voidp u2p(lzo_voidp ptr, lzo_uint off) - LZO_PUBLIC(int) - _lzo_config_check(void) - { -- lzo_bool r = 1; -- union { -- lzo_xint a[2]; unsigned char b[2*LZO_MAX(8,sizeof(lzo_xint))]; --#if defined(LZO_UNALIGNED_OK_8) -- lzo_uint64 c[2]; -+#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030100ul && LZO_CC_CLANG < 0x030300ul)) -+# if 0 -+ volatile -+# endif +-#if !defined(__lzo_noreturn) +-#if (LZO_CC_GNUC >= 0x020700ul) +-# define __lzo_noreturn __attribute__((__noreturn__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) +-# define __lzo_noreturn __declspec(noreturn) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) +-# define __lzo_noreturn __attribute__((__noreturn__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define __lzo_noreturn __attribute__((__noreturn__)) +-#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) +-# define __lzo_noreturn __declspec(noreturn) ++#if !defined(__lzo_static_inline) ++#if (LZO_CC_IBMC) ++# define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline #endif -- unsigned short x[2]; lzo_uint32 y[2]; lzo_uint z[2]; -- } u; -+ union lzo_config_check_union u; - lzo_voidp p; -+ unsigned r = 1; - - u.a[0] = u.a[1] = 0; - p = u2p(&u, 0); - r &= ((* (lzo_bytep) p) == 0); --#if !defined(LZO_CFG_NO_CONFIG_CHECK) --#if defined(LZO_ABI_BIG_ENDIAN) -+#if !(LZO_CFG_NO_CONFIG_CHECK) -+#if (LZO_ABI_BIG_ENDIAN) - u.a[0] = u.a[1] = 0; u.b[sizeof(lzo_uint) - 1] = 128; - p = u2p(&u, 0); - r &= ((* (lzo_uintp) p) == 128); #endif --#if defined(LZO_ABI_LITTLE_ENDIAN) -+#if (LZO_ABI_LITTLE_ENDIAN) - u.a[0] = u.a[1] = 0; u.b[0] = 128; - p = u2p(&u, 0); - r &= ((* (lzo_uintp) p) == 128); +-#if defined(__lzo_noreturn) +-# define __lzo_HAVE_noreturn 1 +-#else +-# define __lzo_noreturn /*empty*/ ++#if !defined(__lzo_static_inline) ++# define __lzo_static_inline static __lzo_inline #endif --#if defined(LZO_UNALIGNED_OK_2) - u.a[0] = u.a[1] = 0; -- u.b[0] = 1; u.b[sizeof(unsigned short) + 1] = 2; -+ u.b[0] = 1; u.b[3] = 2; - p = u2p(&u, 1); -- r &= ((* (lzo_ushortp) p) == 0); -+ r &= UA_GET_NE16(p) == 0; -+ r &= UA_GET_LE16(p) == 0; -+ u.b[1] = 128; -+ r &= UA_GET_LE16(p) == 128; -+ u.b[2] = 129; -+ r &= UA_GET_LE16(p) == LZO_UINT16_C(0x8180); -+#if (LZO_ABI_BIG_ENDIAN) -+ r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8081); +-#if !defined(__lzo_nothrow) +-#if (LZO_CC_GNUC >= 0x030300ul) +-# define __lzo_nothrow __attribute__((__nothrow__)) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) +-# define __lzo_nothrow __declspec(nothrow) +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC) +-# define __lzo_nothrow __attribute__((__nothrow__)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++#if !defined(__lzo_static_forceinline) ++#if (LZO_CC_IBMC) ++# define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline +#endif -+#if (LZO_ABI_LITTLE_ENDIAN) -+ r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8180); - #endif --#if defined(LZO_UNALIGNED_OK_4) - u.a[0] = u.a[1] = 0; -- u.b[0] = 3; u.b[sizeof(lzo_uint32) + 1] = 4; -+ u.b[0] = 3; u.b[5] = 4; - p = u2p(&u, 1); -- r &= ((* (lzo_uint32p) p) == 0); -+ r &= UA_GET_NE32(p) == 0; -+ r &= UA_GET_LE32(p) == 0; -+ u.b[1] = 128; -+ r &= UA_GET_LE32(p) == 128; -+ u.b[2] = 129; u.b[3] = 130; u.b[4] = 131; -+ r &= UA_GET_LE32(p) == LZO_UINT32_C(0x83828180); -+#if (LZO_ABI_BIG_ENDIAN) -+ r &= UA_GET_NE32(p) == LZO_UINT32_C(0x80818283); +#endif -+#if (LZO_ABI_LITTLE_ENDIAN) -+ r &= UA_GET_NE32(p) == LZO_UINT32_C(0x83828180); - #endif --#if defined(LZO_UNALIGNED_OK_8) -+#if defined(UA_GET_NE64) - u.c[0] = u.c[1] = 0; -- u.b[0] = 5; u.b[sizeof(lzo_uint64) + 1] = 6; -+ u.b[0] = 5; u.b[9] = 6; - p = u2p(&u, 1); -- r &= ((* (lzo_uint64p) p) == 0); -+ u.c[0] = u.c[1] = 0; -+ r &= UA_GET_NE64(p) == 0; -+#if defined(UA_GET_LE64) -+ r &= UA_GET_LE64(p) == 0; -+ u.b[1] = 128; -+ r &= UA_GET_LE64(p) == 128; ++#if !defined(__lzo_static_forceinline) ++# define __lzo_static_forceinline static __lzo_forceinline +#endif - #endif --#if defined(lzo_bitops_clz32) -- { unsigned i; lzo_uint32 v = 1; -- for (i = 0; i < 31; i++, v <<= 1) -- r &= lzo_bitops_clz32(v) == 31 - i; -- } -+#if defined(lzo_bitops_ctlz32) -+ { unsigned i = 0; lzo_uint32_t v; -+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { -+ r &= lzo_bitops_ctlz32(v) == 31 - i; -+ r &= lzo_bitops_ctlz32_func(v) == 31 - i; -+ }} - #endif --#if defined(lzo_bitops_clz64) -- { unsigned i; lzo_uint64 v = 1; -- for (i = 0; i < 63; i++, v <<= 1) -- r &= lzo_bitops_clz64(v) == 63 - i; -- } -+#if defined(lzo_bitops_ctlz64) -+ { unsigned i = 0; lzo_uint64_t v; -+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { -+ r &= lzo_bitops_ctlz64(v) == 63 - i; -+ r &= lzo_bitops_ctlz64_func(v) == 63 - i; -+ }} - #endif --#if defined(lzo_bitops_ctz32) -- { unsigned i; lzo_uint32 v = 1; -- for (i = 0; i < 31; i++, v <<= 1) -- r &= lzo_bitops_ctz32(v) == i; -- } -+#if defined(lzo_bitops_cttz32) -+ { unsigned i = 0; lzo_uint32_t v; -+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { -+ r &= lzo_bitops_cttz32(v) == i; -+ r &= lzo_bitops_cttz32_func(v) == i; -+ }} - #endif --#if defined(lzo_bitops_ctz64) -- { unsigned i; lzo_uint64 v = 1; -- for (i = 0; i < 63; i++, v <<= 1) -- r &= lzo_bitops_ctz64(v) == i; -- } -+#if defined(lzo_bitops_cttz64) -+ { unsigned i = 0; lzo_uint64_t v; -+ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { -+ r &= lzo_bitops_cttz64(v) == i; -+ r &= lzo_bitops_cttz64_func(v) == i; -+ }} ++#if !defined(__lzo_static_noinline) ++#if (LZO_CC_IBMC) ++# define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline ++#endif ++#endif ++#if !defined(__lzo_static_noinline) ++# define __lzo_static_noinline static __lzo_noinline ++#endif ++#if !defined(__lzo_c99_extern_inline) ++#if defined(__GNUC_GNU_INLINE__) ++# define __lzo_c99_extern_inline __lzo_inline ++#elif defined(__GNUC_STDC_INLINE__) ++# define __lzo_c99_extern_inline extern __lzo_inline ++#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) ++# define __lzo_c99_extern_inline extern __lzo_inline ++#endif ++#if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline) ++# define __lzo_c99_extern_inline __lzo_inline ++#endif ++#endif ++#if defined(__lzo_c99_extern_inline) ++# ifndef __lzo_HAVE_c99_extern_inline ++# define __lzo_HAVE_c99_extern_inline 1 ++# endif ++#else ++# define __lzo_c99_extern_inline /*empty*/ ++#endif ++#if !defined(__lzo_may_alias) ++#if (LZO_CC_GNUC >= 0x030400ul) ++# define __lzo_may_alias __attribute__((__may_alias__)) ++#elif (LZO_CC_CLANG >= 0x020900ul) ++# define __lzo_may_alias __attribute__((__may_alias__)) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0 ++# define __lzo_may_alias __attribute__((__may_alias__)) ++#elif (LZO_CC_PGI >= 0x0d0a00ul) && 0 ++# define __lzo_may_alias __attribute__((__may_alias__)) ++#endif ++#endif ++#if defined(__lzo_may_alias) ++# ifndef __lzo_HAVE_may_alias ++# define __lzo_HAVE_may_alias 1 ++# endif ++#else ++# define __lzo_may_alias /*empty*/ ++#endif ++#if !defined(__lzo_noreturn) ++#if (LZO_CC_GNUC >= 0x020700ul) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) ++# define __lzo_noreturn __declspec(noreturn) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) ++# define __lzo_noreturn __declspec(noreturn) ++#elif (LZO_CC_PGI >= 0x0d0a00ul) ++# define __lzo_noreturn __attribute__((__noreturn__)) ++#endif ++#endif ++#if defined(__lzo_noreturn) ++# ifndef __lzo_HAVE_noreturn ++# define __lzo_HAVE_noreturn 1 ++# endif ++#else ++# define __lzo_noreturn /*empty*/ ++#endif ++#if !defined(__lzo_nothrow) ++#if (LZO_CC_GNUC >= 0x030300ul) ++# define __lzo_nothrow __attribute__((__nothrow__)) ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus) ++# define __lzo_nothrow __declspec(nothrow) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900)) ++# define __lzo_nothrow __attribute__((__nothrow__)) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) + # define __lzo_nothrow __attribute__((__nothrow__)) + #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) + # define __lzo_nothrow __declspec(nothrow) #endif #endif -+ LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); - - return r == 1 ? LZO_E_OK : LZO_E_ERROR; - } -@@ -2724,11 +4242,11 @@ __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, - #if defined(__LZO_IN_MINILZO) - #elif (LZO_CC_MSC && ((_MSC_VER) < 700)) + #if defined(__lzo_nothrow) ++# ifndef __lzo_HAVE_nothrow + # define __lzo_HAVE_nothrow 1 ++# endif #else --#define ACC_WANT_ACC_CHK_CH 1 --#undef ACCCHK_ASSERT --#define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) -+#define LZO_WANT_ACC_CHK_CH 1 -+#undef LZOCHK_ASSERT -+#define LZOCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) - #endif --#undef ACCCHK_ASSERT -+#undef LZOCHK_ASSERT - - if (v == 0) - return LZO_E_ERROR; -@@ -2736,7 +4254,7 @@ __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, - r = (s1 == -1 || s1 == (int) sizeof(short)) && - (s2 == -1 || s2 == (int) sizeof(int)) && - (s3 == -1 || s3 == (int) sizeof(long)) && -- (s4 == -1 || s4 == (int) sizeof(lzo_uint32)) && -+ (s4 == -1 || s4 == (int) sizeof(lzo_uint32_t)) && - (s5 == -1 || s5 == (int) sizeof(lzo_uint)) && - (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) && - (s7 == -1 || s7 == (int) sizeof(char *)) && -@@ -2779,11 +4297,11 @@ int __far __pascal LibMain ( int a, short b, short c, long d ) - - #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS) - --#if 1 && defined(UA_GET32) -+#if 1 && defined(UA_GET_LE32) - #undef LZO_DICT_USE_PTR - #define LZO_DICT_USE_PTR 0 - #undef lzo_dict_t --#define lzo_dict_t unsigned short -+#define lzo_dict_t lzo_uint16_t + # define __lzo_nothrow /*empty*/ #endif - - #define LZO_NEED_DICT_H 1 -@@ -3088,77 +4606,7 @@ DVAL_ASSERT(lzo_xint dv, const lzo_bytep p) + #if !defined(__lzo_restrict) + #if (LZO_CC_GNUC >= 0x030400ul) + # define __lzo_restrict __restrict__ +-#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) ++#elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus) + # define __lzo_restrict __restrict__ +-#elif (LZO_CC_CLANG || LZO_CC_LLVM) ++#elif (LZO_CC_IBMC >= 1210) ++# define __lzo_restrict __restrict__ ++#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) ++# define __lzo_restrict __restrict__ ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM) + # define __lzo_restrict __restrict__ + #elif (LZO_CC_MSC && (_MSC_VER >= 1400)) + # define __lzo_restrict __restrict ++#elif (LZO_CC_PGI >= 0x0d0a00ul) ++# define __lzo_restrict __restrict__ #endif - - #if 1 && defined(DO_COMPRESS) && !defined(do_compress) --# define do_compress LZO_CPP_ECONCAT2(DO_COMPRESS,_core) --#endif -- --#if defined(UA_GET64) --# define WANT_lzo_bitops_ctz64 1 --#elif defined(UA_GET32) --# define WANT_lzo_bitops_ctz32 1 --#endif -- --#if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) --#include --#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0 --#pragma intrinsic(_BitScanReverse) --static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v) --{ -- unsigned long r; -- (void) _BitScanReverse(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_clz32 lzo_bitops_clz32 --#endif --#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0 --#pragma intrinsic(_BitScanReverse64) --static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v) --{ -- unsigned long r; -- (void) _BitScanReverse64(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_clz64 lzo_bitops_clz64 --#endif --#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) --#pragma intrinsic(_BitScanForward) --static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v) --{ -- unsigned long r; -- (void) _BitScanForward(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_ctz32 lzo_bitops_ctz32 --#endif --#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) --#pragma intrinsic(_BitScanForward64) --static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v) --{ -- unsigned long r; -- (void) _BitScanForward64(&r, v); -- return (unsigned) r; --} --#define lzo_bitops_ctz64 lzo_bitops_ctz64 --#endif -- --#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM) --#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) --#define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v)) --#endif --#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v)) --#endif --#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) --#define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v)) --#endif --#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v)) --#endif --#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32) --#define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v)) --#endif --#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX) --#define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v)) --#endif -+# define do_compress LZO_PP_ECONCAT2(DO_COMPRESS,_core) #endif - - static __lzo_noinline lzo_uint -@@ -3166,7 +4614,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len, - lzo_bytep out, lzo_uintp out_len, - lzo_uint ti, lzo_voidp wrkmem) - { -- register const lzo_bytep ip; -+ const lzo_bytep ip; - lzo_bytep op; - const lzo_bytep const in_end = in + in_len; - const lzo_bytep const ip_end = in + in_len - 20; -@@ -3175,7 +4623,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len, - - op = out; - ip = in; -- ii = ip - ti; -+ ii = ip; - - ip += ti < 4 ? 4 - ti : 0; - for (;;) -@@ -3205,8 +4653,8 @@ next: - goto literal; - - try_match: --#if defined(UA_GET32) -- if (UA_GET32(m_pos) != UA_GET32(ip)) -+#if (LZO_OPT_UNALIGNED32) -+ if (UA_GET_NE32(m_pos) != UA_GET_NE32(ip)) + #if defined(__lzo_restrict) ++# ifndef __lzo_HAVE_restrict + # define __lzo_HAVE_restrict 1 ++# endif #else - if (m_pos[0] != ip[0] || m_pos[1] != ip[1] || m_pos[2] != ip[2] || m_pos[3] != ip[3]) + # define __lzo_restrict /*empty*/ #endif -@@ -3221,49 +4669,43 @@ literal: - lzo_uint m_off; - lzo_uint m_len; - { -- lzo_uint32 dv; -+ lzo_uint32_t dv; - lzo_uint dindex; - literal: - ip += 1 + ((ip - ii) >> 5); - next: - if __lzo_unlikely(ip >= ip_end) - break; -- dv = UA_GET32(ip); -+ dv = UA_GET_LE32(ip); - dindex = DINDEX(dv,ip); - GINDEX(m_off,m_pos,in+dict,dindex,in); - UPDATE_I(dict,0,dindex,ip,in); -- if __lzo_unlikely(dv != UA_GET32(m_pos)) -+ if __lzo_unlikely(dv != UA_GET_LE32(m_pos)) - goto literal; - } ++#if !defined(__lzo_alignof) ++#if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) ++# define __lzo_alignof(e) __alignof__(e) ++#elif (LZO_CC_GHS) && !defined(__cplusplus) ++# define __lzo_alignof(e) __alignof__(e) ++#elif (LZO_CC_IBMC >= 600) ++# define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e)) ++#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) ++# define __lzo_alignof(e) __alignof__(e) ++#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) ++# define __lzo_alignof(e) __alignof(e) ++#elif (LZO_CC_SUNPROC >= 0x5100) ++# define __lzo_alignof(e) __alignof__(e) ++#endif ++#endif ++#if defined(__lzo_alignof) ++# ifndef __lzo_HAVE_alignof ++# define __lzo_HAVE_alignof 1 ++# endif ++#endif ++#if !defined(__lzo_struct_packed) ++#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) ++#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) ++#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) ++#elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) ++# define __lzo_struct_packed(s) struct s { ++# define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__)); ++# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__)); ++#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) ++# define __lzo_struct_packed(s) struct s { ++# define __lzo_struct_packed_end() } __attribute__((__packed__)); ++# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s { ++# define __lzo_struct_packed_end() } __attribute__((__packed__)); ++# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); ++#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) ++# define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s { ++# define __lzo_struct_packed_end() } __pragma(pack(pop)); ++#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) ++# define __lzo_struct_packed(s) _Packed struct s { ++# define __lzo_struct_packed_end() }; ++#endif ++#endif ++#if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma) ++# define __lzo_struct_packed_ma(s) __lzo_struct_packed(s) ++#endif ++#if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end) ++# define __lzo_struct_packed_ma_end() __lzo_struct_packed_end() ++#endif ++#if !defined(__lzo_byte_struct) ++#if defined(__lzo_struct_packed) ++# define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end() ++# define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end() ++#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100)) ++# define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__)); ++# define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__)); ++#endif ++#endif ++#if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma) ++# define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n) ++#endif ++#if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof) ++#if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul)) ++#elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_CILLY || LZO_CC_PCC) ++#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) ++# define __lzo_struct_align16(s) struct __declspec(align(16)) s { ++# define __lzo_struct_align16_end() }; ++# define __lzo_struct_align32(s) struct __declspec(align(32)) s { ++# define __lzo_struct_align32_end() }; ++# define __lzo_struct_align64(s) struct __declspec(align(64)) s { ++# define __lzo_struct_align64_end() }; ++#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_struct_align16(s) struct s { ++# define __lzo_struct_align16_end() } __attribute__((__aligned__(16))); ++# define __lzo_struct_align32(s) struct s { ++# define __lzo_struct_align32_end() } __attribute__((__aligned__(32))); ++# define __lzo_struct_align64(s) struct s { ++# define __lzo_struct_align64_end() } __attribute__((__aligned__(64))); ++#endif ++#endif ++#if !defined(__lzo_union_um) ++#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) ++#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810)) ++#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) ++#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) ++#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) ++# define __lzo_union_am(s) union s { ++# define __lzo_union_am_end() } __lzo_may_alias; ++# define __lzo_union_um(s) union s { ++# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); ++#elif (LZO_CC_IBMC >= 700) ++# define __lzo_union_am(s) __lzo_gnuc_extension__ union s { ++# define __lzo_union_am_end() } __lzo_may_alias; ++# define __lzo_union_um(s) __lzo_gnuc_extension__ union s { ++# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); ++#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) ++# define __lzo_union_um(s) __pragma(pack(push,1)) union s { ++# define __lzo_union_um_end() } __pragma(pack(pop)); ++#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) ++# define __lzo_union_um(s) _Packed union s { ++# define __lzo_union_um_end() }; ++#endif ++#endif ++#if !defined(__lzo_union_am) ++# define __lzo_union_am(s) union s { ++# define __lzo_union_am_end() }; ++#endif ++#if !defined(__lzo_constructor) ++#if (LZO_CC_GNUC >= 0x030400ul) ++# define __lzo_constructor __attribute__((__constructor__,__used__)) ++#elif (LZO_CC_GNUC >= 0x020700ul) ++# define __lzo_constructor __attribute__((__constructor__)) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) ++# define __lzo_constructor __attribute__((__constructor__,__used__)) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_constructor __attribute__((__constructor__)) ++#endif ++#endif ++#if defined(__lzo_constructor) ++# ifndef __lzo_HAVE_constructor ++# define __lzo_HAVE_constructor 1 ++# endif ++#endif ++#if !defined(__lzo_destructor) ++#if (LZO_CC_GNUC >= 0x030400ul) ++# define __lzo_destructor __attribute__((__destructor__,__used__)) ++#elif (LZO_CC_GNUC >= 0x020700ul) ++# define __lzo_destructor __attribute__((__destructor__)) ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) ++# define __lzo_destructor __attribute__((__destructor__,__used__)) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define __lzo_destructor __attribute__((__destructor__)) ++#endif ++#endif ++#if defined(__lzo_destructor) ++# ifndef __lzo_HAVE_destructor ++# define __lzo_HAVE_destructor 1 ++# endif ++#endif ++#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) ++# error "unexpected configuration - check your compiler defines" ++#endif + #if !defined(__lzo_likely) && !defined(__lzo_unlikely) + #if (LZO_CC_GNUC >= 0x030200ul) + # define __lzo_likely(e) (__builtin_expect(!!(e),1)) + # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) ++#elif (LZO_CC_IBMC >= 1010) ++# define __lzo_likely(e) (__builtin_expect(!!(e),1)) ++# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) + #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) + # define __lzo_likely(e) (__builtin_expect(!!(e),1)) + # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +-#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) + # define __lzo_likely(e) (__builtin_expect(!!(e),1)) + # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #endif - -+ ii -= ti; ti = 0; - { -- register lzo_uint t = pd(ip,ii); -+ lzo_uint t = pd(ip,ii); - if (t != 0) - { - if (t <= 3) - { -- op[-2] |= LZO_BYTE(t); --#if defined(UA_COPY32) -- UA_COPY32(op, ii); -+ op[-2] = LZO_BYTE(op[-2] | t); -+#if (LZO_OPT_UNALIGNED32) -+ UA_COPY4(op, ii); - op += t; - #else - { do *op++ = *ii++; while (--t > 0); } #endif - } --#if defined(UA_COPY32) || defined(UA_COPY64) -+#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) - else if (t <= 16) - { - *op++ = LZO_BYTE(t - 3); --#if defined(UA_COPY64) -- UA_COPY64(op, ii); -- UA_COPY64(op+8, ii+8); --#else -- UA_COPY32(op, ii); -- UA_COPY32(op+4, ii+4); -- UA_COPY32(op+8, ii+8); -- UA_COPY32(op+12, ii+12); --#endif -+ UA_COPY8(op, ii); -+ UA_COPY8(op+8, ii+8); - op += t; - } + #if defined(__lzo_likely) ++# ifndef __lzo_HAVE_likely + # define __lzo_HAVE_likely 1 ++# endif + #else + # define __lzo_likely(e) (e) #endif -@@ -3273,31 +4715,21 @@ next: - *op++ = LZO_BYTE(t - 3); - else - { -- register lzo_uint tt = t - 18; -+ lzo_uint tt = t - 18; - *op++ = 0; - while __lzo_unlikely(tt > 255) - { - tt -= 255; --#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) -- * (volatile unsigned char *) op++ = 0; --#else -- *op++ = 0; --#endif -+ UA_SET1(op, 0); -+ op++; - } - assert(tt > 0); - *op++ = LZO_BYTE(tt); - } --#if defined(UA_COPY32) || defined(UA_COPY64) -+#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) - do { --#if defined(UA_COPY64) -- UA_COPY64(op, ii); -- UA_COPY64(op+8, ii+8); --#else -- UA_COPY32(op, ii); -- UA_COPY32(op+4, ii+4); -- UA_COPY32(op+8, ii+8); -- UA_COPY32(op+12, ii+12); --#endif -+ UA_COPY8(op, ii); -+ UA_COPY8(op+8, ii+8); - op += 16; ii += 16; t -= 16; - } while (t >= 16); if (t > 0) + #if defined(__lzo_unlikely) ++# ifndef __lzo_HAVE_unlikely + # define __lzo_HAVE_unlikely 1 ++# endif + #else + # define __lzo_unlikely(e) (e) #endif -@@ -3307,19 +4739,26 @@ next: - } - m_len = 4; - { --#if defined(UA_GET64) -- lzo_uint64 v; -- v = UA_GET64(ip + m_len) ^ UA_GET64(m_pos + m_len); -+#if (LZO_OPT_UNALIGNED64) -+ lzo_uint64_t v; -+ v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); - if __lzo_unlikely(v == 0) { - do { - m_len += 8; -- v = UA_GET64(ip + m_len) ^ UA_GET64(m_pos + m_len); -+ v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); - if __lzo_unlikely(ip + m_len >= ip_end) - goto m_len_done; - } while (v == 0); - } --#if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz64) -- m_len += lzo_bitops_ctz64(v) / CHAR_BIT; -+#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz64) -+ m_len += lzo_bitops_ctlz64(v) / CHAR_BIT; -+#elif (LZO_ABI_BIG_ENDIAN) -+ if ((v >> (64 - CHAR_BIT)) == 0) do { -+ v <<= CHAR_BIT; -+ m_len += 1; -+ } while ((v >> (64 - CHAR_BIT)) == 0); -+#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz64) -+ m_len += lzo_bitops_cttz64(v) / CHAR_BIT; - #elif (LZO_ABI_LITTLE_ENDIAN) - if ((v & UCHAR_MAX) == 0) do { - v >>= CHAR_BIT; -@@ -3330,19 +4769,30 @@ next: - m_len += 1; - } while (ip[m_len] == m_pos[m_len]); - #endif --#elif defined(UA_GET32) -- lzo_uint32 v; -- v = UA_GET32(ip + m_len) ^ UA_GET32(m_pos + m_len); -+#elif (LZO_OPT_UNALIGNED32) -+ lzo_uint32_t v; -+ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); - if __lzo_unlikely(v == 0) { - do { - m_len += 4; -- v = UA_GET32(ip + m_len) ^ UA_GET32(m_pos + m_len); -+ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); -+ if (v != 0) -+ break; -+ m_len += 4; -+ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); - if __lzo_unlikely(ip + m_len >= ip_end) - goto m_len_done; - } while (v == 0); - } --#if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz32) -- m_len += lzo_bitops_ctz32(v) / CHAR_BIT; -+#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz32) -+ m_len += lzo_bitops_ctlz32(v) / CHAR_BIT; -+#elif (LZO_ABI_BIG_ENDIAN) -+ if ((v >> (32 - CHAR_BIT)) == 0) do { -+ v <<= CHAR_BIT; -+ m_len += 1; -+ } while ((v >> (32 - CHAR_BIT)) == 0); -+#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz32) -+ m_len += lzo_bitops_cttz32(v) / CHAR_BIT; - #elif (LZO_ABI_LITTLE_ENDIAN) - if ((v & UCHAR_MAX) == 0) do { - v >>= CHAR_BIT; -@@ -3357,6 +4807,27 @@ next: - if __lzo_unlikely(ip[m_len] == m_pos[m_len]) { - do { - m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; -+ if (ip[m_len] != m_pos[m_len]) -+ break; -+ m_len += 1; - if __lzo_unlikely(ip + m_len >= ip_end) - goto m_len_done; - } while (ip[m_len] == m_pos[m_len]); -@@ -3390,11 +4861,8 @@ m_len_done: - while __lzo_unlikely(m_len > 255) - { - m_len -= 255; --#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) -- * (volatile unsigned char *) op++ = 0; --#else -- *op++ = 0; --#endif -+ UA_SET1(op, 0); -+ op++; - } - *op++ = LZO_BYTE(m_len); - } -@@ -3413,11 +4881,8 @@ m_len_done: - while __lzo_unlikely(m_len > 255) - { - m_len -= 255; --#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) -- * (volatile unsigned char *) op++ = 0; --#else -- *op++ = 0; --#endif -+ UA_SET1(op, 0); -+ op++; - } - *op++ = LZO_BYTE(m_len); - } -@@ -3428,7 +4893,7 @@ m_len_done: - } - - *out_len = pd(op, out); -- return pd(in_end,ii); -+ return pd(in_end,ii-ti); - } - - LZO_PUBLIC(int) -@@ -3468,7 +4933,7 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - if (op == out && t <= 238) - *op++ = LZO_BYTE(17 + t); - else if (t <= 3) -- op[-2] |= LZO_BYTE(t); -+ op[-2] = LZO_BYTE(op[-2] | t); - else if (t <= 18) - *op++ = LZO_BYTE(t - 3); - else -@@ -3479,17 +4944,14 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - while (tt > 255) - { - tt -= 255; --#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) -- -- * (volatile unsigned char *) op++ = 0; --#else -- *op++ = 0; --#endif -+ UA_SET1(op, 0); -+ op++; - } - assert(tt > 0); - *op++ = LZO_BYTE(tt); - } -- do *op++ = *ii++; while (--t > 0); -+ UA_COPYN(op, ii, t); -+ op += t; - } - - *op++ = M4_MARKER | 1; -@@ -3526,10 +4988,13 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - - #undef TEST_IP - #undef TEST_OP -+#undef TEST_IP_AND_TEST_OP - #undef TEST_LB - #undef TEST_LBO - #undef NEED_IP - #undef NEED_OP -+#undef TEST_IV -+#undef TEST_OV - #undef HAVE_TEST_IP - #undef HAVE_TEST_OP - #undef HAVE_NEED_IP -@@ -3544,6 +5009,7 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - # if (LZO_TEST_OVERRUN_INPUT >= 2) - # define NEED_IP(x) \ - if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun -+# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun +-#if !defined(LZO_UNUSED) +-# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) +-# define LZO_UNUSED(var) ((void) &var) +-# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) +-# define LZO_UNUSED(var) if (&var) ; else +-# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define LZO_UNUSED(var) ((void) var) +-# elif (LZO_CC_MSC && (_MSC_VER < 900)) +-# define LZO_UNUSED(var) if (&var) ; else +-# elif (LZO_CC_KEILC) +-# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} +-# elif (LZO_CC_PACIFICC) +-# define LZO_UNUSED(var) ((void) sizeof(var)) +-# elif (LZO_CC_WATCOMC) && defined(__cplusplus) +-# define LZO_UNUSED(var) ((void) var) ++#if !defined(__lzo_static_unused_void_func) ++# if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) ++# define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void) + # else +-# define LZO_UNUSED(var) ((void) &var) ++# define __lzo_static_unused_void_func(f) static __lzo_inline void f(void) # endif #endif - -@@ -3555,12 +5021,13 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - # undef TEST_OP - # define NEED_OP(x) \ - if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun -+# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun +-#if !defined(LZO_UNUSED_FUNC) +-# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) +-# define LZO_UNUSED_FUNC(func) ((void) func) +-# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) +-# define LZO_UNUSED_FUNC(func) if (func) ; else +-# elif (LZO_CC_CLANG || LZO_CC_LLVM) +-# define LZO_UNUSED_FUNC(func) ((void) &func) +-# elif (LZO_CC_MSC && (_MSC_VER < 900)) +-# define LZO_UNUSED_FUNC(func) if (func) ; else +-# elif (LZO_CC_MSC) +-# define LZO_UNUSED_FUNC(func) ((void) &func) +-# elif (LZO_CC_KEILC || LZO_CC_PELLESC) +-# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} ++#if !defined(__lzo_loop_forever) ++# if (LZO_CC_IBMC) ++# define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END + # else +-# define LZO_UNUSED_FUNC(func) ((void) func) ++# define __lzo_loop_forever() do { ; } while __lzo_cte(1) # endif #endif - - #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) --# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun --# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun -+# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun -+# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun - #else - # define TEST_LB(m_pos) ((void) 0) - # define TEST_LBO(m_pos,o) ((void) 0) -@@ -3581,15 +5048,27 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, - # define TEST_OP 1 +-#if !defined(LZO_UNUSED_LABEL) +-# if (LZO_CC_WATCOMC) && defined(__cplusplus) +-# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l +-# elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) +-# define LZO_UNUSED_LABEL(l) if (0) goto l +-# else +-# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l +-# endif ++#if !defined(__lzo_unreachable) ++#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) ++# define __lzo_unreachable() __builtin_unreachable(); ++#elif (LZO_CC_GNUC >= 0x040500ul) ++# define __lzo_unreachable() __builtin_unreachable(); ++#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1 ++# define __lzo_unreachable() __builtin_unreachable(); #endif - -+#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) -+# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) -+#elif defined(HAVE_TEST_IP) -+# define TEST_IP_AND_TEST_OP TEST_IP -+#elif defined(HAVE_TEST_OP) -+# define TEST_IP_AND_TEST_OP TEST_OP -+#else -+# define TEST_IP_AND_TEST_OP 1 +-#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) +#endif -+ - #if defined(NEED_IP) - # define HAVE_NEED_IP 1 - #else - # define NEED_IP(x) ((void) 0) -+# define TEST_IV(x) ((void) 0) - #endif - #if defined(NEED_OP) - # define HAVE_NEED_OP 1 - #else - # define NEED_OP(x) ((void) 0) -+# define TEST_OV(x) ((void) 0) - #endif - - #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) -@@ -3606,14 +5085,14 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - lzo_voidp wrkmem ) ++#if defined(__lzo_unreachable) ++# ifndef __lzo_HAVE_unreachable ++# define __lzo_HAVE_unreachable 1 ++# endif ++#else + # if 0 +-# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var +-# elif 0 && (LZO_CC_GNUC) +-# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var ++# define __lzo_unreachable() ((void)0); + # else +-# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init ++# define __lzo_unreachable() __lzo_loop_forever(); + # endif #endif - { -- register lzo_bytep op; -- register const lzo_bytep ip; -- register lzo_uint t; -+ lzo_bytep op; -+ const lzo_bytep ip; -+ lzo_uint t; - #if defined(COPY_DICT) - lzo_uint m_off; - const lzo_bytep dict_end; - #else -- register const lzo_bytep m_pos; -+ const lzo_bytep m_pos; +-#if !defined(LZO_UNCONST_CAST) +-# if 0 && defined(__cplusplus) +-# define LZO_UNCONST_CAST(t,e) (const_cast (e)) +-# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) +-# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e)))))) +-# else +-# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) +-# endif ++#ifndef __LZO_CTA_NAME ++#if (LZO_CFG_USE_COUNTER) ++# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__) ++#else ++# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__) ++#endif #endif - - const lzo_bytep const ip_end = in + in_len; -@@ -3648,43 +5127,45 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - op = out; - ip = in; - -+ NEED_IP(1); - if (*ip > 17) - { - t = *ip++ - 17; - if (t < 4) - goto match_next; -- assert(t > 0); NEED_OP(t); NEED_IP(t+1); -+ assert(t > 0); NEED_OP(t); NEED_IP(t+3); - do *op++ = *ip++; while (--t > 0); - goto first_literal_run; - } - -- while (TEST_IP && TEST_OP) -+ for (;;) - { -+ NEED_IP(3); - t = *ip++; - if (t >= 16) - goto match; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_IV(t); - NEED_IP(1); - } - t += 15 + *ip++; - } -- assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); --#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) -+ assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); -+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) - t += 3; - if (t >= 8) do - { -- UA_COPY64(op,ip); -+ UA_COPY8(op,ip); - op += 8; ip += 8; t -= 8; - } while (t >= 8); - if (t >= 4) - { -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; t -= 4; - } - if (t > 0) -@@ -3692,19 +5173,19 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - *op++ = *ip++; - if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } - } --#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) --#if !defined(LZO_UNALIGNED_OK_4) -+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - if (PTR_ALIGNED2_4(op,ip)) - { + #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) + # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END + # elif (LZO_CC_DMC || LZO_CC_SYMANTECC) +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END + # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END ++# elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus) ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END ++# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END + # else +-# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; ++# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END + # endif #endif -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; - if (--t > 0) - { - if (t >= 4) - { - do { -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *ip++; while (--t > 0); -@@ -3712,12 +5193,12 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - else - do *op++ = *ip++; while (--t > 0); - } --#if !defined(LZO_UNALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - } - else + #if !defined(LZO_COMPILE_TIME_ASSERT) + # if (LZO_CC_AZTECC) +-# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} ++# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];} + # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) + # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; ++# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) ++# define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));} ++# elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus) ++# define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));} ++# elif (LZO_CC_GNUC >= 0x040700ul) ++# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} + # elif (LZO_CC_MSC && (_MSC_VER < 900)) + # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; + # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) + # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; + # else +-# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} ++# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];} + # endif #endif ++LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1) ++#if defined(__cplusplus) ++extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) } ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3) + #if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) + # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) + # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) +@@ -1730,6 +1965,7 @@ extern "C" { + # define __lzo_cdecl_va __lzo_cdecl #endif --#if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8) -+#if !(LZO_OPT_UNALIGNED32) - { - *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; - do *op++ = *ip++; while (--t > 0); -@@ -3753,7 +5234,7 @@ first_literal_run: + #if !(LZO_CFG_NO_WINDOWS_H) ++#if !defined(LZO_HAVE_WINDOWS_H) + #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) + # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) + # elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) +@@ -1739,60 +1975,614 @@ extern "C" { + # endif #endif - goto match_done; - -- do { -+ for (;;) { - match: - if (t >= 64) - { -@@ -3813,14 +5294,15 @@ match: - t &= 31; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_OV(t); - NEED_IP(1); - } - t += 31 + *ip++; -+ NEED_IP(2); - } - #if defined(COPY_DICT) - #if defined(LZO1Z) -@@ -3836,9 +5318,9 @@ match: - m_pos = op - off; - last_m_off = off; - } --#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) -+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) - m_pos = op - 1; -- m_pos -= UA_GET16(ip) >> 2; -+ m_pos -= UA_GET_LE16(ip) >> 2; - #else - m_pos = op - 1; - m_pos -= (ip[0] >> 2) + (ip[1] << 6); -@@ -3857,14 +5339,15 @@ match: - t &= 7; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_OV(t); - NEED_IP(1); - } - t += 7 + *ip++; -+ NEED_IP(2); - } - #if defined(COPY_DICT) - #if defined(LZO1Z) -@@ -3882,8 +5365,8 @@ match: - #else - #if defined(LZO1Z) - m_pos -= (ip[0] << 6) + (ip[1] >> 2); --#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) -- m_pos -= UA_GET16(ip) >> 2; -+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) -+ m_pos -= UA_GET_LE16(ip) >> 2; - #else - m_pos -= (ip[0] >> 2) + (ip[1] << 6); #endif -@@ -3931,18 +5414,18 @@ match: - #else - - TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); --#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) -+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) - if (op - m_pos >= 8) - { - t += (3 - 1); - if (t >= 8) do - { -- UA_COPY64(op,m_pos); -+ UA_COPY8(op,m_pos); - op += 8; m_pos += 8; t -= 8; - } while (t >= 8); - if (t >= 4) - { -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4; - } - if (t > 0) -@@ -3952,8 +5435,8 @@ match: - } - } - else --#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) --#if !defined(LZO_UNALIGNED_OK_4) -+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) - { - assert((op - m_pos) >= 4); -@@ -3961,10 +5444,10 @@ match: - if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) - { - #endif -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4 - (3 - 1); - do { -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *m_pos++; while (--t > 0); -@@ -3989,7 +5472,7 @@ match_done: - break; - - match_next: -- assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); -+ assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); - #if 0 - do *op++ = *ip++; while (--t > 0); - #else -@@ -3997,16 +5480,10 @@ match_next: - if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } - #endif - t = *ip++; -- } while (TEST_IP && TEST_OP); -+ } - } - --#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) -- *out_len = pd(op, out); -- return LZO_E_EOF_NOT_FOUND; --#endif -- - eof_found: -- assert(t == 1); - *out_len = pd(op, out); - return (ip == ip_end ? LZO_E_OK : - (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); -@@ -4052,10 +5529,13 @@ lookbehind_overrun: - - #undef TEST_IP - #undef TEST_OP -+#undef TEST_IP_AND_TEST_OP - #undef TEST_LB - #undef TEST_LBO - #undef NEED_IP - #undef NEED_OP -+#undef TEST_IV -+#undef TEST_OV - #undef HAVE_TEST_IP - #undef HAVE_TEST_OP - #undef HAVE_NEED_IP -@@ -4070,6 +5550,7 @@ lookbehind_overrun: - # if (LZO_TEST_OVERRUN_INPUT >= 2) - # define NEED_IP(x) \ - if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun -+# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun - # endif - #endif - -@@ -4081,12 +5562,13 @@ lookbehind_overrun: - # undef TEST_OP - # define NEED_OP(x) \ - if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun -+# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun - # endif - #endif - - #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) --# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun --# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun -+# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun -+# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun - #else - # define TEST_LB(m_pos) ((void) 0) - # define TEST_LBO(m_pos,o) ((void) 0) -@@ -4107,15 +5589,27 @@ lookbehind_overrun: - # define TEST_OP 1 - #endif - -+#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) -+# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) -+#elif defined(HAVE_TEST_IP) -+# define TEST_IP_AND_TEST_OP TEST_IP -+#elif defined(HAVE_TEST_OP) -+# define TEST_IP_AND_TEST_OP TEST_OP -+#else -+# define TEST_IP_AND_TEST_OP 1 -+#endif -+ - #if defined(NEED_IP) - # define HAVE_NEED_IP 1 - #else - # define NEED_IP(x) ((void) 0) -+# define TEST_IV(x) ((void) 0) - #endif - #if defined(NEED_OP) - # define HAVE_NEED_OP 1 - #else - # define NEED_OP(x) ((void) 0) -+# define TEST_OV(x) ((void) 0) - #endif - - #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) -@@ -4132,14 +5626,14 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - lzo_voidp wrkmem ) - #endif - { -- register lzo_bytep op; -- register const lzo_bytep ip; -- register lzo_uint t; -+ lzo_bytep op; -+ const lzo_bytep ip; -+ lzo_uint t; - #if defined(COPY_DICT) - lzo_uint m_off; - const lzo_bytep dict_end; - #else -- register const lzo_bytep m_pos; -+ const lzo_bytep m_pos; - #endif - - const lzo_bytep const ip_end = in + in_len; -@@ -4174,43 +5668,45 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - op = out; - ip = in; - -+ NEED_IP(1); - if (*ip > 17) - { - t = *ip++ - 17; - if (t < 4) - goto match_next; -- assert(t > 0); NEED_OP(t); NEED_IP(t+1); -+ assert(t > 0); NEED_OP(t); NEED_IP(t+3); - do *op++ = *ip++; while (--t > 0); - goto first_literal_run; - } - -- while (TEST_IP && TEST_OP) -+ for (;;) - { -+ NEED_IP(3); - t = *ip++; - if (t >= 16) - goto match; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_IV(t); - NEED_IP(1); - } - t += 15 + *ip++; - } -- assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); --#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) -+ assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); -+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) - t += 3; - if (t >= 8) do - { -- UA_COPY64(op,ip); -+ UA_COPY8(op,ip); - op += 8; ip += 8; t -= 8; - } while (t >= 8); - if (t >= 4) - { -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; t -= 4; - } - if (t > 0) -@@ -4218,19 +5714,19 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - *op++ = *ip++; - if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } - } --#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) --#if !defined(LZO_UNALIGNED_OK_4) -+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - if (PTR_ALIGNED2_4(op,ip)) - { - #endif -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; - if (--t > 0) - { - if (t >= 4) - { - do { -- UA_COPY32(op,ip); -+ UA_COPY4(op,ip); - op += 4; ip += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *ip++; while (--t > 0); -@@ -4238,12 +5734,12 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, - else - do *op++ = *ip++; while (--t > 0); - } --#if !defined(LZO_UNALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - } - else - #endif - #endif --#if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8) -+#if !(LZO_OPT_UNALIGNED32) - { - *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; - do *op++ = *ip++; while (--t > 0); -@@ -4279,7 +5775,7 @@ first_literal_run: - #endif - goto match_done; - -- do { -+ for (;;) { - match: - if (t >= 64) - { -@@ -4339,14 +5835,15 @@ match: - t &= 31; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_OV(t); - NEED_IP(1); - } - t += 31 + *ip++; -+ NEED_IP(2); - } - #if defined(COPY_DICT) - #if defined(LZO1Z) -@@ -4362,9 +5859,9 @@ match: - m_pos = op - off; - last_m_off = off; - } --#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) -+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) - m_pos = op - 1; -- m_pos -= UA_GET16(ip) >> 2; -+ m_pos -= UA_GET_LE16(ip) >> 2; - #else - m_pos = op - 1; - m_pos -= (ip[0] >> 2) + (ip[1] << 6); -@@ -4383,14 +5880,15 @@ match: - t &= 7; - if (t == 0) - { -- NEED_IP(1); - while (*ip == 0) - { - t += 255; - ip++; -+ TEST_OV(t); - NEED_IP(1); - } - t += 7 + *ip++; -+ NEED_IP(2); - } - #if defined(COPY_DICT) - #if defined(LZO1Z) -@@ -4408,8 +5906,8 @@ match: - #else - #if defined(LZO1Z) - m_pos -= (ip[0] << 6) + (ip[1] >> 2); --#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) -- m_pos -= UA_GET16(ip) >> 2; -+#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) -+ m_pos -= UA_GET_LE16(ip) >> 2; - #else - m_pos -= (ip[0] >> 2) + (ip[1] << 6); - #endif -@@ -4457,18 +5955,18 @@ match: - #else - - TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); --#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) -+#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) - if (op - m_pos >= 8) - { - t += (3 - 1); - if (t >= 8) do - { -- UA_COPY64(op,m_pos); -+ UA_COPY8(op,m_pos); - op += 8; m_pos += 8; t -= 8; - } while (t >= 8); - if (t >= 4) - { -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4; - } - if (t > 0) -@@ -4478,8 +5976,8 @@ match: - } - } - else --#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) --#if !defined(LZO_UNALIGNED_OK_4) -+#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) -+#if !(LZO_OPT_UNALIGNED32) - if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) - { - assert((op - m_pos) >= 4); -@@ -4487,10 +5985,10 @@ match: - if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) - { - #endif -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4 - (3 - 1); - do { -- UA_COPY32(op,m_pos); -+ UA_COPY4(op,m_pos); - op += 4; m_pos += 4; t -= 4; - } while (t >= 4); - if (t > 0) do *op++ = *m_pos++; while (--t > 0); -@@ -4515,7 +6013,7 @@ match_done: - break; - - match_next: -- assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); -+ assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); - #if 0 - do *op++ = *ip++; while (--t > 0); - #else -@@ -4523,16 +6021,10 @@ match_next: - if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } - #endif - t = *ip++; -- } while (TEST_IP && TEST_OP); -+ } - } - --#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) -- *out_len = pd(op, out); -- return LZO_E_EOF_NOT_FOUND; --#endif -- - eof_found: -- assert(t == 1); - *out_len = pd(op, out); - return (ip == ip_end ? LZO_E_OK : - (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); -@@ -4559,4 +6051,3 @@ lookbehind_overrun: - #endif - - /***** End of minilzo.c *****/ -- -diff --git a/grub-core/lib/minilzo/lzoconf.h b/grub-core/lib/minilzo/lzoconf.h -index 1d0fe14fcda..61be29c5dc2 100644 ---- a/grub-core/lib/minilzo/lzoconf.h -+++ b/grub-core/lib/minilzo/lzoconf.h -@@ -2,22 +2,7 @@ - - This file is part of the LZO real-time data compression library. - -- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer -+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or -@@ -44,9 +29,9 @@ - #ifndef __LZOCONF_H_INCLUDED - #define __LZOCONF_H_INCLUDED 1 - --#define LZO_VERSION 0x2050 --#define LZO_VERSION_STRING "2.05" --#define LZO_VERSION_DATE "Apr 23 2011" -+#define LZO_VERSION 0x2080 -+#define LZO_VERSION_STRING "2.08" -+#define LZO_VERSION_DATE "Jun 29 2014" - - /* internal Autoconf configuration file - only used when building LZO */ - #if defined(LZO_HAVE_CONFIG_H) -@@ -63,7 +48,7 @@ - #if !defined(CHAR_BIT) || (CHAR_BIT != 8) - # error "invalid CHAR_BIT" - #endif --#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) -+#if !defined(UCHAR_MAX) || !defined(USHRT_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) - # error "check your compiler installation" - #endif - #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1) -@@ -85,14 +70,6 @@ extern "C" { - // some core defines - ************************************************************************/ - --#if !defined(LZO_UINT32_C) --# if (UINT_MAX < LZO_0xffffffffL) --# define LZO_UINT32_C(c) c ## UL --# else --# define LZO_UINT32_C(c) ((c) + 0U) --# endif --#endif -- - /* memory checkers */ - #if !defined(__LZO_CHECKER) - # if defined(__BOUNDS_CHECKING_ON) -@@ -111,28 +88,31 @@ extern "C" { - // integral and pointer types - ************************************************************************/ - --/* lzo_uint should match size_t */ -+/* lzo_uint must match size_t */ - #if !defined(LZO_UINT_MAX) --# if defined(LZO_ABI_LLP64) /* WIN64 */ --# if defined(LZO_OS_WIN64) -+# if (LZO_ABI_LLP64) -+# if (LZO_OS_WIN64) - typedef unsigned __int64 lzo_uint; - typedef __int64 lzo_int; - # else -- typedef unsigned long long lzo_uint; -- typedef long long lzo_int; -+ typedef lzo_ullong_t lzo_uint; -+ typedef lzo_llong_t lzo_int; - # endif -+# define LZO_SIZEOF_LZO_UINT 8 - # define LZO_UINT_MAX 0xffffffffffffffffull - # define LZO_INT_MAX 9223372036854775807LL - # define LZO_INT_MIN (-1LL - LZO_INT_MAX) --# elif defined(LZO_ABI_IP32L64) /* MIPS R5900 */ -+# elif (LZO_ABI_IP32L64) /* MIPS R5900 */ - typedef unsigned int lzo_uint; - typedef int lzo_int; -+# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_INT - # define LZO_UINT_MAX UINT_MAX - # define LZO_INT_MAX INT_MAX - # define LZO_INT_MIN INT_MIN - # elif (ULONG_MAX >= LZO_0xffffffffL) - typedef unsigned long lzo_uint; - typedef long lzo_int; -+# define LZO_SIZEOF_LZO_UINT LZO_SIZEOF_LONG - # define LZO_UINT_MAX ULONG_MAX - # define LZO_INT_MAX LONG_MAX - # define LZO_INT_MIN LONG_MIN -@@ -141,63 +121,22 @@ extern "C" { - # endif - #endif - --/* Integral types with 32 bits or more. */ --#if !defined(LZO_UINT32_MAX) --# if (UINT_MAX >= LZO_0xffffffffL) -- typedef unsigned int lzo_uint32; -- typedef int lzo_int32; --# define LZO_UINT32_MAX UINT_MAX --# define LZO_INT32_MAX INT_MAX --# define LZO_INT32_MIN INT_MIN --# elif (ULONG_MAX >= LZO_0xffffffffL) -- typedef unsigned long lzo_uint32; -- typedef long lzo_int32; --# define LZO_UINT32_MAX ULONG_MAX --# define LZO_INT32_MAX LONG_MAX --# define LZO_INT32_MIN LONG_MIN --# else --# error "lzo_uint32" --# endif --#endif -- --/* Integral types with exactly 64 bits. */ --#if !defined(LZO_UINT64_MAX) --# if (LZO_UINT_MAX >= LZO_0xffffffffL) --# if ((((LZO_UINT_MAX) >> 31) >> 31) == 3) --# define lzo_uint64 lzo_uint --# define lzo_int64 lzo_int --# define LZO_UINT64_MAX LZO_UINT_MAX --# define LZO_INT64_MAX LZO_INT_MAX --# define LZO_INT64_MIN LZO_INT_MIN --# endif --# elif (ULONG_MAX >= LZO_0xffffffffL) --# if ((((ULONG_MAX) >> 31) >> 31) == 3) -- typedef unsigned long lzo_uint64; -- typedef long lzo_int64; --# define LZO_UINT64_MAX ULONG_MAX --# define LZO_INT64_MAX LONG_MAX --# define LZO_INT64_MIN LONG_MIN --# endif --# endif --#endif -- --/* The larger type of lzo_uint and lzo_uint32. */ --#if (LZO_UINT_MAX >= LZO_UINT32_MAX) -+/* The larger type of lzo_uint and lzo_uint32_t. */ -+#if (LZO_SIZEOF_LZO_UINT >= 4) - # define lzo_xint lzo_uint - #else --# define lzo_xint lzo_uint32 -+# define lzo_xint lzo_uint32_t - #endif - --/* Memory model that allows to access memory at offsets of lzo_uint. */ --#if !defined(__LZO_MMODEL) --# if (LZO_UINT_MAX <= UINT_MAX) --# define __LZO_MMODEL /*empty*/ --# elif defined(LZO_HAVE_MM_HUGE_PTR) --# define __LZO_MMODEL_HUGE 1 --# define __LZO_MMODEL __huge --# else --# define __LZO_MMODEL /*empty*/ --# endif -+typedef int lzo_bool; -+ -+/* sanity checks */ -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == LZO_SIZEOF_LZO_UINT) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_xint) >= sizeof(lzo_uint32_t)) -+ -+#ifndef __LZO_MMODEL -+#define __LZO_MMODEL /*empty*/ - #endif - - /* no typedef here because of const-pointer issues */ -@@ -206,21 +145,52 @@ extern "C" { - #define lzo_voidp void __LZO_MMODEL * - #define lzo_shortp short __LZO_MMODEL * - #define lzo_ushortp unsigned short __LZO_MMODEL * --#define lzo_uint32p lzo_uint32 __LZO_MMODEL * --#define lzo_int32p lzo_int32 __LZO_MMODEL * --#if defined(LZO_UINT64_MAX) --#define lzo_uint64p lzo_uint64 __LZO_MMODEL * --#define lzo_int64p lzo_int64 __LZO_MMODEL * --#endif --#define lzo_uintp lzo_uint __LZO_MMODEL * - #define lzo_intp lzo_int __LZO_MMODEL * -+#define lzo_uintp lzo_uint __LZO_MMODEL * - #define lzo_xintp lzo_xint __LZO_MMODEL * - #define lzo_voidpp lzo_voidp __LZO_MMODEL * - #define lzo_bytepp lzo_bytep __LZO_MMODEL * --/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ --#define lzo_byte unsigned char __LZO_MMODEL - --typedef int lzo_bool; -+#define lzo_int8_tp lzo_int8_t __LZO_MMODEL * -+#define lzo_uint8_tp lzo_uint8_t __LZO_MMODEL * -+#define lzo_int16_tp lzo_int16_t __LZO_MMODEL * -+#define lzo_uint16_tp lzo_uint16_t __LZO_MMODEL * -+#define lzo_int32_tp lzo_int32_t __LZO_MMODEL * -+#define lzo_uint32_tp lzo_uint32_t __LZO_MMODEL * -+#if defined(lzo_int64_t) -+#define lzo_int64_tp lzo_int64_t __LZO_MMODEL * -+#define lzo_uint64_tp lzo_uint64_t __LZO_MMODEL * -+#endif -+ -+/* Older LZO versions used to support ancient systems and memory models -+ * like 16-bit MSDOS with __huge pointers and Cray PVP, but these -+ * obsolete configurations are not supported any longer. -+ */ -+#if defined(__LZO_MMODEL_HUGE) -+#error "__LZO_MMODEL_HUGE is unsupported" -+#endif -+#if (LZO_MM_PVP) -+#error "LZO_MM_PVP is unsupported" -+#endif -+#if (LZO_SIZEOF_INT < 4) -+#error "LZO_SIZEOF_INT < 4 is unsupported" -+#endif -+#if (__LZO_UINTPTR_T_IS_POINTER) -+#error "__LZO_UINTPTR_T_IS_POINTER is unsupported" -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) >= 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) >= 4) -+/* Strange configurations where sizeof(lzo_uint) != sizeof(size_t) should -+ * work but have not received much testing lately, so be strict here. -+ */ -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp)) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep)) - - - /*********************************************************************** -@@ -315,7 +285,7 @@ struct lzo_callback_t - /* a progress indicator callback function (set to 0 to disable) */ - lzo_progress_func_t nprogress; - -- /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress -+ /* INFO: the first parameter "self" of the nalloc/nfree/nprogress - * callbacks points back to this struct, so you are free to store - * some extra info in the following variables. */ - lzo_voidp user1; -@@ -343,6 +313,9 @@ struct lzo_callback_t - #define LZO_E_INPUT_NOT_CONSUMED (-8) - #define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ - #define LZO_E_INVALID_ARGUMENT (-10) -+#define LZO_E_INVALID_ALIGNMENT (-11) /* pointer argument is not properly aligned */ -+#define LZO_E_OUTPUT_NOT_CONSUMED (-12) -+#define LZO_E_INTERNAL_ERROR (-99) - - - #ifndef lzo_sizeof_dict_t -@@ -356,7 +329,7 @@ struct lzo_callback_t - * compiler's view of various types are consistent. - */ - #define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ -- (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ -+ (int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\ - (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ - (int)sizeof(lzo_callback_t)) - LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int); -@@ -379,18 +352,22 @@ LZO_EXTERN(lzo_voidp) - lzo_memset(lzo_voidp buf, int c, lzo_uint len); - - /* checksum functions */ --LZO_EXTERN(lzo_uint32) -- lzo_adler32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); --LZO_EXTERN(lzo_uint32) -- lzo_crc32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); --LZO_EXTERN(const lzo_uint32p) -+LZO_EXTERN(lzo_uint32_t) -+ lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); -+LZO_EXTERN(lzo_uint32_t) -+ lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); -+LZO_EXTERN(const lzo_uint32_tp) - lzo_get_crc32_table(void); - - /* misc. */ - LZO_EXTERN(int) _lzo_config_check(void); --typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; --typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; --typedef union { void *vp; lzo_bytep bp; lzo_uint u; lzo_uint32 u32; unsigned long l; } lzo_align_t; -+typedef union { -+ lzo_voidp a00; lzo_bytep a01; lzo_uint a02; lzo_xint a03; lzo_uintptr_t a04; -+ void *a05; unsigned char *a06; unsigned long a07; size_t a08; ptrdiff_t a09; -+#if defined(lzo_int64_t) -+ lzo_uint64_t a10; -+#endif -+} lzo_align_t; - - /* align a char pointer on a boundary that is a multiple of 'size' */ - LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); -@@ -399,9 +376,30 @@ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); - - - /*********************************************************************** --// deprecated macros - only for backward compatibility with LZO v1.xx -+// deprecated macros - only for backward compatibility - ************************************************************************/ - -+/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ -+#define lzo_byte unsigned char -+/* deprecated type names */ -+#define lzo_int32 lzo_int32_t -+#define lzo_uint32 lzo_uint32_t -+#define lzo_int32p lzo_int32_t __LZO_MMODEL * -+#define lzo_uint32p lzo_uint32_t __LZO_MMODEL * -+#define LZO_INT32_MAX LZO_INT32_C(2147483647) -+#define LZO_UINT32_MAX LZO_UINT32_C(4294967295) -+#if defined(lzo_int64_t) -+#define lzo_int64 lzo_int64_t -+#define lzo_uint64 lzo_uint64_t -+#define lzo_int64p lzo_int64_t __LZO_MMODEL * -+#define lzo_uint64p lzo_uint64_t __LZO_MMODEL * -+#define LZO_INT64_MAX LZO_INT64_C(9223372036854775807) -+#define LZO_UINT64_MAX LZO_UINT64_C(18446744073709551615) -+#endif -+/* deprecated types */ -+typedef union { lzo_bytep a; lzo_uint b; } __lzo_pu_u; -+typedef union { lzo_bytep a; lzo_uint32_t b; } __lzo_pu32_u; -+ - #if defined(LZO_CFG_COMPAT) - - #define __LZOCONF_H 1 -@@ -443,4 +441,4 @@ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); - #endif /* already included */ - - --/* vim:set ts=4 et: */ -+/* vim:set ts=4 sw=4 et: */ -diff --git a/grub-core/lib/minilzo/lzodefs.h b/grub-core/lib/minilzo/lzodefs.h -index 0e40e332a8d..f4ae9487ebe 100644 ---- a/grub-core/lib/minilzo/lzodefs.h -+++ b/grub-core/lib/minilzo/lzodefs.h -@@ -2,22 +2,7 @@ - - This file is part of the LZO real-time data compression library. - -- Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer -- Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer -+ Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or -@@ -47,12 +32,6 @@ - #if defined(__CYGWIN32__) && !defined(__CYGWIN__) - # define __CYGWIN__ __CYGWIN32__ - #endif --#if defined(__IBMCPP__) && !defined(__IBMC__) --# define __IBMC__ __IBMCPP__ --#endif --#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) --# define __INTEL_COMPILER __ICL --#endif - #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) - # define _ALL_SOURCE 1 - #endif -@@ -61,19 +40,30 @@ - # define __LONG_MAX__ 9223372036854775807L - # endif - #endif --#if defined(__INTEL_COMPILER) && defined(__linux__) -+#if !defined(LZO_CFG_NO_DISABLE_WUNDEF) -+#if defined(__ARMCC_VERSION) -+# pragma diag_suppress 193 -+#elif defined(__clang__) && defined(__clang_minor__) -+# pragma clang diagnostic ignored "-Wundef" -+#elif defined(__INTEL_COMPILER) - # pragma warning(disable: 193) --#endif --#if defined(__KEIL__) && defined(__C166__) -+#elif defined(__KEIL__) && defined(__C166__) - # pragma warning disable = 322 --#elif 0 && defined(__C251__) --# pragma warning disable = 322 --#endif --#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) --# if (_MSC_VER >= 1300) -+#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__) -+# if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2)) -+# pragma GCC diagnostic ignored "-Wundef" -+# endif -+#elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) -+# if ((_MSC_VER-0) >= 1300) - # pragma warning(disable: 4668) - # endif - #endif -+#endif -+#if 0 && defined(__POCC__) && defined(_WIN32) -+# if (__POCC__ >= 400) -+# pragma warn(disable: 2216) -+# endif -+#endif - #if 0 && defined(__WATCOMC__) - # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) - # pragma warning 203 9 -@@ -82,13 +72,29 @@ - #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) - # pragma option -h - #endif -+#if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC) -+#ifndef _CRT_NONSTDC_NO_DEPRECATE -+#define _CRT_NONSTDC_NO_DEPRECATE 1 -+#endif -+#ifndef _CRT_NONSTDC_NO_WARNINGS -+#define _CRT_NONSTDC_NO_WARNINGS 1 -+#endif -+#ifndef _CRT_SECURE_NO_DEPRECATE -+#define _CRT_SECURE_NO_DEPRECATE 1 -+#endif -+#ifndef _CRT_SECURE_NO_WARNINGS -+#define _CRT_SECURE_NO_WARNINGS 1 -+#endif -+#endif - #if 0 --#define LZO_0xffffL 0xfffful --#define LZO_0xffffffffL 0xfffffffful -+#define LZO_0xffffUL 0xfffful -+#define LZO_0xffffffffUL 0xfffffffful - #else --#define LZO_0xffffL 65535ul --#define LZO_0xffffffffL 4294967295ul -+#define LZO_0xffffUL 65535ul -+#define LZO_0xffffffffUL 4294967295ul - #endif -+#define LZO_0xffffL LZO_0xffffUL -+#define LZO_0xffffffffL LZO_0xffffffffUL - #if (LZO_0xffffL == LZO_0xffffffffL) - # error "your preprocessor is broken 1" - #endif -@@ -103,6 +109,13 @@ - # error "your preprocessor is broken 4" - #endif - #endif -+#if defined(__COUNTER__) -+# ifndef LZO_CFG_USE_COUNTER -+# define LZO_CFG_USE_COUNTER 1 -+# endif -+#else -+# undef LZO_CFG_USE_COUNTER -+#endif - #if (UINT_MAX == LZO_0xffffL) - #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) - # if !defined(MSDOS) -@@ -233,14 +246,31 @@ - #endif - #define LZO_PP_STRINGIZE(x) #x - #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) -+#define LZO_PP_CONCAT0() /*empty*/ -+#define LZO_PP_CONCAT1(a) a - #define LZO_PP_CONCAT2(a,b) a ## b - #define LZO_PP_CONCAT3(a,b,c) a ## b ## c - #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d - #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -+#define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f -+#define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g -+#define LZO_PP_ECONCAT0() LZO_PP_CONCAT0() -+#define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a) - #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) - #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) - #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) - #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) -+#define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f) -+#define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g) -+#define LZO_PP_EMPTY /*empty*/ -+#define LZO_PP_EMPTY0() /*empty*/ -+#define LZO_PP_EMPTY1(a) /*empty*/ -+#define LZO_PP_EMPTY2(a,b) /*empty*/ -+#define LZO_PP_EMPTY3(a,b,c) /*empty*/ -+#define LZO_PP_EMPTY4(a,b,c,d) /*empty*/ -+#define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/ -+#define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/ -+#define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/ - #if 1 - #define LZO_CPP_STRINGIZE(x) #x - #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) -@@ -248,12 +278,16 @@ - #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c - #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d - #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -+#define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f -+#define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g - #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) - #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) - #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) - #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) -+#define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f) -+#define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g) - #endif --#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) -+#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-!!(b))) - (o)) << 1) + (o)*!!(b)) - #if 1 && defined(__cplusplus) - # if !defined(__STDC_CONSTANT_MACROS) - # define __STDC_CONSTANT_MACROS 1 -@@ -263,9 +297,13 @@ - # endif - #endif - #if defined(__cplusplus) --# define LZO_EXTERN_C extern "C" -+# define LZO_EXTERN_C extern "C" -+# define LZO_EXTERN_C_BEGIN extern "C" { -+# define LZO_EXTERN_C_END } - #else --# define LZO_EXTERN_C extern -+# define LZO_EXTERN_C extern -+# define LZO_EXTERN_C_BEGIN /*empty*/ -+# define LZO_EXTERN_C_END /*empty*/ - #endif - #if !defined(__LZO_OS_OVERRIDE) - #if (LZO_OS_FREESTANDING) -@@ -366,12 +404,12 @@ - #elif defined(__VMS) - # define LZO_OS_VMS 1 - # define LZO_INFO_OS "vms" --#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -+#elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__) - # define LZO_OS_CONSOLE 1 - # define LZO_OS_CONSOLE_PS2 1 - # define LZO_INFO_OS "console" - # define LZO_INFO_OS_CONSOLE "ps2" --#elif (defined(__mips__) && defined(__psp__)) -+#elif defined(__mips__) && defined(__psp__) - # define LZO_OS_CONSOLE 1 - # define LZO_OS_CONSOLE_PSP 1 - # define LZO_INFO_OS "console" -@@ -399,9 +437,18 @@ - # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) - # define LZO_OS_POSIX_LINUX 1 - # define LZO_INFO_OS_POSIX "linux" --# elif defined(__APPLE__) || defined(__MACOS__) --# define LZO_OS_POSIX_MACOSX 1 --# define LZO_INFO_OS_POSIX "macosx" -+# elif defined(__APPLE__) && defined(__MACH__) -+# if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000) -+# define LZO_OS_POSIX_DARWIN 1040 -+# define LZO_INFO_OS_POSIX "darwin_iphone" -+# elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040) -+# define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ -+# define LZO_INFO_OS_POSIX "darwin" -+# else -+# define LZO_OS_POSIX_DARWIN 1 -+# define LZO_INFO_OS_POSIX "darwin" -+# endif -+# define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN - # elif defined(__minix__) || defined(__minix) - # define LZO_OS_POSIX_MINIX 1 - # define LZO_INFO_OS_POSIX "minix" -@@ -436,18 +483,18 @@ - #endif - #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - # if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) - # if (UINT_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) -@@ -463,59 +510,65 @@ - # define LZO_INFO_CC "sdcc" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) - #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) --# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) -+# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0)) - # define LZO_INFO_CC "Pathscale C" - # define LZO_INFO_CCVER __PATHSCALE__ --#elif defined(__INTEL_COMPILER) --# define LZO_CC_INTELC 1 -+# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) ++#endif ++#ifndef LZO_SIZEOF_SHORT ++#if defined(SIZEOF_SHORT) ++# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) ++#elif defined(__SIZEOF_SHORT__) ++# define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_INT ++#if defined(SIZEOF_INT) ++# define LZO_SIZEOF_INT (SIZEOF_INT) ++#elif defined(__SIZEOF_INT__) ++# define LZO_SIZEOF_INT (__SIZEOF_INT__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_LONG ++#if defined(SIZEOF_LONG) ++# define LZO_SIZEOF_LONG (SIZEOF_LONG) ++#elif defined(__SIZEOF_LONG__) ++# define LZO_SIZEOF_LONG (__SIZEOF_LONG__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_LONG_LONG ++#if defined(SIZEOF_LONG_LONG) ++# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) ++#elif defined(__SIZEOF_LONG_LONG__) ++# define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__) ++#endif ++#endif ++#ifndef LZO_SIZEOF___INT16 ++#if defined(SIZEOF___INT16) ++# define LZO_SIZEOF___INT16 (SIZEOF___INT16) ++#endif ++#endif ++#ifndef LZO_SIZEOF___INT32 ++#if defined(SIZEOF___INT32) ++# define LZO_SIZEOF___INT32 (SIZEOF___INT32) ++#endif ++#endif ++#ifndef LZO_SIZEOF___INT64 ++#if defined(SIZEOF___INT64) ++# define LZO_SIZEOF___INT64 (SIZEOF___INT64) ++#endif ++#endif ++#ifndef LZO_SIZEOF_VOID_P ++#if defined(SIZEOF_VOID_P) ++# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) ++#elif defined(__SIZEOF_POINTER__) ++# define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_SIZE_T ++#if defined(SIZEOF_SIZE_T) ++# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) ++#elif defined(__SIZEOF_SIZE_T__) ++# define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__) ++#endif ++#endif ++#ifndef LZO_SIZEOF_PTRDIFF_T ++#if defined(SIZEOF_PTRDIFF_T) ++# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) ++#elif defined(__SIZEOF_PTRDIFF_T__) ++# define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__) ++#endif ++#endif ++#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) ++#if !defined(LZO_SIZEOF_SHORT) ++# if (LZO_ARCH_CRAY_PVP) ++# define LZO_SIZEOF_SHORT 8 ++# elif (USHRT_MAX == LZO_0xffffL) ++# define LZO_SIZEOF_SHORT 2 ++# elif (__LZO_LSR(USHRT_MAX,7) == 1) ++# define LZO_SIZEOF_SHORT 1 ++# elif (__LZO_LSR(USHRT_MAX,15) == 1) ++# define LZO_SIZEOF_SHORT 2 ++# elif (__LZO_LSR(USHRT_MAX,31) == 1) ++# define LZO_SIZEOF_SHORT 4 ++# elif (__LZO_LSR(USHRT_MAX,63) == 1) ++# define LZO_SIZEOF_SHORT 8 ++# elif (__LZO_LSR(USHRT_MAX,127) == 1) ++# define LZO_SIZEOF_SHORT 16 ++# else ++# error "LZO_SIZEOF_SHORT" +# endif -+#elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0) -+# define LZO_CC_INTELC __INTEL_COMPILER - # define LZO_INFO_CC "Intel C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) --# if defined(_WIN32) || defined(_WIN64) --# define LZO_CC_SYNTAX_MSC 1 --# else --# define LZO_CC_SYNTAX_GNUC 1 -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_INTELC_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # endif - #elif defined(__POCC__) && defined(_WIN32) - # define LZO_CC_PELLESC 1 - # define LZO_INFO_CC "Pelles C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) --#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+#elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) - # if defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -+# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # else --# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -+# define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) - # endif -+# define LZO_CC_ARMCC __ARMCC_VERSION -+# define LZO_INFO_CC "ARM C Compiler" -+# define LZO_INFO_CCVER __VERSION__ -+#elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__) - # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) --# define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__) -+# define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0)) - # else --# define LZO_CC_CLANG_CLANG 0x010000L -+# define LZO_CC_CLANG 0x010000L ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short)) ++#if !defined(LZO_SIZEOF_INT) ++# if (LZO_ARCH_CRAY_PVP) ++# define LZO_SIZEOF_INT 8 ++# elif (UINT_MAX == LZO_0xffffL) ++# define LZO_SIZEOF_INT 2 ++# elif (UINT_MAX == LZO_0xffffffffL) ++# define LZO_SIZEOF_INT 4 ++# elif (__LZO_LSR(UINT_MAX,7) == 1) ++# define LZO_SIZEOF_INT 1 ++# elif (__LZO_LSR(UINT_MAX,15) == 1) ++# define LZO_SIZEOF_INT 2 ++# elif (__LZO_LSR(UINT_MAX,31) == 1) ++# define LZO_SIZEOF_INT 4 ++# elif (__LZO_LSR(UINT_MAX,63) == 1) ++# define LZO_SIZEOF_INT 8 ++# elif (__LZO_LSR(UINT_MAX,127) == 1) ++# define LZO_SIZEOF_INT 16 ++# else ++# error "LZO_SIZEOF_INT" +# endif -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_CLANG_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # endif --# define LZO_CC_CLANG LZO_CC_CLANG_GNUC - # define LZO_INFO_CC "clang" - # define LZO_INFO_CCVER __VERSION__ - #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) - # if defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -+# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) - # else --# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -+# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) - # endif - # define LZO_CC_LLVM LZO_CC_LLVM_GNUC - # define LZO_INFO_CC "llvm-gcc" - # define LZO_INFO_CCVER __VERSION__ --#elif defined(__GNUC__) && defined(__VERSION__) --# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) --# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) --# elif defined(__GNUC_MINOR__) --# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) --# else --# define LZO_CC_GNUC (__GNUC__ * 0x10000L) --# endif --# define LZO_INFO_CC "gcc" --# define LZO_INFO_CCVER __VERSION__ - #elif defined(__ACK__) && defined(_ACK) - # define LZO_CC_ACK 1 - # define LZO_INFO_CC "Amsterdam Compiler Kit C" - # define LZO_INFO_CCVER "unknown" -+#elif defined(__ARMCC_VERSION) && !defined(__GNUC__) -+# define LZO_CC_ARMCC __ARMCC_VERSION -+# define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION -+# define LZO_INFO_CC "ARM C Compiler" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION) - #elif defined(__AZTEC_C__) - # define LZO_CC_AZTECC 1 - # define LZO_INFO_CC "Aztec C" -@@ -540,10 +593,23 @@ - # define LZO_CC_DECC 1 - # define LZO_INFO_CC "DEC C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) -+#elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0) -+# define LZO_CC_GHS 1 -+# define LZO_INFO_CC "Green Hills C" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER) -+# if defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_GHS_MSC _MSC_VER -+# elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -+# define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int)) ++#if !defined(LZO_SIZEOF_LONG) ++# if (ULONG_MAX == LZO_0xffffffffL) ++# define LZO_SIZEOF_LONG 4 ++# elif (__LZO_LSR(ULONG_MAX,7) == 1) ++# define LZO_SIZEOF_LONG 1 ++# elif (__LZO_LSR(ULONG_MAX,15) == 1) ++# define LZO_SIZEOF_LONG 2 ++# elif (__LZO_LSR(ULONG_MAX,31) == 1) ++# define LZO_SIZEOF_LONG 4 ++# elif (__LZO_LSR(ULONG_MAX,39) == 1) ++# define LZO_SIZEOF_LONG 5 ++# elif (__LZO_LSR(ULONG_MAX,63) == 1) ++# define LZO_SIZEOF_LONG 8 ++# elif (__LZO_LSR(ULONG_MAX,127) == 1) ++# define LZO_SIZEOF_LONG 16 ++# else ++# error "LZO_SIZEOF_LONG" +# endif - #elif defined(__HIGHC__) - # define LZO_CC_HIGHC 1 - # define LZO_INFO_CC "MetaWare High C" - # define LZO_INFO_CCVER "unknown" -+#elif defined(__HP_aCC) && ((__HP_aCC-0) > 0) -+# define LZO_CC_HPACC __HP_aCC -+# define LZO_INFO_CC "HP aCC" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC) - #elif defined(__IAR_SYSTEMS_ICC__) - # define LZO_CC_IARC 1 - # define LZO_INFO_CC "IAR C" -@@ -552,10 +618,14 @@ - # else - # define LZO_INFO_CCVER "unknown" - # endif --#elif defined(__IBMC__) --# define LZO_CC_IBMC 1 -+#elif defined(__IBMC__) && ((__IBMC__-0) > 0) -+# define LZO_CC_IBMC __IBMC__ - # define LZO_INFO_CC "IBM C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) -+#elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0) -+# define LZO_CC_IBMC __IBMCPP__ -+# define LZO_INFO_CC "IBM C" -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__) - #elif defined(__KEIL__) && defined(__C166__) - # define LZO_CC_KEILC 1 - # define LZO_INFO_CC "Keil C" -@@ -572,16 +642,8 @@ - # else - # define LZO_INFO_CCVER "unknown" - # endif --#elif defined(_MSC_VER) --# define LZO_CC_MSC 1 --# define LZO_INFO_CC "Microsoft C" --# if defined(_MSC_FULL_VER) --# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) --# else --# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) --# endif --#elif defined(__MWERKS__) --# define LZO_CC_MWERKS 1 -+#elif defined(__MWERKS__) && ((__MWERKS__-0) > 0) -+# define LZO_CC_MWERKS __MWERKS__ - # define LZO_INFO_CC "Metrowerks C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) - #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) -@@ -592,6 +654,15 @@ - # define LZO_CC_PACIFICC 1 - # define LZO_INFO_CC "Pacific C" - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) -+#elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) -+# if defined(__PGIC_PATCHLEVEL__) -+# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0)) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__) ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long)) ++#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) ++#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) ++# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) ++# if (LZO_CC_GNUC >= 0x030300ul) ++# if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0)) ++# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG ++# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) ++# define LZO_SIZEOF_LONG_LONG 4 ++# endif ++# endif ++# endif ++#endif ++#endif ++#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) ++#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) ++#if (LZO_ARCH_I086 && LZO_CC_DMC) ++#elif (LZO_CC_CILLY) && defined(__GNUC__) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_OS_WIN64 || defined(_WIN64)) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) ++# define LZO_SIZEOF___INT64 8 ++#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64)) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64)) ++# define LZO_SIZEOF___INT64 8 ++#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64) ++# define LZO_SIZEOF_LONG_LONG 8 ++#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) ++#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) ++# define LZO_SIZEOF_LONG_LONG 8 ++#endif ++#endif ++#endif ++#if defined(__cplusplus) && (LZO_CC_GNUC) ++# if (LZO_CC_GNUC < 0x020800ul) ++# undef LZO_SIZEOF_LONG_LONG ++# endif ++#endif ++#if (LZO_CFG_NO_LONG_LONG) ++# undef LZO_SIZEOF_LONG_LONG ++#elif defined(__NO_LONG_LONG) ++# undef LZO_SIZEOF_LONG_LONG ++#elif defined(_NO_LONGLONG) ++# undef LZO_SIZEOF_LONG_LONG ++#endif ++#if !defined(LZO_WORDSIZE) ++#if (LZO_ARCH_ALPHA) ++# define LZO_WORDSIZE 8 ++#elif (LZO_ARCH_AMD64) ++# define LZO_WORDSIZE 8 ++#elif (LZO_ARCH_AVR) ++# define LZO_WORDSIZE 1 ++#elif (LZO_ARCH_H8300) ++# if defined(__NORMAL_MODE__) ++# define LZO_WORDSIZE 4 ++# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) ++# define LZO_WORDSIZE 4 +# else -+# define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0" ++# define LZO_WORDSIZE 2 +# endif -+# define LZO_INFO_CC "Portland Group PGI C" - #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) - # define LZO_CC_PGI 1 - # define LZO_INFO_CC "Portland Group PGI C" -@@ -606,7 +677,7 @@ - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) - #elif defined(__SUNPRO_C) - # define LZO_INFO_CC "SunPro C" --# if ((__SUNPRO_C)+0 > 0) -+# if ((__SUNPRO_C-0) > 0) - # define LZO_CC_SUNPROC __SUNPRO_C - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) - # else -@@ -615,7 +686,7 @@ - # endif - #elif defined(__SUNPRO_CC) - # define LZO_INFO_CC "SunPro C" --# if ((__SUNPRO_CC)+0 > 0) -+# if ((__SUNPRO_CC-0) > 0) - # define LZO_CC_SUNPROC __SUNPRO_CC - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) - # else -@@ -641,16 +712,46 @@ - #elif defined(__ZTC__) - # define LZO_CC_ZORTECHC 1 - # define LZO_INFO_CC "Zortech C" --# if (__ZTC__ == 0x310) -+# if ((__ZTC__-0) == 0x310) - # define LZO_INFO_CCVER "0x310" - # else - # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) - # endif -+#elif defined(__GNUC__) && defined(__VERSION__) -+# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0)) -+# elif defined(__GNUC_MINOR__) -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100) ++#elif (LZO_ARCH_I086) ++# define LZO_WORDSIZE 2 ++#elif (LZO_ARCH_IA64) ++# define LZO_WORDSIZE 8 ++#elif (LZO_ARCH_M16C) ++# define LZO_WORDSIZE 2 ++#elif (LZO_ARCH_SPU) ++# define LZO_WORDSIZE 4 ++#elif (LZO_ARCH_Z80) ++# define LZO_WORDSIZE 1 ++#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) ++# define LZO_WORDSIZE 8 ++#elif (LZO_OS_OS400 || defined(__OS400__)) ++# define LZO_WORDSIZE 8 ++#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) ++# define LZO_WORDSIZE 8 ++#endif ++#endif ++#if !defined(LZO_SIZEOF_VOID_P) ++#if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) ++# define LZO_SIZEOF_VOID_P 4 ++#elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) ++# define LZO_SIZEOF_VOID_P 8 ++#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) ++# define LZO_SIZEOF_VOID_P 8 ++#elif defined(__LP64__) || defined(__LP64) || defined(_LP64) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) ++# define LZO_SIZEOF_VOID_P 8 ++#elif (LZO_ARCH_AVR) ++# define LZO_SIZEOF_VOID_P 2 ++#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) ++# define LZO_SIZEOF_VOID_P 2 ++#elif (LZO_ARCH_H8300) ++# if defined(__NORMAL_MODE__) ++# define LZO_SIZEOF_VOID_P 2 ++# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) ++# define LZO_SIZEOF_VOID_P 4 +# else -+# define LZO_CC_GNUC (__GNUC__ * 0x10000L) ++# define LZO_SIZEOF_VOID_P 2 +# endif -+# define LZO_INFO_CC "gcc" -+# define LZO_INFO_CCVER __VERSION__ -+#elif defined(_MSC_VER) && ((_MSC_VER-0) > 0) -+# define LZO_CC_MSC _MSC_VER -+# define LZO_INFO_CC "Microsoft C" -+# if defined(_MSC_FULL_VER) -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) ++# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT ++# endif ++#elif (LZO_ARCH_I086) ++# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) ++# define LZO_SIZEOF_VOID_P 2 ++# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) ++# define LZO_SIZEOF_VOID_P 4 +# else -+# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) ++# error "invalid LZO_ARCH_I086 memory model" +# endif - #else - # define LZO_CC_UNKNOWN 1 - # define LZO_INFO_CC "unknown" - # define LZO_INFO_CCVER "unknown" - #endif -+#if (LZO_CC_GNUC) && defined(__OPEN64__) -+# if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__) -+# define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0)) -+# define LZO_CC_OPEN64_GNUC LZO_CC_GNUC ++#elif (LZO_ARCH_M16C) ++# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) ++# define LZO_SIZEOF_VOID_P 4 ++# else ++# define LZO_SIZEOF_VOID_P 2 +# endif -+#endif -+#if (LZO_CC_GNUC) && defined(__PCC__) -+# if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__) -+# define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0)) -+# define LZO_CC_PCC_GNUC LZO_CC_GNUC ++#elif (LZO_ARCH_SPU) ++# define LZO_SIZEOF_VOID_P 4 ++#elif (LZO_ARCH_Z80) ++# define LZO_SIZEOF_VOID_P 2 ++#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) ++# define LZO_SIZEOF_VOID_P 4 ++#elif (LZO_OS_OS400 || defined(__OS400__)) ++# if defined(__LLP64_IFC__) ++# define LZO_SIZEOF_VOID_P 8 ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG ++# else ++# define LZO_SIZEOF_VOID_P 16 ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +# endif ++#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) ++# define LZO_SIZEOF_VOID_P 8 ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG +#endif - #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) - # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" - #endif -@@ -668,8 +769,10 @@ - # define LZO_INFO_ARCH "generic" - #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - # define LZO_ARCH_I086 1 --# define LZO_ARCH_IA16 1 - # define LZO_INFO_ARCH "i086" -+#elif defined(__aarch64__) -+# define LZO_ARCH_ARM64 1 -+# define LZO_INFO_ARCH "arm64" - #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) - # define LZO_ARCH_ALPHA 1 - # define LZO_INFO_ARCH "alpha" -@@ -685,10 +788,10 @@ - # define LZO_INFO_ARCH "arm_thumb" - #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) - # define LZO_ARCH_ARM 1 --# if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) -+# if defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 1) - # define LZO_ARCH_ARM_THUMB 1 - # define LZO_INFO_ARCH "arm_thumb" --# elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) -+# elif defined(__CPU_MODE__) && ((__CPU_MODE__-0) == 2) - # define LZO_INFO_ARCH "arm" - # else - # define LZO_INFO_ARCH "arm" -@@ -806,53 +909,147 @@ - # error "FIXME - missing define for CPU architecture" - #endif - #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) --# error "FIXME - missing WIN32 define for CPU architecture" -+# error "FIXME - missing LZO_OS_WIN32 define for CPU architecture" - #endif - #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) --# error "FIXME - missing WIN64 define for CPU architecture" -+# error "FIXME - missing LZO_OS_WIN64 define for CPU architecture" - #endif - #if (LZO_OS_OS216 || LZO_OS_WIN16) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) - # define LZO_ARCH_I086PM 1 --# define LZO_ARCH_IA16PM 1 - #endif --#if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM) --# error "this should not happen" -+#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) -+# define LZO_ARCH_X64 1 -+#elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_AMD64 1 - #endif --#if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086) --# error "this should not happen" -+#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) -+# define LZO_ARCH_AARCH64 1 -+#elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_ARM64 1 +#endif -+#if (LZO_ARCH_I386 && !LZO_ARCH_X86) -+# define LZO_ARCH_X86 1 -+#elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE) -+# define LZO_ARCH_I386 1 ++#if !defined(LZO_SIZEOF_VOID_P) ++# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG ++#endif ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) ++#if !defined(LZO_SIZEOF_SIZE_T) ++#if (LZO_ARCH_I086 || LZO_ARCH_M16C) ++# define LZO_SIZEOF_SIZE_T 2 ++#endif ++#endif ++#if !defined(LZO_SIZEOF_SIZE_T) ++# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P ++#endif ++#if defined(offsetof) ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t)) ++#endif ++#if !defined(LZO_SIZEOF_PTRDIFF_T) ++#if (LZO_ARCH_I086) ++# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P ++# elif (LZO_MM_COMPACT || LZO_MM_LARGE) ++# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) ++# define LZO_SIZEOF_PTRDIFF_T 4 ++# else ++# define LZO_SIZEOF_PTRDIFF_T 2 ++# endif ++# else ++# error "invalid LZO_ARCH_I086 memory model" ++# endif ++#endif +#endif -+#if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64) -+# error "unexpected configuration - check your compiler defines" ++#if !defined(LZO_SIZEOF_PTRDIFF_T) ++# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T +#endif -+#if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) -+# error "unexpected configuration - check your compiler defines" ++#if defined(offsetof) ++LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)) +#endif -+#if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86) -+# error "unexpected configuration - check your compiler defines" ++#if !defined(LZO_WORDSIZE) ++# define LZO_WORDSIZE LZO_SIZEOF_VOID_P +#endif -+#if (LZO_ARCH_ARM_THUMB && !LZO_ARCH_ARM) -+# error "unexpected configuration - check your compiler defines" ++#if (LZO_ABI_NEUTRAL_ENDIAN) ++# undef LZO_ABI_BIG_ENDIAN ++# undef LZO_ABI_LITTLE_ENDIAN ++#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) ++#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) ++# if (__LITTLE_ENDIAN__ == 1) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++# else ++# define LZO_ABI_BIG_ENDIAN 1 ++# endif ++#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC) ++# if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) ++# error "unexpected configuration - check your compiler defines" ++# elif defined(__BIG_ENDIAN) ++# define LZO_ABI_BIG_ENDIAN 1 ++# else ++# define LZO_ABI_LITTLE_ENDIAN 1 ++# endif ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__) ++# define LZO_ABI_LITTLE_ENDIAN 1 ++#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) ++# define LZO_ABI_BIG_ENDIAN 1 ++#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) ++# define LZO_ABI_LITTLE_ENDIAN 1 +#endif -+#if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM_THUMB) -+# error "unexpected configuration - check your compiler defines" +#endif -+#if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM_THUMB) ++#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) +# error "unexpected configuration - check your compiler defines" +#endif -+#if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2) -+# error "unexpected configuration - check your compiler defines" ++#if (LZO_ABI_BIG_ENDIAN) ++# define LZO_INFO_ABI_ENDIAN "be" ++#elif (LZO_ABI_LITTLE_ENDIAN) ++# define LZO_INFO_ABI_ENDIAN "le" ++#elif (LZO_ABI_NEUTRAL_ENDIAN) ++# define LZO_INFO_ABI_ENDIAN "neutral" ++#endif ++#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) ++# define LZO_ABI_I8LP16 1 ++# define LZO_INFO_ABI_PM "i8lp16" ++#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) ++# define LZO_ABI_ILP16 1 ++# define LZO_INFO_ABI_PM "ilp16" ++#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) ++# define LZO_ABI_LP32 1 ++# define LZO_INFO_ABI_PM "lp32" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) ++# define LZO_ABI_ILP32 1 ++# define LZO_INFO_ABI_PM "ilp32" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) ++# define LZO_ABI_LLP64 1 ++# define LZO_INFO_ABI_PM "llp64" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) ++# define LZO_ABI_LP64 1 ++# define LZO_INFO_ABI_PM "lp64" ++#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) ++# define LZO_ABI_ILP64 1 ++# define LZO_INFO_ABI_PM "ilp64" ++#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) ++# define LZO_ABI_IP32L64 1 ++# define LZO_INFO_ABI_PM "ip32l64" +#endif -+#if (LZO_ARCH_I086PM && !LZO_ARCH_I086) -+# error "unexpected configuration - check your compiler defines" - #endif - #if (LZO_ARCH_I086) - # if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #if (LZO_ARCH_I386) - # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - # if (ULONG_MAX != LZO_0xffffffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif --#if !defined(__LZO_MM_OVERRIDE) -+#if (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+# if !defined(LZO_TARGET_FEATURE_SSE2) -+# if defined(__SSE2__) -+# define LZO_TARGET_FEATURE_SSE2 1 -+# elif defined(_MSC_VER) && ((defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2)) || defined(_M_AMD64)) -+# define LZO_TARGET_FEATURE_SSE2 1 -+# endif ++#if 0 ++#elif !defined(__LZO_LIBC_OVERRIDE) ++#if (LZO_LIBC_NAKED) ++# define LZO_INFO_LIBC "naked" ++#elif (LZO_LIBC_FREESTANDING) ++# define LZO_INFO_LIBC "freestanding" ++#elif (LZO_LIBC_MOSTLY_FREESTANDING) ++# define LZO_INFO_LIBC "mfreestanding" ++#elif (LZO_LIBC_ISOC90) ++# define LZO_INFO_LIBC "isoc90" ++#elif (LZO_LIBC_ISOC99) ++# define LZO_INFO_LIBC "isoc99" ++#elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION) ++# define LZO_LIBC_ISOC90 1 ++# define LZO_INFO_LIBC "isoc90" ++#elif defined(__dietlibc__) ++# define LZO_LIBC_DIETLIBC 1 ++# define LZO_INFO_LIBC "dietlibc" ++#elif defined(_NEWLIB_VERSION) ++# define LZO_LIBC_NEWLIB 1 ++# define LZO_INFO_LIBC "newlib" ++#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) ++# if defined(__UCLIBC_SUBLEVEL__) ++# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0)) ++# else ++# define LZO_LIBC_UCLIBC 0x00090bL +# endif -+# if !defined(LZO_TARGET_FEATURE_SSSE3) -+# if (LZO_TARGET_FEATURE_SSE2) -+# if defined(__SSSE3__) -+# define LZO_TARGET_FEATURE_SSSE3 1 -+# elif defined(_MSC_VER) && defined(__AVX__) -+# define LZO_TARGET_FEATURE_SSSE3 1 ++# define LZO_INFO_LIBC "uc" "libc" ++#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) ++# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100) ++# define LZO_INFO_LIBC "glibc" ++#elif (LZO_CC_MWERKS) && defined(__MSL__) ++# define LZO_LIBC_MSL __MSL__ ++# define LZO_INFO_LIBC "msl" ++#elif 1 && defined(__IAR_SYSTEMS_ICC__) ++# define LZO_LIBC_ISOC90 1 ++# define LZO_INFO_LIBC "isoc90" ++#else ++# define LZO_LIBC_DEFAULT 1 ++# define LZO_INFO_LIBC "default" ++#endif ++#endif ++#if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) ++# define LZO_ASM_SYNTAX_MSC 1 ++#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) ++#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) ++#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) ++# define LZO_ASM_SYNTAX_GNUC 1 ++#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) ++# define LZO_ASM_SYNTAX_GNUC 1 ++#elif (LZO_CC_GNUC) ++# define LZO_ASM_SYNTAX_GNUC 1 ++#endif ++#if (LZO_ASM_SYNTAX_GNUC) ++#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) ++# define __LZO_ASM_CLOBBER "ax" ++# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ ++# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ ++# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ ++#elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) ++# define __LZO_ASM_CLOBBER "memory" ++# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ ++# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" ++# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ ++#else ++# define __LZO_ASM_CLOBBER "cc", "memory" ++# define __LZO_ASM_CLOBBER_LIST_CC : "cc" ++# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" ++# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ ++#endif ++#endif + #if (LZO_ARCH_ALPHA) +-# define LZO_OPT_AVOID_UINT_INDEX 1 +-# define LZO_OPT_AVOID_SHORT 1 +-# define LZO_OPT_AVOID_USHORT 1 ++# define LZO_OPT_AVOID_UINT_INDEX 1 + #elif (LZO_ARCH_AMD64) +-# define LZO_OPT_AVOID_INT_INDEX 1 +-# define LZO_OPT_AVOID_UINT_INDEX 1 +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 +-# define LZO_OPT_UNALIGNED64 1 +-#elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) ++# define LZO_OPT_AVOID_INT_INDEX 1 ++# define LZO_OPT_AVOID_UINT_INDEX 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED64 ++# define LZO_OPT_UNALIGNED64 1 ++# endif + #elif (LZO_ARCH_ARM) +-# define LZO_OPT_AVOID_SHORT 1 +-# define LZO_OPT_AVOID_USHORT 1 ++# if defined(__ARM_FEATURE_UNALIGNED) ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 7) ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 6) && !defined(__TARGET_PROFILE_M) ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 +# endif +# endif ++#elif (LZO_ARCH_ARM64) ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 +# endif -+# if !defined(LZO_TARGET_FEATURE_SSE4_2) -+# if (LZO_TARGET_FEATURE_SSSE3) -+# if defined(__SSE4_2__) -+# define LZO_TARGET_FEATURE_SSE4_2 1 ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED64 ++# define LZO_OPT_UNALIGNED64 1 ++# endif + #elif (LZO_ARCH_CRIS) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif + #elif (LZO_ARCH_I386) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif + #elif (LZO_ARCH_IA64) +-# define LZO_OPT_AVOID_INT_INDEX 1 +-# define LZO_OPT_AVOID_UINT_INDEX 1 +-# define LZO_OPT_PREFER_POSTINC 1 ++# define LZO_OPT_AVOID_INT_INDEX 1 ++# define LZO_OPT_AVOID_UINT_INDEX 1 ++# define LZO_OPT_PREFER_POSTINC 1 + #elif (LZO_ARCH_M68K) +-# define LZO_OPT_PREFER_POSTINC 1 +-# define LZO_OPT_PREFER_PREDEC 1 ++# define LZO_OPT_PREFER_POSTINC 1 ++# define LZO_OPT_PREFER_PREDEC 1 + # if defined(__mc68020__) && !defined(__mcoldfire__) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 ++# endif + # endif + #elif (LZO_ARCH_MIPS) +-# define LZO_OPT_AVOID_UINT_INDEX 1 ++# define LZO_OPT_AVOID_UINT_INDEX 1 + #elif (LZO_ARCH_POWERPC) +-# define LZO_OPT_PREFER_PREINC 1 +-# define LZO_OPT_PREFER_PREDEC 1 ++# define LZO_OPT_PREFER_PREINC 1 ++# define LZO_OPT_PREFER_PREDEC 1 + # if (LZO_ABI_BIG_ENDIAN) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 ++# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 +# endif -+# endif -+# endif -+# if !defined(LZO_TARGET_FEATURE_AVX) -+# if (LZO_TARGET_FEATURE_SSSE3) -+# if defined(__AVX__) -+# define LZO_TARGET_FEATURE_AVX 1 ++# if (LZO_WORDSIZE == 8) ++# ifndef LZO_OPT_UNALIGNED64 ++# define LZO_OPT_UNALIGNED64 1 ++# endif +# endif + # endif + #elif (LZO_ARCH_S390) +-# define LZO_OPT_UNALIGNED16 1 +-# define LZO_OPT_UNALIGNED32 1 +-# if (LZO_SIZEOF_SIZE_T == 8) +-# define LZO_OPT_UNALIGNED64 1 ++# ifndef LZO_OPT_UNALIGNED16 ++# define LZO_OPT_UNALIGNED16 1 +# endif ++# ifndef LZO_OPT_UNALIGNED32 ++# define LZO_OPT_UNALIGNED32 1 +# endif -+# if !defined(LZO_TARGET_FEATURE_AVX2) -+# if (LZO_TARGET_FEATURE_AVX) -+# if defined(__AVX2__) -+# define LZO_TARGET_FEATURE_AVX2 1 ++# if (LZO_WORDSIZE == 8) ++# ifndef LZO_OPT_UNALIGNED64 ++# define LZO_OPT_UNALIGNED64 1 +# endif -+# endif -+# endif + # endif + #elif (LZO_ARCH_SH) +-# define LZO_OPT_PREFER_POSTINC 1 +-# define LZO_OPT_PREFER_PREDEC 1 ++# define LZO_OPT_PREFER_POSTINC 1 ++# define LZO_OPT_PREFER_PREDEC 1 + #endif + #ifndef LZO_CFG_NO_INLINE_ASM +-#if (LZO_CC_LLVM) ++#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) + # define LZO_CFG_NO_INLINE_ASM 1 ++#elif (LZO_CC_LLVM) ++# define LZO_CFG_NO_INLINE_ASM 1 +#endif -+#if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2)) -+# error "unexpected configuration - check your compiler defines" + #endif ++#if (LZO_CFG_NO_INLINE_ASM) ++# undef LZO_ASM_SYNTAX_MSC ++# undef LZO_ASM_SYNTAX_GNUC ++# undef __LZO_ASM_CLOBBER ++# undef __LZO_ASM_CLOBBER_LIST_CC ++# undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY ++# undef __LZO_ASM_CLOBBER_LIST_EMPTY + #endif + #ifndef LZO_CFG_NO_UNALIGNED + #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) +@@ -1804,25 +2594,6 @@ extern "C" { + # undef LZO_OPT_UNALIGNED32 + # undef LZO_OPT_UNALIGNED64 + #endif +-#if (LZO_CFG_NO_INLINE_ASM) +-#elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) +-# define LZO_ASM_SYNTAX_MSC 1 +-#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) +-#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) +-#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) +-# define LZO_ASM_SYNTAX_GNUC 1 +-#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) +-# define LZO_ASM_SYNTAX_GNUC 1 +-#endif +-#if (LZO_ASM_SYNTAX_GNUC) +-#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) +-# define __LZO_ASM_CLOBBER "ax" +-#elif (LZO_CC_INTELC) +-# define __LZO_ASM_CLOBBER "memory" +-#else +-# define __LZO_ASM_CLOBBER "cc", "memory" +-#endif +-#endif + #if defined(__LZO_INFOSTR_MM) + #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) + # define __LZO_INFOSTR_MM "" +@@ -1866,6 +2637,381 @@ extern "C" { + #define LZO_INFO_STRING \ + LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ + " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER ++#if !(LZO_CFG_SKIP_LZO_TYPES) ++#if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0)) ++# error "missing defines for sizes" +#endif -+#if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3)) -+# error "unexpected configuration - check your compiler defines" ++#if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0)) ++# error "missing defines for sizes" +#endif -+#if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3)) -+# error "unexpected configuration - check your compiler defines" ++#if !defined(lzo_llong_t) ++#if (LZO_SIZEOF_LONG_LONG+0 > 0) ++__lzo_gnuc_extension__ typedef long long lzo_llong_t__; ++__lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__; ++# define lzo_llong_t lzo_llong_t__ ++# define lzo_ullong_t lzo_ullong_t__ +#endif -+#if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX)) -+# error "unexpected configuration - check your compiler defines" +#endif -+#if (LZO_ARCH_ARM) -+# if !defined(LZO_TARGET_FEATURE_NEON) -+# if defined(__ARM_NEON__) -+# define LZO_TARGET_FEATURE_NEON 1 -+# endif -+# endif -+#elif (LZO_ARCH_ARM64) -+# if !defined(LZO_TARGET_FEATURE_NEON) -+# if 1 -+# define LZO_TARGET_FEATURE_NEON 1 -+# endif -+# endif ++#if !defined(lzo_int16e_t) ++#if (LZO_SIZEOF_LONG == 2) ++# define lzo_int16e_t long ++# define lzo_uint16e_t unsigned long ++#elif (LZO_SIZEOF_INT == 2) ++# define lzo_int16e_t int ++# define lzo_uint16e_t unsigned int ++#elif (LZO_SIZEOF_SHORT == 2) ++# define lzo_int16e_t short int ++# define lzo_uint16e_t unsigned short int ++#elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) ++ typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__))); ++ typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__))); ++# define lzo_int16e_t lzo_int16e_hi_t__ ++# define lzo_uint16e_t lzo_uint16e_hi_t__ ++#elif (LZO_SIZEOF___INT16 == 2) ++# define lzo_int16e_t __int16 ++# define lzo_uint16e_t unsigned __int16 ++#else +#endif -+#if 0 -+#elif !defined(__LZO_MM_OVERRIDE) - #if (LZO_ARCH_I086) - #if (UINT_MAX != LZO_0xffffL) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - #endif - #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) - # define LZO_MM_TINY 1 -@@ -879,7 +1076,7 @@ - #elif (LZO_CC_ZORTECHC && defined(__VCM__)) - # define LZO_MM_LARGE 1 - #else --# error "unknown memory model" -+# error "unknown LZO_ARCH_I086 memory model" - #endif - #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) - #define LZO_HAVE_MM_HUGE_PTR 1 -@@ -902,10 +1099,10 @@ - #endif - #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) - # if (LZO_OS_DOS16) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # elif (LZO_CC_ZORTECHC) - # else --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - # endif - #endif - #ifdef __cplusplus -@@ -937,7 +1134,7 @@ extern "C" { - #endif - #elif (LZO_ARCH_C166) - #if !defined(__MODEL__) --# error "FIXME - C166 __MODEL__" -+# error "FIXME - LZO_ARCH_C166 __MODEL__" - #elif ((__MODEL__) == 0) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 1) -@@ -951,11 +1148,11 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - C166 __MODEL__" -+# error "FIXME - LZO_ARCH_C166 __MODEL__" - #endif - #elif (LZO_ARCH_MCS251) - #if !defined(__MODEL__) --# error "FIXME - MCS251 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS251 __MODEL__" - #elif ((__MODEL__) == 0) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 2) -@@ -967,11 +1164,11 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - MCS251 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS251 __MODEL__" - #endif - #elif (LZO_ARCH_MCS51) - #if !defined(__MODEL__) --# error "FIXME - MCS51 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS51 __MODEL__" - #elif ((__MODEL__) == 1) - # define LZO_MM_SMALL 1 - #elif ((__MODEL__) == 2) -@@ -983,7 +1180,7 @@ extern "C" { - #elif ((__MODEL__) == 5) - # define LZO_MM_XSMALL 1 - #else --# error "FIXME - MCS51 __MODEL__" -+# error "FIXME - LZO_ARCH_MCS51 __MODEL__" - #endif - #elif (LZO_ARCH_CRAY_PVP) - # define LZO_MM_PVP 1 -@@ -1010,35 +1207,818 @@ extern "C" { - # error "unknown memory model" - #endif - #endif -+#if !defined(__lzo_gnuc_extension__) -+#if (LZO_CC_GNUC >= 0x020800ul) -+# define __lzo_gnuc_extension__ __extension__ -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_gnuc_extension__ __extension__ -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_gnuc_extension__ __extension__ ++#endif ++#if defined(lzo_int16e_t) ++# define LZO_SIZEOF_LZO_INT16E_T 2 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T) ++#endif ++#if !defined(lzo_int32e_t) ++#if (LZO_SIZEOF_LONG == 4) ++# define lzo_int32e_t long int ++# define lzo_uint32e_t unsigned long int ++#elif (LZO_SIZEOF_INT == 4) ++# define lzo_int32e_t int ++# define lzo_uint32e_t unsigned int ++#elif (LZO_SIZEOF_SHORT == 4) ++# define lzo_int32e_t short int ++# define lzo_uint32e_t unsigned short int ++#elif (LZO_SIZEOF_LONG_LONG == 4) ++# define lzo_int32e_t lzo_llong_t ++# define lzo_uint32e_t lzo_ullong_t ++#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) ++ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); ++ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); ++# define lzo_int32e_t lzo_int32e_si_t__ ++# define lzo_uint32e_t lzo_uint32e_si_t__ ++#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) ++ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); ++ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); ++# define lzo_int32e_t lzo_int32e_si_t__ ++# define lzo_uint32e_t lzo_uint32e_si_t__ ++# define LZO_INT32_C(c) (c##LL) ++# define LZO_UINT32_C(c) (c##ULL) ++#elif (LZO_SIZEOF___INT32 == 4) ++# define lzo_int32e_t __int32 ++# define lzo_uint32e_t unsigned __int32 +#else +#endif +#endif -+#if !defined(__lzo_gnuc_extension__) -+# define __lzo_gnuc_extension__ /*empty*/ ++#if defined(lzo_int32e_t) ++# define LZO_SIZEOF_LZO_INT32E_T 4 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T) ++#endif ++#if !defined(lzo_int64e_t) ++#if (LZO_SIZEOF___INT64 == 8) ++# if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64) ++# define LZO_CFG_TYPE_PREFER___INT64 1 ++# endif +#endif -+#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0 -+# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 -+# elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200)) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 ++#if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) ++# define lzo_int64e_t int ++# define lzo_uint64e_t unsigned int ++# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_INT ++#elif (LZO_SIZEOF_LONG == 8) ++# define lzo_int64e_t long int ++# define lzo_uint64e_t unsigned long int ++# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG ++#elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64) ++# define lzo_int64e_t lzo_llong_t ++# define lzo_uint64e_t lzo_ullong_t ++# if (LZO_CC_BORLANDC) ++# define LZO_INT64_C(c) ((c) + 0ll) ++# define LZO_UINT64_C(c) ((c) + 0ull) ++# elif 0 ++# define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL)) ++# define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL)) +# else -+# define LZO_CFG_USE_NEW_STYLE_CASTS 1 ++# define LZO_INT64_C(c) (c##LL) ++# define LZO_UINT64_C(c) (c##ULL) ++# endif ++# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG_LONG ++#elif (LZO_SIZEOF___INT64 == 8) ++# define lzo_int64e_t __int64 ++# define lzo_uint64e_t unsigned __int64 ++# if (LZO_CC_BORLANDC) ++# define LZO_INT64_C(c) ((c) + 0i64) ++# define LZO_UINT64_C(c) ((c) + 0ui64) ++# else ++# define LZO_INT64_C(c) (c##i64) ++# define LZO_UINT64_C(c) (c##ui64) +# endif ++# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF___INT64 ++#else +#endif -+#if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 +#endif -+#if !defined(__cplusplus) -+# if defined(LZO_CFG_USE_NEW_STYLE_CASTS) -+# undef LZO_CFG_USE_NEW_STYLE_CASTS -+# endif -+# define LZO_CFG_USE_NEW_STYLE_CASTS 0 ++#if defined(lzo_int64e_t) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T) +#endif -+#if !defined(LZO_REINTERPRET_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast (e)) -+# endif ++#if !defined(lzo_int32l_t) ++#if defined(lzo_int32e_t) ++# define lzo_int32l_t lzo_int32e_t ++# define lzo_uint32l_t lzo_uint32e_t ++# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T ++#elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) ++# define lzo_int32l_t int ++# define lzo_uint32l_t unsigned int ++# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT ++#elif (LZO_SIZEOF_LONG >= 4) ++# define lzo_int32l_t long int ++# define lzo_uint32l_t unsigned long int ++# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG ++#else ++# error "lzo_int32l_t" +#endif -+#if !defined(LZO_REINTERPRET_CAST) -+# define LZO_REINTERPRET_CAST(t,e) ((t) (e)) +#endif -+#if !defined(LZO_STATIC_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_STATIC_CAST(t,e) (static_cast (e)) -+# endif ++#if 1 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T) +#endif -+#if !defined(LZO_STATIC_CAST) -+# define LZO_STATIC_CAST(t,e) ((t) (e)) ++#if !defined(lzo_int64l_t) ++#if defined(lzo_int64e_t) ++# define lzo_int64l_t lzo_int64e_t ++# define lzo_uint64l_t lzo_uint64e_t ++# define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T ++#else +#endif -+#if !defined(LZO_STATIC_CAST2) -+# define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e)) +#endif -+#if !defined(LZO_UNCONST_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNCONST_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNCONST_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e))))) -+# endif ++#if defined(lzo_int64l_t) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T) +#endif -+#if !defined(LZO_UNCONST_CAST) -+# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e)))) ++#if !defined(lzo_int32f_t) ++#if (LZO_SIZEOF_SIZE_T >= 8) ++# define lzo_int32f_t lzo_int64l_t ++# define lzo_uint32f_t lzo_uint64l_t ++# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T ++#else ++# define lzo_int32f_t lzo_int32l_t ++# define lzo_uint32f_t lzo_uint32l_t ++# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T +#endif -+#if !defined(LZO_UNCONST_VOLATILE_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) -+# endif +#endif -+#if !defined(LZO_UNCONST_VOLATILE_CAST) -+# define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e)))) ++#if 1 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T) +#endif -+#if !defined(LZO_UNVOLATILE_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNVOLATILE_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e))))) -+# endif ++#if !defined(lzo_int64f_t) ++#if defined(lzo_int64l_t) ++# define lzo_int64f_t lzo_int64l_t ++# define lzo_uint64f_t lzo_uint64l_t ++# define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T ++#else +#endif -+#if !defined(LZO_UNVOLATILE_CAST) -+# define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e)))) +#endif -+#if !defined(LZO_UNVOLATILE_CONST_CAST) -+# if (LZO_CFG_USE_NEW_STYLE_CASTS) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast (e)) -+# elif (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e)) -+# elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e))))) -+# endif ++#if defined(lzo_int64f_t) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T) +#endif -+#if !defined(LZO_UNVOLATILE_CONST_CAST) -+# define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e)))) ++#if !defined(lzo_intptr_t) ++#if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16)) ++# define __LZO_INTPTR_T_IS_POINTER 1 ++ typedef char* lzo_intptr_t; ++ typedef char* lzo_uintptr_t; ++# define lzo_intptr_t lzo_intptr_t ++# define lzo_uintptr_t lzo_uintptr_t ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P ++#elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4)) ++ typedef __w64 int lzo_intptr_t; ++ typedef __w64 unsigned int lzo_uintptr_t; ++# define lzo_intptr_t lzo_intptr_t ++# define lzo_uintptr_t lzo_uintptr_t ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT ++#elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P) ++# define lzo_intptr_t short ++# define lzo_uintptr_t unsigned short ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT ++#elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) ++# define lzo_intptr_t int ++# define lzo_uintptr_t unsigned int ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT ++#elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P) ++# define lzo_intptr_t long ++# define lzo_uintptr_t unsigned long ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG ++#elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P) ++# define lzo_intptr_t lzo_int64l_t ++# define lzo_uintptr_t lzo_uint64l_t ++# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T ++#else ++# error "lzo_intptr_t" +#endif -+#if !defined(LZO_PCAST) -+# if (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_PCAST(t,e) ((t) (e)) -+# endif +#endif -+#if !defined(LZO_PCAST) -+# define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e)) ++#if 1 ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *)) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t)) +#endif -+#if !defined(LZO_CCAST) -+# if (LZO_HAVE_MM_HUGE_PTR) -+# define LZO_CCAST(t,e) ((t) (e)) -+# endif ++#if !defined(lzo_word_t) ++#if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0) ++#if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER) ++# define lzo_word_t lzo_uintptr_t ++# define lzo_sword_t lzo_intptr_t ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T ++#elif (LZO_WORDSIZE == LZO_SIZEOF_LONG) ++# define lzo_word_t unsigned long ++# define lzo_sword_t long ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG ++#elif (LZO_WORDSIZE == LZO_SIZEOF_INT) ++# define lzo_word_t unsigned int ++# define lzo_sword_t int ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT ++#elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT) ++# define lzo_word_t unsigned short ++# define lzo_sword_t short ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT ++#elif (LZO_WORDSIZE == 1) ++# define lzo_word_t unsigned char ++# define lzo_sword_t signed char ++# define LZO_SIZEOF_LZO_WORD_T 1 ++#elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T) ++# define lzo_word_t lzo_uint64l_t ++# define lzo_sword_t lzo_int64l_t ++# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T ++#elif (LZO_ARCH_SPU) && (LZO_CC_GNUC) ++#if 0 ++ typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__))); ++ typedef int lzo_sword_t __attribute__((__mode__(__V16QI__))); ++# define lzo_word_t lzo_word_t ++# define lzo_sword_t lzo_sword_t ++# define LZO_SIZEOF_LZO_WORD_T 16 +#endif -+#if !defined(LZO_CCAST) -+# define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e)) ++#else ++# error "lzo_word_t" ++#endif ++#endif ++#endif ++#if 1 && defined(lzo_word_t) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE) ++ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE) ++#endif ++#if 1 ++#define lzo_int8_t signed char ++#define lzo_uint8_t unsigned char ++#define LZO_SIZEOF_LZO_INT8_T 1 ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t)) ++#endif ++#if defined(lzo_int16e_t) ++#define lzo_int16_t lzo_int16e_t ++#define lzo_uint16_t lzo_uint16e_t ++#define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t)) +#endif -+#if !defined(LZO_ICONV) -+# define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e) ++#if defined(lzo_int32e_t) ++#define lzo_int32_t lzo_int32e_t ++#define lzo_uint32_t lzo_uint32e_t ++#define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t)) +#endif -+#if !defined(LZO_ICAST) -+# define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e) ++#if defined(lzo_int64e_t) ++#define lzo_int64_t lzo_int64e_t ++#define lzo_uint64_t lzo_uint64e_t ++#define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t)) +#endif -+#if !defined(LZO_ITRUNC) -+# define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e) ++#if 1 ++#define lzo_int_least32_t lzo_int32l_t ++#define lzo_uint_least32_t lzo_uint32l_t ++#define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t)) +#endif -+#if !defined(__lzo_cte) -+# if (LZO_CC_MSC || LZO_CC_WATCOMC) -+# define __lzo_cte(e) ((void)0,(e)) -+# elif 1 -+# define __lzo_cte(e) ((void)0,(e)) -+# endif ++#if defined(lzo_int64l_t) ++#define lzo_int_least64_t lzo_int64l_t ++#define lzo_uint_least64_t lzo_uint64l_t ++#define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t)) +#endif -+#if !defined(__lzo_cte) -+# define __lzo_cte(e) (e) ++#if 1 ++#define lzo_int_fast32_t lzo_int32f_t ++#define lzo_uint_fast32_t lzo_uint32f_t ++#define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t)) +#endif -+#if !defined(LZO_BLOCK_BEGIN) -+# define LZO_BLOCK_BEGIN do { -+# define LZO_BLOCK_END } while __lzo_cte(0) ++#if defined(lzo_int64f_t) ++#define lzo_int_fast64_t lzo_int64f_t ++#define lzo_uint_fast64_t lzo_uint64f_t ++#define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t)) +#endif -+#if !defined(LZO_UNUSED) -+# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) -+# define LZO_UNUSED(var) ((void) &var) -+# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) -+# define LZO_UNUSED(var) if (&var) ; else -+# elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul)) -+# define LZO_UNUSED(var) ((void) &var) -+# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define LZO_UNUSED(var) ((void) var) -+# elif (LZO_CC_MSC && (_MSC_VER < 900)) -+# define LZO_UNUSED(var) if (&var) ; else -+# elif (LZO_CC_KEILC) -+# define LZO_UNUSED(var) {LZO_EXTERN_C int lzo_unused__[1-2*!(sizeof(var)>0)];} -+# elif (LZO_CC_PACIFICC) -+# define LZO_UNUSED(var) ((void) sizeof(var)) -+# elif (LZO_CC_WATCOMC) && defined(__cplusplus) -+# define LZO_UNUSED(var) ((void) var) ++#if !defined(LZO_INT16_C) ++# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2) ++# define LZO_INT16_C(c) ((c) + 0) ++# define LZO_UINT16_C(c) ((c) + 0U) ++# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2) ++# define LZO_INT16_C(c) ((c) + 0L) ++# define LZO_UINT16_C(c) ((c) + 0UL) ++# elif (LZO_SIZEOF_INT >= 2) ++# define LZO_INT16_C(c) (c) ++# define LZO_UINT16_C(c) (c##U) ++# elif (LZO_SIZEOF_LONG >= 2) ++# define LZO_INT16_C(c) (c##L) ++# define LZO_UINT16_C(c) (c##UL) +# else -+# define LZO_UNUSED(var) ((void) &var) ++# error "LZO_INT16_C" +# endif +#endif -+#if !defined(LZO_UNUSED_FUNC) -+# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) -+# define LZO_UNUSED_FUNC(func) ((void) func) -+# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) -+# define LZO_UNUSED_FUNC(func) if (func) ; else -+# elif (LZO_CC_CLANG || LZO_CC_LLVM) -+# define LZO_UNUSED_FUNC(func) ((void) &func) -+# elif (LZO_CC_MSC && (_MSC_VER < 900)) -+# define LZO_UNUSED_FUNC(func) if (func) ; else -+# elif (LZO_CC_MSC) -+# define LZO_UNUSED_FUNC(func) ((void) &func) -+# elif (LZO_CC_KEILC || LZO_CC_PELLESC) -+# define LZO_UNUSED_FUNC(func) {LZO_EXTERN_C int lzo_unused_func__[1-2*!(sizeof((int)func)>0)];} ++#if !defined(LZO_INT32_C) ++# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4) ++# define LZO_INT32_C(c) ((c) + 0) ++# define LZO_UINT32_C(c) ((c) + 0U) ++# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4) ++# define LZO_INT32_C(c) ((c) + 0L) ++# define LZO_UINT32_C(c) ((c) + 0UL) ++# elif (LZO_SIZEOF_INT >= 4) ++# define LZO_INT32_C(c) (c) ++# define LZO_UINT32_C(c) (c##U) ++# elif (LZO_SIZEOF_LONG >= 4) ++# define LZO_INT32_C(c) (c##L) ++# define LZO_UINT32_C(c) (c##UL) ++# elif (LZO_SIZEOF_LONG_LONG >= 4) ++# define LZO_INT32_C(c) (c##LL) ++# define LZO_UINT32_C(c) (c##ULL) +# else -+# define LZO_UNUSED_FUNC(func) ((void) func) ++# error "LZO_INT32_C" +# endif +#endif -+#if !defined(LZO_UNUSED_LABEL) -+# if (LZO_CC_CLANG >= 0x020800ul) -+# define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l))) -+# elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) -+# define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l ++#if !defined(LZO_INT64_C) && defined(lzo_int64l_t) ++# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8) ++# define LZO_INT64_C(c) ((c) + 0) ++# define LZO_UINT64_C(c) ((c) + 0U) ++# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8) ++# define LZO_INT64_C(c) ((c) + 0L) ++# define LZO_UINT64_C(c) ((c) + 0UL) ++# elif (LZO_SIZEOF_INT >= 8) ++# define LZO_INT64_C(c) (c) ++# define LZO_UINT64_C(c) (c##U) ++# elif (LZO_SIZEOF_LONG >= 8) ++# define LZO_INT64_C(c) (c##L) ++# define LZO_UINT64_C(c) (c##UL) +# else -+# define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l ++# error "LZO_INT64_C" +# endif +#endif -+#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) -+# if 0 -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var -+# elif 0 && (LZO_CC_GNUC) -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var -+# else -+# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init -+# endif +#endif -+#if !defined(__lzo_inline) -+#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) -+#elif defined(__cplusplus) -+# define __lzo_inline inline -+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) -+# define __lzo_inline inline -+#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) -+# define __lzo_inline __inline -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+# define __lzo_inline __inline__ -+#elif (LZO_CC_DMC) -+# define __lzo_inline __inline -+#elif (LZO_CC_GHS) -+# define __lzo_inline __inline__ -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_inline __inline__ -+#elif (LZO_CC_INTELC) -+# define __lzo_inline __inline -+#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) -+# define __lzo_inline __inline -+#elif (LZO_CC_MSC && (_MSC_VER >= 900)) -+# define __lzo_inline __inline -+#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_inline __inline__ + + #endif + +@@ -1874,7 +3020,7 @@ extern "C" { + #undef LZO_HAVE_CONFIG_H + #include "minilzo.h" + +-#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2050) ++#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2080) + # error "version mismatch in miniLZO source files" + #endif + +@@ -1886,23 +3032,9 @@ extern "C" { + #define __LZO_CONF_H 1 + + #if !defined(__LZO_IN_MINILZO) +-#if (LZO_CFG_FREESTANDING) ++#if defined(LZO_CFG_FREESTANDING) && (LZO_CFG_FREESTANDING) + # define LZO_LIBC_FREESTANDING 1 + # define LZO_OS_FREESTANDING 1 +-# define ACC_LIBC_FREESTANDING 1 +-# define ACC_OS_FREESTANDING 1 +-#endif +-#if (LZO_CFG_NO_UNALIGNED) +-# define ACC_CFG_NO_UNALIGNED 1 +-#endif +-#if (LZO_ARCH_GENERIC) +-# define ACC_ARCH_GENERIC 1 +-#endif +-#if (LZO_ABI_NEUTRAL_ENDIAN) +-# define ACC_ABI_NEUTRAL_ENDIAN 1 +-#endif +-#if (LZO_HAVE_CONFIG_H) +-# define ACC_CONFIG_NO_HEADER 1 + #endif + #if defined(LZO_CFG_EXTRA_CONFIG_HEADER) + # include LZO_CFG_EXTRA_CONFIG_HEADER +@@ -1911,22 +3043,27 @@ extern "C" { + # error "include this file first" + #endif + #include "lzo/lzoconf.h" ++#if defined(LZO_CFG_EXTRA_CONFIG_HEADER2) ++# include LZO_CFG_EXTRA_CONFIG_HEADER2 ++#endif + #endif + +-#if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED) ++#if (LZO_VERSION < 0x2080) || !defined(__LZOCONF_H_INCLUDED) + # error "version mismatch" + #endif + +-#if (LZO_CC_BORLANDC && LZO_ARCH_I086) +-# pragma option -h ++#if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1100)) ++# pragma warning(disable: 4702) + #endif +- + #if (LZO_CC_MSC && (_MSC_VER >= 1000)) + # pragma warning(disable: 4127 4701) ++# pragma warning(disable: 4514 4710 4711) + #endif + #if (LZO_CC_MSC && (_MSC_VER >= 1300)) + # pragma warning(disable: 4820) +-# pragma warning(disable: 4514 4710 4711) ++#endif ++#if (LZO_CC_MSC && (_MSC_VER >= 1800)) ++# pragma warning(disable: 4746) + #endif + + #if (LZO_CC_SUNPROC) +@@ -1937,48 +3074,15 @@ extern "C" { + #endif + #endif + +-#if (__LZO_MMODEL_HUGE) && !(LZO_HAVE_MM_HUGE_PTR) +-# error "this should not happen - check defines for __huge" +-#endif +- +-#if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING) +-#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) +-# define ACC_WANT_ACC_INCD_H 1 +-# define ACC_WANT_ACC_INCE_H 1 +-# define ACC_WANT_ACC_INCI_H 1 ++#if defined(__LZO_IN_MINILZO) || (LZO_CFG_FREESTANDING) + #elif 1 + # include + #else +-# define ACC_WANT_ACC_INCD_H 1 ++# define LZO_WANT_ACC_INCD_H 1 + #endif +- +-#if (LZO_ARCH_I086) +-# define ACC_MM_AHSHIFT LZO_MM_AHSHIFT +-# define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0]) +-# define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1]) +-# define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o))) +-#endif +- +-#if !defined(lzo_uintptr_t) +-# if defined(__LZO_MMODEL_HUGE) +-# define lzo_uintptr_t unsigned long +-# elif 1 && defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16) +-# define __LZO_UINTPTR_T_IS_POINTER 1 +- typedef char* lzo_uintptr_t; +-# define lzo_uintptr_t lzo_uintptr_t +-# elif (LZO_SIZEOF_SIZE_T == LZO_SIZEOF_VOID_P) +-# define lzo_uintptr_t size_t +-# elif (LZO_SIZEOF_LONG == LZO_SIZEOF_VOID_P) +-# define lzo_uintptr_t unsigned long +-# elif (LZO_SIZEOF_INT == LZO_SIZEOF_VOID_P) +-# define lzo_uintptr_t unsigned int +-# elif (LZO_SIZEOF_LONG_LONG == LZO_SIZEOF_VOID_P) +-# define lzo_uintptr_t unsigned long long +-# else +-# define lzo_uintptr_t size_t +-# endif ++#if defined(LZO_HAVE_CONFIG_H) ++# define LZO_CFG_NO_CONFIG_HEADER 1 + #endif +-LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) + + #if 1 && !defined(LZO_CFG_FREESTANDING) + #if 1 && !defined(HAVE_STRING_H) +@@ -2002,6 +3106,23 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) + #include + #endif + ++#if 1 || defined(lzo_int8_t) || defined(lzo_uint8_t) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint8_t) == 1) ++#endif ++#if 1 || defined(lzo_int16_t) || defined(lzo_uint16_t) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint16_t) == 2) ++#endif ++#if 1 || defined(lzo_int32_t) || defined(lzo_uint32_t) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32_t) == 4) +#endif ++#if defined(lzo_int64_t) || defined(lzo_uint64_t) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64_t) == 8) +#endif -+#if defined(__lzo_inline) -+# ifndef __lzo_HAVE_inline -+# define __lzo_HAVE_inline 1 -+# endif ++ + #if (LZO_CFG_FREESTANDING) + # undef HAVE_MEMCMP + # undef HAVE_MEMCPY +@@ -2012,169 +3133,635 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) + #if !(HAVE_MEMCMP) + # undef memcmp + # define memcmp(a,b,c) lzo_memcmp(a,b,c) +-#elif !(__LZO_MMODEL_HUGE) +#else -+# define __lzo_inline /*empty*/ -+#endif -+#if !defined(__lzo_forceinline) -+#if (LZO_CC_GNUC >= 0x030200ul) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) -+# define __lzo_forceinline __forceinline -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -+# define __lzo_forceinline __forceinline -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -+#endif -+#endif -+#if defined(__lzo_forceinline) -+# ifndef __lzo_HAVE_forceinline -+# define __lzo_HAVE_forceinline 1 -+# endif + # undef lzo_memcmp + # define lzo_memcmp(a,b,c) memcmp(a,b,c) + #endif + #if !(HAVE_MEMCPY) + # undef memcpy + # define memcpy(a,b,c) lzo_memcpy(a,b,c) +-#elif !(__LZO_MMODEL_HUGE) +#else -+# define __lzo_forceinline __lzo_inline -+#endif -+#if !defined(__lzo_noinline) -+#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) -+# define __lzo_noinline __attribute__((__noinline__,__used__)) -+#elif (LZO_CC_GNUC >= 0x030200ul) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) -+# define __lzo_noinline __declspec(noinline) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_noinline __declspec(noinline) -+#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) -+# if defined(__cplusplus) -+# else -+# define __lzo_noinline __declspec(noinline) + # undef lzo_memcpy + # define lzo_memcpy(a,b,c) memcpy(a,b,c) + #endif + #if !(HAVE_MEMMOVE) + # undef memmove + # define memmove(a,b,c) lzo_memmove(a,b,c) +-#elif !(__LZO_MMODEL_HUGE) ++#else + # undef lzo_memmove + # define lzo_memmove(a,b,c) memmove(a,b,c) + #endif + #if !(HAVE_MEMSET) + # undef memset + # define memset(a,b,c) lzo_memset(a,b,c) +-#elif !(__LZO_MMODEL_HUGE) ++#else + # undef lzo_memset + # define lzo_memset(a,b,c) memset(a,b,c) + #endif + +-#undef NDEBUG +-#if (LZO_CFG_FREESTANDING) +-# undef LZO_DEBUG +-# define NDEBUG 1 +-# undef assert +-# define assert(e) ((void)0) ++#undef NDEBUG ++#if (LZO_CFG_FREESTANDING) ++# undef LZO_DEBUG ++# define NDEBUG 1 ++# undef assert ++# define assert(e) ((void)0) ++#else ++# if !defined(LZO_DEBUG) ++# define NDEBUG 1 +# endif -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_noinline __attribute__((__noinline__)) -+#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_noinline __attribute__((__noinline__)) ++# include +#endif -+#endif -+#if defined(__lzo_noinline) -+# ifndef __lzo_HAVE_noinline -+# define __lzo_HAVE_noinline 1 -+# endif ++ ++#if 0 && defined(__BOUNDS_CHECKING_ON) ++# include +#else -+# define __lzo_noinline /*empty*/ -+#endif -+#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) -+# error "unexpected configuration - check your compiler defines" -+#endif -+#if !defined(__lzo_static_inline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline -+#endif -+#endif -+#if !defined(__lzo_static_inline) -+# define __lzo_static_inline static __lzo_inline -+#endif -+#if !defined(__lzo_static_forceinline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline -+#endif -+#endif -+#if !defined(__lzo_static_forceinline) -+# define __lzo_static_forceinline static __lzo_forceinline -+#endif -+#if !defined(__lzo_static_noinline) -+#if (LZO_CC_IBMC) -+# define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline -+#endif -+#endif -+#if !defined(__lzo_static_noinline) -+# define __lzo_static_noinline static __lzo_noinline -+#endif -+#if !defined(__lzo_c99_extern_inline) -+#if defined(__GNUC_GNU_INLINE__) -+# define __lzo_c99_extern_inline __lzo_inline -+#elif defined(__GNUC_STDC_INLINE__) -+# define __lzo_c99_extern_inline extern __lzo_inline -+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L) -+# define __lzo_c99_extern_inline extern __lzo_inline -+#endif -+#if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline) -+# define __lzo_c99_extern_inline __lzo_inline ++# define BOUNDS_CHECKING_OFF_DURING(stmt) stmt ++# define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) +#endif ++ ++#if (LZO_CFG_PGO) ++# undef __lzo_likely ++# undef __lzo_unlikely ++# define __lzo_likely(e) (e) ++# define __lzo_unlikely(e) (e) +#endif -+#if defined(__lzo_c99_extern_inline) -+# ifndef __lzo_HAVE_c99_extern_inline -+# define __lzo_HAVE_c99_extern_inline 1 -+# endif ++ ++#undef _ ++#undef __ ++#undef ___ ++#undef ____ ++#undef _p0 ++#undef _p1 ++#undef _p2 ++#undef _p3 ++#undef _p4 ++#undef _s0 ++#undef _s1 ++#undef _s2 ++#undef _s3 ++#undef _s4 ++#undef _ww ++ ++#if 1 ++# define LZO_BYTE(x) ((unsigned char) (x)) +#else -+# define __lzo_c99_extern_inline /*empty*/ -+#endif -+#if !defined(__lzo_may_alias) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_CLANG >= 0x020900ul) -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0 -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#elif (LZO_CC_PGI >= 0x0d0a00ul) && 0 -+# define __lzo_may_alias __attribute__((__may_alias__)) -+#endif ++# define LZO_BYTE(x) ((unsigned char) ((x) & 0xff)) +#endif -+#if defined(__lzo_may_alias) -+# ifndef __lzo_HAVE_may_alias -+# define __lzo_HAVE_may_alias 1 -+# endif ++ ++#define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b)) ++#define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b)) ++#define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c)) ++#define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c)) ++ ++#define lzo_sizeof(type) ((lzo_uint) (sizeof(type))) ++ ++#define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array)))) ++ ++#define LZO_SIZE(bits) (1u << (bits)) ++#define LZO_MASK(bits) (LZO_SIZE(bits) - 1) ++ ++#define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) ++#define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) ++ ++#if !defined(DMUL) ++#if 0 ++ ++# define DMUL(a,b) ((lzo_xint) ((lzo_uint32_t)(a) * (lzo_uint32_t)(b))) +#else -+# define __lzo_may_alias /*empty*/ -+#endif -+#if !defined(__lzo_noreturn) -+#if (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) -+# define __lzo_noreturn __declspec(noreturn) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_noreturn __attribute__((__noreturn__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -+# define __lzo_noreturn __declspec(noreturn) -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_noreturn __attribute__((__noreturn__)) ++# define DMUL(a,b) ((lzo_xint) ((a) * (b))) +#endif +#endif -+#if defined(__lzo_noreturn) -+# ifndef __lzo_HAVE_noreturn -+# define __lzo_HAVE_noreturn 1 -+# endif -+#else -+# define __lzo_noreturn /*empty*/ -+#endif -+#if !defined(__lzo_nothrow) -+#if (LZO_CC_GNUC >= 0x030300ul) -+# define __lzo_nothrow __attribute__((__nothrow__)) -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus) -+# define __lzo_nothrow __declspec(nothrow) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900)) -+# define __lzo_nothrow __attribute__((__nothrow__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_nothrow __attribute__((__nothrow__)) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) -+# define __lzo_nothrow __declspec(nothrow) ++ ++#ifndef __LZO_FUNC_H ++#define __LZO_FUNC_H 1 ++ ++#if !defined(LZO_BITOPS_USE_ASM_BITSCAN) && !defined(LZO_BITOPS_USE_GNUC_BITSCAN) && !defined(LZO_BITOPS_USE_MSC_BITSCAN) ++#if 1 && (LZO_ARCH_AMD64) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_ASM_SYNTAX_GNUC) ++#define LZO_BITOPS_USE_ASM_BITSCAN 1 ++#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul)))) ++#define LZO_BITOPS_USE_GNUC_BITSCAN 1 ++#elif (LZO_OS_WIN32 || LZO_OS_WIN64) && ((LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 1010)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) ++#define LZO_BITOPS_USE_MSC_BITSCAN 1 ++#if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) ++#include +#endif ++#if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) ++#pragma intrinsic(_BitScanReverse) ++#pragma intrinsic(_BitScanForward) +#endif -+#if defined(__lzo_nothrow) -+# ifndef __lzo_HAVE_nothrow -+# define __lzo_HAVE_nothrow 1 -+# endif -+#else -+# define __lzo_nothrow /*empty*/ ++#if (LZO_CC_MSC) && (LZO_ARCH_AMD64) ++#pragma intrinsic(_BitScanReverse64) ++#pragma intrinsic(_BitScanForward64) +#endif -+#if !defined(__lzo_restrict) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_IBMC >= 1210) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600)) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM) -+# define __lzo_restrict __restrict__ -+#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) -+# define __lzo_restrict __restrict -+#elif (LZO_CC_PGI >= 0x0d0a00ul) -+# define __lzo_restrict __restrict__ +#endif +#endif -+#if defined(__lzo_restrict) -+# ifndef __lzo_HAVE_restrict -+# define __lzo_HAVE_restrict 1 -+# endif ++ ++__lzo_static_forceinline unsigned lzo_bitops_ctlz32_func(lzo_uint32_t v) ++{ ++#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) ++ unsigned long r; (void) _BitScanReverse(&r, v); return (unsigned) r ^ 31; ++#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) ++#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) ++ lzo_uint32_t r; ++ __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); ++ return (unsigned) r ^ 31; ++#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) ++#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT == 4) ++ unsigned r; r = (unsigned) __builtin_clz(v); return r; ++#define lzo_bitops_ctlz32(v) ((unsigned) __builtin_clz(v)) +#else -+# define __lzo_restrict /*empty*/ ++ LZO_UNUSED(v); return 0; +#endif -+#if !defined(__lzo_alignof) -+#if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_GHS) && !defined(__cplusplus) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_IBMC >= 600) -+# define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e)) -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) -+# define __lzo_alignof(e) __alignof__(e) -+#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_alignof(e) __alignof(e) -+#elif (LZO_CC_SUNPROC >= 0x5100) -+# define __lzo_alignof(e) __alignof__(e) ++} ++ ++#if defined(lzo_uint64_t) ++__lzo_static_forceinline unsigned lzo_bitops_ctlz64_func(lzo_uint64_t v) ++{ ++#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) ++ unsigned long r; (void) _BitScanReverse64(&r, v); return (unsigned) r ^ 63; ++#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) ++#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) ++ lzo_uint64_t r; ++ __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); ++ return (unsigned) r ^ 63; ++#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) ++#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG == 8) && (LZO_WORDSIZE >= 8) ++ unsigned r; r = (unsigned) __builtin_clzl(v); return r; ++#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzl(v)) ++#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG == 8) && (LZO_WORDSIZE >= 8) ++ unsigned r; r = (unsigned) __builtin_clzll(v); return r; ++#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzll(v)) ++#else ++ LZO_UNUSED(v); return 0; +#endif ++} +#endif -+#if defined(__lzo_alignof) -+# ifndef __lzo_HAVE_alignof -+# define __lzo_HAVE_alignof 1 -+# endif ++ ++__lzo_static_forceinline unsigned lzo_bitops_cttz32_func(lzo_uint32_t v) ++{ ++#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) ++ unsigned long r; (void) _BitScanForward(&r, v); return (unsigned) r; ++#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) ++#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) ++ lzo_uint32_t r; ++ __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); ++ return (unsigned) r; ++#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) ++#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT >= 4) ++ unsigned r; r = (unsigned) __builtin_ctz(v); return r; ++#define lzo_bitops_cttz32(v) ((unsigned) __builtin_ctz(v)) ++#else ++ LZO_UNUSED(v); return 0; +#endif -+#if !defined(__lzo_struct_packed) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) -+#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) -+#elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) -+# define __lzo_struct_packed(s) struct s { -+# define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__)); -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_struct_packed(s) struct s { -+# define __lzo_struct_packed_end() } __attribute__((__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s { -+# define __lzo_struct_packed_end() } __attribute__((__packed__)); -+# define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s { -+# define __lzo_struct_packed_end() } __pragma(pack(pop)); -+#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) -+# define __lzo_struct_packed(s) _Packed struct s { -+# define __lzo_struct_packed_end() }; ++} ++ ++#if defined(lzo_uint64_t) ++__lzo_static_forceinline unsigned lzo_bitops_cttz64_func(lzo_uint64_t v) ++{ ++#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) ++ unsigned long r; (void) _BitScanForward64(&r, v); return (unsigned) r; ++#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) ++#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) ++ lzo_uint64_t r; ++ __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); ++ return (unsigned) r; ++#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) ++#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG >= 8) && (LZO_WORDSIZE >= 8) ++ unsigned r; r = (unsigned) __builtin_ctzl(v); return r; ++#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzl(v)) ++#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG >= 8) && (LZO_WORDSIZE >= 8) ++ unsigned r; r = (unsigned) __builtin_ctzll(v); return r; ++#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzll(v)) ++#else ++ LZO_UNUSED(v); return 0; +#endif ++} +#endif -+#if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma) -+# define __lzo_struct_packed_ma(s) __lzo_struct_packed(s) ++ ++#if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) ++static void __attribute__((__unused__)) ++#else ++__lzo_static_forceinline void +#endif -+#if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end) -+# define __lzo_struct_packed_ma_end() __lzo_struct_packed_end() ++lzo_bitops_unused_funcs(void) ++{ ++ LZO_UNUSED_FUNC(lzo_bitops_ctlz32_func); ++ LZO_UNUSED_FUNC(lzo_bitops_cttz32_func); ++#if defined(lzo_uint64_t) ++ LZO_UNUSED_FUNC(lzo_bitops_ctlz64_func); ++ LZO_UNUSED_FUNC(lzo_bitops_cttz64_func); +#endif -+#if !defined(__lzo_byte_struct) -+#if defined(__lzo_struct_packed) -+# define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end() -+# define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end() -+#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__)); -+# define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__)); ++ LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); ++} ++ ++#if defined(__lzo_alignof) && !(LZO_CFG_NO_UNALIGNED) ++#ifndef __lzo_memops_tcheck ++#define __lzo_memops_tcheck(t,a,b) ((void)0, sizeof(t) == (a) && __lzo_alignof(t) == (b)) +#endif +#endif -+#if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma) -+# define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n) ++#ifndef lzo_memops_TU0p ++#define lzo_memops_TU0p void __LZO_MMODEL * +#endif -+#if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof) -+#if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul)) -+#elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_CILLY || LZO_CC_PCC) -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_struct_align16(s) struct __declspec(align(16)) s { -+# define __lzo_struct_align16_end() }; -+# define __lzo_struct_align32(s) struct __declspec(align(32)) s { -+# define __lzo_struct_align32_end() }; -+# define __lzo_struct_align64(s) struct __declspec(align(64)) s { -+# define __lzo_struct_align64_end() }; -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_struct_align16(s) struct s { -+# define __lzo_struct_align16_end() } __attribute__((__aligned__(16))); -+# define __lzo_struct_align32(s) struct s { -+# define __lzo_struct_align32_end() } __attribute__((__aligned__(32))); -+# define __lzo_struct_align64(s) struct s { -+# define __lzo_struct_align64_end() } __attribute__((__aligned__(64))); ++#ifndef lzo_memops_TU1p ++#define lzo_memops_TU1p unsigned char __LZO_MMODEL * +#endif ++#ifndef lzo_memops_TU2p ++#if (LZO_OPT_UNALIGNED16) ++typedef lzo_uint16_t __lzo_may_alias lzo_memops_TU2; ++#define lzo_memops_TU2p volatile lzo_memops_TU2 * ++#elif defined(__lzo_byte_struct) ++__lzo_byte_struct(lzo_memops_TU2_struct,2) ++typedef struct lzo_memops_TU2_struct lzo_memops_TU2; ++#else ++struct lzo_memops_TU2_struct { unsigned char a[2]; } __lzo_may_alias; ++typedef struct lzo_memops_TU2_struct lzo_memops_TU2; +#endif -+#if !defined(__lzo_union_um) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul)) -+#elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810)) -+#elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul)) -+#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus) -+#elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100)) -+# define __lzo_union_am(s) union s { -+# define __lzo_union_am_end() } __lzo_may_alias; -+# define __lzo_union_um(s) union s { -+# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_IBMC >= 700) -+# define __lzo_union_am(s) __lzo_gnuc_extension__ union s { -+# define __lzo_union_am_end() } __lzo_may_alias; -+# define __lzo_union_um(s) __lzo_gnuc_extension__ union s { -+# define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__)); -+#elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300)) -+# define __lzo_union_um(s) __pragma(pack(push,1)) union s { -+# define __lzo_union_um_end() } __pragma(pack(pop)); -+#elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900)) -+# define __lzo_union_um(s) _Packed union s { -+# define __lzo_union_um_end() }; ++#ifndef lzo_memops_TU2p ++#define lzo_memops_TU2p lzo_memops_TU2 * +#endif +#endif -+#if !defined(__lzo_union_am) -+# define __lzo_union_am(s) union s { -+# define __lzo_union_am_end() }; ++#ifndef lzo_memops_TU4p ++#if (LZO_OPT_UNALIGNED32) ++typedef lzo_uint32_t __lzo_may_alias lzo_memops_TU4; ++#define lzo_memops_TU4p volatile lzo_memops_TU4 __LZO_MMODEL * ++#elif defined(__lzo_byte_struct) ++__lzo_byte_struct(lzo_memops_TU4_struct,4) ++typedef struct lzo_memops_TU4_struct lzo_memops_TU4; ++#else ++struct lzo_memops_TU4_struct { unsigned char a[4]; } __lzo_may_alias; ++typedef struct lzo_memops_TU4_struct lzo_memops_TU4; +#endif -+#if !defined(__lzo_constructor) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_constructor __attribute__((__constructor__,__used__)) -+#elif (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_constructor __attribute__((__constructor__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_constructor __attribute__((__constructor__,__used__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_constructor __attribute__((__constructor__)) ++#ifndef lzo_memops_TU4p ++#define lzo_memops_TU4p lzo_memops_TU4 __LZO_MMODEL * ++#endif ++#endif ++#ifndef lzo_memops_TU8p ++#if (LZO_OPT_UNALIGNED64) ++typedef lzo_uint64_t __lzo_may_alias lzo_memops_TU8; ++#define lzo_memops_TU8p volatile lzo_memops_TU8 __LZO_MMODEL * ++#elif defined(__lzo_byte_struct) ++__lzo_byte_struct(lzo_memops_TU8_struct,8) ++typedef struct lzo_memops_TU8_struct lzo_memops_TU8; ++#else ++struct lzo_memops_TU8_struct { unsigned char a[8]; } __lzo_may_alias; ++typedef struct lzo_memops_TU8_struct lzo_memops_TU8; +#endif ++#ifndef lzo_memops_TU8p ++#define lzo_memops_TU8p lzo_memops_TU8 __LZO_MMODEL * +#endif -+#if defined(__lzo_constructor) -+# ifndef __lzo_HAVE_constructor -+# define __lzo_HAVE_constructor 1 -+# endif +#endif -+#if !defined(__lzo_destructor) -+#if (LZO_CC_GNUC >= 0x030400ul) -+# define __lzo_destructor __attribute__((__destructor__,__used__)) -+#elif (LZO_CC_GNUC >= 0x020700ul) -+# define __lzo_destructor __attribute__((__destructor__)) -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800)) -+# define __lzo_destructor __attribute__((__destructor__,__used__)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_destructor __attribute__((__destructor__)) ++#ifndef lzo_memops_set_TU1p ++#define lzo_memops_set_TU1p volatile lzo_memops_TU1p +#endif ++#ifndef lzo_memops_move_TU1p ++#define lzo_memops_move_TU1p lzo_memops_TU1p +#endif -+#if defined(__lzo_destructor) -+# ifndef __lzo_HAVE_destructor -+# define __lzo_HAVE_destructor 1 -+# endif ++#define LZO_MEMOPS_SET1(dd,cc) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_set_TU1p d__1 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ ++ d__1[0] = LZO_BYTE(cc); \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_SET2(dd,cc) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_set_TU1p d__2 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ ++ d__2[0] = LZO_BYTE(cc); d__2[1] = LZO_BYTE(cc); \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_SET3(dd,cc) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_set_TU1p d__3 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ ++ d__3[0] = LZO_BYTE(cc); d__3[1] = LZO_BYTE(cc); d__3[2] = LZO_BYTE(cc); \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_SET4(dd,cc) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_set_TU1p d__4 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \ ++ d__4[0] = LZO_BYTE(cc); d__4[1] = LZO_BYTE(cc); d__4[2] = LZO_BYTE(cc); d__4[3] = LZO_BYTE(cc); \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_MOVE1(dd,ss) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_move_TU1p d__1 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ ++ const lzo_memops_move_TU1p s__1 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ ++ d__1[0] = s__1[0]; \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_MOVE2(dd,ss) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_move_TU1p d__2 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ ++ const lzo_memops_move_TU1p s__2 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ ++ d__2[0] = s__2[0]; d__2[1] = s__2[1]; \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_MOVE3(dd,ss) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_move_TU1p d__3 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ ++ const lzo_memops_move_TU1p s__3 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ ++ d__3[0] = s__3[0]; d__3[1] = s__3[1]; d__3[2] = s__3[2]; \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_MOVE4(dd,ss) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_move_TU1p d__4 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ ++ const lzo_memops_move_TU1p s__4 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ ++ d__4[0] = s__4[0]; d__4[1] = s__4[1]; d__4[2] = s__4[2]; d__4[3] = s__4[3]; \ ++ LZO_BLOCK_END ++#define LZO_MEMOPS_MOVE8(dd,ss) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_move_TU1p d__8 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \ ++ const lzo_memops_move_TU1p s__8 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \ ++ d__8[0] = s__8[0]; d__8[1] = s__8[1]; d__8[2] = s__8[2]; d__8[3] = s__8[3]; \ ++ d__8[4] = s__8[4]; d__8[5] = s__8[5]; d__8[6] = s__8[6]; d__8[7] = s__8[7]; \ ++ LZO_BLOCK_END ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU1p)0)==1) ++#define LZO_MEMOPS_COPY1(dd,ss) LZO_MEMOPS_MOVE1(dd,ss) ++#if (LZO_OPT_UNALIGNED16) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0)==2) ++#define LZO_MEMOPS_COPY2(dd,ss) \ ++ * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) ++#elif defined(__lzo_memops_tcheck) ++#define LZO_MEMOPS_COPY2(dd,ss) \ ++ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU2,2,1)) { \ ++ * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss); \ ++ } else { LZO_MEMOPS_MOVE2(dd,ss); } LZO_BLOCK_END ++#else ++#define LZO_MEMOPS_COPY2(dd,ss) LZO_MEMOPS_MOVE2(dd,ss) +#endif -+#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) -+# error "unexpected configuration - check your compiler defines" ++#if (LZO_OPT_UNALIGNED32) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0)==4) ++#define LZO_MEMOPS_COPY4(dd,ss) \ ++ * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) ++#elif defined(__lzo_memops_tcheck) ++#define LZO_MEMOPS_COPY4(dd,ss) \ ++ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU4,4,1)) { \ ++ * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss); \ ++ } else { LZO_MEMOPS_MOVE4(dd,ss); } LZO_BLOCK_END ++#else ++#define LZO_MEMOPS_COPY4(dd,ss) LZO_MEMOPS_MOVE4(dd,ss) +#endif -+#if !defined(__lzo_likely) && !defined(__lzo_unlikely) -+#if (LZO_CC_GNUC >= 0x030200ul) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#elif (LZO_CC_IBMC >= 1010) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -+# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) ++#if (LZO_WORDSIZE != 8) ++#define LZO_MEMOPS_COPY8(dd,ss) \ ++ LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END ++#else ++#if (LZO_OPT_UNALIGNED64) ++LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8) ++#define LZO_MEMOPS_COPY8(dd,ss) \ ++ * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) ++#elif (LZO_OPT_UNALIGNED32) ++#define LZO_MEMOPS_COPY8(dd,ss) \ ++ LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END ++#elif defined(__lzo_memops_tcheck) ++#define LZO_MEMOPS_COPY8(dd,ss) \ ++ LZO_BLOCK_BEGIN if (__lzo_memops_tcheck(lzo_memops_TU8,8,1)) { \ ++ * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss); \ ++ } else { LZO_MEMOPS_MOVE8(dd,ss); } LZO_BLOCK_END ++#else ++#define LZO_MEMOPS_COPY8(dd,ss) LZO_MEMOPS_MOVE8(dd,ss) +#endif +#endif -+#if defined(__lzo_likely) -+# ifndef __lzo_HAVE_likely -+# define __lzo_HAVE_likely 1 -+# endif ++#define LZO_MEMOPS_COPYN(dd,ss,nn) \ ++ LZO_BLOCK_BEGIN \ ++ lzo_memops_TU1p d__n = (lzo_memops_TU1p) (lzo_memops_TU0p) (dd); \ ++ const lzo_memops_TU1p s__n = (const lzo_memops_TU1p) (const lzo_memops_TU0p) (ss); \ ++ lzo_uint n__n = (nn); \ ++ while ((void)0, n__n >= 8) { LZO_MEMOPS_COPY8(d__n, s__n); d__n += 8; s__n += 8; n__n -= 8; } \ ++ if ((void)0, n__n >= 4) { LZO_MEMOPS_COPY4(d__n, s__n); d__n += 4; s__n += 4; n__n -= 4; } \ ++ if ((void)0, n__n > 0) do { *d__n++ = *s__n++; } while (--n__n > 0); \ ++ LZO_BLOCK_END ++ ++__lzo_static_forceinline lzo_uint16_t lzo_memops_get_le16(const lzo_voidp ss) ++{ ++ lzo_uint16_t v; ++#if (LZO_ABI_LITTLE_ENDIAN) ++ LZO_MEMOPS_COPY2(&v, ss); ++#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) ++ const lzo_memops_TU2p s = (const lzo_memops_TU2p) ss; ++ unsigned long vv; ++ __asm__("lhbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); ++ v = (lzo_uint16_t) vv; + #else +-# if !defined(LZO_DEBUG) +-# define NDEBUG 1 +-# endif +-# include ++ const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; ++ v = (lzo_uint16_t) (((lzo_uint16_t)s[0]) | ((lzo_uint16_t)s[1] << 8)); + #endif +- +-#if 0 && defined(__BOUNDS_CHECKING_ON) +-# include ++ return v; ++} ++#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) ++#define LZO_MEMOPS_GET_LE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) + #else +-# define BOUNDS_CHECKING_OFF_DURING(stmt) stmt +-# define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) ++#define LZO_MEMOPS_GET_LE16(ss) lzo_memops_get_le16(ss) + #endif + +-#if !defined(__lzo_inline) +-# define __lzo_inline /*empty*/ +-#endif +-#if !defined(__lzo_forceinline) +-# define __lzo_forceinline /*empty*/ ++__lzo_static_forceinline lzo_uint32_t lzo_memops_get_le32(const lzo_voidp ss) ++{ ++ lzo_uint32_t v; ++#if (LZO_ABI_LITTLE_ENDIAN) ++ LZO_MEMOPS_COPY4(&v, ss); ++#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) ++ const lzo_memops_TU4p s = (const lzo_memops_TU4p) ss; ++ unsigned long vv; ++ __asm__("lwbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); ++ v = (lzo_uint32_t) vv; +#else -+# define __lzo_likely(e) (e) -+#endif -+#if defined(__lzo_unlikely) -+# ifndef __lzo_HAVE_unlikely -+# define __lzo_HAVE_unlikely 1 -+# endif ++ const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; ++ v = (lzo_uint32_t) (((lzo_uint32_t)s[0]) | ((lzo_uint32_t)s[1] << 8) | ((lzo_uint32_t)s[2] << 16) | ((lzo_uint32_t)s[3] << 24)); + #endif +-#if !defined(__lzo_noinline) +-# define __lzo_noinline /*empty*/ ++ return v; ++} ++#if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN) ++#define LZO_MEMOPS_GET_LE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) +#else -+# define __lzo_unlikely(e) (e) ++#define LZO_MEMOPS_GET_LE32(ss) lzo_memops_get_le32(ss) + #endif + +-#if (LZO_CFG_PGO) +-# undef __acc_likely +-# undef __acc_unlikely +-# undef __lzo_likely +-# undef __lzo_unlikely +-# define __acc_likely(e) (e) +-# define __acc_unlikely(e) (e) +-# define __lzo_likely(e) (e) +-# define __lzo_unlikely(e) (e) ++#if (LZO_OPT_UNALIGNED64) && (LZO_ABI_LITTLE_ENDIAN) ++#define LZO_MEMOPS_GET_LE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) + #endif + +-#if 1 +-# define LZO_BYTE(x) ((unsigned char) (x)) ++__lzo_static_forceinline lzo_uint16_t lzo_memops_get_ne16(const lzo_voidp ss) ++{ ++ lzo_uint16_t v; ++ LZO_MEMOPS_COPY2(&v, ss); ++ return v; ++} ++#if (LZO_OPT_UNALIGNED16) ++#define LZO_MEMOPS_GET_NE16(ss) * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) + #else +-# define LZO_BYTE(x) ((unsigned char) ((x) & 0xff)) ++#define LZO_MEMOPS_GET_NE16(ss) lzo_memops_get_ne16(ss) + #endif + +-#define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b)) +-#define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b)) +-#define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c)) +-#define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c)) +- +-#define lzo_sizeof(type) ((lzo_uint) (sizeof(type))) ++__lzo_static_forceinline lzo_uint32_t lzo_memops_get_ne32(const lzo_voidp ss) ++{ ++ lzo_uint32_t v; ++ LZO_MEMOPS_COPY4(&v, ss); ++ return v; ++} ++#if (LZO_OPT_UNALIGNED32) ++#define LZO_MEMOPS_GET_NE32(ss) * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) ++#else ++#define LZO_MEMOPS_GET_NE32(ss) lzo_memops_get_ne32(ss) +#endif -+#if !defined(__lzo_static_unused_void_func) -+# if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -+# define __lzo_static_unused_void_func(f) static void __attribute__((__unused__)) f(void) -+# else -+# define __lzo_static_unused_void_func(f) static __lzo_inline void f(void) -+# endif + +-#define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array)))) ++#if (LZO_OPT_UNALIGNED64) ++#define LZO_MEMOPS_GET_NE64(ss) * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) +#endif -+#if !defined(__lzo_loop_forever) -+# if (LZO_CC_IBMC) -+# define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END -+# else -+# define __lzo_loop_forever() do { ; } while __lzo_cte(1) -+# endif + +-#define LZO_SIZE(bits) (1u << (bits)) +-#define LZO_MASK(bits) (LZO_SIZE(bits) - 1) ++__lzo_static_forceinline void lzo_memops_put_le16(lzo_voidp dd, lzo_uint16_t vv) ++{ ++#if (LZO_ABI_LITTLE_ENDIAN) ++ LZO_MEMOPS_COPY2(dd, &vv); ++#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) ++ lzo_memops_TU2p d = (lzo_memops_TU2p) dd; ++ unsigned long v = vv; ++ __asm__("sthbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); ++#else ++ lzo_memops_TU1p d = (lzo_memops_TU1p) dd; ++ d[0] = LZO_BYTE((vv ) & 0xff); ++ d[1] = LZO_BYTE((vv >> 8) & 0xff); +#endif -+#if !defined(__lzo_unreachable) -+#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) -+# define __lzo_unreachable() __builtin_unreachable(); -+#elif (LZO_CC_GNUC >= 0x040500ul) -+# define __lzo_unreachable() __builtin_unreachable(); -+#elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1 -+# define __lzo_unreachable() __builtin_unreachable(); ++} ++#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) ++#define LZO_MEMOPS_PUT_LE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv)) ++#else ++#define LZO_MEMOPS_PUT_LE16(dd,vv) lzo_memops_put_le16(dd,vv) +#endif + +-#define LZO_LSIZE(bits) (1ul << (bits)) +-#define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1) ++__lzo_static_forceinline void lzo_memops_put_le32(lzo_voidp dd, lzo_uint32_t vv) ++{ ++#if (LZO_ABI_LITTLE_ENDIAN) ++ LZO_MEMOPS_COPY4(dd, &vv); ++#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) ++ lzo_memops_TU4p d = (lzo_memops_TU4p) dd; ++ unsigned long v = vv; ++ __asm__("stwbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); ++#else ++ lzo_memops_TU1p d = (lzo_memops_TU1p) dd; ++ d[0] = LZO_BYTE((vv ) & 0xff); ++ d[1] = LZO_BYTE((vv >> 8) & 0xff); ++ d[2] = LZO_BYTE((vv >> 16) & 0xff); ++ d[3] = LZO_BYTE((vv >> 24) & 0xff); +#endif -+#if defined(__lzo_unreachable) -+# ifndef __lzo_HAVE_unreachable -+# define __lzo_HAVE_unreachable 1 -+# endif ++} ++#if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN) ++#define LZO_MEMOPS_PUT_LE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv)) +#else -+# if 0 -+# define __lzo_unreachable() ((void)0); -+# else -+# define __lzo_unreachable() __lzo_loop_forever(); -+# endif ++#define LZO_MEMOPS_PUT_LE32(dd,vv) lzo_memops_put_le32(dd,vv) +#endif -+#ifndef __LZO_CTA_NAME -+#if (LZO_CFG_USE_COUNTER) -+# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__) + +-#define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) +-#define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) ++__lzo_static_forceinline void lzo_memops_put_ne16(lzo_voidp dd, lzo_uint16_t vv) ++{ ++ LZO_MEMOPS_COPY2(dd, &vv); ++} ++#if (LZO_OPT_UNALIGNED16) ++#define LZO_MEMOPS_PUT_NE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv)) +#else -+# define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__) ++#define LZO_MEMOPS_PUT_NE16(dd,vv) lzo_memops_put_ne16(dd,vv) +#endif + +-#if !defined(DMUL) +-#if 0 ++__lzo_static_forceinline void lzo_memops_put_ne32(lzo_voidp dd, lzo_uint32_t vv) ++{ ++ LZO_MEMOPS_COPY4(dd, &vv); ++} ++#if (LZO_OPT_UNALIGNED32) ++#define LZO_MEMOPS_PUT_NE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv)) ++#else ++#define LZO_MEMOPS_PUT_NE32(dd,vv) lzo_memops_put_ne32(dd,vv) +#endif -+#if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) -+# if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END -+# elif (LZO_CC_DMC || LZO_CC_SYMANTECC) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END -+# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END -+# elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END -+# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END -+# else -+# define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END -+# endif + +-# define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b))) ++#if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) ++static void __attribute__((__unused__)) + #else +-# define DMUL(a,b) ((lzo_xint) ((a) * (b))) ++__lzo_static_forceinline void + #endif ++lzo_memops_unused_funcs(void) ++{ ++ LZO_UNUSED_FUNC(lzo_memops_get_le16); ++ LZO_UNUSED_FUNC(lzo_memops_get_le32); ++ LZO_UNUSED_FUNC(lzo_memops_get_ne16); ++ LZO_UNUSED_FUNC(lzo_memops_get_ne32); ++ LZO_UNUSED_FUNC(lzo_memops_put_le16); ++ LZO_UNUSED_FUNC(lzo_memops_put_le32); ++ LZO_UNUSED_FUNC(lzo_memops_put_ne16); ++ LZO_UNUSED_FUNC(lzo_memops_put_ne32); ++ LZO_UNUSED_FUNC(lzo_memops_unused_funcs); ++} ++ + #endif + +-#if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386 || LZO_ARCH_POWERPC) +-# if (LZO_SIZEOF_SHORT == 2) +-# define LZO_UNALIGNED_OK_2 1 +-# endif +-# if (LZO_SIZEOF_INT == 4) +-# define LZO_UNALIGNED_OK_4 1 +-# endif ++#ifndef UA_SET1 ++#define UA_SET1 LZO_MEMOPS_SET1 + #endif +-#if 1 && (LZO_ARCH_AMD64) +-# if defined(LZO_UINT64_MAX) +-# define LZO_UNALIGNED_OK_8 1 +-# endif ++#ifndef UA_SET2 ++#define UA_SET2 LZO_MEMOPS_SET2 + #endif +-#if (LZO_CFG_NO_UNALIGNED) +-# undef LZO_UNALIGNED_OK_2 +-# undef LZO_UNALIGNED_OK_4 +-# undef LZO_UNALIGNED_OK_8 +-#endif +- +-#undef UA_GET16 +-#undef UA_SET16 +-#undef UA_COPY16 +-#undef UA_GET32 +-#undef UA_SET32 +-#undef UA_COPY32 +-#undef UA_GET64 +-#undef UA_SET64 +-#undef UA_COPY64 +-#if defined(LZO_UNALIGNED_OK_2) +- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(unsigned short) == 2) +-# if 1 && defined(ACC_UA_COPY16) +-# define UA_GET16 ACC_UA_GET16 +-# define UA_SET16 ACC_UA_SET16 +-# define UA_COPY16 ACC_UA_COPY16 +-# else +-# define UA_GET16(p) (* (__lzo_ua_volatile const lzo_ushortp) (__lzo_ua_volatile const lzo_voidp) (p)) +-# define UA_SET16(p,v) ((* (__lzo_ua_volatile lzo_ushortp) (__lzo_ua_volatile lzo_voidp) (p)) = (unsigned short) (v)) +-# define UA_COPY16(d,s) UA_SET16(d, UA_GET16(s)) +-# endif ++#ifndef UA_SET3 ++#define UA_SET3 LZO_MEMOPS_SET3 + #endif +-#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) +- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4) +-# if 1 && defined(ACC_UA_COPY32) +-# define UA_GET32 ACC_UA_GET32 +-# define UA_SET32 ACC_UA_SET32 +-# define UA_COPY32 ACC_UA_COPY32 +-# else +-# define UA_GET32(p) (* (__lzo_ua_volatile const lzo_uint32p) (__lzo_ua_volatile const lzo_voidp) (p)) +-# define UA_SET32(p,v) ((* (__lzo_ua_volatile lzo_uint32p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint32) (v)) +-# define UA_COPY32(d,s) UA_SET32(d, UA_GET32(s)) +-# endif ++#ifndef UA_SET4 ++#define UA_SET4 LZO_MEMOPS_SET4 + #endif +-#if defined(LZO_UNALIGNED_OK_8) +- LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64) == 8) +-# if 1 && defined(ACC_UA_COPY64) +-# define UA_GET64 ACC_UA_GET64 +-# define UA_SET64 ACC_UA_SET64 +-# define UA_COPY64 ACC_UA_COPY64 +-# else +-# define UA_GET64(p) (* (__lzo_ua_volatile const lzo_uint64p) (__lzo_ua_volatile const lzo_voidp) (p)) +-# define UA_SET64(p,v) ((* (__lzo_ua_volatile lzo_uint64p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint64) (v)) +-# define UA_COPY64(d,s) UA_SET64(d, UA_GET64(s)) +-# endif ++#ifndef UA_MOVE1 ++#define UA_MOVE1 LZO_MEMOPS_MOVE1 +#endif -+#if !defined(LZO_COMPILE_TIME_ASSERT) -+# if (LZO_CC_AZTECC) -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];} -+# elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) -+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -+# elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__) -+# define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));} -+# elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus) -+# define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));} -+# elif (LZO_CC_GNUC >= 0x040700ul) -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));} -+# elif (LZO_CC_MSC && (_MSC_VER < 900)) -+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -+# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) -+# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -+# else -+# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];} -+# endif ++#ifndef UA_MOVE2 ++#define UA_MOVE2 LZO_MEMOPS_MOVE2 +#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1) -+#if defined(__cplusplus) -+extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) } ++#ifndef UA_MOVE3 ++#define UA_MOVE3 LZO_MEMOPS_MOVE3 +#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3) -+#if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) -+# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) -+# elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) -+# define __lzo_cdecl __cdecl -+# define __lzo_cdecl_atexit /*empty*/ -+# define __lzo_cdecl_main __cdecl -+# if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) -+# define __lzo_cdecl_qsort __pascal -+# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) -+# define __lzo_cdecl_qsort _stdcall -+# else -+# define __lzo_cdecl_qsort __cdecl -+# endif -+# elif (LZO_CC_WATCOMC) -+# define __lzo_cdecl __cdecl -+# else -+# define __lzo_cdecl __cdecl -+# define __lzo_cdecl_atexit __cdecl -+# define __lzo_cdecl_main __cdecl -+# define __lzo_cdecl_qsort __cdecl -+# endif -+# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) -+# elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) -+# define __lzo_cdecl_sighandler __pascal -+# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) -+# define __lzo_cdecl_sighandler _stdcall -+# elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) -+# define __lzo_cdecl_sighandler __clrcall -+# elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) -+# if defined(_DLL) -+# define __lzo_cdecl_sighandler _far _cdecl _loadds -+# elif defined(_MT) -+# define __lzo_cdecl_sighandler _far _cdecl -+# else -+# define __lzo_cdecl_sighandler _cdecl -+# endif -+# else -+# define __lzo_cdecl_sighandler __cdecl -+# endif -+#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) -+# define __lzo_cdecl __cdecl -+#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) -+# define __lzo_cdecl cdecl ++#ifndef UA_MOVE4 ++#define UA_MOVE4 LZO_MEMOPS_MOVE4 +#endif -+#if !defined(__lzo_cdecl) -+# define __lzo_cdecl /*empty*/ ++#ifndef UA_MOVE8 ++#define UA_MOVE8 LZO_MEMOPS_MOVE8 +#endif -+#if !defined(__lzo_cdecl_atexit) -+# define __lzo_cdecl_atexit /*empty*/ ++#ifndef UA_COPY1 ++#define UA_COPY1 LZO_MEMOPS_COPY1 +#endif -+#if !defined(__lzo_cdecl_main) -+# define __lzo_cdecl_main /*empty*/ ++#ifndef UA_COPY2 ++#define UA_COPY2 LZO_MEMOPS_COPY2 +#endif -+#if !defined(__lzo_cdecl_qsort) -+# define __lzo_cdecl_qsort /*empty*/ ++#ifndef UA_COPY3 ++#define UA_COPY3 LZO_MEMOPS_COPY3 +#endif -+#if !defined(__lzo_cdecl_sighandler) -+# define __lzo_cdecl_sighandler /*empty*/ ++#ifndef UA_COPY4 ++#define UA_COPY4 LZO_MEMOPS_COPY4 +#endif -+#if !defined(__lzo_cdecl_va) -+# define __lzo_cdecl_va __lzo_cdecl ++#ifndef UA_COPY8 ++#define UA_COPY8 LZO_MEMOPS_COPY8 +#endif -+#if !(LZO_CFG_NO_WINDOWS_H) -+#if !defined(LZO_HAVE_WINDOWS_H) -+#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) -+# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) -+# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) -+# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) -+# else -+# define LZO_HAVE_WINDOWS_H 1 -+# endif ++#ifndef UA_COPYN ++#define UA_COPYN LZO_MEMOPS_COPYN +#endif ++#ifndef UA_COPYN_X ++#define UA_COPYN_X LZO_MEMOPS_COPYN +#endif ++#ifndef UA_GET_LE16 ++#define UA_GET_LE16 LZO_MEMOPS_GET_LE16 +#endif -+#ifndef LZO_SIZEOF_SHORT - #if defined(SIZEOF_SHORT) - # define LZO_SIZEOF_SHORT (SIZEOF_SHORT) -+#elif defined(__SIZEOF_SHORT__) -+# define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__) - #endif ++#ifndef UA_GET_LE32 ++#define UA_GET_LE32 LZO_MEMOPS_GET_LE32 +#endif -+#ifndef LZO_SIZEOF_INT - #if defined(SIZEOF_INT) - # define LZO_SIZEOF_INT (SIZEOF_INT) -+#elif defined(__SIZEOF_INT__) -+# define LZO_SIZEOF_INT (__SIZEOF_INT__) - #endif ++#ifdef LZO_MEMOPS_GET_LE64 ++#ifndef UA_GET_LE64 ++#define UA_GET_LE64 LZO_MEMOPS_GET_LE64 +#endif -+#ifndef LZO_SIZEOF_LONG - #if defined(SIZEOF_LONG) - # define LZO_SIZEOF_LONG (SIZEOF_LONG) -+#elif defined(__SIZEOF_LONG__) -+# define LZO_SIZEOF_LONG (__SIZEOF_LONG__) - #endif +#endif -+#ifndef LZO_SIZEOF_LONG_LONG - #if defined(SIZEOF_LONG_LONG) - # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) -+#elif defined(__SIZEOF_LONG_LONG__) -+# define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__) - #endif ++#ifndef UA_GET_NE16 ++#define UA_GET_NE16 LZO_MEMOPS_GET_NE16 +#endif -+#ifndef LZO_SIZEOF___INT16 - #if defined(SIZEOF___INT16) - # define LZO_SIZEOF___INT16 (SIZEOF___INT16) - #endif ++#ifndef UA_GET_NE32 ++#define UA_GET_NE32 LZO_MEMOPS_GET_NE32 +#endif -+#ifndef LZO_SIZEOF___INT32 - #if defined(SIZEOF___INT32) - # define LZO_SIZEOF___INT32 (SIZEOF___INT32) - #endif ++#ifdef LZO_MEMOPS_GET_NE64 ++#ifndef UA_GET_NE64 ++#define UA_GET_NE64 LZO_MEMOPS_GET_NE64 +#endif -+#ifndef LZO_SIZEOF___INT64 - #if defined(SIZEOF___INT64) - # define LZO_SIZEOF___INT64 (SIZEOF___INT64) - #endif +#endif -+#ifndef LZO_SIZEOF_VOID_P - #if defined(SIZEOF_VOID_P) - # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) -+#elif defined(__SIZEOF_POINTER__) -+# define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__) - #endif ++#ifndef UA_PUT_LE16 ++#define UA_PUT_LE16 LZO_MEMOPS_PUT_LE16 +#endif -+#ifndef LZO_SIZEOF_SIZE_T - #if defined(SIZEOF_SIZE_T) - # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) -+#elif defined(__SIZEOF_SIZE_T__) -+# define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__) - #endif ++#ifndef UA_PUT_LE32 ++#define UA_PUT_LE32 LZO_MEMOPS_PUT_LE32 +#endif -+#ifndef LZO_SIZEOF_PTRDIFF_T - #if defined(SIZEOF_PTRDIFF_T) - # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) -+#elif defined(__SIZEOF_PTRDIFF_T__) -+# define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__) ++#ifndef UA_PUT_NE16 ++#define UA_PUT_NE16 LZO_MEMOPS_PUT_NE16 +#endif ++#ifndef UA_PUT_NE32 ++#define UA_PUT_NE32 LZO_MEMOPS_PUT_NE32 #endif - #define __LZO_LSR(x,b) (((x)+0ul) >> (b)) - #if !defined(LZO_SIZEOF_SHORT) -@@ -1060,6 +2040,7 @@ extern "C" { - # error "LZO_SIZEOF_SHORT" - # endif - #endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short)) - #if !defined(LZO_SIZEOF_INT) - # if (LZO_ARCH_CRAY_PVP) - # define LZO_SIZEOF_INT 8 -@@ -1081,6 +2062,7 @@ extern "C" { - # error "LZO_SIZEOF_INT" - # endif - #endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int)) - #if !defined(LZO_SIZEOF_LONG) - # if (ULONG_MAX == LZO_0xffffffffL) - # define LZO_SIZEOF_LONG 4 -@@ -1090,6 +2072,8 @@ extern "C" { - # define LZO_SIZEOF_LONG 2 - # elif (__LZO_LSR(ULONG_MAX,31) == 1) - # define LZO_SIZEOF_LONG 4 -+# elif (__LZO_LSR(ULONG_MAX,39) == 1) -+# define LZO_SIZEOF_LONG 5 - # elif (__LZO_LSR(ULONG_MAX,63) == 1) - # define LZO_SIZEOF_LONG 8 - # elif (__LZO_LSR(ULONG_MAX,127) == 1) -@@ -1098,11 +2082,12 @@ extern "C" { - # error "LZO_SIZEOF_LONG" - # endif - #endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long)) - #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) - #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) - # if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) - # if (LZO_CC_GNUC >= 0x030300ul) --# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) -+# if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0)) - # define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG - # elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) - # define LZO_SIZEOF_LONG_LONG 4 -@@ -1116,7 +2101,7 @@ extern "C" { - #if (LZO_ARCH_I086 && LZO_CC_DMC) - #elif (LZO_CC_CILLY) && defined(__GNUC__) - # define LZO_SIZEOF_LONG_LONG 8 --#elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -+#elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) - # define LZO_SIZEOF_LONG_LONG 8 - #elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) - # define LZO_SIZEOF_LONG_LONG 8 -@@ -1138,11 +2123,13 @@ extern "C" { - # define LZO_SIZEOF___INT64 8 - #elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) - # define LZO_SIZEOF___INT64 8 --#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) -+#elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64)) -+# define LZO_SIZEOF_LONG_LONG 8 -+#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64)) - # define LZO_SIZEOF___INT64 8 - #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) - # define LZO_SIZEOF_LONG_LONG 8 --#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -+#elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64) - # define LZO_SIZEOF_LONG_LONG 8 - #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) - #elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -@@ -1155,87 +2142,127 @@ extern "C" { - # undef LZO_SIZEOF_LONG_LONG - # endif - #endif --#if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) -+#if (LZO_CFG_NO_LONG_LONG) -+# undef LZO_SIZEOF_LONG_LONG -+#elif defined(__NO_LONG_LONG) -+# undef LZO_SIZEOF_LONG_LONG -+#elif defined(_NO_LONGLONG) - # undef LZO_SIZEOF_LONG_LONG + + #define MEMCPY8_DS(dest,src,len) \ +@@ -2195,25 +3782,10 @@ LZO_EXTERN(const lzo_bytep) lzo_copyright(void); + extern "C" { #endif --#if !defined(LZO_SIZEOF_VOID_P) --#if (LZO_ARCH_I086) --# define __LZO_WORDSIZE 2 --# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) --# define LZO_SIZEOF_VOID_P 2 --# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) --# define LZO_SIZEOF_VOID_P 4 -+#if !defined(LZO_WORDSIZE) -+#if (LZO_ARCH_ALPHA) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_AMD64) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_AVR) -+# define LZO_WORDSIZE 1 -+#elif (LZO_ARCH_H8300) -+# if defined(__NORMAL_MODE__) -+# define LZO_WORDSIZE 4 -+# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) -+# define LZO_WORDSIZE 4 - # else --# error "LZO_MM" -+# define LZO_WORDSIZE 2 - # endif --#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) --# define __LZO_WORDSIZE 1 -+#elif (LZO_ARCH_I086) -+# define LZO_WORDSIZE 2 -+#elif (LZO_ARCH_IA64) -+# define LZO_WORDSIZE 8 -+#elif (LZO_ARCH_M16C) -+# define LZO_WORDSIZE 2 -+#elif (LZO_ARCH_SPU) -+# define LZO_WORDSIZE 4 -+#elif (LZO_ARCH_Z80) -+# define LZO_WORDSIZE 1 -+#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -+# define LZO_WORDSIZE 8 -+#elif (LZO_OS_OS400 || defined(__OS400__)) -+# define LZO_WORDSIZE 8 -+#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -+# define LZO_WORDSIZE 8 -+#endif -+#endif -+#if !defined(LZO_SIZEOF_VOID_P) -+#if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) -+# define LZO_SIZEOF_VOID_P 4 -+#elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) -+# define LZO_SIZEOF_VOID_P 8 -+#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) -+# define LZO_SIZEOF_VOID_P 8 -+#elif defined(__LP64__) || defined(__LP64) || defined(_LP64) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8) -+# define LZO_SIZEOF_VOID_P 8 -+#elif (LZO_ARCH_AVR) - # define LZO_SIZEOF_VOID_P 2 - #elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) - # define LZO_SIZEOF_VOID_P 2 - #elif (LZO_ARCH_H8300) - # if defined(__NORMAL_MODE__) --# define __LZO_WORDSIZE 4 - # define LZO_SIZEOF_VOID_P 2 - # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) --# define __LZO_WORDSIZE 4 - # define LZO_SIZEOF_VOID_P 4 - # else --# define __LZO_WORDSIZE 2 - # define LZO_SIZEOF_VOID_P 2 - # endif - # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) - # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT - # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT - # endif -+#elif (LZO_ARCH_I086) -+# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) -+# define LZO_SIZEOF_VOID_P 2 -+# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) -+# define LZO_SIZEOF_VOID_P 4 -+# else -+# error "invalid LZO_ARCH_I086 memory model" -+# endif - #elif (LZO_ARCH_M16C) --# define __LZO_WORDSIZE 2 - # if defined(__m32c_cpu__) || defined(__m32cm_cpu__) - # define LZO_SIZEOF_VOID_P 4 - # else - # define LZO_SIZEOF_VOID_P 2 - # endif -+#elif (LZO_ARCH_SPU) -+# define LZO_SIZEOF_VOID_P 4 -+#elif (LZO_ARCH_Z80) -+# define LZO_SIZEOF_VOID_P 2 - #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) --# define __LZO_WORDSIZE 8 - # define LZO_SIZEOF_VOID_P 4 --#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) --# define __LZO_WORDSIZE 8 --# define LZO_SIZEOF_VOID_P 8 --#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) --# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - #elif (LZO_OS_OS400 || defined(__OS400__)) --# define __LZO_WORDSIZE LZO_SIZEOF_LONG --# define LZO_SIZEOF_VOID_P 16 --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG --#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) --# define LZO_SIZEOF_VOID_P 8 --# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG --# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG --#elif (LZO_ARCH_SPU) --# if 0 --# define __LZO_WORDSIZE 16 --# endif --# define LZO_SIZEOF_VOID_P 4 --#else --# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG + +-#if !defined(lzo_uintptr_t) +-# if (__LZO_MMODEL_HUGE) +-# define lzo_uintptr_t unsigned long +-# else +-# define lzo_uintptr_t acc_uintptr_t +-# ifdef __ACC_INTPTR_T_IS_POINTER +-# define __LZO_UINTPTR_T_IS_POINTER 1 +-# endif +-# endif +-#endif +- + #if (LZO_ARCH_I086) +-#define PTR(a) ((lzo_bytep) (a)) +-#define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0) +-#define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0) ++#error "LZO_ARCH_I086 is unsupported" + #elif (LZO_MM_PVP) +-#define PTR(a) ((lzo_bytep) (a)) +-#define PTR_ALIGNED_8(a) ((((lzo_uintptr_t)(a)) >> 61) == 0) +-#define PTR_ALIGNED2_8(a,b) ((((lzo_uintptr_t)(a)|(lzo_uintptr_t)(b)) >> 61) == 0) ++#error "LZO_MM_PVP is unsupported" + #else + #define PTR(a) ((lzo_uintptr_t) (a)) + #define PTR_LINEAR(a) PTR(a) +@@ -2243,24 +3815,28 @@ typedef union + unsigned long a_ulong; + lzo_int a_lzo_int; + lzo_uint a_lzo_uint; +- lzo_int32 a_lzo_int32; +- lzo_uint32 a_lzo_uint32; +-#if defined(LZO_UINT64_MAX) +- lzo_int64 a_lzo_int64; +- lzo_uint64 a_lzo_uint64; -#endif ++ lzo_xint a_lzo_xint; ++ lzo_int16_t a_lzo_int16_t; ++ lzo_uint16_t a_lzo_uint16_t; ++ lzo_int32_t a_lzo_int32_t; ++ lzo_uint32_t a_lzo_uint32_t; ++#if defined(lzo_uint64_t) ++ lzo_int64_t a_lzo_int64_t; ++ lzo_uint64_t a_lzo_uint64_t; ++#endif ++ size_t a_size_t; + ptrdiff_t a_ptrdiff_t; + lzo_uintptr_t a_lzo_uintptr_t; +- lzo_voidp a_lzo_voidp; + void * a_void_p; +- lzo_bytep a_lzo_bytep; +- lzo_bytepp a_lzo_bytepp; +- lzo_uintp a_lzo_uintp; +- lzo_uint * a_lzo_uint_p; +- lzo_uint32p a_lzo_uint32p; +- lzo_uint32 * a_lzo_uint32_p; +- unsigned char * a_uchar_p; + char * a_char_p; ++ unsigned char * a_uchar_p; ++ const void * a_c_void_p; ++ const char * a_c_char_p; ++ const unsigned char * a_c_uchar_p; ++ lzo_voidp a_lzo_voidp; ++ lzo_bytep a_lzo_bytep; ++ const lzo_voidp a_c_lzo_voidp; ++ const lzo_bytep a_c_lzo_bytep; + } + lzo_full_align_t; + +@@ -2276,18 +3852,14 @@ lzo_full_align_t; + + #ifndef LZO_DICT_USE_PTR + #define LZO_DICT_USE_PTR 1 +-#if 0 && (LZO_ARCH_I086) +-# undef LZO_DICT_USE_PTR +-# define LZO_DICT_USE_PTR 0 -#endif --#if !defined(LZO_WORDSIZE) --# if defined(__LZO_WORDSIZE) --# define LZO_WORDSIZE __LZO_WORDSIZE -+# if defined(__LLP64_IFC__) -+# define LZO_SIZEOF_VOID_P 8 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - # else --# define LZO_WORDSIZE LZO_SIZEOF_VOID_P -+# define LZO_SIZEOF_VOID_P 16 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG - # endif -+#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -+# define LZO_SIZEOF_VOID_P 8 -+# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -+# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG #endif -+#endif -+#if !defined(LZO_SIZEOF_VOID_P) -+# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG -+#endif -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) - #if !defined(LZO_SIZEOF_SIZE_T) - #if (LZO_ARCH_I086 || LZO_ARCH_M16C) - # define LZO_SIZEOF_SIZE_T 2 --#else -+#endif -+#endif -+#if !defined(LZO_SIZEOF_SIZE_T) - # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P + + #if (LZO_DICT_USE_PTR) + # define lzo_dict_t const lzo_bytep +-# define lzo_dict_p lzo_dict_t __LZO_MMODEL * ++# define lzo_dict_p lzo_dict_t * + #else + # define lzo_dict_t lzo_uint +-# define lzo_dict_p lzo_dict_t __LZO_MMODEL * ++# define lzo_dict_p lzo_dict_t * #endif -+#if defined(offsetof) -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t)) + #endif - #if !defined(LZO_SIZEOF_PTRDIFF_T) +@@ -2300,10 +3872,9 @@ __lzo_ptr_linear(const lzo_voidp ptr) + lzo_uintptr_t p; + #if (LZO_ARCH_I086) -@@ -1248,11 +2275,18 @@ extern "C" { - # define LZO_SIZEOF_PTRDIFF_T 2 - # endif - # else --# error "LZO_MM" -+# error "invalid LZO_ARCH_I086 memory model" - # endif --#else -+#endif -+#endif -+#if !defined(LZO_SIZEOF_PTRDIFF_T) - # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T - #endif -+#if defined(offsetof) -+LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t)) -+#endif -+#if !defined(LZO_WORDSIZE) -+# define LZO_WORDSIZE LZO_SIZEOF_VOID_P - #endif - #if (LZO_ABI_NEUTRAL_ENDIAN) - # undef LZO_ABI_BIG_ENDIAN -@@ -1264,7 +2298,7 @@ extern "C" { - # define LZO_ABI_LITTLE_ENDIAN 1 - #elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) - # define LZO_ABI_LITTLE_ENDIAN 1 --#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390) -+#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU) - # define LZO_ABI_BIG_ENDIAN 1 - #elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) - # if (__LITTLE_ENDIAN__ == 1) -@@ -1280,6 +2314,19 @@ extern "C" { - # define LZO_ABI_BIG_ENDIAN 1 - #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) - # define LZO_ABI_LITTLE_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC) -+# if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) -+# error "unexpected configuration - check your compiler defines" -+# elif defined(__BIG_ENDIAN) -+# define LZO_ABI_BIG_ENDIAN 1 -+# else -+# define LZO_ABI_LITTLE_ENDIAN 1 -+# endif -+# define LZO_ABI_LITTLE_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__) -+# define LZO_ABI_BIG_ENDIAN 1 -+#elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__) -+# define LZO_ABI_LITTLE_ENDIAN 1 - #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) - # define LZO_ABI_BIG_ENDIAN 1 - #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) -@@ -1287,7 +2334,7 @@ extern "C" { - #endif - #endif - #if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) --# error "this should not happen" -+# error "unexpected configuration - check your compiler defines" - #endif - #if (LZO_ABI_BIG_ENDIAN) - # define LZO_INFO_ABI_ENDIAN "be" -@@ -1302,6 +2349,9 @@ extern "C" { - #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) - # define LZO_ABI_ILP16 1 - # define LZO_INFO_ABI_PM "ilp16" -+#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) -+# define LZO_ABI_LP32 1 -+# define LZO_INFO_ABI_PM "lp32" - #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) - # define LZO_ABI_ILP32 1 - # define LZO_INFO_ABI_PM "ilp32" -@@ -1318,7 +2368,8 @@ extern "C" { - # define LZO_ABI_IP32L64 1 - # define LZO_INFO_ABI_PM "ip32l64" - #endif --#if !defined(__LZO_LIBC_OVERRIDE) -+#if 0 -+#elif !defined(__LZO_LIBC_OVERRIDE) - #if (LZO_LIBC_NAKED) - # define LZO_INFO_LIBC "naked" - #elif (LZO_LIBC_FREESTANDING) -@@ -1329,6 +2380,9 @@ extern "C" { - # define LZO_INFO_LIBC "isoc90" - #elif (LZO_LIBC_ISOC99) - # define LZO_INFO_LIBC "isoc99" -+#elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION) -+# define LZO_LIBC_ISOC90 1 -+# define LZO_INFO_LIBC "isoc90" - #elif defined(__dietlibc__) - # define LZO_LIBC_DIETLIBC 1 - # define LZO_INFO_LIBC "dietlibc" -@@ -1337,13 +2391,13 @@ extern "C" { - # define LZO_INFO_LIBC "newlib" - #elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) - # if defined(__UCLIBC_SUBLEVEL__) --# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) -+# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0)) - # else - # define LZO_LIBC_UCLIBC 0x00090bL - # endif --# define LZO_INFO_LIBC "uclibc" -+# define LZO_INFO_LIBC "uc" "libc" - #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) --# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) -+# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100) - # define LZO_INFO_LIBC "glibc" - #elif (LZO_CC_MWERKS) && defined(__MSL__) - # define LZO_LIBC_MSL __MSL__ -@@ -1356,423 +2410,159 @@ extern "C" { - # define LZO_INFO_LIBC "default" - #endif +- p = (((lzo_uintptr_t)(ACC_PTR_FP_SEG(ptr))) << (16 - ACC_MM_AHSHIFT)) + (ACC_PTR_FP_OFF(ptr)); ++#error "LZO_ARCH_I086 is unsupported" + #elif (LZO_MM_PVP) +- p = (lzo_uintptr_t) (ptr); +- p = (p << 3) | (p >> 61); ++#error "LZO_MM_PVP is unsupported" + #else + p = (lzo_uintptr_t) PTR_LINEAR(ptr); #endif --#if !defined(__lzo_gnuc_extension__) --#if (LZO_CC_GNUC >= 0x020800ul) --# define __lzo_gnuc_extension__ __extension__ --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_gnuc_extension__ __extension__ --#else --# define __lzo_gnuc_extension__ /*empty*/ --#endif --#endif --#if !defined(__lzo_ua_volatile) --# define __lzo_ua_volatile volatile --#endif --#if !defined(__lzo_alignof) --#if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) --# define __lzo_alignof(e) __alignof__(e) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) --# define __lzo_alignof(e) __alignof__(e) --#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) --# define __lzo_alignof(e) __alignof(e) --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_alignof(e) __alignof__(e) --#endif --#endif --#if defined(__lzo_alignof) --# define __lzo_HAVE_alignof 1 --#endif --#if !defined(__lzo_constructor) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_constructor __attribute__((__constructor__,__used__)) --#elif (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_constructor __attribute__((__constructor__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_constructor __attribute__((__constructor__)) --#endif --#endif --#if defined(__lzo_constructor) --# define __lzo_HAVE_constructor 1 --#endif --#if !defined(__lzo_destructor) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_destructor __attribute__((__destructor__,__used__)) --#elif (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_destructor __attribute__((__destructor__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_destructor __attribute__((__destructor__)) --#endif --#endif --#if defined(__lzo_destructor) --# define __lzo_HAVE_destructor 1 --#endif --#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) --# error "this should not happen" --#endif --#if !defined(__lzo_inline) --#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) --#elif defined(__cplusplus) --# define __lzo_inline inline --#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) --# define __lzo_inline __inline --#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) --# define __lzo_inline __inline__ --#elif (LZO_CC_DMC) --# define __lzo_inline __inline --#elif (LZO_CC_INTELC) --# define __lzo_inline __inline --#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) --# define __lzo_inline __inline --#elif (LZO_CC_MSC && (_MSC_VER >= 900)) --# define __lzo_inline __inline --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_inline __inline__ --#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) --# define __lzo_inline inline --#endif --#endif --#if defined(__lzo_inline) --# define __lzo_HAVE_inline 1 --#else --# define __lzo_inline /*empty*/ --#endif --#if !defined(__lzo_forceinline) --#if (LZO_CC_GNUC >= 0x030200ul) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) --# define __lzo_forceinline __forceinline --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) --# define __lzo_forceinline __forceinline --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) --#endif --#endif --#if defined(__lzo_forceinline) --# define __lzo_HAVE_forceinline 1 +@@ -2314,9 +3885,8 @@ __lzo_ptr_linear(const lzo_voidp ptr) + LZO_PUBLIC(unsigned) + __lzo_align_gap(const lzo_voidp ptr, lzo_uint size) + { +-#if defined(__LZO_UINTPTR_T_IS_POINTER) +- size_t n = (size_t) ptr; +- n = (((n + size - 1) / size) * size) - n; ++#if (__LZO_UINTPTR_T_IS_POINTER) ++#error "__LZO_UINTPTR_T_IS_POINTER is unsupported" + #else + lzo_uintptr_t p, n; + p = __lzo_ptr_linear(ptr); +@@ -2342,7 +3912,7 @@ static const char __lzo_copyright[] = + #else + "\r\n\n" + "LZO data compression library.\n" +- "$Copyright: LZO Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\n" ++ "$Copyright: LZO Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer\n" + "\n" + "http://www.oberhumer.com $\n\n" + "$Id: LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE " $\n" +@@ -2352,11 +3922,7 @@ static const char __lzo_copyright[] = + LZO_PUBLIC(const lzo_bytep) + lzo_copyright(void) + { +-#if (LZO_OS_DOS16 && LZO_CC_TURBOC) +- return (lzo_voidp) __lzo_copyright; -#else --# define __lzo_forceinline /*empty*/ + return (const lzo_bytep) __lzo_copyright; -#endif --#if !defined(__lzo_noinline) --#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) --# define __lzo_noinline __attribute__((__noinline__,__used__)) --#elif (LZO_CC_GNUC >= 0x030200ul) --# define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) --# define __lzo_noinline __declspec(noinline) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) --# define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_noinline __attribute__((__noinline__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) --# define __lzo_noinline __declspec(noinline) --#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) --# if defined(__cplusplus) --# else --# define __lzo_noinline __declspec(noinline) --# endif --#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) --# define __lzo_noinline __attribute__((__noinline__)) + } + + LZO_PUBLIC(unsigned) +@@ -2393,16 +3959,16 @@ _lzo_version_date(void) + #define LZO_NMAX 5552 + + #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1 +-#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1); +-#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2); +-#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4); +-#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8); ++#define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1) ++#define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2) ++#define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4) ++#define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8) + +-LZO_PUBLIC(lzo_uint32) +-lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len) ++LZO_PUBLIC(lzo_uint32_t) ++lzo_adler32(lzo_uint32_t adler, const lzo_bytep buf, lzo_uint len) + { +- lzo_uint32 s1 = adler & 0xffff; +- lzo_uint32 s2 = (adler >> 16) & 0xffff; ++ lzo_uint32_t s1 = adler & 0xffff; ++ lzo_uint32_t s2 = (adler >> 16) & 0xffff; + unsigned k; + + if (buf == NULL) +@@ -2459,8 +4025,8 @@ lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len) + LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo_hsize_t len) + { + #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP) +- const lzo_hbyte_p p1 = (const lzo_hbyte_p) s1; +- const lzo_hbyte_p p2 = (const lzo_hbyte_p) s2; ++ const lzo_hbyte_p p1 = LZO_STATIC_CAST(const lzo_hbyte_p, s1); ++ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, s2); + if __lzo_likely(len > 0) do + { + int d = *p1 - *p2; +@@ -2476,8 +4042,8 @@ LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo + LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) + { + #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY) +- lzo_hbyte_p p1 = (lzo_hbyte_p) dest; +- const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; ++ lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest); ++ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src); + if (!(len > 0) || p1 == p2) + return dest; + do +@@ -2491,8 +4057,8 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src + LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) + { + #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE) +- lzo_hbyte_p p1 = (lzo_hbyte_p) dest; +- const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; ++ lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest); ++ const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src); + if (!(len > 0) || p1 == p2) + return dest; + if (p1 < p2) +@@ -2514,16 +4080,17 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p sr + return memmove(dest, src, len); + #endif + } +-LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len) ++LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int cc, lzo_hsize_t len) + { + #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET) +- lzo_hbyte_p p = (lzo_hbyte_p) s; ++ lzo_hbyte_p p = LZO_STATIC_CAST(lzo_hbyte_p, s); ++ unsigned char c = LZO_ITRUNC(unsigned char, cc); + if __lzo_likely(len > 0) do +- *p++ = (unsigned char) c; ++ *p++ = c; + while __lzo_likely(--len > 0); + return s; + #else +- return memset(s, c, len); ++ return memset(s, cc, len); + #endif + } + #undef LZOLIB_PUBLIC +@@ -2532,105 +4099,28 @@ LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len) + + #if !defined(__LZO_IN_MINILZO) + +-#define ACC_WANT_ACC_CHK_CH 1 +-#undef ACCCHK_ASSERT +- +- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int) +- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) +- +- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int32) +- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32) +- ACCCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) +- ACCCHK_ASSERT(sizeof(lzo_uint32) >= 4) +-#if defined(LZO_UINT64_MAX) +- ACCCHK_ASSERT(sizeof(lzo_uint64) == 8) +- ACCCHK_ASSERT_IS_SIGNED_T(lzo_int64) +- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint64) -#endif +- +-#if !defined(__LZO_UINTPTR_T_IS_POINTER) +- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) -#endif --#if defined(__lzo_noinline) --# define __lzo_HAVE_noinline 1 --#else --# define __lzo_noinline /*empty*/ +- ACCCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) +- +- ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) +- ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint32)) +- ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint)) +- ACCCHK_ASSERT(sizeof(lzo_xint) == sizeof(lzo_uint32) || sizeof(lzo_xint) == sizeof(lzo_uint)) ++#define LZO_WANT_ACC_CHK_CH 1 ++#undef LZOCHK_ASSERT + ++ LZOCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) ++ LZOCHK_ASSERT_IS_SIGNED_T(lzo_int) ++ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) ++#if !(__LZO_UINTPTR_T_IS_POINTER) ++ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) + #endif +-#undef ACCCHK_ASSERT ++ LZOCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) ++ LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) + +-#if 0 +-#define WANT_lzo_bitops_clz32 1 +-#define WANT_lzo_bitops_clz64 1 -#endif --#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) --# error "this should not happen" +-#define WANT_lzo_bitops_ctz32 1 +-#define WANT_lzo_bitops_ctz64 1 +- +-#if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) +-#include +-#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0 +-#pragma intrinsic(_BitScanReverse) +-static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v) +-{ +- unsigned long r; +- (void) _BitScanReverse(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_clz32 lzo_bitops_clz32 -#endif --#if !defined(__lzo_noreturn) --#if (LZO_CC_GNUC >= 0x020700ul) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) --# define __lzo_noreturn __declspec(noreturn) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_noreturn __attribute__((__noreturn__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) --# define __lzo_noreturn __declspec(noreturn) +-#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0 +-#pragma intrinsic(_BitScanReverse64) +-static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v) +-{ +- unsigned long r; +- (void) _BitScanReverse64(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_clz64 lzo_bitops_clz64 -#endif +-#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) +-#pragma intrinsic(_BitScanForward) +-static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v) +-{ +- unsigned long r; +- (void) _BitScanForward(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_ctz32 lzo_bitops_ctz32 -#endif --#if defined(__lzo_noreturn) --# define __lzo_HAVE_noreturn 1 --#else --# define __lzo_noreturn /*empty*/ +-#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) +-#pragma intrinsic(_BitScanForward64) +-static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v) +-{ +- unsigned long r; +- (void) _BitScanForward64(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_ctz64 lzo_bitops_ctz64 + #endif ++#undef LZOCHK_ASSERT + +-#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM) +-#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) +-#define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v)) -#endif --#if !defined(__lzo_nothrow) --#if (LZO_CC_GNUC >= 0x030300ul) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) --# define __lzo_nothrow __declspec(nothrow) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_nothrow __attribute__((__nothrow__)) --#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) --# define __lzo_nothrow __declspec(nothrow) +-#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) +-#define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v)) -#endif +-#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) +-#define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v)) -#endif --#if defined(__lzo_nothrow) --# define __lzo_HAVE_nothrow 1 --#else --# define __lzo_nothrow /*empty*/ +-#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) +-#define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v)) -#endif --#if !defined(__lzo_restrict) --#if (LZO_CC_GNUC >= 0x030400ul) --# define __lzo_restrict __restrict__ --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) --# define __lzo_restrict __restrict__ --#elif (LZO_CC_CLANG || LZO_CC_LLVM) --# define __lzo_restrict __restrict__ --#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) --# define __lzo_restrict __restrict +-#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32) +-#define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v)) -#endif +-#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX) +-#define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v)) -#endif --#if defined(__lzo_restrict) --# define __lzo_HAVE_restrict 1 --#else --# define __lzo_restrict /*empty*/ ++union lzo_config_check_union { ++ lzo_uint a[2]; ++ unsigned char b[2*LZO_MAX(8,sizeof(lzo_uint))]; ++#if defined(lzo_uint64_t) ++ lzo_uint64_t c[2]; + #endif ++}; + + #if 0 + #define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off))) +@@ -2644,73 +4134,101 @@ static __lzo_noinline lzo_voidp u2p(lzo_voidp ptr, lzo_uint off) + LZO_PUBLIC(int) + _lzo_config_check(void) + { +- lzo_bool r = 1; +- union { +- lzo_xint a[2]; unsigned char b[2*LZO_MAX(8,sizeof(lzo_xint))]; +-#if defined(LZO_UNALIGNED_OK_8) +- lzo_uint64 c[2]; -#endif --#if !defined(__lzo_likely) && !defined(__lzo_unlikely) --#if (LZO_CC_GNUC >= 0x030200ul) --# define __lzo_likely(e) (__builtin_expect(!!(e),1)) --# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) --#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) --# define __lzo_likely(e) (__builtin_expect(!!(e),1)) --# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) --#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define __lzo_likely(e) (__builtin_expect(!!(e),1)) --# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) +- unsigned short x[2]; lzo_uint32 y[2]; lzo_uint z[2]; +- } u; ++#if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030100ul && LZO_CC_CLANG < 0x030300ul)) ++# if 0 ++ volatile ++# endif ++#endif ++ union lzo_config_check_union u; + lzo_voidp p; ++ unsigned r = 1; + + u.a[0] = u.a[1] = 0; + p = u2p(&u, 0); + r &= ((* (lzo_bytep) p) == 0); +-#if !defined(LZO_CFG_NO_CONFIG_CHECK) +-#if defined(LZO_ABI_BIG_ENDIAN) ++#if !(LZO_CFG_NO_CONFIG_CHECK) ++#if (LZO_ABI_BIG_ENDIAN) + u.a[0] = u.a[1] = 0; u.b[sizeof(lzo_uint) - 1] = 128; + p = u2p(&u, 0); + r &= ((* (lzo_uintp) p) == 128); + #endif +-#if defined(LZO_ABI_LITTLE_ENDIAN) ++#if (LZO_ABI_LITTLE_ENDIAN) + u.a[0] = u.a[1] = 0; u.b[0] = 128; + p = u2p(&u, 0); + r &= ((* (lzo_uintp) p) == 128); + #endif +-#if defined(LZO_UNALIGNED_OK_2) + u.a[0] = u.a[1] = 0; +- u.b[0] = 1; u.b[sizeof(unsigned short) + 1] = 2; ++ u.b[0] = 1; u.b[3] = 2; + p = u2p(&u, 1); +- r &= ((* (lzo_ushortp) p) == 0); ++ r &= UA_GET_NE16(p) == 0; ++ r &= UA_GET_LE16(p) == 0; ++ u.b[1] = 128; ++ r &= UA_GET_LE16(p) == 128; ++ u.b[2] = 129; ++ r &= UA_GET_LE16(p) == LZO_UINT16_C(0x8180); ++#if (LZO_ABI_BIG_ENDIAN) ++ r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8081); ++#endif ++#if (LZO_ABI_LITTLE_ENDIAN) ++ r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8180); + #endif +-#if defined(LZO_UNALIGNED_OK_4) + u.a[0] = u.a[1] = 0; +- u.b[0] = 3; u.b[sizeof(lzo_uint32) + 1] = 4; ++ u.b[0] = 3; u.b[5] = 4; + p = u2p(&u, 1); +- r &= ((* (lzo_uint32p) p) == 0); ++ r &= UA_GET_NE32(p) == 0; ++ r &= UA_GET_LE32(p) == 0; ++ u.b[1] = 128; ++ r &= UA_GET_LE32(p) == 128; ++ u.b[2] = 129; u.b[3] = 130; u.b[4] = 131; ++ r &= UA_GET_LE32(p) == LZO_UINT32_C(0x83828180); ++#if (LZO_ABI_BIG_ENDIAN) ++ r &= UA_GET_NE32(p) == LZO_UINT32_C(0x80818283); + #endif +-#if defined(LZO_UNALIGNED_OK_8) ++#if (LZO_ABI_LITTLE_ENDIAN) ++ r &= UA_GET_NE32(p) == LZO_UINT32_C(0x83828180); ++#endif ++#if defined(UA_GET_NE64) + u.c[0] = u.c[1] = 0; +- u.b[0] = 5; u.b[sizeof(lzo_uint64) + 1] = 6; ++ u.b[0] = 5; u.b[9] = 6; + p = u2p(&u, 1); +- r &= ((* (lzo_uint64p) p) == 0); -#endif +-#if defined(lzo_bitops_clz32) +- { unsigned i; lzo_uint32 v = 1; +- for (i = 0; i < 31; i++, v <<= 1) +- r &= lzo_bitops_clz32(v) == 31 - i; +- } -#endif --#if defined(__lzo_likely) --# define __lzo_HAVE_likely 1 --#else --# define __lzo_likely(e) (e) +-#if defined(lzo_bitops_clz64) +- { unsigned i; lzo_uint64 v = 1; +- for (i = 0; i < 63; i++, v <<= 1) +- r &= lzo_bitops_clz64(v) == 63 - i; +- } -#endif --#if defined(__lzo_unlikely) --# define __lzo_HAVE_unlikely 1 --#else --# define __lzo_unlikely(e) (e) +-#if defined(lzo_bitops_ctz32) +- { unsigned i; lzo_uint32 v = 1; +- for (i = 0; i < 31; i++, v <<= 1) +- r &= lzo_bitops_ctz32(v) == i; +- } -#endif --#if !defined(LZO_UNUSED) --# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) --# define LZO_UNUSED(var) ((void) &var) --# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) --# define LZO_UNUSED(var) if (&var) ; else --# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define LZO_UNUSED(var) ((void) var) --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_UNUSED(var) if (&var) ; else --# elif (LZO_CC_KEILC) --# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} --# elif (LZO_CC_PACIFICC) --# define LZO_UNUSED(var) ((void) sizeof(var)) --# elif (LZO_CC_WATCOMC) && defined(__cplusplus) --# define LZO_UNUSED(var) ((void) var) --# else --# define LZO_UNUSED(var) ((void) &var) --# endif +-#if defined(lzo_bitops_ctz64) +- { unsigned i; lzo_uint64 v = 1; +- for (i = 0; i < 63; i++, v <<= 1) +- r &= lzo_bitops_ctz64(v) == i; +- } -#endif --#if !defined(LZO_UNUSED_FUNC) --# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) --# define LZO_UNUSED_FUNC(func) ((void) func) --# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) --# define LZO_UNUSED_FUNC(func) if (func) ; else --# elif (LZO_CC_CLANG || LZO_CC_LLVM) --# define LZO_UNUSED_FUNC(func) ((void) &func) --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_UNUSED_FUNC(func) if (func) ; else --# elif (LZO_CC_MSC) --# define LZO_UNUSED_FUNC(func) ((void) &func) --# elif (LZO_CC_KEILC || LZO_CC_PELLESC) --# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} --# else --# define LZO_UNUSED_FUNC(func) ((void) func) --# endif -#endif --#if !defined(LZO_UNUSED_LABEL) --# if (LZO_CC_WATCOMC) && defined(__cplusplus) --# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l --# elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) --# define LZO_UNUSED_LABEL(l) if (0) goto l --# else --# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l --# endif ++ u.c[0] = u.c[1] = 0; ++ r &= UA_GET_NE64(p) == 0; ++#if defined(UA_GET_LE64) ++ r &= UA_GET_LE64(p) == 0; ++ u.b[1] = 128; ++ r &= UA_GET_LE64(p) == 128; ++#endif ++#endif ++#if defined(lzo_bitops_ctlz32) ++ { unsigned i = 0; lzo_uint32_t v; ++ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { ++ r &= lzo_bitops_ctlz32(v) == 31 - i; ++ r &= lzo_bitops_ctlz32_func(v) == 31 - i; ++ }} ++#endif ++#if defined(lzo_bitops_ctlz64) ++ { unsigned i = 0; lzo_uint64_t v; ++ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { ++ r &= lzo_bitops_ctlz64(v) == 63 - i; ++ r &= lzo_bitops_ctlz64_func(v) == 63 - i; ++ }} ++#endif ++#if defined(lzo_bitops_cttz32) ++ { unsigned i = 0; lzo_uint32_t v; ++ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { ++ r &= lzo_bitops_cttz32(v) == i; ++ r &= lzo_bitops_cttz32_func(v) == i; ++ }} ++#endif ++#if defined(lzo_bitops_cttz64) ++ { unsigned i = 0; lzo_uint64_t v; ++ for (v = 1; v != 0 && r == 1; v <<= 1, i++) { ++ r &= lzo_bitops_cttz64(v) == i; ++ r &= lzo_bitops_cttz64_func(v) == i; ++ }} ++#endif ++#endif ++ LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); + + return r == 1 ? LZO_E_OK : LZO_E_ERROR; + } +@@ -2724,11 +4242,11 @@ __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, + #if defined(__LZO_IN_MINILZO) + #elif (LZO_CC_MSC && ((_MSC_VER) < 700)) + #else +-#define ACC_WANT_ACC_CHK_CH 1 +-#undef ACCCHK_ASSERT +-#define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) ++#define LZO_WANT_ACC_CHK_CH 1 ++#undef LZOCHK_ASSERT ++#define LZOCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) + #endif +-#undef ACCCHK_ASSERT ++#undef LZOCHK_ASSERT + + if (v == 0) + return LZO_E_ERROR; +@@ -2736,7 +4254,7 @@ __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, + r = (s1 == -1 || s1 == (int) sizeof(short)) && + (s2 == -1 || s2 == (int) sizeof(int)) && + (s3 == -1 || s3 == (int) sizeof(long)) && +- (s4 == -1 || s4 == (int) sizeof(lzo_uint32)) && ++ (s4 == -1 || s4 == (int) sizeof(lzo_uint32_t)) && + (s5 == -1 || s5 == (int) sizeof(lzo_uint)) && + (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) && + (s7 == -1 || s7 == (int) sizeof(char *)) && +@@ -2779,11 +4297,11 @@ int __far __pascal LibMain ( int a, short b, short c, long d ) + + #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS) + +-#if 1 && defined(UA_GET32) ++#if 1 && defined(UA_GET_LE32) + #undef LZO_DICT_USE_PTR + #define LZO_DICT_USE_PTR 0 + #undef lzo_dict_t +-#define lzo_dict_t unsigned short ++#define lzo_dict_t lzo_uint16_t + #endif + + #define LZO_NEED_DICT_H 1 +@@ -3088,77 +4606,7 @@ DVAL_ASSERT(lzo_xint dv, const lzo_bytep p) + #endif + + #if 1 && defined(DO_COMPRESS) && !defined(do_compress) +-# define do_compress LZO_CPP_ECONCAT2(DO_COMPRESS,_core) -#endif --#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) --# if 0 --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var --# elif 0 && (LZO_CC_GNUC) --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var --# else --# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init --# endif +- +-#if defined(UA_GET64) +-# define WANT_lzo_bitops_ctz64 1 +-#elif defined(UA_GET32) +-# define WANT_lzo_bitops_ctz32 1 -#endif --#if !defined(LZO_UNCONST_CAST) --# if 0 && defined(__cplusplus) --# define LZO_UNCONST_CAST(t,e) (const_cast (e)) --# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) --# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e)))))) --# else --# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) --# endif +- +-#if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400))) +-#include +-#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0 +-#pragma intrinsic(_BitScanReverse) +-static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v) +-{ +- unsigned long r; +- (void) _BitScanReverse(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_clz32 lzo_bitops_clz32 -#endif --#if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) --# if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; --# elif (LZO_CC_DMC || LZO_CC_SYMANTECC) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; --# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; --# else --# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; --# endif +-#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0 +-#pragma intrinsic(_BitScanReverse64) +-static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v) +-{ +- unsigned long r; +- (void) _BitScanReverse64(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_clz64 lzo_bitops_clz64 -#endif --#if !defined(LZO_COMPILE_TIME_ASSERT) --# if (LZO_CC_AZTECC) --# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} --# elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) --# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; --# elif (LZO_CC_MSC && (_MSC_VER < 900)) --# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; --# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) --# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; --# else --# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} --# endif +-#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) +-#pragma intrinsic(_BitScanForward) +-static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v) +-{ +- unsigned long r; +- (void) _BitScanForward(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_ctz32 lzo_bitops_ctz32 -#endif --#if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) --# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) --# elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) --# define __lzo_cdecl __cdecl --# define __lzo_cdecl_atexit /*empty*/ --# define __lzo_cdecl_main __cdecl --# if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) --# define __lzo_cdecl_qsort __pascal --# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) --# define __lzo_cdecl_qsort _stdcall --# else --# define __lzo_cdecl_qsort __cdecl --# endif --# elif (LZO_CC_WATCOMC) --# define __lzo_cdecl __cdecl --# else --# define __lzo_cdecl __cdecl --# define __lzo_cdecl_atexit __cdecl --# define __lzo_cdecl_main __cdecl --# define __lzo_cdecl_qsort __cdecl --# endif --# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) --# elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) --# define __lzo_cdecl_sighandler __pascal --# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) --# define __lzo_cdecl_sighandler _stdcall --# elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) --# define __lzo_cdecl_sighandler __clrcall --# elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) --# if defined(_DLL) --# define __lzo_cdecl_sighandler _far _cdecl _loadds --# elif defined(_MT) --# define __lzo_cdecl_sighandler _far _cdecl --# else --# define __lzo_cdecl_sighandler _cdecl --# endif --# else --# define __lzo_cdecl_sighandler __cdecl --# endif --#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) --# define __lzo_cdecl __cdecl --#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) --# define __lzo_cdecl cdecl +-#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) +-#pragma intrinsic(_BitScanForward64) +-static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v) +-{ +- unsigned long r; +- (void) _BitScanForward64(&r, v); +- return (unsigned) r; +-} +-#define lzo_bitops_ctz64 lzo_bitops_ctz64 -#endif --#if !defined(__lzo_cdecl) --# define __lzo_cdecl /*empty*/ +- +-#elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || LZO_CC_LLVM) +-#if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) +-#define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v)) -#endif --#if !defined(__lzo_cdecl_atexit) --# define __lzo_cdecl_atexit /*empty*/ +-#if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) +-#define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v)) -#endif --#if !defined(__lzo_cdecl_main) --# define __lzo_cdecl_main /*empty*/ +-#if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32) +-#define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v)) -#endif --#if !defined(__lzo_cdecl_qsort) --# define __lzo_cdecl_qsort /*empty*/ +-#if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX) +-#define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v)) -#endif --#if !defined(__lzo_cdecl_sighandler) --# define __lzo_cdecl_sighandler /*empty*/ +-#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32) +-#define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v)) -#endif --#if !defined(__lzo_cdecl_va) --# define __lzo_cdecl_va __lzo_cdecl +-#if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX) +-#define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v)) -#endif --#if !(LZO_CFG_NO_WINDOWS_H) --#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) --# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) --# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) --# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) --# else --# define LZO_HAVE_WINDOWS_H 1 --# endif -+#if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -+# define LZO_ASM_SYNTAX_MSC 1 -+#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -+#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) -+#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#elif (LZO_CC_GNUC) -+# define LZO_ASM_SYNTAX_GNUC 1 -+#endif -+#if (LZO_ASM_SYNTAX_GNUC) -+#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) -+# define __LZO_ASM_CLOBBER "ax" -+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ -+#elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000)) -+# define __LZO_ASM_CLOBBER "memory" -+# define __LZO_ASM_CLOBBER_LIST_CC /*empty*/ -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory" -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ -+#else -+# define __LZO_ASM_CLOBBER "cc", "memory" -+# define __LZO_ASM_CLOBBER_LIST_CC : "cc" -+# define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory" -+# define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/ ++# define do_compress LZO_PP_ECONCAT2(DO_COMPRESS,_core) #endif + + static __lzo_noinline lzo_uint +@@ -3166,7 +4614,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len, + lzo_bytep out, lzo_uintp out_len, + lzo_uint ti, lzo_voidp wrkmem) + { +- register const lzo_bytep ip; ++ const lzo_bytep ip; + lzo_bytep op; + const lzo_bytep const in_end = in + in_len; + const lzo_bytep const ip_end = in + in_len - 20; +@@ -3175,7 +4623,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len, + + op = out; + ip = in; +- ii = ip - ti; ++ ii = ip; + + ip += ti < 4 ? 4 - ti : 0; + for (;;) +@@ -3205,8 +4653,8 @@ next: + goto literal; + + try_match: +-#if defined(UA_GET32) +- if (UA_GET32(m_pos) != UA_GET32(ip)) ++#if (LZO_OPT_UNALIGNED32) ++ if (UA_GET_NE32(m_pos) != UA_GET_NE32(ip)) + #else + if (m_pos[0] != ip[0] || m_pos[1] != ip[1] || m_pos[2] != ip[2] || m_pos[3] != ip[3]) #endif - #if (LZO_ARCH_ALPHA) --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_AVOID_SHORT 1 --# define LZO_OPT_AVOID_USHORT 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 - #elif (LZO_ARCH_AMD64) --# define LZO_OPT_AVOID_INT_INDEX 1 --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 --# define LZO_OPT_UNALIGNED64 1 --#elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) -+# define LZO_OPT_AVOID_INT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - #elif (LZO_ARCH_ARM) --# define LZO_OPT_AVOID_SHORT 1 --# define LZO_OPT_AVOID_USHORT 1 -+# if defined(__ARM_FEATURE_UNALIGNED) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 7) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# elif defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM+0) >= 6) && !defined(__TARGET_PROFILE_M) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# endif -+#elif (LZO_ARCH_ARM64) -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - #elif (LZO_ARCH_CRIS) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - #elif (LZO_ARCH_I386) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - #elif (LZO_ARCH_IA64) --# define LZO_OPT_AVOID_INT_INDEX 1 --# define LZO_OPT_AVOID_UINT_INDEX 1 --# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_AVOID_INT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 -+# define LZO_OPT_PREFER_POSTINC 1 - #elif (LZO_ARCH_M68K) --# define LZO_OPT_PREFER_POSTINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 - # if defined(__mc68020__) && !defined(__mcoldfire__) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif - # endif - #elif (LZO_ARCH_MIPS) --# define LZO_OPT_AVOID_UINT_INDEX 1 -+# define LZO_OPT_AVOID_UINT_INDEX 1 - #elif (LZO_ARCH_POWERPC) --# define LZO_OPT_PREFER_PREINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_PREINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 - # if (LZO_ABI_BIG_ENDIAN) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# if (LZO_WORDSIZE == 8) -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif -+# endif - # endif - #elif (LZO_ARCH_S390) --# define LZO_OPT_UNALIGNED16 1 --# define LZO_OPT_UNALIGNED32 1 --# if (LZO_SIZEOF_SIZE_T == 8) --# define LZO_OPT_UNALIGNED64 1 -+# ifndef LZO_OPT_UNALIGNED16 -+# define LZO_OPT_UNALIGNED16 1 -+# endif -+# ifndef LZO_OPT_UNALIGNED32 -+# define LZO_OPT_UNALIGNED32 1 -+# endif -+# if (LZO_WORDSIZE == 8) -+# ifndef LZO_OPT_UNALIGNED64 -+# define LZO_OPT_UNALIGNED64 1 -+# endif - # endif - #elif (LZO_ARCH_SH) --# define LZO_OPT_PREFER_POSTINC 1 --# define LZO_OPT_PREFER_PREDEC 1 -+# define LZO_OPT_PREFER_POSTINC 1 -+# define LZO_OPT_PREFER_PREDEC 1 +@@ -3221,49 +4669,43 @@ literal: + lzo_uint m_off; + lzo_uint m_len; + { +- lzo_uint32 dv; ++ lzo_uint32_t dv; + lzo_uint dindex; + literal: + ip += 1 + ((ip - ii) >> 5); + next: + if __lzo_unlikely(ip >= ip_end) + break; +- dv = UA_GET32(ip); ++ dv = UA_GET_LE32(ip); + dindex = DINDEX(dv,ip); + GINDEX(m_off,m_pos,in+dict,dindex,in); + UPDATE_I(dict,0,dindex,ip,in); +- if __lzo_unlikely(dv != UA_GET32(m_pos)) ++ if __lzo_unlikely(dv != UA_GET_LE32(m_pos)) + goto literal; + } + #endif + ++ ii -= ti; ti = 0; + { +- register lzo_uint t = pd(ip,ii); ++ lzo_uint t = pd(ip,ii); + if (t != 0) + { + if (t <= 3) + { +- op[-2] |= LZO_BYTE(t); +-#if defined(UA_COPY32) +- UA_COPY32(op, ii); ++ op[-2] = LZO_BYTE(op[-2] | t); ++#if (LZO_OPT_UNALIGNED32) ++ UA_COPY4(op, ii); + op += t; + #else + { do *op++ = *ii++; while (--t > 0); } #endif - #ifndef LZO_CFG_NO_INLINE_ASM --#if (LZO_CC_LLVM) -+#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) - # define LZO_CFG_NO_INLINE_ASM 1 -+#elif (LZO_CC_LLVM) -+# define LZO_CFG_NO_INLINE_ASM 1 -+#endif + } +-#if defined(UA_COPY32) || defined(UA_COPY64) ++#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) + else if (t <= 16) + { + *op++ = LZO_BYTE(t - 3); +-#if defined(UA_COPY64) +- UA_COPY64(op, ii); +- UA_COPY64(op+8, ii+8); +-#else +- UA_COPY32(op, ii); +- UA_COPY32(op+4, ii+4); +- UA_COPY32(op+8, ii+8); +- UA_COPY32(op+12, ii+12); +-#endif ++ UA_COPY8(op, ii); ++ UA_COPY8(op+8, ii+8); + op += t; + } #endif -+#if (LZO_CFG_NO_INLINE_ASM) -+# undef LZO_ASM_SYNTAX_MSC -+# undef LZO_ASM_SYNTAX_GNUC -+# undef __LZO_ASM_CLOBBER -+# undef __LZO_ASM_CLOBBER_LIST_CC -+# undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY -+# undef __LZO_ASM_CLOBBER_LIST_EMPTY +@@ -3273,31 +4715,21 @@ next: + *op++ = LZO_BYTE(t - 3); + else + { +- register lzo_uint tt = t - 18; ++ lzo_uint tt = t - 18; + *op++ = 0; + while __lzo_unlikely(tt > 255) + { + tt -= 255; +-#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) +- * (volatile unsigned char *) op++ = 0; +-#else +- *op++ = 0; +-#endif ++ UA_SET1(op, 0); ++ op++; + } + assert(tt > 0); + *op++ = LZO_BYTE(tt); + } +-#if defined(UA_COPY32) || defined(UA_COPY64) ++#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) + do { +-#if defined(UA_COPY64) +- UA_COPY64(op, ii); +- UA_COPY64(op+8, ii+8); +-#else +- UA_COPY32(op, ii); +- UA_COPY32(op+4, ii+4); +- UA_COPY32(op+8, ii+8); +- UA_COPY32(op+12, ii+12); +-#endif ++ UA_COPY8(op, ii); ++ UA_COPY8(op+8, ii+8); + op += 16; ii += 16; t -= 16; + } while (t >= 16); if (t > 0) #endif - #ifndef LZO_CFG_NO_UNALIGNED - #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) -@@ -1784,25 +2574,6 @@ extern "C" { - # undef LZO_OPT_UNALIGNED32 - # undef LZO_OPT_UNALIGNED64 +@@ -3307,19 +4739,26 @@ next: + } + m_len = 4; + { +-#if defined(UA_GET64) +- lzo_uint64 v; +- v = UA_GET64(ip + m_len) ^ UA_GET64(m_pos + m_len); ++#if (LZO_OPT_UNALIGNED64) ++ lzo_uint64_t v; ++ v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); + if __lzo_unlikely(v == 0) { + do { + m_len += 8; +- v = UA_GET64(ip + m_len) ^ UA_GET64(m_pos + m_len); ++ v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); + if __lzo_unlikely(ip + m_len >= ip_end) + goto m_len_done; + } while (v == 0); + } +-#if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz64) +- m_len += lzo_bitops_ctz64(v) / CHAR_BIT; ++#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz64) ++ m_len += lzo_bitops_ctlz64(v) / CHAR_BIT; ++#elif (LZO_ABI_BIG_ENDIAN) ++ if ((v >> (64 - CHAR_BIT)) == 0) do { ++ v <<= CHAR_BIT; ++ m_len += 1; ++ } while ((v >> (64 - CHAR_BIT)) == 0); ++#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz64) ++ m_len += lzo_bitops_cttz64(v) / CHAR_BIT; + #elif (LZO_ABI_LITTLE_ENDIAN) + if ((v & UCHAR_MAX) == 0) do { + v >>= CHAR_BIT; +@@ -3330,19 +4769,30 @@ next: + m_len += 1; + } while (ip[m_len] == m_pos[m_len]); + #endif +-#elif defined(UA_GET32) +- lzo_uint32 v; +- v = UA_GET32(ip + m_len) ^ UA_GET32(m_pos + m_len); ++#elif (LZO_OPT_UNALIGNED32) ++ lzo_uint32_t v; ++ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); + if __lzo_unlikely(v == 0) { + do { + m_len += 4; +- v = UA_GET32(ip + m_len) ^ UA_GET32(m_pos + m_len); ++ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); ++ if (v != 0) ++ break; ++ m_len += 4; ++ v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); + if __lzo_unlikely(ip + m_len >= ip_end) + goto m_len_done; + } while (v == 0); + } +-#if (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz32) +- m_len += lzo_bitops_ctz32(v) / CHAR_BIT; ++#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz32) ++ m_len += lzo_bitops_ctlz32(v) / CHAR_BIT; ++#elif (LZO_ABI_BIG_ENDIAN) ++ if ((v >> (32 - CHAR_BIT)) == 0) do { ++ v <<= CHAR_BIT; ++ m_len += 1; ++ } while ((v >> (32 - CHAR_BIT)) == 0); ++#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz32) ++ m_len += lzo_bitops_cttz32(v) / CHAR_BIT; + #elif (LZO_ABI_LITTLE_ENDIAN) + if ((v & UCHAR_MAX) == 0) do { + v >>= CHAR_BIT; +@@ -3357,6 +4807,27 @@ next: + if __lzo_unlikely(ip[m_len] == m_pos[m_len]) { + do { + m_len += 1; ++ if (ip[m_len] != m_pos[m_len]) ++ break; ++ m_len += 1; ++ if (ip[m_len] != m_pos[m_len]) ++ break; ++ m_len += 1; ++ if (ip[m_len] != m_pos[m_len]) ++ break; ++ m_len += 1; ++ if (ip[m_len] != m_pos[m_len]) ++ break; ++ m_len += 1; ++ if (ip[m_len] != m_pos[m_len]) ++ break; ++ m_len += 1; ++ if (ip[m_len] != m_pos[m_len]) ++ break; ++ m_len += 1; ++ if (ip[m_len] != m_pos[m_len]) ++ break; ++ m_len += 1; + if __lzo_unlikely(ip + m_len >= ip_end) + goto m_len_done; + } while (ip[m_len] == m_pos[m_len]); +@@ -3390,11 +4861,8 @@ m_len_done: + while __lzo_unlikely(m_len > 255) + { + m_len -= 255; +-#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) +- * (volatile unsigned char *) op++ = 0; +-#else +- *op++ = 0; +-#endif ++ UA_SET1(op, 0); ++ op++; + } + *op++ = LZO_BYTE(m_len); + } +@@ -3413,11 +4881,8 @@ m_len_done: + while __lzo_unlikely(m_len > 255) + { + m_len -= 255; +-#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) +- * (volatile unsigned char *) op++ = 0; +-#else +- *op++ = 0; +-#endif ++ UA_SET1(op, 0); ++ op++; + } + *op++ = LZO_BYTE(m_len); + } +@@ -3428,7 +4893,7 @@ m_len_done: + } + + *out_len = pd(op, out); +- return pd(in_end,ii); ++ return pd(in_end,ii-ti); + } + + LZO_PUBLIC(int) +@@ -3468,7 +4933,7 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, + if (op == out && t <= 238) + *op++ = LZO_BYTE(17 + t); + else if (t <= 3) +- op[-2] |= LZO_BYTE(t); ++ op[-2] = LZO_BYTE(op[-2] | t); + else if (t <= 18) + *op++ = LZO_BYTE(t - 3); + else +@@ -3479,17 +4944,14 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, + while (tt > 255) + { + tt -= 255; +-#if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400)) +- +- * (volatile unsigned char *) op++ = 0; +-#else +- *op++ = 0; +-#endif ++ UA_SET1(op, 0); ++ op++; + } + assert(tt > 0); + *op++ = LZO_BYTE(tt); + } +- do *op++ = *ii++; while (--t > 0); ++ UA_COPYN(op, ii, t); ++ op += t; + } + + *op++ = M4_MARKER | 1; +@@ -3526,10 +4988,13 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, + + #undef TEST_IP + #undef TEST_OP ++#undef TEST_IP_AND_TEST_OP + #undef TEST_LB + #undef TEST_LBO + #undef NEED_IP + #undef NEED_OP ++#undef TEST_IV ++#undef TEST_OV + #undef HAVE_TEST_IP + #undef HAVE_TEST_OP + #undef HAVE_NEED_IP +@@ -3544,6 +5009,7 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, + # if (LZO_TEST_OVERRUN_INPUT >= 2) + # define NEED_IP(x) \ + if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun ++# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun + # endif #endif --#if (LZO_CFG_NO_INLINE_ASM) --#elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) --# define LZO_ASM_SYNTAX_MSC 1 --#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) --#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) --#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) --# define LZO_ASM_SYNTAX_GNUC 1 --#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) --# define LZO_ASM_SYNTAX_GNUC 1 --#endif --#if (LZO_ASM_SYNTAX_GNUC) --#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) --# define __LZO_ASM_CLOBBER "ax" --#elif (LZO_CC_INTELC) --# define __LZO_ASM_CLOBBER "memory" --#else --# define __LZO_ASM_CLOBBER "cc", "memory" --#endif --#endif - #if defined(__LZO_INFOSTR_MM) - #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) - # define __LZO_INFOSTR_MM "" -@@ -1846,7 +2617,382 @@ extern "C" { - #define LZO_INFO_STRING \ - LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ - " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER -+#if !(LZO_CFG_SKIP_LZO_TYPES) -+#if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0)) -+# error "missing defines for sizes" -+#endif -+#if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0)) -+# error "missing defines for sizes" -+#endif -+#if !defined(lzo_llong_t) -+#if (LZO_SIZEOF_LONG_LONG+0 > 0) -+__lzo_gnuc_extension__ typedef long long lzo_llong_t__; -+__lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__; -+# define lzo_llong_t lzo_llong_t__ -+# define lzo_ullong_t lzo_ullong_t__ -+#endif -+#endif -+#if !defined(lzo_int16e_t) -+#if (LZO_SIZEOF_LONG == 2) -+# define lzo_int16e_t long -+# define lzo_uint16e_t unsigned long -+#elif (LZO_SIZEOF_INT == 2) -+# define lzo_int16e_t int -+# define lzo_uint16e_t unsigned int -+#elif (LZO_SIZEOF_SHORT == 2) -+# define lzo_int16e_t short int -+# define lzo_uint16e_t unsigned short int -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) -+ typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__))); -+ typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__))); -+# define lzo_int16e_t lzo_int16e_hi_t__ -+# define lzo_uint16e_t lzo_uint16e_hi_t__ -+#elif (LZO_SIZEOF___INT16 == 2) -+# define lzo_int16e_t __int16 -+# define lzo_uint16e_t unsigned __int16 -+#else -+#endif -+#endif -+#if defined(lzo_int16e_t) -+# define LZO_SIZEOF_LZO_INT16E_T 2 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T) -+#endif -+#if !defined(lzo_int32e_t) -+#if (LZO_SIZEOF_LONG == 4) -+# define lzo_int32e_t long int -+# define lzo_uint32e_t unsigned long int -+#elif (LZO_SIZEOF_INT == 4) -+# define lzo_int32e_t int -+# define lzo_uint32e_t unsigned int -+#elif (LZO_SIZEOF_SHORT == 4) -+# define lzo_int32e_t short int -+# define lzo_uint32e_t unsigned short int -+#elif (LZO_SIZEOF_LONG_LONG == 4) -+# define lzo_int32e_t lzo_llong_t -+# define lzo_uint32e_t lzo_ullong_t -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) -+ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); -+ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); -+# define lzo_int32e_t lzo_int32e_si_t__ -+# define lzo_uint32e_t lzo_uint32e_si_t__ -+#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) -+ typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); -+ typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); -+# define lzo_int32e_t lzo_int32e_si_t__ -+# define lzo_uint32e_t lzo_uint32e_si_t__ -+# define LZO_INT32_C(c) (c##LL) -+# define LZO_UINT32_C(c) (c##ULL) -+#elif (LZO_SIZEOF___INT32 == 4) -+# define lzo_int32e_t __int32 -+# define lzo_uint32e_t unsigned __int32 -+#else -+#endif -+#endif -+#if defined(lzo_int32e_t) -+# define LZO_SIZEOF_LZO_INT32E_T 4 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T) -+#endif -+#if !defined(lzo_int64e_t) -+#if (LZO_SIZEOF___INT64 == 8) -+# if (LZO_CC_BORLANDC) && !(LZO_CFG_TYPE_PREFER___INT64) -+# define LZO_CFG_TYPE_PREFER___INT64 1 -+# endif -+#endif -+#if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_int64e_t int -+# define lzo_uint64e_t unsigned int -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG == 8) -+# define lzo_int64e_t long int -+# define lzo_uint64e_t unsigned long int -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG -+#elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_TYPE_PREFER___INT64) -+# define lzo_int64e_t lzo_llong_t -+# define lzo_uint64e_t lzo_ullong_t -+# if (LZO_CC_BORLANDC) -+# define LZO_INT64_C(c) ((c) + 0ll) -+# define LZO_UINT64_C(c) ((c) + 0ull) -+# elif 0 -+# define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL)) -+# define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL)) -+# else -+# define LZO_INT64_C(c) (c##LL) -+# define LZO_UINT64_C(c) (c##ULL) -+# endif -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF_LONG_LONG -+#elif (LZO_SIZEOF___INT64 == 8) -+# define lzo_int64e_t __int64 -+# define lzo_uint64e_t unsigned __int64 -+# if (LZO_CC_BORLANDC) -+# define LZO_INT64_C(c) ((c) + 0i64) -+# define LZO_UINT64_C(c) ((c) + 0ui64) -+# else -+# define LZO_INT64_C(c) (c##i64) -+# define LZO_UINT64_C(c) (c##ui64) -+# endif -+# define LZO_SIZEOF_LZO_INT64E_T LZO_SIZEOF___INT64 -+#else -+#endif -+#endif -+#if defined(lzo_int64e_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T) -+#endif -+#if !defined(lzo_int32l_t) -+#if defined(lzo_int32e_t) -+# define lzo_int32l_t lzo_int32e_t -+# define lzo_uint32l_t lzo_uint32e_t -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T -+#elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_int32l_t int -+# define lzo_uint32l_t unsigned int -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG >= 4) -+# define lzo_int32l_t long int -+# define lzo_uint32l_t unsigned long int -+# define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG -+#else -+# error "lzo_int32l_t" -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T) -+#endif -+#if !defined(lzo_int64l_t) -+#if defined(lzo_int64e_t) -+# define lzo_int64l_t lzo_int64e_t -+# define lzo_uint64l_t lzo_uint64e_t -+# define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T -+#else -+#endif -+#endif -+#if defined(lzo_int64l_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T) -+#endif -+#if !defined(lzo_int32f_t) -+#if (LZO_SIZEOF_SIZE_T >= 8) -+# define lzo_int32f_t lzo_int64l_t -+# define lzo_uint32f_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T -+#else -+# define lzo_int32f_t lzo_int32l_t -+# define lzo_uint32f_t lzo_uint32l_t -+# define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T) -+#endif -+#if !defined(lzo_int64f_t) -+#if defined(lzo_int64l_t) -+# define lzo_int64f_t lzo_int64l_t -+# define lzo_uint64f_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T -+#else -+#endif -+#endif -+#if defined(lzo_int64f_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T) -+#endif -+#if !defined(lzo_intptr_t) -+#if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16)) -+# define __LZO_INTPTR_T_IS_POINTER 1 -+ typedef char* lzo_intptr_t; -+ typedef char* lzo_uintptr_t; -+# define lzo_intptr_t lzo_intptr_t -+# define lzo_uintptr_t lzo_uintptr_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P -+#elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4)) -+ typedef __w64 int lzo_intptr_t; -+ typedef __w64 unsigned int lzo_uintptr_t; -+# define lzo_intptr_t lzo_intptr_t -+# define lzo_uintptr_t lzo_uintptr_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t short -+# define lzo_uintptr_t unsigned short -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT -+#elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG) -+# define lzo_intptr_t int -+# define lzo_uintptr_t unsigned int -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT -+#elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t long -+# define lzo_uintptr_t unsigned long -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG -+#elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P) -+# define lzo_intptr_t lzo_int64l_t -+# define lzo_uintptr_t lzo_uint64l_t -+# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T + +@@ -3555,12 +5021,13 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, + # undef TEST_OP + # define NEED_OP(x) \ + if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun ++# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun + # endif + #endif + + #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) +-# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun +-# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun ++# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun ++# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun + #else + # define TEST_LB(m_pos) ((void) 0) + # define TEST_LBO(m_pos,o) ((void) 0) +@@ -3581,15 +5048,27 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, + # define TEST_OP 1 + #endif + ++#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) ++# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) ++#elif defined(HAVE_TEST_IP) ++# define TEST_IP_AND_TEST_OP TEST_IP ++#elif defined(HAVE_TEST_OP) ++# define TEST_IP_AND_TEST_OP TEST_OP +#else -+# error "lzo_intptr_t" -+#endif -+#endif -+#if 1 -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *)) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t)) -+#endif -+#if !defined(lzo_word_t) -+#if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0) -+#if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER) -+# define lzo_word_t lzo_uintptr_t -+# define lzo_sword_t lzo_intptr_t -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T -+#elif (LZO_WORDSIZE == LZO_SIZEOF_LONG) -+# define lzo_word_t unsigned long -+# define lzo_sword_t long -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG -+#elif (LZO_WORDSIZE == LZO_SIZEOF_INT) -+# define lzo_word_t unsigned int -+# define lzo_sword_t int -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT -+#elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT) -+# define lzo_word_t unsigned short -+# define lzo_sword_t short -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT -+#elif (LZO_WORDSIZE == 1) -+# define lzo_word_t unsigned char -+# define lzo_sword_t signed char -+# define LZO_SIZEOF_LZO_WORD_T 1 -+#elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T) -+# define lzo_word_t lzo_uint64l_t -+# define lzo_sword_t lzo_int64l_t -+# define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T -+#elif (LZO_ARCH_SPU) && (LZO_CC_GNUC) -+#if 0 -+ typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__))); -+ typedef int lzo_sword_t __attribute__((__mode__(__V16QI__))); -+# define lzo_word_t lzo_word_t -+# define lzo_sword_t lzo_sword_t -+# define LZO_SIZEOF_LZO_WORD_T 16 ++# define TEST_IP_AND_TEST_OP 1 +#endif ++ + #if defined(NEED_IP) + # define HAVE_NEED_IP 1 + #else + # define NEED_IP(x) ((void) 0) ++# define TEST_IV(x) ((void) 0) + #endif + #if defined(NEED_OP) + # define HAVE_NEED_OP 1 + #else + # define NEED_OP(x) ((void) 0) ++# define TEST_OV(x) ((void) 0) + #endif + + #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) +@@ -3606,14 +5085,14 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + lzo_voidp wrkmem ) + #endif + { +- register lzo_bytep op; +- register const lzo_bytep ip; +- register lzo_uint t; ++ lzo_bytep op; ++ const lzo_bytep ip; ++ lzo_uint t; + #if defined(COPY_DICT) + lzo_uint m_off; + const lzo_bytep dict_end; + #else +- register const lzo_bytep m_pos; ++ const lzo_bytep m_pos; + #endif + + const lzo_bytep const ip_end = in + in_len; +@@ -3648,43 +5127,45 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + op = out; + ip = in; + ++ NEED_IP(1); + if (*ip > 17) + { + t = *ip++ - 17; + if (t < 4) + goto match_next; +- assert(t > 0); NEED_OP(t); NEED_IP(t+1); ++ assert(t > 0); NEED_OP(t); NEED_IP(t+3); + do *op++ = *ip++; while (--t > 0); + goto first_literal_run; + } + +- while (TEST_IP && TEST_OP) ++ for (;;) + { ++ NEED_IP(3); + t = *ip++; + if (t >= 16) + goto match; + if (t == 0) + { +- NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; ++ TEST_IV(t); + NEED_IP(1); + } + t += 15 + *ip++; + } +- assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); +-#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) ++ assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); ++#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) + t += 3; + if (t >= 8) do + { +- UA_COPY64(op,ip); ++ UA_COPY8(op,ip); + op += 8; ip += 8; t -= 8; + } while (t >= 8); + if (t >= 4) + { +- UA_COPY32(op,ip); ++ UA_COPY4(op,ip); + op += 4; ip += 4; t -= 4; + } + if (t > 0) +@@ -3692,19 +5173,19 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + *op++ = *ip++; + if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } + } +-#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) +-#if !defined(LZO_UNALIGNED_OK_4) ++#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) ++#if !(LZO_OPT_UNALIGNED32) + if (PTR_ALIGNED2_4(op,ip)) + { + #endif +- UA_COPY32(op,ip); ++ UA_COPY4(op,ip); + op += 4; ip += 4; + if (--t > 0) + { + if (t >= 4) + { + do { +- UA_COPY32(op,ip); ++ UA_COPY4(op,ip); + op += 4; ip += 4; t -= 4; + } while (t >= 4); + if (t > 0) do *op++ = *ip++; while (--t > 0); +@@ -3712,12 +5193,12 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + else + do *op++ = *ip++; while (--t > 0); + } +-#if !defined(LZO_UNALIGNED_OK_4) ++#if !(LZO_OPT_UNALIGNED32) + } + else + #endif + #endif +-#if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8) ++#if !(LZO_OPT_UNALIGNED32) + { + *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; + do *op++ = *ip++; while (--t > 0); +@@ -3753,7 +5234,7 @@ first_literal_run: + #endif + goto match_done; + +- do { ++ for (;;) { + match: + if (t >= 64) + { +@@ -3813,14 +5294,15 @@ match: + t &= 31; + if (t == 0) + { +- NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; ++ TEST_OV(t); + NEED_IP(1); + } + t += 31 + *ip++; ++ NEED_IP(2); + } + #if defined(COPY_DICT) + #if defined(LZO1Z) +@@ -3836,9 +5318,9 @@ match: + m_pos = op - off; + last_m_off = off; + } +-#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) ++#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) + m_pos = op - 1; +- m_pos -= UA_GET16(ip) >> 2; ++ m_pos -= UA_GET_LE16(ip) >> 2; + #else + m_pos = op - 1; + m_pos -= (ip[0] >> 2) + (ip[1] << 6); +@@ -3857,14 +5339,15 @@ match: + t &= 7; + if (t == 0) + { +- NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; ++ TEST_OV(t); + NEED_IP(1); + } + t += 7 + *ip++; ++ NEED_IP(2); + } + #if defined(COPY_DICT) + #if defined(LZO1Z) +@@ -3882,8 +5365,8 @@ match: + #else + #if defined(LZO1Z) + m_pos -= (ip[0] << 6) + (ip[1] >> 2); +-#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) +- m_pos -= UA_GET16(ip) >> 2; ++#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) ++ m_pos -= UA_GET_LE16(ip) >> 2; + #else + m_pos -= (ip[0] >> 2) + (ip[1] << 6); + #endif +@@ -3931,18 +5414,18 @@ match: + #else + + TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); +-#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) ++#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) + if (op - m_pos >= 8) + { + t += (3 - 1); + if (t >= 8) do + { +- UA_COPY64(op,m_pos); ++ UA_COPY8(op,m_pos); + op += 8; m_pos += 8; t -= 8; + } while (t >= 8); + if (t >= 4) + { +- UA_COPY32(op,m_pos); ++ UA_COPY4(op,m_pos); + op += 4; m_pos += 4; t -= 4; + } + if (t > 0) +@@ -3952,8 +5435,8 @@ match: + } + } + else +-#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) +-#if !defined(LZO_UNALIGNED_OK_4) ++#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) ++#if !(LZO_OPT_UNALIGNED32) + if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) + { + assert((op - m_pos) >= 4); +@@ -3961,10 +5444,10 @@ match: + if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) + { + #endif +- UA_COPY32(op,m_pos); ++ UA_COPY4(op,m_pos); + op += 4; m_pos += 4; t -= 4 - (3 - 1); + do { +- UA_COPY32(op,m_pos); ++ UA_COPY4(op,m_pos); + op += 4; m_pos += 4; t -= 4; + } while (t >= 4); + if (t > 0) do *op++ = *m_pos++; while (--t > 0); +@@ -3989,7 +5472,7 @@ match_done: + break; + + match_next: +- assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); ++ assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); + #if 0 + do *op++ = *ip++; while (--t > 0); + #else +@@ -3997,16 +5480,10 @@ match_next: + if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } + #endif + t = *ip++; +- } while (TEST_IP && TEST_OP); ++ } + } + +-#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) +- *out_len = pd(op, out); +- return LZO_E_EOF_NOT_FOUND; +-#endif +- + eof_found: +- assert(t == 1); + *out_len = pd(op, out); + return (ip == ip_end ? LZO_E_OK : + (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); +@@ -4052,10 +5529,13 @@ lookbehind_overrun: + + #undef TEST_IP + #undef TEST_OP ++#undef TEST_IP_AND_TEST_OP + #undef TEST_LB + #undef TEST_LBO + #undef NEED_IP + #undef NEED_OP ++#undef TEST_IV ++#undef TEST_OV + #undef HAVE_TEST_IP + #undef HAVE_TEST_OP + #undef HAVE_NEED_IP +@@ -4070,6 +5550,7 @@ lookbehind_overrun: + # if (LZO_TEST_OVERRUN_INPUT >= 2) + # define NEED_IP(x) \ + if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun ++# define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun + # endif + #endif + +@@ -4081,12 +5562,13 @@ lookbehind_overrun: + # undef TEST_OP + # define NEED_OP(x) \ + if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun ++# define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun + # endif + #endif + + #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) +-# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun +-# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun ++# define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun ++# define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun + #else + # define TEST_LB(m_pos) ((void) 0) + # define TEST_LBO(m_pos,o) ((void) 0) +@@ -4107,15 +5589,27 @@ lookbehind_overrun: + # define TEST_OP 1 + #endif + ++#if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP) ++# define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP) ++#elif defined(HAVE_TEST_IP) ++# define TEST_IP_AND_TEST_OP TEST_IP ++#elif defined(HAVE_TEST_OP) ++# define TEST_IP_AND_TEST_OP TEST_OP +#else -+# error "lzo_word_t" -+#endif -+#endif -+#endif -+#if 1 && defined(lzo_word_t) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE) -+ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE) -+#endif -+#if 1 -+#define lzo_int8_t signed char -+#define lzo_uint8_t unsigned char -+#define LZO_SIZEOF_LZO_INT8_T 1 -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t)) -+#endif -+#if defined(lzo_int16e_t) -+#define lzo_int16_t lzo_int16e_t -+#define lzo_uint16_t lzo_uint16e_t -+#define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t)) -+#endif -+#if defined(lzo_int32e_t) -+#define lzo_int32_t lzo_int32e_t -+#define lzo_uint32_t lzo_uint32e_t -+#define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t)) -+#endif -+#if defined(lzo_int64e_t) -+#define lzo_int64_t lzo_int64e_t -+#define lzo_uint64_t lzo_uint64e_t -+#define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t)) -+#endif -+#if 1 -+#define lzo_int_least32_t lzo_int32l_t -+#define lzo_uint_least32_t lzo_uint32l_t -+#define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t)) -+#endif -+#if defined(lzo_int64l_t) -+#define lzo_int_least64_t lzo_int64l_t -+#define lzo_uint_least64_t lzo_uint64l_t -+#define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t)) -+#endif -+#if 1 -+#define lzo_int_fast32_t lzo_int32f_t -+#define lzo_uint_fast32_t lzo_uint32f_t -+#define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t)) -+#endif -+#if defined(lzo_int64f_t) -+#define lzo_int_fast64_t lzo_int64f_t -+#define lzo_uint_fast64_t lzo_uint64f_t -+#define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8) -+LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t)) -+#endif -+#if !defined(LZO_INT16_C) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2) -+# define LZO_INT16_C(c) ((c) + 0) -+# define LZO_UINT16_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2) -+# define LZO_INT16_C(c) ((c) + 0L) -+# define LZO_UINT16_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 2) -+# define LZO_INT16_C(c) (c) -+# define LZO_UINT16_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 2) -+# define LZO_INT16_C(c) (c##L) -+# define LZO_UINT16_C(c) (c##UL) -+# else -+# error "LZO_INT16_C" -+# endif -+#endif -+#if !defined(LZO_INT32_C) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4) -+# define LZO_INT32_C(c) ((c) + 0) -+# define LZO_UINT32_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4) -+# define LZO_INT32_C(c) ((c) + 0L) -+# define LZO_UINT32_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 4) -+# define LZO_INT32_C(c) (c) -+# define LZO_UINT32_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 4) -+# define LZO_INT32_C(c) (c##L) -+# define LZO_UINT32_C(c) (c##UL) -+# elif (LZO_SIZEOF_LONG_LONG >= 4) -+# define LZO_INT32_C(c) (c##LL) -+# define LZO_UINT32_C(c) (c##ULL) -+# else -+# error "LZO_INT32_C" -+# endif -+#endif -+#if !defined(LZO_INT64_C) && defined(lzo_int64l_t) -+# if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8) -+# define LZO_INT64_C(c) ((c) + 0) -+# define LZO_UINT64_C(c) ((c) + 0U) -+# elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8) -+# define LZO_INT64_C(c) ((c) + 0L) -+# define LZO_UINT64_C(c) ((c) + 0UL) -+# elif (LZO_SIZEOF_INT >= 8) -+# define LZO_INT64_C(c) (c) -+# define LZO_UINT64_C(c) (c##U) -+# elif (LZO_SIZEOF_LONG >= 8) -+# define LZO_INT64_C(c) (c##L) -+# define LZO_UINT64_C(c) (c##UL) -+# else -+# error "LZO_INT64_C" -+# endif -+#endif ++# define TEST_IP_AND_TEST_OP 1 +#endif ++ + #if defined(NEED_IP) + # define HAVE_NEED_IP 1 + #else + # define NEED_IP(x) ((void) 0) ++# define TEST_IV(x) ((void) 0) + #endif + #if defined(NEED_OP) + # define HAVE_NEED_OP 1 + #else + # define NEED_OP(x) ((void) 0) ++# define TEST_OV(x) ((void) 0) + #endif + + #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) +@@ -4132,14 +5626,14 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + lzo_voidp wrkmem ) + #endif + { +- register lzo_bytep op; +- register const lzo_bytep ip; +- register lzo_uint t; ++ lzo_bytep op; ++ const lzo_bytep ip; ++ lzo_uint t; + #if defined(COPY_DICT) + lzo_uint m_off; + const lzo_bytep dict_end; + #else +- register const lzo_bytep m_pos; ++ const lzo_bytep m_pos; + #endif - #endif /* already included */ + const lzo_bytep const ip_end = in + in_len; +@@ -4174,43 +5668,45 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + op = out; + ip = in; --/* vim:set ts=4 et: */ -+/* vim:set ts=4 sw=4 et: */ ++ NEED_IP(1); + if (*ip > 17) + { + t = *ip++ - 17; + if (t < 4) + goto match_next; +- assert(t > 0); NEED_OP(t); NEED_IP(t+1); ++ assert(t > 0); NEED_OP(t); NEED_IP(t+3); + do *op++ = *ip++; while (--t > 0); + goto first_literal_run; + } + +- while (TEST_IP && TEST_OP) ++ for (;;) + { ++ NEED_IP(3); + t = *ip++; + if (t >= 16) + goto match; + if (t == 0) + { +- NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; ++ TEST_IV(t); + NEED_IP(1); + } + t += 15 + *ip++; + } +- assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); +-#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) ++ assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); ++#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) + t += 3; + if (t >= 8) do + { +- UA_COPY64(op,ip); ++ UA_COPY8(op,ip); + op += 8; ip += 8; t -= 8; + } while (t >= 8); + if (t >= 4) + { +- UA_COPY32(op,ip); ++ UA_COPY4(op,ip); + op += 4; ip += 4; t -= 4; + } + if (t > 0) +@@ -4218,19 +5714,19 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + *op++ = *ip++; + if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } + } +-#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) +-#if !defined(LZO_UNALIGNED_OK_4) ++#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) ++#if !(LZO_OPT_UNALIGNED32) + if (PTR_ALIGNED2_4(op,ip)) + { + #endif +- UA_COPY32(op,ip); ++ UA_COPY4(op,ip); + op += 4; ip += 4; + if (--t > 0) + { + if (t >= 4) + { + do { +- UA_COPY32(op,ip); ++ UA_COPY4(op,ip); + op += 4; ip += 4; t -= 4; + } while (t >= 4); + if (t > 0) do *op++ = *ip++; while (--t > 0); +@@ -4238,12 +5734,12 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, + else + do *op++ = *ip++; while (--t > 0); + } +-#if !defined(LZO_UNALIGNED_OK_4) ++#if !(LZO_OPT_UNALIGNED32) + } + else + #endif + #endif +-#if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8) ++#if !(LZO_OPT_UNALIGNED32) + { + *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; + do *op++ = *ip++; while (--t > 0); +@@ -4279,7 +5775,7 @@ first_literal_run: + #endif + goto match_done; + +- do { ++ for (;;) { + match: + if (t >= 64) + { +@@ -4339,14 +5835,15 @@ match: + t &= 31; + if (t == 0) + { +- NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; ++ TEST_OV(t); + NEED_IP(1); + } + t += 31 + *ip++; ++ NEED_IP(2); + } + #if defined(COPY_DICT) + #if defined(LZO1Z) +@@ -4362,9 +5859,9 @@ match: + m_pos = op - off; + last_m_off = off; + } +-#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) ++#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) + m_pos = op - 1; +- m_pos -= UA_GET16(ip) >> 2; ++ m_pos -= UA_GET_LE16(ip) >> 2; + #else + m_pos = op - 1; + m_pos -= (ip[0] >> 2) + (ip[1] << 6); +@@ -4383,14 +5880,15 @@ match: + t &= 7; + if (t == 0) + { +- NEED_IP(1); + while (*ip == 0) + { + t += 255; + ip++; ++ TEST_OV(t); + NEED_IP(1); + } + t += 7 + *ip++; ++ NEED_IP(2); + } + #if defined(COPY_DICT) + #if defined(LZO1Z) +@@ -4408,8 +5906,8 @@ match: + #else + #if defined(LZO1Z) + m_pos -= (ip[0] << 6) + (ip[1] >> 2); +-#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) +- m_pos -= UA_GET16(ip) >> 2; ++#elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) ++ m_pos -= UA_GET_LE16(ip) >> 2; + #else + m_pos -= (ip[0] >> 2) + (ip[1] << 6); + #endif +@@ -4457,18 +5955,18 @@ match: + #else + + TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); +-#if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4) ++#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) + if (op - m_pos >= 8) + { + t += (3 - 1); + if (t >= 8) do + { +- UA_COPY64(op,m_pos); ++ UA_COPY8(op,m_pos); + op += 8; m_pos += 8; t -= 8; + } while (t >= 8); + if (t >= 4) + { +- UA_COPY32(op,m_pos); ++ UA_COPY4(op,m_pos); + op += 4; m_pos += 4; t -= 4; + } + if (t > 0) +@@ -4478,8 +5976,8 @@ match: + } + } + else +-#elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) +-#if !defined(LZO_UNALIGNED_OK_4) ++#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) ++#if !(LZO_OPT_UNALIGNED32) + if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) + { + assert((op - m_pos) >= 4); +@@ -4487,10 +5985,10 @@ match: + if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) + { + #endif +- UA_COPY32(op,m_pos); ++ UA_COPY4(op,m_pos); + op += 4; m_pos += 4; t -= 4 - (3 - 1); + do { +- UA_COPY32(op,m_pos); ++ UA_COPY4(op,m_pos); + op += 4; m_pos += 4; t -= 4; + } while (t >= 4); + if (t > 0) do *op++ = *m_pos++; while (--t > 0); +@@ -4515,7 +6013,7 @@ match_done: + break; + + match_next: +- assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); ++ assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); + #if 0 + do *op++ = *ip++; while (--t > 0); + #else +@@ -4523,16 +6021,10 @@ match_next: + if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } + #endif + t = *ip++; +- } while (TEST_IP && TEST_OP); ++ } + } + +-#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) +- *out_len = pd(op, out); +- return LZO_E_EOF_NOT_FOUND; +-#endif +- + eof_found: +- assert(t == 1); + *out_len = pd(op, out); + return (ip == ip_end ? LZO_E_OK : + (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); +@@ -4559,4 +6051,3 @@ lookbehind_overrun: + #endif + + /***** End of minilzo.c *****/ +- diff --git a/grub-core/lib/minilzo/minilzo.h b/grub-core/lib/minilzo/minilzo.h -index 74fefa9fe20..79374546748 100644 +index 74fefa9..7937454 100644 --- a/grub-core/lib/minilzo/minilzo.h +++ b/grub-core/lib/minilzo/minilzo.h @@ -2,22 +2,7 @@ @@ -8507,3 +8785,6 @@ index 74fefa9fe20..79374546748 100644 #define LZO1X_MEM_DECOMPRESS (0) +-- +1.8.3.1 + diff --git a/0014-Allow-fallback-to-include-entries-by-title-not-just-.patch b/0014-Allow-fallback-to-include-entries-by-title-not-just-.patch index bee65ed21e1a0ce5eb8b5705d03afe0ffdd90cd0..9a4eac86656771177cf00b173e6dedeba839b846 100644 --- a/0014-Allow-fallback-to-include-entries-by-title-not-just-.patch +++ b/0014-Allow-fallback-to-include-entries-by-title-not-just-.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From f12a6d6082e3d532b676e3835e833df2d818416b Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Fri, 5 Sep 2014 10:07:04 -0400 -Subject: [PATCH] Allow "fallback" to include entries by title, not just - number. +Subject: [PATCH 014/220] Allow "fallback" to include entries by title, not + just number. Resolves: rhbz#1026084 @@ -12,7 +12,7 @@ Signed-off-by: Peter Jones 1 file changed, 58 insertions(+), 27 deletions(-) diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index e7a83c2d6e2..d2f64b05e0a 100644 +index d5e0c79..9175ad2 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -163,16 +163,41 @@ grub_menu_set_timeout (int timeout) @@ -139,3 +139,6 @@ index e7a83c2d6e2..d2f64b05e0a 100644 /* Get the entry number from the variable NAME. */ static int get_entry_number (grub_menu_t menu, const char *name) +-- +1.8.3.1 + diff --git a/0015-Add-GRUB_DISABLE_UUID.patch b/0015-Add-GRUB_DISABLE_UUID.patch index a6856d28d0bcc3a86315807521ef4f28e6f3ac1a..fe853dc28baf49988a8d36a93592cfae55fb5662 100644 --- a/0015-Add-GRUB_DISABLE_UUID.patch +++ b/0015-Add-GRUB_DISABLE_UUID.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From be1ed0f8e7ddf8747049c6e132c25032d2fef9ca Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 4 Sep 2014 16:49:25 -0400 -Subject: [PATCH] Add GRUB_DISABLE_UUID. +Subject: [PATCH 015/220] Add GRUB_DISABLE_UUID. This will cause "search --fs-uuid --set=root ..." not to be generated by grub2-mkconfig, and instead simply attempt to use the grub device name @@ -15,7 +15,7 @@ Signed-off-by: Peter Jones 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi -index 2adfa97bee8..2fd32608c01 100644 +index 8779507..6f52430 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1441,6 +1441,13 @@ enable the use of partition UUIDs, set this option to @samp{false}. @@ -33,7 +33,7 @@ index 2adfa97bee8..2fd32608c01 100644 If graphical video support is required, either because the @samp{gfxterm} graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set, diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index bc5a3f17541..b0a8626dd1c 100644 +index 523d4e0..9ecbcfb 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -133,12 +133,12 @@ fi @@ -83,7 +83,7 @@ index bc5a3f17541..b0a8626dd1c 100644 GRUB_GFXMODE \ GRUB_BACKGROUND \ diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 0f801cab3e4..1001a12232b 100644 +index 0f801ca..1001a12 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -156,7 +156,7 @@ prepare_grub_to_access_device () @@ -104,3 +104,6 @@ index 0f801cab3e4..1001a12232b 100644 echo "$fs_uuid"; else echo $device |sed 's, ,_,g' +-- +1.8.3.1 + diff --git a/0016-Make-exit-take-a-return-code.patch b/0016-Make-exit-take-a-return-code.patch index 937c7744a7bed977204d7a77d5addd9666297c16..4f409bd8fca304677cc82c03ad0ac2e773477a9c 100644 --- a/0016-Make-exit-take-a-return-code.patch +++ b/0016-Make-exit-take-a-return-code.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 479a8c2d36a28aaac12bf349ea09999655b90353 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 26 Feb 2014 21:49:12 -0500 -Subject: [PATCH] Make "exit" take a return code. +Subject: [PATCH 016/220] Make "exit" take a return code. This adds "exit" with a return code. With this patch, any "exit" command /may/ include a return code, and on platforms that support @@ -20,17 +20,17 @@ Signed-off-by: Peter Jones grub-core/kern/mips/arc/init.c | 2 +- grub-core/kern/mips/loongson/init.c | 2 +- grub-core/kern/mips/qemu_mips/init.c | 2 +- - grub-core/kern/misc.c | 2 +- + grub-core/kern/misc.c | 11 ++++++++++- grub-core/kern/uboot/init.c | 6 +++--- grub-core/kern/xen/init.c | 2 +- include/grub/misc.h | 2 +- - 14 files changed, 39 insertions(+), 21 deletions(-) + 14 files changed, 48 insertions(+), 21 deletions(-) diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c -index a3a11824172..b25ca4b9f17 100644 +index 6bbce31..6d66b7c 100644 --- a/grub-core/commands/minicmd.c +++ b/grub-core/commands/minicmd.c -@@ -176,12 +176,24 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)), +@@ -179,12 +179,24 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)), } /* exit */ @@ -60,7 +60,7 @@ index a3a11824172..b25ca4b9f17 100644 } diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 708581fcbde..e339f264b3a 100644 +index 6e1ceb9..370ce03 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -164,11 +164,16 @@ grub_reboot (void) @@ -83,7 +83,7 @@ index 708581fcbde..e339f264b3a 100644 } diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c -index 425bb960347..55ea5a11ccd 100644 +index 425bb96..55ea5a1 100644 --- a/grub-core/kern/emu/main.c +++ b/grub-core/kern/emu/main.c @@ -67,7 +67,7 @@ grub_reboot (void) @@ -96,10 +96,10 @@ index 425bb960347..55ea5a11ccd 100644 grub_reboot (); } diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c -index 76661337f10..82012a72fcb 100644 +index 65db79b..19cd007 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c -@@ -137,9 +137,10 @@ xasprintf (const char *fmt, ...) +@@ -139,9 +139,10 @@ xasprintf (const char *fmt, ...) #if !defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL) void @@ -113,7 +113,7 @@ index 76661337f10..82012a72fcb 100644 #endif diff --git a/grub-core/kern/i386/coreboot/init.c b/grub-core/kern/i386/coreboot/init.c -index 3314f027fec..36f9134b7b7 100644 +index 3314f02..36f9134 100644 --- a/grub-core/kern/i386/coreboot/init.c +++ b/grub-core/kern/i386/coreboot/init.c @@ -41,7 +41,7 @@ extern grub_uint8_t _end[]; @@ -126,7 +126,7 @@ index 3314f027fec..36f9134b7b7 100644 /* We can't use grub_fatal() in this function. This would create an infinite loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */ diff --git a/grub-core/kern/i386/qemu/init.c b/grub-core/kern/i386/qemu/init.c -index 271b6fbfabd..9fafe98f015 100644 +index 271b6fb..9fafe98 100644 --- a/grub-core/kern/i386/qemu/init.c +++ b/grub-core/kern/i386/qemu/init.c @@ -42,7 +42,7 @@ extern grub_uint8_t _end[]; @@ -139,10 +139,10 @@ index 271b6fbfabd..9fafe98f015 100644 /* We can't use grub_fatal() in this function. This would create an infinite loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */ diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 0d8ebf58b95..f5423ce27d9 100644 +index d483e35..e71d158 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c -@@ -68,7 +68,7 @@ grub_addr_t grub_ieee1275_original_stack; +@@ -71,7 +71,7 @@ grub_addr_t grub_ieee1275_original_stack; #endif void @@ -152,7 +152,7 @@ index 0d8ebf58b95..f5423ce27d9 100644 grub_ieee1275_exit (); } diff --git a/grub-core/kern/mips/arc/init.c b/grub-core/kern/mips/arc/init.c -index 3834a149093..86b3a25ec40 100644 +index 3834a14..86b3a25 100644 --- a/grub-core/kern/mips/arc/init.c +++ b/grub-core/kern/mips/arc/init.c @@ -276,7 +276,7 @@ grub_halt (void) @@ -165,7 +165,7 @@ index 3834a149093..86b3a25ec40 100644 GRUB_ARC_FIRMWARE_VECTOR->exit (); diff --git a/grub-core/kern/mips/loongson/init.c b/grub-core/kern/mips/loongson/init.c -index 7b96531b983..dff598ca7b0 100644 +index 7b96531..dff598c 100644 --- a/grub-core/kern/mips/loongson/init.c +++ b/grub-core/kern/mips/loongson/init.c @@ -304,7 +304,7 @@ grub_halt (void) @@ -178,7 +178,7 @@ index 7b96531b983..dff598ca7b0 100644 grub_halt (); } diff --git a/grub-core/kern/mips/qemu_mips/init.c b/grub-core/kern/mips/qemu_mips/init.c -index be88b77d22d..8b6c55ffc01 100644 +index be88b77..8b6c55f 100644 --- a/grub-core/kern/mips/qemu_mips/init.c +++ b/grub-core/kern/mips/qemu_mips/init.c @@ -75,7 +75,7 @@ grub_machine_fini (int flags __attribute__ ((unused))) @@ -191,10 +191,10 @@ index be88b77d22d..8b6c55ffc01 100644 grub_halt (); } diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 3b633d51f4c..952411d5dc6 100644 +index 3b633d5..cd63a8c 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -1095,7 +1095,7 @@ grub_abort (void) +@@ -1095,9 +1095,18 @@ grub_abort (void) grub_getkey (); } @@ -202,9 +202,20 @@ index 3b633d51f4c..952411d5dc6 100644 + grub_exit (1); } ++#if defined (__clang__) && !defined (GRUB_UTIL) ++/* clang emits references to abort(). */ ++void __attribute__ ((noreturn)) ++abort (void) ++{ ++ grub_abort (); ++} ++#endif ++ void + grub_fatal (const char *fmt, ...) + { diff --git a/grub-core/kern/uboot/init.c b/grub-core/kern/uboot/init.c -index 3e338645c57..be2a5be1d07 100644 +index 3e33864..be2a5be 100644 --- a/grub-core/kern/uboot/init.c +++ b/grub-core/kern/uboot/init.c @@ -39,9 +39,9 @@ extern grub_size_t grub_total_module_size; @@ -229,10 +240,10 @@ index 3e338645c57..be2a5be1d07 100644 else if (ver > API_SIG_VERSION) { diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c -index 0559c033c3d..fce526d417b 100644 +index 782ca72..708b060 100644 --- a/grub-core/kern/xen/init.c +++ b/grub-core/kern/xen/init.c -@@ -549,7 +549,7 @@ grub_machine_init (void) +@@ -584,7 +584,7 @@ grub_machine_init (void) } void @@ -242,7 +253,7 @@ index 0559c033c3d..fce526d417b 100644 struct sched_shutdown arg; diff --git a/include/grub/misc.h b/include/grub/misc.h -index 372f009e84f..83fd69f4ada 100644 +index ee48eb7..f9135b6 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -334,7 +334,7 @@ int EXPORT_FUNC(grub_vsnprintf) (char *str, grub_size_t n, const char *fmt, @@ -254,3 +265,6 @@ index 372f009e84f..83fd69f4ada 100644 grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r); +-- +1.8.3.1 + diff --git a/0017-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch b/0017-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch index 942116a394cc855e66814f2667e735ac8df90b1a..e67aa4b7414957650484bce8fd4ec4cb4b6c4266 100644 --- a/0017-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch +++ b/0017-Mark-po-exclude.pot-as-binary-so-git-won-t-try-to-di.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 9851c77af2f615927719300b632f38d51d8f1d27 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 22 Jul 2015 11:21:01 -0400 -Subject: [PATCH] Mark po/exclude.pot as binary so git won't try to diff - nonprintables. +Subject: [PATCH 017/220] Mark po/exclude.pot as binary so git won't try to + diff nonprintables. Signed-off-by: Peter Jones --- @@ -12,8 +12,11 @@ Signed-off-by: Peter Jones diff --git a/.gitattributes b/.gitattributes new file mode 100644 -index 00000000000..33ffaa40460 +index 0000000..33ffaa4 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +po/exclude.pot binary +-- +1.8.3.1 + diff --git a/0018-Make-efi-machines-load-an-env-block-from-a-variable.patch b/0018-Make-efi-machines-load-an-env-block-from-a-variable.patch index 2748c1c6067a8b6a2373488ac1293cf6896016f6..b99effdb8fd8e08a62e276dad2734d95db7e23d6 100644 --- a/0018-Make-efi-machines-load-an-env-block-from-a-variable.patch +++ b/0018-Make-efi-machines-load-an-env-block-from-a-variable.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 2c806ded764dd0e69dbc4e1b95a390bb65bbd019 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 7 Dec 2015 14:20:49 -0500 -Subject: [PATCH] Make efi machines load an env block from a variable +Subject: [PATCH 018/220] Make efi machines load an env block from a variable Signed-off-by: Peter Jones --- @@ -10,10 +10,10 @@ Signed-off-by: Peter Jones 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index e92a7ef322f..f8065388213 100644 +index eb1088f..41b5e16 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -191,6 +191,7 @@ kernel = { +@@ -203,6 +203,7 @@ kernel = { efi = term/efi/console.c; efi = kern/acpi.c; efi = kern/efi/acpi.c; @@ -22,7 +22,7 @@ index e92a7ef322f..f8065388213 100644 i386_multiboot = kern/i386/pc/acpi.c; i386_coreboot = kern/acpi.c; diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c -index 3dfdf2d22b0..71d2279a0c1 100644 +index 3dfdf2d..71d2279 100644 --- a/grub-core/kern/efi/init.c +++ b/grub-core/kern/efi/init.c @@ -25,9 +25,40 @@ @@ -79,3 +79,6 @@ index 3dfdf2d22b0..71d2279a0c1 100644 char **device, char **path); +-- +1.8.3.1 + diff --git a/0019-DHCP-client-ID-and-UUID-options-added.patch b/0019-DHCP-client-ID-and-UUID-options-added.patch index ddc17fe85a8322878a40f3c11e712b39462cef27..2d07496c723d286b477b675cb06d351ff758b7f0 100644 --- a/0019-DHCP-client-ID-and-UUID-options-added.patch +++ b/0019-DHCP-client-ID-and-UUID-options-added.patch @@ -1,31 +1,31 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 93dd0d49c319a8611cfe346c21706d2390cbf854 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo -Date: Tue, 27 Nov 2012 17:18:53 -0200 -Subject: [PATCH] DHCP client ID and UUID options added. +Date: Mon, 8 Jul 2019 14:10:58 +0200 +Subject: [PATCH 019/220] DHCP client ID and UUID options added. --- - grub-core/net/bootp.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++----- + grub-core/net/bootp.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++----- include/grub/net.h | 2 ++ - 2 files changed, 81 insertions(+), 8 deletions(-) + 2 files changed, 79 insertions(+), 8 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 9e2fdb795f5..f03eeab2fb4 100644 +index 04cfbb0..0e6e41a 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c -@@ -25,6 +25,49 @@ - #include - #include +@@ -95,6 +95,49 @@ enum + /* Max timeout when waiting for BOOTP/DHCP reply */ + #define GRUB_DHCP_MAX_PACKET_TIMEOUT 32 +static char * +grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)), -+ const char *val __attribute__ ((unused))) ++ const char *val __attribute__ ((unused))) +{ + return NULL; +} + +static void +set_env_limn_ro (const char *intername, const char *suffix, -+ const char *value, grub_size_t len) ++ const char *value, grub_size_t len) +{ + char *varname, *varvalue; + char *ptr; @@ -59,60 +59,58 @@ index 9e2fdb795f5..f03eeab2fb4 100644 + return val + 'a' - 10; +} + - static void - parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) - { -@@ -55,6 +98,9 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) - - taglength = *ptr++; + static const void * + find_dhcp_option (const struct grub_net_bootp_packet *bp, grub_size_t size, + grub_uint8_t opt_code, grub_uint8_t *opt_len) +@@ -152,6 +195,9 @@ again: + if (i + taglength >= size) + return NULL; + grub_dprintf("net", "DHCP option %u (0x%02x) found with length %u.\n", + tagtype, tagtype, taglength); + - switch (tagtype) + /* FIXME RFC 3396 options concatentation */ + if (tagtype == opt_code) { - case GRUB_NET_BOOTP_NETMASK: -@@ -120,6 +166,39 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) - taglength); - break; +@@ -354,6 +400,37 @@ grub_net_configure_by_dhcp_ack (const char *name, + } + grub_net_add_ipv4_local (inter, mask); -+ case GRUB_NET_BOOTP_CLIENT_ID: -+ set_env_limn_ro (name, "clientid", (char *) ptr, taglength); -+ break; -+ -+ case GRUB_NET_BOOTP_CLIENT_UUID: -+ { -+ if (taglength != 17) -+ break; -+ -+ /* The format is 9cfe245e-d0c8-bd45-a79f-54ea5fbd3d97 */ ++ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_CLIENT_ID, &opt_len); ++ if (opt) ++ { ++ set_env_limn_ro (name, "clientid", (char *) opt, opt_len); ++ } + -+ ptr += 1; -+ taglength -= 1; ++ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_CLIENT_UUID, &opt_len); ++ if (opt && opt_len == 17) ++ { ++ /* The format is 9cfe245e-d0c8-bd45-a79f-54ea5fbd3d97 */ + -+ char *val = grub_malloc (2 * taglength + 4 + 1); -+ int i = 0; -+ int j = 0; -+ for (i = 0; i < taglength; i++) -+ { -+ val[2 * i + j] = hexdigit (ptr[i] >> 4); -+ val[2 * i + 1 + j] = hexdigit (ptr[i] & 0xf); ++ opt += 1; ++ opt_len -= 1; + -+ if ((i == 3) || (i == 5) || (i == 7) || (i == 9)) -+ { -+ j++; -+ val[2 * i + 1+ j] = '-'; -+ } -+ } ++ char *val = grub_malloc (2 * opt_len + 4 + 1); ++ int i = 0; ++ int j = 0; ++ for (i = 0; i < opt_len; i++) ++ { ++ val[2 * i + j] = hexdigit (opt[i] >> 4); ++ val[2 * i + 1 + j] = hexdigit (opt[i] & 0xf); + -+ set_env_limn_ro (name, "clientuuid", (char *) val, 2 * taglength + 4); ++ if ((i == 3) || (i == 5) || (i == 7) || (i == 9)) ++ { ++ j++; ++ val[2 * i + 1+ j] = '-'; + } -+ break; ++ } ++ set_env_limn_ro (name, "clientuuid", (char *) val, 2 * opt_len + 4); ++ } + - /* If you need any other options please contact GRUB - development team. */ - } -@@ -302,14 +381,6 @@ grub_net_process_dhcp (struct grub_net_buff *nb, + /* We do not implement dead gateway detection and the first entry SHOULD + be preferred one */ + opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_ROUTER, &opt_len); +@@ -631,14 +708,6 @@ grub_net_process_dhcp (struct grub_net_buff *nb, } } @@ -128,15 +126,18 @@ index 9e2fdb795f5..f03eeab2fb4 100644 grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), int argc, char **args) diff --git a/include/grub/net.h b/include/grub/net.h -index 1096b24322e..e266bae23f4 100644 +index 4a9069a..556c54e 100644 --- a/include/grub/net.h +++ b/include/grub/net.h -@@ -457,6 +457,8 @@ enum +@@ -462,6 +462,8 @@ enum GRUB_NET_BOOTP_DOMAIN = 0x0f, GRUB_NET_BOOTP_ROOT_PATH = 0x11, GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12, + GRUB_NET_BOOTP_CLIENT_ID = 0x3d, + GRUB_NET_BOOTP_CLIENT_UUID = 0x61, - GRUB_NET_BOOTP_END = 0xff - }; - + GRUB_NET_DHCP_REQUESTED_IP_ADDRESS = 50, + GRUB_NET_DHCP_OVERLOAD = 52, + GRUB_NET_DHCP_MESSAGE_TYPE = 53, +-- +1.8.3.1 + diff --git a/0021-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch b/0020-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch similarity index 86% rename from 0021-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch rename to 0020-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch index e219fa5452e5681f9da33a1d1c16cba2e53d85fb..4e436b956d1ccfab4f36cd2b65fd8cebf40fa7cd 100644 --- a/0021-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch +++ b/0020-Fix-bad-test-on-GRUB_DISABLE_SUBMENU.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 07241ef86e2d39264a89c5a3d789cb0cc9f41c81 Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Wed, 12 Mar 2014 10:58:16 -0400 -Subject: [PATCH] Fix bad test on GRUB_DISABLE_SUBMENU. +Subject: [PATCH 020/220] Fix bad test on GRUB_DISABLE_SUBMENU. The file /etc/grub.d/10_linux does @@ -20,7 +20,7 @@ Resolves: rhbz#1063414 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 61ebd7dc714..87a7da34982 100644 +index 4532266..58defdb 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -261,7 +261,11 @@ while [ "x$list" != "x" ] ; do @@ -36,3 +36,6 @@ index 61ebd7dc714..87a7da34982 100644 linux_entry "${OS}" "${version}" simple \ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" +-- +1.8.3.1 + diff --git a/0020-trim-arp-packets-with-abnormal-size.patch b/0020-trim-arp-packets-with-abnormal-size.patch deleted file mode 100644 index 1a6990a09dfd6b4a58dba3219e30a668f2641ee4..0000000000000000000000000000000000000000 --- a/0020-trim-arp-packets-with-abnormal-size.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Paulo Flabiano Smorigo -Date: Wed, 5 Feb 2014 09:42:42 -0200 -Subject: [PATCH] trim arp packets with abnormal size - -GRUB uses arp request to create the arp response. If the incoming packet -is foobared, GRUB needs to trim the arp response packet before sending it. ---- - grub-core/net/arp.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c -index 54306e3b16d..d1c69ed2b55 100644 ---- a/grub-core/net/arp.c -+++ b/grub-core/net/arp.c -@@ -150,6 +150,12 @@ grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card, - if (grub_net_addr_cmp (&inf->address, &target_addr) == 0 - && arp_packet->op == grub_cpu_to_be16_compile_time (ARP_REQUEST)) - { -+ if ((nb->tail - nb->data) > 50) -+ { -+ grub_dprintf ("net", "arp packet with abnormal size (%ld bytes).\n", -+ nb->tail - nb->data); -+ nb->tail = nb->data + 50; -+ } - grub_net_link_level_address_t target; - struct grub_net_buff nb_reply; - struct arppkt *arp_reply; diff --git a/0022-Add-support-for-UEFI-operating-systems-returned-by-o.patch b/0021-Add-support-for-UEFI-operating-systems-returned-by-o.patch similarity index 85% rename from 0022-Add-support-for-UEFI-operating-systems-returned-by-o.patch rename to 0021-Add-support-for-UEFI-operating-systems-returned-by-o.patch index 6ddda34a5283963078a789ae08710a687df33a17..5bc833aaeb0bfd3f7b150302542f14f7ce113981 100644 --- a/0022-Add-support-for-UEFI-operating-systems-returned-by-o.patch +++ b/0021-Add-support-for-UEFI-operating-systems-returned-by-o.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From bfa8c75e6921c3584538c7ecef354f7136133af3 Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Wed, 12 Jun 2013 11:51:49 -0400 -Subject: [PATCH] Add support for UEFI operating systems returned by os-prober +Subject: [PATCH 021/220] Add support for UEFI operating systems returned by + os-prober os-prober returns UEFI operating systems in the form: @@ -14,7 +15,7 @@ contrast to legacy OSes, where path is the device string. Handle this case. 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in -index 515a68c7aa0..9b8f5968e2d 100644 +index 515a68c..9b8f596 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -328,8 +328,23 @@ EOF @@ -44,3 +45,6 @@ index 515a68c7aa0..9b8f5968e2d 100644 + esac esac done +-- +1.8.3.1 + diff --git a/0023-Migrate-PPC-from-Yaboot-to-Grub2.patch b/0022-Migrate-PPC-from-Yaboot-to-Grub2.patch similarity index 93% rename from 0023-Migrate-PPC-from-Yaboot-to-Grub2.patch rename to 0022-Migrate-PPC-from-Yaboot-to-Grub2.patch index 7008926dbf3cbe3618ff1905708bcf4245764687..5465fb7ab50ffa860f6708d036653e5ce388dee9 100644 --- a/0023-Migrate-PPC-from-Yaboot-to-Grub2.patch +++ b/0022-Migrate-PPC-from-Yaboot-to-Grub2.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From b29012d97aac59ab69aff7806cb012d6270706e2 Mon Sep 17 00:00:00 2001 From: Mark Hamzy Date: Wed, 28 Mar 2012 14:46:41 -0500 -Subject: [PATCH] Migrate PPC from Yaboot to Grub2 +Subject: [PATCH 022/220] Migrate PPC from Yaboot to Grub2 Add configuration support for serial terminal consoles. This will set the maximum screen size so that text is not overwritten. @@ -12,26 +12,26 @@ maximum screen size so that text is not overwritten. create mode 100644 util/grub.d/20_ppc_terminfo.in diff --git a/Makefile.util.def b/Makefile.util.def -index 3180ac880a9..c7b775bce73 100644 +index 969d32f..8717774 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -487,6 +487,13 @@ script = { - condition = COND_HOST_LINUX; +@@ -497,6 +497,13 @@ script = { }; -+script = { + script = { + name = '20_ppc_terminfo'; + common = util/grub.d/20_ppc_terminfo.in; + installdir = grubconf; + condition = COND_HOST_LINUX; +}; + - script = { ++script = { name = '30_os-prober'; common = util/grub.d/30_os-prober.in; + installdir = grubconf; diff --git a/util/grub.d/20_ppc_terminfo.in b/util/grub.d/20_ppc_terminfo.in new file mode 100644 -index 00000000000..10d66586820 +index 0000000..10d6658 --- /dev/null +++ b/util/grub.d/20_ppc_terminfo.in @@ -0,0 +1,114 @@ @@ -149,3 +149,6 @@ index 00000000000..10d66586820 +cat << EOF + terminfo -g ${X}x${Y} ${TERMINAL} +EOF +-- +1.8.3.1 + diff --git a/0024-Add-fw_path-variable-revised.patch b/0023-Add-fw_path-variable-revised.patch similarity index 89% rename from 0024-Add-fw_path-variable-revised.patch rename to 0023-Add-fw_path-variable-revised.patch index 3126d2e7976176074564e6caeec8d3206209d9c2..2f1bb696a29f7f0b954780e54c59d8f2a62d169e 100644 --- a/0024-Add-fw_path-variable-revised.patch +++ b/0023-Add-fw_path-variable-revised.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 0a416bfa1cb5647bcba96513edf4f6c8b68c79ba Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Wed, 19 Sep 2012 21:22:55 -0300 -Subject: [PATCH] Add fw_path variable (revised) +Subject: [PATCH 023/220] Add fw_path variable (revised) This patch makes grub look for its config file on efi where the app was found. It was originally written by Matthew Garrett, and adapted to fix the @@ -14,7 +14,7 @@ https://bugzilla.redhat.com/show_bug.cgi?id=857936 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index 9cad0c4485c..8ab7794c47b 100644 +index 9cad0c4..8ab7794 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c @@ -127,16 +127,15 @@ grub_set_prefix_and_root (void) @@ -41,7 +41,7 @@ index 9cad0c4485c..8ab7794c47b 100644 } diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 249e19bc788..759c475c4d9 100644 +index 222e239..394bfbe 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -338,7 +338,30 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), @@ -59,7 +59,7 @@ index 249e19bc788..759c475c4d9 100644 + { + grub_file_t file; + -+ file = grub_file_open (config); ++ file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG); + if (file) + { + grub_file_close (file); @@ -76,3 +76,6 @@ index 249e19bc788..759c475c4d9 100644 prefix = grub_env_get ("prefix"); if (prefix) +-- +1.8.3.1 + diff --git a/0025-Pass-x-hex-hex-straight-through-unmolested.patch b/0024-Pass-x-hex-hex-straight-through-unmolested.patch similarity index 87% rename from 0025-Pass-x-hex-hex-straight-through-unmolested.patch rename to 0024-Pass-x-hex-hex-straight-through-unmolested.patch index 5f4884d0596f9c8795f4d67cf5e9b3e0b9214103..d080ca755670dc7f07c407fd7e203f51f54b7f57 100644 --- a/0025-Pass-x-hex-hex-straight-through-unmolested.patch +++ b/0024-Pass-x-hex-hex-straight-through-unmolested.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 98acf7f62203f6dda6e735743ce4e4f410d451e1 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 1 Oct 2012 13:24:37 -0400 -Subject: [PATCH] Pass "\x[[:hex:]][[:hex:]]" straight through unmolested. +Subject: [PATCH 024/220] Pass "\x[[:hex:]][[:hex:]]" straight through + unmolested. --- grub-core/commands/wildcard.c | 16 +++++++++++++++- @@ -10,7 +11,7 @@ Subject: [PATCH] Pass "\x[[:hex:]][[:hex:]]" straight through unmolested. 3 files changed, 84 insertions(+), 9 deletions(-) diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c -index 9b4e72766ff..02c46f9fdfa 100644 +index 4a106ca..560d437 100644 --- a/grub-core/commands/wildcard.c +++ b/grub-core/commands/wildcard.c @@ -462,6 +462,12 @@ check_file (const char *dir, const char *basename) @@ -44,7 +45,7 @@ index 9b4e72766ff..02c46f9fdfa 100644 *optr++ = iptr[1]; iptr += 2; diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c -index d5e10ee8798..0a5b2afb94b 100644 +index ed0b149..e0fb0a9 100644 --- a/grub-core/lib/cmdline.c +++ b/grub-core/lib/cmdline.c @@ -20,6 +20,12 @@ @@ -75,7 +76,7 @@ index d5e10ee8798..0a5b2afb94b 100644 size++; else if (*c == ' ') space = 1; -@@ -85,7 +97,25 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, +@@ -86,7 +98,25 @@ grub_create_loader_cmdline (int argc, char *argv[], char *buf, while (*c) { @@ -103,10 +104,10 @@ index d5e10ee8798..0a5b2afb94b 100644 *buf++ = *c; diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index ab78ca87f90..cf6cd6601d6 100644 +index 0d05d6b..ba38b5e 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c -@@ -55,6 +55,12 @@ static struct grub_script_scope *scope = 0; +@@ -56,6 +56,12 @@ static struct grub_script_scope *scope = 0; /* Wildcard translator for GRUB script. */ struct grub_script_wildcard_translator *grub_wildcard_translator; @@ -119,7 +120,7 @@ index ab78ca87f90..cf6cd6601d6 100644 static char* wildcard_escape (const char *s) { -@@ -71,7 +77,15 @@ wildcard_escape (const char *s) +@@ -72,7 +78,15 @@ wildcard_escape (const char *s) i = 0; while ((ch = *s++)) { @@ -136,7 +137,7 @@ index ab78ca87f90..cf6cd6601d6 100644 p[i++] = '\\'; p[i++] = ch; } -@@ -95,7 +109,14 @@ wildcard_unescape (const char *s) +@@ -96,7 +110,14 @@ wildcard_unescape (const char *s) i = 0; while ((ch = *s++)) { @@ -152,7 +153,7 @@ index ab78ca87f90..cf6cd6601d6 100644 p[i++] = *s++; else p[i++] = ch; -@@ -397,10 +418,20 @@ parse_string (const char *str, +@@ -398,10 +419,20 @@ parse_string (const char *str, switch (*ptr) { case '\\': @@ -177,3 +178,6 @@ index ab78ca87f90..cf6cd6601d6 100644 break; case '$': if (escaped) +-- +1.8.3.1 + diff --git a/0026-Add-X-option-to-printf-functions.patch b/0025-Add-X-option-to-printf-functions.patch similarity index 89% rename from 0026-Add-X-option-to-printf-functions.patch rename to 0025-Add-X-option-to-printf-functions.patch index 4fd28fc165ea482e4a669c875602c947934ddad3..30b51f12fd1366236f243adb0c5d4c2dc31228e5 100644 --- a/0026-Add-X-option-to-printf-functions.patch +++ b/0025-Add-X-option-to-printf-functions.patch @@ -1,14 +1,14 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 29e1ec69b76c2e5d95cf339e60461f22cb0aeed6 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Tue, 27 Nov 2012 16:58:39 -0200 -Subject: [PATCH] Add %X option to printf functions. +Subject: [PATCH 025/220] Add %X option to printf functions. --- grub-core/kern/misc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 952411d5dc6..8344526be7f 100644 +index cd63a8c..2656a67 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -588,7 +588,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r) @@ -53,3 +53,6 @@ index 952411d5dc6..8344526be7f 100644 case 'u': case 'd': { +-- +1.8.3.1 + diff --git a/0027-Search-for-specific-config-file-for-netboot.patch b/0026-Search-for-specific-config-file-for-netboot.patch similarity index 94% rename from 0027-Search-for-specific-config-file-for-netboot.patch rename to 0026-Search-for-specific-config-file-for-netboot.patch index 7436e0324610e1195a33f7713c3ed61ea78dcfd5..98263fb51655c3d3c124638683052b76e6804949 100644 --- a/0027-Search-for-specific-config-file-for-netboot.patch +++ b/0026-Search-for-specific-config-file-for-netboot.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 0b390eb5dbd310c6c1a92e001b35981c90f27565 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Tue, 27 Nov 2012 17:22:07 -0200 -Subject: [PATCH] Search for specific config file for netboot +Subject: [PATCH 026/220] Search for specific config file for netboot This patch implements a search for a specific configuration when the config file is on a remoteserver. It uses the following order: @@ -22,7 +22,7 @@ https://bugzilla.redhat.com/show_bug.cgi?id=873406 3 files changed, 135 insertions(+), 4 deletions(-) diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 10773fc3435..0769bf850d3 100644 +index d5d726a..0645456 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -1735,6 +1735,124 @@ grub_net_restore_hw (void) @@ -43,7 +43,7 @@ index 10773fc3435..0769bf850d3 100644 + grub_dprintf ("net", "probe %s\n", config); + + grub_file_t file; -+ file = grub_file_open (config); ++ file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG); + + if (file) + { @@ -151,7 +151,7 @@ index 10773fc3435..0769bf850d3 100644 static grub_command_t cmd_addaddr, cmd_deladdr, cmd_addroute, cmd_delroute; diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 759c475c4d9..b2654ef62e8 100644 +index 394bfbe..9ef9848 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -33,6 +33,7 @@ @@ -187,10 +187,10 @@ index 759c475c4d9..b2654ef62e8 100644 grub_enter_normal_mode (config); grub_free (config); diff --git a/include/grub/net.h b/include/grub/net.h -index e266bae23f4..50d62ab0c8c 100644 +index 556c54e..ff6d347 100644 --- a/include/grub/net.h +++ b/include/grub/net.h -@@ -566,4 +566,7 @@ extern char *grub_net_default_server; +@@ -578,4 +578,7 @@ extern char *grub_net_default_server; #define VLANTAG_IDENTIFIER 0x8100 @@ -198,3 +198,6 @@ index e266bae23f4..50d62ab0c8c 100644 +grub_net_search_configfile (char *config); + #endif /* ! GRUB_NET_HEADER */ +-- +1.8.3.1 + diff --git a/0113-Add-blscfg-command-support-to-parse-BootLoaderSpec-c.patch b/0027-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch similarity index 39% rename from 0113-Add-blscfg-command-support-to-parse-BootLoaderSpec-c.patch rename to 0027-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch index 63b0529ce0a35703b2da63c1ae2f9d20b02ad553..450dab898800164e559765329ea592f062a2de3d 100644 --- a/0113-Add-blscfg-command-support-to-parse-BootLoaderSpec-c.patch +++ b/0027-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch @@ -1,76 +1,114 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 6f68e870cac4b87ef7caf2bd305de9ffa1907791 Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Fri, 9 Dec 2016 15:40:58 -0500 -Subject: [PATCH] Add blscfg command support to parse BootLoaderSpec config - fragments +Date: Tue, 22 Jan 2013 06:31:38 +0100 +Subject: [PATCH 027/220] blscfg: add blscfg module to parse Boot Loader + Specification snippets The BootLoaderSpec (BLS) defines a scheme where different bootloaders can share a format for boot items and a configuration directory that accepts these common configurations as drop-in files. -GRUB2 already has a blscfg modle that can parse the config snippets using -the bls_import command, change it to blscfg and improve the BLS support. +Signed-off-by: Peter Jones +Signed-off-by: Javier Martinez Canillas +[wjt: some cleanups and fixes] +Signed-off-by: Will Thompson --- - grub-core/Makefile.core.def | 4 +- - grub-core/commands/blscfg.c | 796 ++++++++++++++++++++++++++++++++++++++++--- - grub-core/commands/loadenv.c | 77 +---- - grub-core/commands/loadenv.h | 93 +++++ - include/grub/compiler.h | 2 + - 5 files changed, 840 insertions(+), 132 deletions(-) + grub-core/Makefile.core.def | 11 + + grub-core/commands/blscfg.c | 1096 ++++++++++++++++++++++++++++++++++++++++ + grub-core/commands/legacycfg.c | 5 +- + grub-core/commands/loadenv.c | 77 +-- + grub-core/commands/loadenv.h | 93 ++++ + grub-core/commands/menuentry.c | 20 +- + grub-core/normal/main.c | 6 + + include/grub/compiler.h | 2 + + include/grub/menu.h | 13 + + include/grub/normal.h | 2 +- + 10 files changed, 1243 insertions(+), 82 deletions(-) + create mode 100644 grub-core/commands/blscfg.c create mode 100644 grub-core/commands/loadenv.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 27563743ba9..96ccb402125 100644 +index 41b5e16..57e253a 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -129,6 +129,7 @@ kernel = { - common = kern/rescue_parser.c; - common = kern/rescue_reader.c; - common = kern/term.c; -+ common = kern/qsort.c; +@@ -812,6 +812,16 @@ module = { + }; - noemu = kern/compiler-rt.c; - noemu = kern/mm.c; -@@ -774,8 +775,7 @@ module = { module = { - name = blscfg; - common = commands/blscfg.c; -- enable = i386_efi; -- enable = x86_64_efi; ++ name = blscfg; ++ common = commands/blscfg.c; ++ common = commands/loadenv.h; ++ enable = powerpc_ieee1275; + enable = efi; - enable = i386_pc; ++ enable = i386_pc; ++ enable = emu; ++}; ++ ++module = { + name = boot; + common = commands/boot.c; + i386_pc = lib/i386/pc/biosnum.c; +@@ -988,6 +998,7 @@ module = { + module = { + name = loadenv; + common = commands/loadenv.c; ++ common = commands/loadenv.h; + common = lib/envblk.c; }; diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 4274aca5a9d..86796c8cd83 100644 ---- a/grub-core/commands/blscfg.c +new file mode 100644 +index 0000000..54458b1 +--- /dev/null +++ b/grub-core/commands/blscfg.c -@@ -30,32 +30,405 @@ - #include - #include - #include +@@ -0,0 +1,1096 @@ ++/*-*- Mode: C; c-basic-offset: 2; indent-tabs-mode: t -*-*/ ++ ++/* bls.c - implementation of the boot loader spec */ ++ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * ++ * GRUB is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * GRUB is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with GRUB. If not, see . ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include +#include - - GRUB_MOD_LICENSE ("GPLv3+"); - ++ ++#include ++ ++GRUB_MOD_LICENSE ("GPLv3+"); ++ +#include "loadenv.h" + +#define GRUB_BLS_CONFIG_PATH "/loader/entries/" ++#ifdef GRUB_MACHINE_EMU ++#define GRUB_BOOT_DEVICE "/boot" ++#else +#define GRUB_BOOT_DEVICE "($root)" - #ifdef GRUB_MACHINE_EFI - #define GRUB_LINUX_CMD "linuxefi" - #define GRUB_INITRD_CMD "initrdefi" --#define GRUB_BLS_CONFIG_PATH "/EFI/fedora/loader/entries/" --#define GRUB_BOOT_DEVICE "($boot)" - #else - #define GRUB_LINUX_CMD "linux" - #define GRUB_INITRD_CMD "initrd" --#define GRUB_BLS_CONFIG_PATH "/loader/entries/" --#define GRUB_BOOT_DEVICE "($root)" - #endif - --static int parse_entry ( -+#define grub_free(x) ({grub_dprintf("blscfg", "%s freeing %p\n", __func__, x); grub_free(x); }) ++#endif + +struct keyval +{ @@ -78,46 +116,9 @@ index 4274aca5a9d..86796c8cd83 100644 + char *val; +}; + -+struct bls_entry -+{ -+ struct keyval **keyvals; -+ int nkeyvals; -+}; -+ -+static struct bls_entry **entries; -+static int nentries; -+ -+static struct bls_entry *bls_new_entry(void) -+{ -+ struct bls_entry **new_entries; -+ struct bls_entry *entry; -+ int new_n = nentries + 1; -+ -+ new_entries = grub_realloc (entries, new_n * sizeof (struct bls_entry *)); -+ if (!new_entries) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ "couldn't find space for BLS entry list"); -+ return NULL; -+ } -+ -+ entries = new_entries; -+ -+ entry = grub_malloc (sizeof (*entry)); -+ if (!entry) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ "couldn't find space for BLS entry list"); -+ return NULL; -+ } -+ -+ grub_memset (entry, 0, sizeof (*entry)); -+ entries[nentries] = entry; ++static struct bls_entry *entries = NULL; + -+ nentries = new_n; -+ -+ return entry; -+} ++#define FOR_BLS_ENTRIES(var) FOR_LIST_ELEMENTS (var, entries) + +static int bls_add_keyval(struct bls_entry *entry, char *key, char *val) +{ @@ -157,108 +158,41 @@ index 4274aca5a9d..86796c8cd83 100644 + kv->val = v; + + entry->keyvals[entry->nkeyvals] = kv; -+ grub_dprintf("blscfg", "new keyval at %p:%p:%p\n", entry->keyvals[entry->nkeyvals], k, v); ++ grub_dprintf("blscfg", "new keyval at %p:%s:%s\n", entry->keyvals[entry->nkeyvals], k, v); + entry->nkeyvals = new_n; + + return 0; +} + -+static void bls_free_entry(struct bls_entry *entry) -+{ -+ int i; -+ -+ grub_dprintf("blscfg", "%s got here\n", __func__); -+ for (i = 0; i < entry->nkeyvals; i++) -+ { -+ struct keyval *kv = entry->keyvals[i]; -+ grub_free ((void *)kv->key); -+ grub_free (kv->val); -+ grub_free (kv); -+ } -+ -+ grub_free (entry->keyvals); -+ grub_memset (entry, 0, sizeof (*entry)); -+ grub_free (entry); -+} -+ -+static int keyval_cmp (const void *p0, const void *p1, -+ void *state UNUSED) -+{ -+ const struct keyval *kv0 = *(struct keyval * const *)p0; -+ const struct keyval *kv1 = *(struct keyval * const *)p1; -+ int rc; -+ -+ rc = grub_strcmp(kv0->key, kv1->key); -+ -+ return rc; -+} -+ +/* Find they value of the key named by keyname. If there are allowed to be + * more than one, pass a pointer to an int set to -1 the first time, and pass + * the same pointer through each time after, and it'll return them in sorted -+ * order. */ ++ * order as defined in the BLS fragment file */ +static char *bls_get_val(struct bls_entry *entry, const char *keyname, int *last) +{ -+ char *foo = (char *)""; -+ struct keyval *kv = NULL, **kvp, key = {keyname, foo}, *keyp = &key; ++ int idx, start = 0; ++ struct keyval *kv = NULL; + -+ /* if we've already found an entry that matches, just iterate */ -+ if (last && *last >= 0) -+ { -+ int next = ++last[0]; -+ -+ if (next == entry->nkeyvals) -+ { -+done: -+ *last = -1; -+ return NULL; -+ } ++ if (last) ++ start = *last + 1; + -+ kv = entry->keyvals[next]; -+ if (grub_strcmp (keyname, kv->key)) -+ goto done; ++ for (idx = start; idx < entry->nkeyvals; idx++) { ++ kv = entry->keyvals[idx]; + -+ return kv->val; -+ } ++ if (!grub_strcmp (keyname, kv->key)) ++ break; ++ } + -+ kvp = grub_bsearch(&keyp, &entry->keyvals[0], entry->nkeyvals, -+ sizeof (struct keyval *), keyval_cmp, NULL); -+ if (kvp) -+ kv = *kvp; ++ if (idx == entry->nkeyvals) { ++ if (last) ++ *last = -1; ++ return NULL; ++ } + -+ if (kv) -+ { -+ /* if we've got uninitialized but present state, track back until we find -+ * the first match */ -+ if (last) -+ { -+ grub_dprintf("blscfg", "%s trying to find another entry because last was set\n", __func__); -+ /* figure out the position of this entry in the array */ -+ int idx; -+ for (idx = 0 ; idx < entry->nkeyvals; idx++) -+ if (entry->keyvals[idx] == kv) -+ break; -+ *last = idx; -+ -+ while (idx > 0) -+ { -+ struct keyval *kvtmp = entry->keyvals[idx-1]; -+ if (idx == 0 || grub_strcmp (keyname, kvtmp->key)) -+ { -+ /* if we're at the start, or if the previous entry doesn't -+ * match, then we're done */ -+ *last = idx; -+ break; -+ } -+ else -+ /* but if it does match, keep going backwards */ -+ idx--; -+ } -+ } ++ if (last) ++ *last = idx; + -+ return kv->val; -+ } -+ return NULL; ++ return kv->val; +} + +#define goto_return(x) ({ ret = (x); goto finish; }) @@ -277,7 +211,7 @@ index 4274aca5a9d..86796c8cd83 100644 + int isnum; + int ret = 0; + -+ grub_dprintf("blscfg", "%s got here\n", __func__); ++ grub_dprintf("blscfg", "%s comparing %s and %s\n", __func__, a, b); + if (!grub_strcmp(a, b)) + return 0; + @@ -386,129 +320,233 @@ index 4274aca5a9d..86796c8cd83 100644 + return ret; +} + -+typedef int (*void_cmp_t)(void *, void *); -+ -+static int nulcmp(char *s0, char *s1, void_cmp_t cmp) ++/* returns name/version/release */ ++/* NULL string pointer returned if nothing found */ ++static void ++split_package_string (char *package_string, char **name, ++ char **version, char **release) +{ -+ grub_dprintf("blscfg", "%s got here\n", __func__); -+ if (s1 && !s0) -+ return 1; -+ if (s0 && !s1) -+ return -1; -+ if (!s0 && !s1) -+ return 0; -+ if (cmp) -+ return cmp(s0, s1); -+ return grub_strcmp(s0, s1); ++ char *package_version, *package_release; ++ ++ /* Release */ ++ package_release = grub_strrchr (package_string, '-'); ++ ++ if (package_release != NULL) ++ *package_release++ = '\0'; ++ ++ *release = package_release; ++ ++ if (name == NULL) ++ { ++ *version = package_string; ++ } ++ else ++ { ++ /* Version */ ++ package_version = grub_strrchr(package_string, '-'); ++ ++ if (package_version != NULL) ++ *package_version++ = '\0'; ++ ++ *version = package_version; ++ /* Name */ ++ *name = package_string; ++ } ++ ++ /* Bubble up non-null values from release to name */ ++ if (name != NULL && *name == NULL) ++ { ++ *name = (*version == NULL ? *release : *version); ++ *version = *release; ++ *release = NULL; ++ } ++ if (*version == NULL) ++ { ++ *version = *release; ++ *release = NULL; ++ } +} + +static int -+bls_keyval_cmp(struct bls_entry *e0, struct bls_entry *e1, const char *keyname) ++split_cmp(char *nvr0, char *nvr1, int has_name) +{ -+ char *val0, *val1; ++ int ret = 0; ++ char *name0, *version0, *release0; ++ char *name1, *version1, *release1; + -+ val0 = bls_get_val (e0, keyname, NULL); -+ val1 = bls_get_val (e1, keyname, NULL); ++ split_package_string(nvr0, has_name ? &name0 : NULL, &version0, &release0); ++ split_package_string(nvr1, has_name ? &name1 : NULL, &version1, &release1); + -+ if (val1 && !val0) -+ return 1; ++ if (has_name) ++ { ++ ret = vercmp(name0 == NULL ? "" : name0, ++ name1 == NULL ? "" : name1); ++ if (ret != 0) ++ return ret; ++ } + -+ if (val0 && !val1) -+ return -1; ++ ret = vercmp(version0 == NULL ? "" : version0, ++ version1 == NULL ? "" : version1); ++ if (ret != 0) ++ return ret; + -+ if (!val0 && !val1) -+ return 0; ++ ret = vercmp(release0 == NULL ? "" : release0, ++ release1 == NULL ? "" : release1); ++ return ret; ++} ++ ++/* return 1: e0 is newer than e1 */ ++/* 0: e0 and e1 are the same version */ ++/* -1: e1 is newer than e0 */ ++static int bls_cmp(const struct bls_entry *e0, const struct bls_entry *e1) ++{ ++ char *id0, *id1; ++ int r; ++ ++ id0 = grub_strdup(e0->filename); ++ id1 = grub_strdup(e1->filename); ++ ++ r = split_cmp(id0, id1, 1); ++ ++ grub_free(id0); ++ grub_free(id1); + -+ return nulcmp(val0, val1, (void_cmp_t)vercmp); ++ return r; +} + -+static int bls_cmp(const void *p0, const void *p1, void *state UNUSED) ++static void list_add_tail(struct bls_entry *head, struct bls_entry *item) +{ -+ struct bls_entry * e0 = *(struct bls_entry **)p0; -+ struct bls_entry * e1 = *(struct bls_entry **)p1; -+ int rc = 0; ++ item->next = head; ++ if (head->prev) ++ head->prev->next = item; ++ item->prev = head->prev; ++ head->prev = item; ++} + -+ rc = bls_keyval_cmp (e0, e1, "id"); ++static int bls_add_entry(struct bls_entry *entry) ++{ ++ struct bls_entry *e, *last = NULL; ++ int rc; ++ ++ if (!entries) { ++ grub_dprintf ("blscfg", "Add entry with id \"%s\"\n", entry->filename); ++ entries = entry; ++ return 0; ++ } + -+ if (rc == 0) -+ rc = bls_keyval_cmp (e0, e1, "title"); ++ FOR_BLS_ENTRIES(e) { ++ rc = bls_cmp(entry, e); + -+ if (rc == 0) -+ rc = bls_keyval_cmp (e0, e1, "linux"); ++ if (!rc) ++ return GRUB_ERR_BAD_ARGUMENT; + -+ return rc; ++ if (rc == 1) { ++ grub_dprintf ("blscfg", "Add entry with id \"%s\"\n", entry->filename); ++ list_add_tail (e, entry); ++ if (e == entries) { ++ entries = entry; ++ entry->prev = NULL; ++ } ++ return 0; ++ } ++ last = e; ++ } ++ ++ if (last) { ++ grub_dprintf ("blscfg", "Add entry with id \"%s\"\n", entry->filename); ++ last->next = entry; ++ entry->prev = last; ++ } ++ ++ return 0; +} + ++struct read_entry_info { ++ const char *devid; ++ const char *dirname; ++ grub_file_t file; ++}; ++ +static int read_entry ( - const char *filename, -- const struct grub_dirhook_info *info __attribute__ ((unused)), -- void *data __attribute__ ((unused))) -+ const struct grub_dirhook_info *info UNUSED, ++ const char *filename, ++ const struct grub_dirhook_info *dirhook_info UNUSED, + void *data) - { - grub_size_t n; - char *p; - grub_file_t f = NULL; - grub_off_t sz; -- char *title = NULL, *options = NULL, *clinux = NULL, *initrd = NULL, *src = NULL; -- const char *args[2] = { NULL, NULL }; ++{ ++ grub_size_t m = 0, n, clip = 0; ++ int rc = 0; ++ char *p = NULL; ++ grub_file_t f = NULL; + struct bls_entry *entry; -+ const char *dirname= (const char *)data; -+ const char *devid = grub_env_get ("boot"); ++ struct read_entry_info *info = (struct read_entry_info *)data; + + grub_dprintf ("blscfg", "filename: \"%s\"\n", filename); - - if (filename[0] == '.') - return 0; -@@ -67,7 +440,7 @@ static int parse_entry ( - if (grub_strcmp (filename + n - 5, ".conf") != 0) - return 0; - -- p = grub_xasprintf (GRUB_BLS_CONFIG_PATH "%s", filename); -+ p = grub_xasprintf ("(%s)%s/%s", devid, dirname, filename); - - f = grub_file_open (p); - if (!f) -@@ -77,54 +450,169 @@ static int parse_entry ( - if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024) - goto finish; - -+ entry = bls_new_entry(); ++ ++ n = grub_strlen (filename); ++ ++ if (info->file) ++ { ++ f = info->file; ++ } ++ else ++ { ++ if (filename[0] == '.') ++ return 0; ++ ++ if (n <= 5) ++ return 0; ++ ++ if (grub_strcmp (filename + n - 5, ".conf") != 0) ++ return 0; ++ ++ p = grub_xasprintf ("(%s)%s/%s", info->devid, info->dirname, filename); ++ ++ f = grub_file_open (p, GRUB_FILE_TYPE_CONFIG); ++ if (!f) ++ goto finish; ++ } ++ ++ entry = grub_zalloc (sizeof (*entry)); + if (!entry) + goto finish; + - for (;;) - { - char *buf; ++ if (info->file) ++ { ++ char *slash; ++ ++ if (n > 5 && !grub_strcmp (filename + n - 5, ".conf") == 0) ++ clip = 5; ++ ++ slash = grub_strrchr (filename, '/'); ++ if (!slash) ++ slash = grub_strrchr (filename, '\\'); ++ ++ while (*slash == '/' || *slash == '\\') ++ slash++; ++ ++ m = slash ? slash - filename : 0; ++ } ++ else ++ { ++ m = 0; ++ clip = 5; ++ } ++ n -= m; ++ ++ entry->filename = grub_strndup(filename + m, n - clip); ++ if (!entry->filename) ++ goto finish; ++ ++ entry->filename[n - 5] = '\0'; ++ ++ for (;;) ++ { ++ char *buf; + char *separator; -+ int rc; - - buf = grub_file_getline (f); - if (!buf) - break; - -- if (grub_strncmp (buf, "title ", 6) == 0) -- { -- grub_free (title); -- title = grub_strdup (buf + 6); -- if (!title) -- goto finish; -- } -- else if (grub_strncmp (buf, "options ", 8) == 0) -- { -- grub_free (options); -- options = grub_strdup (buf + 8); -- if (!options) -- goto finish; -- } -- else if (grub_strncmp (buf, "linux ", 6) == 0) -- { -- grub_free (clinux); -- clinux = grub_strdup (buf + 6); -- if (!clinux) -- goto finish; -- } -- else if (grub_strncmp (buf, "initrd ", 7) == 0) ++ ++ buf = grub_file_getline (f); ++ if (!buf) ++ break; ++ + while (buf && buf[0] && (buf[0] == ' ' || buf[0] == '\t')) + buf++; + if (buf[0] == '#') @@ -520,29 +558,29 @@ index 4274aca5a9d..86796c8cd83 100644 + separator = grub_strchr (buf, '\t'); + + if (!separator || separator[1] == '\0') - { -- grub_free (initrd); -- initrd = grub_strdup (buf + 7); -- if (!initrd) -- goto finish; ++ { + grub_free (buf); + break; - } - -- grub_free(buf); ++ } ++ + separator[0] = '\0'; + -+ rc = bls_add_keyval (entry, buf, separator+1); ++ do { ++ separator++; ++ } while (*separator == ' ' || *separator == '\t'); ++ ++ rc = bls_add_keyval (entry, buf, separator); + grub_free (buf); + if (rc < 0) + break; + } + -+ grub_qsort(&entry->keyvals[0], entry->nkeyvals, sizeof (struct keyval *), -+ keyval_cmp, NULL); ++ if (!rc) ++ bls_add_entry(entry); + +finish: -+ grub_free (p); ++ if (p) ++ grub_free (p); + + if (f) + grub_file_close (f); @@ -552,7 +590,7 @@ index 4274aca5a9d..86796c8cd83 100644 + +static grub_envblk_t saved_env = NULL; + -+static int ++static int UNUSED +save_var (const char *name, const char *value, void *whitelist UNUSED) +{ + const char *val = grub_env_get (name); @@ -564,7 +602,7 @@ index 4274aca5a9d..86796c8cd83 100644 + return 0; +} + -+static int ++static int UNUSED +unset_var (const char *name, const char *value UNUSED, void *whitelist) +{ + grub_dprintf("blscfg", "restoring \"%s\"\n", name); @@ -572,9 +610,8 @@ index 4274aca5a9d..86796c8cd83 100644 + { + grub_env_unset (name); + return 0; - } - -- if (!linux) ++ } ++ + if (test_whitelist_membership (name, + (const grub_env_whitelist_t *) whitelist)) + grub_env_unset (name); @@ -618,7 +655,101 @@ index 4274aca5a9d..86796c8cd83 100644 + return list; +} + -+static void create_entry (struct bls_entry *entry, const char *cfgfile) ++static char *field_append(bool is_var, char *buffer, char *start, char *end) ++{ ++ char *temp = grub_strndup(start, end - start + 1); ++ const char *field = temp; ++ ++ if (is_var) { ++ field = grub_env_get (temp); ++ if (!field) ++ return buffer; ++ } ++ ++ if (!buffer) { ++ buffer = grub_strdup(field); ++ if (!buffer) ++ return NULL; ++ } else { ++ buffer = grub_realloc (buffer, grub_strlen(buffer) + grub_strlen(field)); ++ if (!buffer) ++ return NULL; ++ ++ grub_stpcpy (buffer + grub_strlen(buffer), field); ++ } ++ ++ return buffer; ++} ++ ++static char *expand_val(char *value) ++{ ++ char *buffer = NULL; ++ char *start = value; ++ char *end = value; ++ bool is_var = false; ++ ++ if (!value) ++ return NULL; ++ ++ while (*value) { ++ if (*value == '$') { ++ if (start != end) { ++ buffer = field_append(is_var, buffer, start, end); ++ if (!buffer) ++ return NULL; ++ } ++ ++ is_var = true; ++ start = value + 1; ++ } else if (is_var) { ++ if (!grub_isalnum(*value) && *value != '_') { ++ buffer = field_append(is_var, buffer, start, end); ++ is_var = false; ++ start = value; ++ } ++ } ++ ++ end = value; ++ value++; ++ } ++ ++ if (start != end) { ++ buffer = field_append(is_var, buffer, start, end); ++ if (!buffer) ++ return NULL; ++ } ++ ++ return buffer; ++} ++ ++static char **early_initrd_list (const char *initrd) ++{ ++ int nlist = 0; ++ char **list = NULL; ++ char *separator; ++ ++ while ((separator = grub_strchr (initrd, ' '))) ++ { ++ list = grub_realloc (list, (nlist + 2) * sizeof (char *)); ++ if (!list) ++ return NULL; ++ ++ list[nlist++] = grub_strndup(initrd, separator - initrd); ++ list[nlist] = NULL; ++ initrd = separator + 1; ++ } ++ ++ list = grub_realloc (list, (nlist + 2) * sizeof (char *)); ++ if (!list) ++ return NULL; ++ ++ list[nlist++] = grub_strndup(initrd, grub_strlen(initrd)); ++ list[nlist] = NULL; ++ ++ return list; ++} ++ ++static void create_entry (struct bls_entry *entry) +{ + int argc = 0; + const char **argv = NULL; @@ -626,8 +757,13 @@ index 4274aca5a9d..86796c8cd83 100644 + char *title = NULL; + char *clinux = NULL; + char *options = NULL; ++ char **initrds = NULL; + char *initrd = NULL; -+ char *id = NULL; ++ const char *early_initrd = NULL; ++ char **early_initrds = NULL; ++ char *initrd_prefix = NULL; ++ char *id = entry->filename; ++ char *dotconf = id; + char *hotkey = NULL; + + char *users = NULL; @@ -636,25 +772,36 @@ index 4274aca5a9d..86796c8cd83 100644 + char **args = NULL; + + char *src = NULL; -+ int i; ++ int i, index; + + grub_dprintf("blscfg", "%s got here\n", __func__); + clinux = bls_get_val (entry, "linux", NULL); + if (!clinux) - { -- grub_printf ("Skipping file %s with no 'linux' key.", p); -+ grub_dprintf ("blscfg", "Skipping file %s with no 'linux' key.\n", cfgfile); - goto finish; - } - -- args[0] = title ? title : filename; ++ { ++ grub_dprintf ("blscfg", "Skipping file %s with no 'linux' key.\n", entry->filename); ++ goto finish; ++ } ++ ++ /* ++ * strip the ".conf" off the end before we make it our "id" field. ++ */ ++ do ++ { ++ dotconf = grub_strstr(dotconf, ".conf"); ++ } while (dotconf != NULL && dotconf[5] != '\0'); ++ if (dotconf) ++ dotconf[0] = '\0'; ++ + title = bls_get_val (entry, "title", NULL); -+ options = bls_get_val (entry, "options", NULL); -+ initrd = bls_get_val (entry, "initrd", NULL); -+ id = bls_get_val (entry, "id", NULL); - ++ options = expand_val (bls_get_val (entry, "options", NULL)); ++ ++ if (!options) ++ options = expand_val (grub_env_get("default_kernelopts")); ++ ++ initrds = bls_make_list (entry, "initrd", NULL); ++ + hotkey = bls_get_val (entry, "grub_hotkey", NULL); -+ users = bls_get_val (entry, "grub_users", NULL); ++ users = expand_val (bls_get_val (entry, "grub_users", NULL)); + classes = bls_make_list (entry, "grub_class", NULL); + args = bls_make_list (entry, "grub_arg", &argc); + @@ -665,293 +812,377 @@ index 4274aca5a9d..86796c8cd83 100644 + argv[i] = args[i-1]; + argv[argc] = NULL; + -+ grub_dprintf("blscfg", "adding menu entry for \"%s\"\n", title); - src = grub_xasprintf ("load_video\n" - "set gfx_payload=keep\n" - "insmod gzio\n" -@@ -133,40 +621,219 @@ static int parse_entry ( - GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", - initrd ? GRUB_INITRD_CMD " " : "", initrd ? GRUB_BOOT_DEVICE : "", initrd ? initrd : "", initrd ? "\n" : ""); - -- grub_normal_add_menu_entry (1, args, NULL, NULL, "bls", NULL, NULL, src, 0); -+ grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0); - - finish: -- grub_free (p); -- grub_free (title); -- grub_free (options); -- grub_free (clinux); -- grub_free (initrd); -- grub_free (src); -+ if (classes) -+ grub_free (classes); -+ grub_dprintf("blscfg", "%s got here\n", __func__); -+ if (args) -+ grub_free (args); ++ early_initrd = grub_env_get("early_initrd"); + -+ if (argv) -+ grub_free (argv); ++ grub_dprintf ("blscfg", "adding menu entry for \"%s\" with id \"%s\"\n", ++ title, id); ++ if (early_initrd) ++ { ++ early_initrds = early_initrd_list(early_initrd); ++ if (!early_initrds) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ goto finish; ++ } + -+ if (src) -+ grub_free (src); -+ grub_dprintf("blscfg", "%s got here\n", __func__); ++ if (initrds != NULL && initrds[0] != NULL) ++ { ++ initrd_prefix = grub_strrchr (initrds[0], '/'); ++ initrd_prefix = grub_strndup(initrds[0], initrd_prefix - initrds[0] + 1); ++ } ++ else ++ { ++ initrd_prefix = grub_strrchr (clinux, '/'); ++ initrd_prefix = grub_strndup(clinux, initrd_prefix - clinux + 1); ++ } ++ ++ if (!initrd_prefix) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ goto finish; ++ } ++ } ++ ++ if (early_initrds || initrds) ++ { ++ int initrd_size = sizeof ("initrd"); ++ char *tmp; ++ ++ for (i = 0; early_initrds != NULL && early_initrds[i] != NULL; i++) ++ initrd_size += sizeof (" " GRUB_BOOT_DEVICE) \ ++ + grub_strlen(initrd_prefix) \ ++ + grub_strlen (early_initrds[i]) + 1; ++ ++ for (i = 0; initrds != NULL && initrds[i] != NULL; i++) ++ initrd_size += sizeof (" " GRUB_BOOT_DEVICE) \ ++ + grub_strlen (initrds[i]) + 1; ++ initrd_size += 1; ++ ++ initrd = grub_malloc (initrd_size); ++ if (!initrd) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ goto finish; ++ } ++ ++ ++ tmp = grub_stpcpy(initrd, "initrd"); ++ for (i = 0; early_initrds != NULL && early_initrds[i] != NULL; i++) ++ { ++ grub_dprintf ("blscfg", "adding early initrd %s\n", early_initrds[i]); ++ tmp = grub_stpcpy (tmp, " " GRUB_BOOT_DEVICE); ++ tmp = grub_stpcpy (tmp, initrd_prefix); ++ tmp = grub_stpcpy (tmp, early_initrds[i]); ++ grub_free(early_initrds[i]); ++ } ++ ++ for (i = 0; initrds != NULL && initrds[i] != NULL; i++) ++ { ++ grub_dprintf ("blscfg", "adding initrd %s\n", initrds[i]); ++ tmp = grub_stpcpy (tmp, " " GRUB_BOOT_DEVICE); ++ tmp = grub_stpcpy (tmp, initrds[i]); ++ } ++ tmp = grub_stpcpy (tmp, "\n"); ++ } ++ ++ src = grub_xasprintf ("load_video\n" ++ "set gfxpayload=keep\n" ++ "insmod gzio\n" ++ "linux %s%s%s%s\n" ++ "%s", ++ GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", ++ initrd ? initrd : ""); ++ ++ grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0, &index, entry); ++ grub_dprintf ("blscfg", "Added entry %d id:\"%s\"\n", index, id); ++ ++finish: ++ grub_free (initrd); ++ grub_free (initrd_prefix); ++ grub_free (early_initrds); ++ grub_free (initrds); ++ grub_free (options); ++ grub_free (classes); ++ grub_free (args); ++ grub_free (argv); ++ grub_free (src); +} + +struct find_entry_info { ++ const char *dirname; ++ const char *devid; + grub_device_t dev; + grub_fs_t fs; -+ int efi; +}; + +/* -+ * filename: if the directory is /EFI/something/ , filename is "something" -+ * info: unused -+ * data: the filesystem object the file is on. ++ * info: the filesystem object the file is on. + */ -+static int find_entry (const char *filename, -+ const struct grub_dirhook_info *dirhook_info UNUSED, -+ void *data) ++static int find_entry (struct find_entry_info *info) +{ -+ struct find_entry_info *info = (struct find_entry_info *)data; -+ grub_file_t f = NULL; -+ char *grubenv_path = NULL; -+ grub_envblk_t env = NULL; -+ char *default_blsdir = NULL; -+ const char *blsdir = NULL; -+ char *saved_env_buf = NULL; ++ struct read_entry_info read_entry_info; ++ grub_fs_t blsdir_fs = NULL; ++ grub_device_t blsdir_dev = NULL; ++ const char *blsdir = info->dirname; ++ int fallback = 0; + int r = 0; -+ const char *devid = grub_env_get ("boot"); + -+ grub_dprintf("blscfg", "%s got here\n", __func__); -+ if (!grub_strcmp (filename, ".") || -+ !grub_strcmp (filename, "..")) -+ return 0; ++ if (!blsdir) { ++ blsdir = grub_env_get ("blsdir"); ++ if (!blsdir) ++ blsdir = GRUB_BLS_CONFIG_PATH; ++ } + -+ if (info->efi && !grub_strcasecmp (filename, "boot")) -+ return 0; ++ read_entry_info.file = NULL; ++ read_entry_info.dirname = blsdir; + -+ saved_env_buf = grub_malloc (512); ++ grub_dprintf ("blscfg", "scanning blsdir: %s\n", blsdir); + -+ // set a default blsdir -+ if (info->efi) -+ default_blsdir = grub_xasprintf ("/EFI/%s%s", filename, -+ GRUB_BLS_CONFIG_PATH); -+ else -+ default_blsdir = grub_xasprintf ("%s", GRUB_BLS_CONFIG_PATH); ++ blsdir_dev = info->dev; ++ blsdir_fs = info->fs; ++ read_entry_info.devid = info->devid; + -+ grub_env_set ("blsdir", default_blsdir); -+ grub_dprintf ("blscfg", "default_blsdir: \"%s\"\n", default_blsdir); ++read_fallback: ++ r = blsdir_fs->fs_dir (blsdir_dev, read_entry_info.dirname, read_entry, ++ &read_entry_info); ++ if (r != 0) { ++ grub_dprintf ("blscfg", "read_entry returned error\n"); ++ grub_err_t e; ++ do ++ { ++ e = grub_error_pop(); ++ } while (e); ++ } + -+ /* -+ * try to load a grubenv from /EFI/wherever/grubenv -+ */ -+ if (info->efi) -+ grubenv_path = grub_xasprintf ("(%s)/EFI/%s/grubenv", devid, filename); -+ else -+ grubenv_path = grub_xasprintf ("(%s)/grub2/grubenv", devid); ++ if (r && !info->dirname && !fallback) { ++ read_entry_info.dirname = "/boot" GRUB_BLS_CONFIG_PATH; ++ grub_dprintf ("blscfg", "Entries weren't found in %s, fallback to %s\n", ++ blsdir, read_entry_info.dirname); ++ fallback = 1; ++ goto read_fallback; ++ } + -+ grub_dprintf ("blscfg", "looking for \"%s\"\n", grubenv_path); -+ f = grub_file_open (grubenv_path); ++ return 0; ++} + -+ grub_dprintf ("blscfg", "%s it\n", f ? "found" : "did not find"); -+ grub_free (grubenv_path); -+ if (f) -+ { -+ grub_off_t sz; ++static grub_err_t ++bls_load_entries (const char *path) ++{ ++ grub_size_t len; ++ grub_fs_t fs; ++ grub_device_t dev; ++ static grub_err_t r; ++ const char *devid = NULL; ++ char *blsdir = NULL; ++ struct find_entry_info info = { ++ .dev = NULL, ++ .fs = NULL, ++ .dirname = NULL, ++ }; ++ struct read_entry_info rei = { ++ .devid = NULL, ++ .dirname = NULL, ++ }; ++ ++ if (path) { ++ len = grub_strlen (path); ++ if (grub_strcmp (path + len - 5, ".conf") == 0) { ++ rei.file = grub_file_open (path, GRUB_FILE_TYPE_CONFIG); ++ if (!rei.file) ++ return grub_errno; ++ /* ++ * read_entry() closes the file ++ */ ++ return read_entry(path, NULL, &rei); ++ } else if (path[0] == '(') { ++ devid = path + 1; ++ ++ blsdir = grub_strchr (path, ')'); ++ if (!blsdir) ++ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Filepath isn't correct")); ++ ++ *blsdir = '\0'; ++ blsdir = blsdir + 1; ++ } ++ } + -+ grub_dprintf ("blscfg", "getting size\n"); -+ sz = grub_file_size (f); -+ if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024) -+ goto finish; ++ if (!devid) { ++#ifdef GRUB_MACHINE_EMU ++ devid = "host"; ++#elif defined(GRUB_MACHINE_EFI) ++ devid = grub_env_get ("root"); ++#else ++ devid = grub_env_get ("boot"); ++#endif ++ if (!devid) ++ return grub_error (GRUB_ERR_FILE_NOT_FOUND, ++ N_("variable `%s' isn't set"), "boot"); ++ } + -+ grub_dprintf ("blscfg", "reading env\n"); -+ env = read_envblk_file (f); -+ if (!env) -+ goto finish; -+ grub_dprintf ("blscfg", "read env file\n"); -+ -+ grub_memset (saved_env_buf, '#', 512); -+ grub_memcpy (saved_env_buf, GRUB_ENVBLK_SIGNATURE, -+ sizeof (GRUB_ENVBLK_SIGNATURE)); -+ grub_dprintf ("blscfg", "saving env\n"); -+ saved_env = grub_envblk_open (saved_env_buf, 512); -+ if (!saved_env) -+ goto finish; ++ grub_dprintf ("blscfg", "opening %s\n", devid); ++ dev = grub_device_open (devid); ++ if (!dev) ++ return grub_errno; + -+ // save everything listed in "env" with values from our existing grub env -+ grub_envblk_iterate (env, NULL, save_var); -+ // set everything from our loaded grubenv into the real grub env -+ grub_envblk_iterate (env, NULL, set_var); -+ } -+ else ++ grub_dprintf ("blscfg", "probing fs\n"); ++ fs = grub_fs_probe (dev); ++ if (!fs) + { -+ grub_err_t e; -+ grub_dprintf ("blscfg", "no such file\n"); -+ do -+ { -+ e = grub_error_pop(); -+ } while (e); -+ ++ r = grub_errno; ++ goto finish; + } + -+ blsdir = grub_env_get ("blsdir"); -+ if (!blsdir) -+ goto finish; ++ info.dirname = blsdir; ++ info.devid = devid; ++ info.dev = dev; ++ info.fs = fs; ++ find_entry(&info); + -+ grub_dprintf ("blscfg", "blsdir: \"%s\"\n", blsdir); -+ if (blsdir[0] != '/' && info->efi) -+ blsdir = grub_xasprintf ("/EFI/%s/%s/", filename, blsdir); -+ else -+ blsdir = grub_strdup (blsdir); ++finish: ++ if (dev) ++ grub_device_close (dev); + -+ if (!blsdir) -+ goto finish; ++ return r; ++} + -+ grub_dprintf ("blscfg", "blsdir: \"%s\"\n", blsdir); -+ r = info->fs->dir (info->dev, blsdir, read_entry, (char *)blsdir); -+ if (r != 0) { -+ grub_dprintf ("blscfg", "read_entry returned error\n"); -+ grub_err_t e; -+ do -+ { -+ e = grub_error_pop(); -+ } while (e); -+ } ++static bool ++is_default_entry(const char *def_entry, struct bls_entry *entry, int idx) ++{ ++ const char *title; ++ int def_idx; + -+ grub_dprintf ("blscfg", "Sorting %d entries\n", nentries); -+ grub_qsort(&entries[0], nentries, sizeof (struct bls_entry *), bls_cmp, NULL); ++ if (!def_entry) ++ return false; + -+ grub_dprintf ("blscfg", "%s Creating %d entries from bls\n", __func__, nentries); -+ for (r = nentries - 1; r >= 0; r--) -+ create_entry(entries[r], filename); ++ if (grub_strcmp(def_entry, entry->filename) == 0) ++ return true; + -+ for (r = 0; r < nentries; r++) -+ bls_free_entry (entries[r]); -+finish: -+ nentries = 0; ++ title = bls_get_val(entry, "title", NULL); + -+ grub_free (entries); -+ entries = NULL; ++ if (title && grub_strcmp(def_entry, title) == 0) ++ return true; + -+ grub_free ((char *)blsdir); ++ def_idx = (int)grub_strtol(def_entry, NULL, 0); ++ if (grub_errno == GRUB_ERR_BAD_NUMBER) { ++ grub_errno = GRUB_ERR_NONE; ++ return false; ++ } + -+ grub_env_unset ("blsdir"); ++ if (def_idx == idx) ++ return true; + -+ if (saved_env) -+ { -+ // remove everything from the real environment that's defined in env -+ grub_envblk_iterate (env, NULL, unset_var); ++ return false; ++} + -+ // re-set the things from our original environment -+ grub_envblk_iterate (saved_env, NULL, set_var); -+ grub_envblk_close (saved_env); -+ saved_env = NULL; ++static grub_err_t ++bls_create_entries (bool show_default, bool show_non_default, char *entry_id) ++{ ++ const char *def_entry = NULL; ++ struct bls_entry *entry = NULL; ++ int idx = 0; ++ ++ def_entry = grub_env_get("default"); ++ ++ grub_dprintf ("blscfg", "%s Creating entries from bls\n", __func__); ++ FOR_BLS_ENTRIES(entry) { ++ if (entry->visible) { ++ idx++; ++ continue; + } -+ else if (saved_env_buf) -+ { -+ // if we have a saved environment, grub_envblk_close() freed this. -+ grub_free (saved_env_buf); ++ ++ if ((show_default && is_default_entry(def_entry, entry, idx)) || ++ (show_non_default && !is_default_entry(def_entry, entry, idx)) || ++ (entry_id && grub_strcmp(entry_id, entry->filename) == 0)) { ++ create_entry(entry); ++ entry->visible = 1; + } ++ idx++; ++ } + -+ if (env) -+ grub_envblk_close (env); - - if (f) - grub_file_close (f); - -+ grub_free (default_blsdir); ++ return GRUB_ERR_NONE; ++} + - return 0; - } - - static grub_err_t --grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)), -- int argc __attribute__ ((unused)), -- char **args __attribute__ ((unused))) ++static grub_err_t +grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, -+ int argc UNUSED, -+ char **args UNUSED) - { - grub_fs_t fs; - grub_device_t dev; - static grub_err_t r; - const char *devid; -+ struct find_entry_info info = -+ { -+ .dev = NULL, -+ .fs = NULL, -+ .efi = 0, -+ }; - -- devid = grub_env_get ("root"); -+ -+ grub_dprintf ("blscfg", "finding boot\n"); -+ devid = grub_env_get ("boot"); - if (!devid) -- return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "root"); -+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, -+ N_("variable `%s' isn't set"), "boot"); - -+ grub_dprintf ("blscfg", "opening %s\n", devid); - dev = grub_device_open (devid); - if (!dev) - return grub_errno; - -+ grub_dprintf ("blscfg", "probing fs\n"); - fs = grub_fs_probe (dev); - if (!fs) - { -@@ -174,7 +841,17 @@ grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)), - goto finish; - } - -- r = fs->dir (dev, GRUB_BLS_CONFIG_PATH, parse_entry, NULL); -+ info.dev = dev; -+ info.fs = fs; -+#ifdef GRUB_MACHINE_EFI -+ info.efi = 1; -+ grub_dprintf ("blscfg", "scanning /EFI/\n"); -+ r = fs->dir (dev, "/EFI/", find_entry, &info); -+#else -+ info.efi = 0; -+ grub_dprintf ("blscfg", "scanning %s\n", GRUB_BLS_CONFIG_PATH); -+ r = fs->dir (dev, "/", find_entry, &info); -+#endif - - finish: - if (dev) -@@ -184,18 +861,27 @@ finish: - } - - static grub_extcmd_t cmd; ++ int argc, char **args) ++{ ++ grub_err_t r; ++ char *path = NULL; ++ char *entry_id = NULL; ++ bool show_default = true; ++ bool show_non_default = true; ++ ++ if (argc == 1) { ++ if (grub_strcmp (args[0], "default") == 0) { ++ show_non_default = false; ++ } else if (grub_strcmp (args[0], "non-default") == 0) { ++ show_default = false; ++ } else if (args[0][0] == '(') { ++ path = args[0]; ++ } else { ++ entry_id = args[0]; ++ show_default = false; ++ show_non_default = false; ++ } ++ } ++ ++ r = bls_load_entries(path); ++ if (r) ++ return r; ++ ++ return bls_create_entries(show_default, show_non_default, entry_id); ++} ++ ++static grub_extcmd_t cmd; +static grub_extcmd_t oldcmd; - - GRUB_MOD_INIT(bls) - { -- cmd = grub_register_extcmd ("bls_import", -- grub_cmd_bls_import, ++ ++GRUB_MOD_INIT(blscfg) ++{ + grub_dprintf("blscfg", "%s got here\n", __func__); + cmd = grub_register_extcmd ("blscfg", + grub_cmd_blscfg, - 0, - NULL, - N_("Import Boot Loader Specification snippets."), - NULL); ++ 0, ++ NULL, ++ N_("Import Boot Loader Specification snippets."), ++ NULL); + oldcmd = grub_register_extcmd ("bls_import", + grub_cmd_blscfg, + 0, + NULL, + N_("Import Boot Loader Specification snippets."), + NULL); - } - - GRUB_MOD_FINI(bls) - { - grub_unregister_extcmd (cmd); ++} ++ ++GRUB_MOD_FINI(blscfg) ++{ ++ grub_unregister_extcmd (cmd); + grub_unregister_extcmd (oldcmd); - } ++} +diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c +index db7a8f0..891eac5 100644 +--- a/grub-core/commands/legacycfg.c ++++ b/grub-core/commands/legacycfg.c +@@ -133,7 +133,7 @@ legacy_file (const char *filename) + args[0] = oldname; + grub_normal_add_menu_entry (1, args, NULL, NULL, "legacy", + NULL, NULL, +- entrysrc, 0); ++ entrysrc, 0, NULL, NULL); + grub_free (args); + entrysrc[0] = 0; + grub_free (oldname); +@@ -186,7 +186,8 @@ legacy_file (const char *filename) + } + args[0] = entryname; + grub_normal_add_menu_entry (1, args, NULL, NULL, NULL, +- NULL, NULL, entrysrc, 0); ++ NULL, NULL, entrysrc, 0, NULL, ++ NULL); + grub_free (args); + } + diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c -index acd93d123ed..91c99456091 100644 +index 3fd664a..163b9a0 100644 --- a/grub-core/commands/loadenv.c +++ b/grub-core/commands/loadenv.c @@ -28,6 +28,8 @@ @@ -963,7 +1194,7 @@ index acd93d123ed..91c99456091 100644 GRUB_MOD_LICENSE ("GPLv3+"); static const struct grub_arg_option options[] = -@@ -84,81 +86,6 @@ open_envblk_file (char *filename, int untrusted) +@@ -79,81 +81,6 @@ open_envblk_file (char *filename, return file; } @@ -1047,7 +1278,7 @@ index acd93d123ed..91c99456091 100644 { diff --git a/grub-core/commands/loadenv.h b/grub-core/commands/loadenv.h new file mode 100644 -index 00000000000..952f46121bd +index 0000000..952f461 --- /dev/null +++ b/grub-core/commands/loadenv.h @@ -0,0 +1,93 @@ @@ -1144,8 +1375,104 @@ index 00000000000..952f46121bd + + return 0; +} +diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c +index 2c5363d..9faf2be 100644 +--- a/grub-core/commands/menuentry.c ++++ b/grub-core/commands/menuentry.c +@@ -78,7 +78,7 @@ grub_normal_add_menu_entry (int argc, const char **args, + char **classes, const char *id, + const char *users, const char *hotkey, + const char *prefix, const char *sourcecode, +- int submenu) ++ int submenu, int *index, struct bls_entry *bls) + { + int menu_hotkey = 0; + char **menu_args = NULL; +@@ -149,9 +149,12 @@ grub_normal_add_menu_entry (int argc, const char **args, + if (! menu_title) + goto fail; + ++ grub_dprintf ("menu", "id:\"%s\"\n", id); ++ grub_dprintf ("menu", "title:\"%s\"\n", menu_title); + menu_id = grub_strdup (id ? : menu_title); + if (! menu_id) + goto fail; ++ grub_dprintf ("menu", "menu_id:\"%s\"\n", menu_id); + + /* Save argc, args to pass as parameters to block arg later. */ + menu_args = grub_malloc (sizeof (char*) * (argc + 1)); +@@ -170,8 +173,12 @@ grub_normal_add_menu_entry (int argc, const char **args, + } + + /* Add the menu entry at the end of the list. */ ++ int ind=0; + while (*last) +- last = &(*last)->next; ++ { ++ ind++; ++ last = &(*last)->next; ++ } + + *last = grub_zalloc (sizeof (**last)); + if (! *last) +@@ -188,8 +195,11 @@ grub_normal_add_menu_entry (int argc, const char **args, + (*last)->args = menu_args; + (*last)->sourcecode = menu_sourcecode; + (*last)->submenu = submenu; ++ (*last)->bls = bls; + + menu->size++; ++ if (index) ++ *index = ind; + return GRUB_ERR_NONE; + + fail: +@@ -286,7 +296,8 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args) + users, + ctxt->state[2].arg, 0, + ctxt->state[3].arg, +- ctxt->extcmd->cmd->name[0] == 's'); ++ ctxt->extcmd->cmd->name[0] == 's', ++ NULL, NULL); + + src = args[argc - 1]; + args[argc - 1] = NULL; +@@ -303,7 +314,8 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args) + ctxt->state[0].args, ctxt->state[4].arg, + users, + ctxt->state[2].arg, prefix, src + 1, +- ctxt->extcmd->cmd->name[0] == 's'); ++ ctxt->extcmd->cmd->name[0] == 's', NULL, ++ NULL); + + src[len - 1] = ch; + args[argc - 1] = src; +diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c +index 9ef9848..a326b19 100644 +--- a/grub-core/normal/main.c ++++ b/grub-core/normal/main.c +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -70,6 +71,11 @@ grub_normal_free_menu (grub_menu_t menu) + grub_free (entry->args); + } + ++ if (entry->bls) ++ { ++ entry->bls->visible = 0; ++ } ++ + grub_free ((void *) entry->id); + grub_free ((void *) entry->users); + grub_free ((void *) entry->title); diff --git a/include/grub/compiler.h b/include/grub/compiler.h -index c9e1d7a73dc..9859ff4cc79 100644 +index c9e1d7a..9859ff4 100644 --- a/include/grub/compiler.h +++ b/include/grub/compiler.h @@ -48,4 +48,6 @@ @@ -1155,3 +1482,50 @@ index c9e1d7a73dc..9859ff4cc79 100644 +#define UNUSED __attribute__((__unused__)) + #endif /* ! GRUB_COMPILER_HEADER */ +diff --git a/include/grub/menu.h b/include/grub/menu.h +index ee2b5e9..0acdc2a 100644 +--- a/include/grub/menu.h ++++ b/include/grub/menu.h +@@ -20,6 +20,16 @@ + #ifndef GRUB_MENU_HEADER + #define GRUB_MENU_HEADER 1 + ++struct bls_entry ++{ ++ struct bls_entry *next; ++ struct bls_entry *prev; ++ struct keyval **keyvals; ++ int nkeyvals; ++ char *filename; ++ int visible; ++}; ++ + struct grub_menu_entry_class + { + char *name; +@@ -60,6 +70,9 @@ struct grub_menu_entry + + /* The next element. */ + struct grub_menu_entry *next; ++ ++ /* BLS used to populate the entry */ ++ struct bls_entry *bls; + }; + typedef struct grub_menu_entry *grub_menu_entry_t; + +diff --git a/include/grub/normal.h b/include/grub/normal.h +index 218cbab..8839ad8 100644 +--- a/include/grub/normal.h ++++ b/include/grub/normal.h +@@ -145,7 +145,7 @@ grub_normal_add_menu_entry (int argc, const char **args, char **classes, + const char *id, + const char *users, const char *hotkey, + const char *prefix, const char *sourcecode, +- int submenu); ++ int submenu, int *index, struct bls_entry *bls); + + grub_err_t + grub_normal_set_password (const char *user, const char *password); +-- +1.8.3.1 + diff --git a/0029-Add-devicetree-loading.patch b/0028-Add-devicetree-loading.patch similarity index 86% rename from 0029-Add-devicetree-loading.patch rename to 0028-Add-devicetree-loading.patch index 4cb1a2a741f67ff46aaff6f47408258f96216ca6..f60d16eb9b992623cb9e0c7ad62a79c927e51ab9 100644 --- a/0029-Add-devicetree-loading.patch +++ b/0028-Add-devicetree-loading.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 5c649924a8e4d233f922c21408eeeaac5b30bc73 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 14 Jan 2014 13:12:23 -0500 -Subject: [PATCH] Add devicetree loading +Subject: [PATCH 028/220] Add devicetree loading Signed-off-by: Peter Jones @@ -20,7 +20,7 @@ Signed-off-by: David A. Marlin 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index b0a8626dd1c..f68d4925ee6 100644 +index 9ecbcfb..c645351 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -254,7 +254,8 @@ export GRUB_DEFAULT \ @@ -34,23 +34,23 @@ index b0a8626dd1c..f68d4925ee6 100644 if test "x${grub_cfg}" != "x"; then rm -f "${grub_cfg}.new" diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 87a7da34982..233754ff296 100644 +index 58defdb..dd31284 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in -@@ -153,6 +153,13 @@ EOF - sed "s/^/$submenu_indentation/" << EOF - echo '$(echo "$message" | grub_quote)' +@@ -155,6 +155,13 @@ EOF initrd $(echo $initrd_path) -+EOF -+ fi + EOF + fi + if test -n "${fdt}" ; then + message="$(gettext_printf "Loading fdt ...")" + sed "s/^/$submenu_indentation/" << EOF + echo '$(echo "$message" | grub_quote)' + devicetree ${rel_dirname}/${fdt} - EOF - fi ++EOF ++ fi sed "s/^/$submenu_indentation/" << EOF + } + EOF @@ -236,6 +243,14 @@ while [ "x$list" != "x" ] ; do gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 fi @@ -66,3 +66,6 @@ index 87a7da34982..233754ff296 100644 config= for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do if test -e "${i}" ; then +-- +1.8.3.1 + diff --git a/0028-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch b/0028-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch deleted file mode 100644 index fd63493c33f53dcbd2c8a3991e53076831671899..0000000000000000000000000000000000000000 --- a/0028-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch +++ /dev/null @@ -1,248 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Fedora Ninjas -Date: Tue, 22 Jan 2013 06:31:38 +0100 -Subject: [PATCH] blscfg: add blscfg module to parse Boot Loader Specification - snippets - -http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec - -Works like this: - - insmod blscfg - bls_import - -Done! You should now have menu items for your snippets in place. - -Signed-off-by: Peter Jones ---- - grub-core/Makefile.core.def | 8 ++ - grub-core/commands/blscfg.c | 201 ++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 209 insertions(+) - create mode 100644 grub-core/commands/blscfg.c - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index f8065388213..cd0902b46b8 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -768,6 +768,14 @@ module = { - common = commands/blocklist.c; - }; - -+module = { -+ name = blscfg; -+ common = commands/blscfg.c; -+ enable = i386_efi; -+ enable = x86_64_efi; -+ enable = i386_pc; -+}; -+ - module = { - name = boot; - common = commands/boot.c; -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -new file mode 100644 -index 00000000000..4274aca5a9d ---- /dev/null -+++ b/grub-core/commands/blscfg.c -@@ -0,0 +1,201 @@ -+/*-*- Mode: C; c-basic-offset: 2; indent-tabs-mode: t -*-*/ -+ -+/* bls.c - implementation of the boot loader spec */ -+ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+GRUB_MOD_LICENSE ("GPLv3+"); -+ -+#ifdef GRUB_MACHINE_EFI -+#define GRUB_LINUX_CMD "linuxefi" -+#define GRUB_INITRD_CMD "initrdefi" -+#define GRUB_BLS_CONFIG_PATH "/EFI/fedora/loader/entries/" -+#define GRUB_BOOT_DEVICE "($boot)" -+#else -+#define GRUB_LINUX_CMD "linux" -+#define GRUB_INITRD_CMD "initrd" -+#define GRUB_BLS_CONFIG_PATH "/loader/entries/" -+#define GRUB_BOOT_DEVICE "($root)" -+#endif -+ -+static int parse_entry ( -+ const char *filename, -+ const struct grub_dirhook_info *info __attribute__ ((unused)), -+ void *data __attribute__ ((unused))) -+{ -+ grub_size_t n; -+ char *p; -+ grub_file_t f = NULL; -+ grub_off_t sz; -+ char *title = NULL, *options = NULL, *clinux = NULL, *initrd = NULL, *src = NULL; -+ const char *args[2] = { NULL, NULL }; -+ -+ if (filename[0] == '.') -+ return 0; -+ -+ n = grub_strlen (filename); -+ if (n <= 5) -+ return 0; -+ -+ if (grub_strcmp (filename + n - 5, ".conf") != 0) -+ return 0; -+ -+ p = grub_xasprintf (GRUB_BLS_CONFIG_PATH "%s", filename); -+ -+ f = grub_file_open (p); -+ if (!f) -+ goto finish; -+ -+ sz = grub_file_size (f); -+ if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024) -+ goto finish; -+ -+ for (;;) -+ { -+ char *buf; -+ -+ buf = grub_file_getline (f); -+ if (!buf) -+ break; -+ -+ if (grub_strncmp (buf, "title ", 6) == 0) -+ { -+ grub_free (title); -+ title = grub_strdup (buf + 6); -+ if (!title) -+ goto finish; -+ } -+ else if (grub_strncmp (buf, "options ", 8) == 0) -+ { -+ grub_free (options); -+ options = grub_strdup (buf + 8); -+ if (!options) -+ goto finish; -+ } -+ else if (grub_strncmp (buf, "linux ", 6) == 0) -+ { -+ grub_free (clinux); -+ clinux = grub_strdup (buf + 6); -+ if (!clinux) -+ goto finish; -+ } -+ else if (grub_strncmp (buf, "initrd ", 7) == 0) -+ { -+ grub_free (initrd); -+ initrd = grub_strdup (buf + 7); -+ if (!initrd) -+ goto finish; -+ } -+ -+ grub_free(buf); -+ } -+ -+ if (!linux) -+ { -+ grub_printf ("Skipping file %s with no 'linux' key.", p); -+ goto finish; -+ } -+ -+ args[0] = title ? title : filename; -+ -+ src = grub_xasprintf ("load_video\n" -+ "set gfx_payload=keep\n" -+ "insmod gzio\n" -+ GRUB_LINUX_CMD " %s%s%s%s\n" -+ "%s%s%s%s", -+ GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", -+ initrd ? GRUB_INITRD_CMD " " : "", initrd ? GRUB_BOOT_DEVICE : "", initrd ? initrd : "", initrd ? "\n" : ""); -+ -+ grub_normal_add_menu_entry (1, args, NULL, NULL, "bls", NULL, NULL, src, 0); -+ -+finish: -+ grub_free (p); -+ grub_free (title); -+ grub_free (options); -+ grub_free (clinux); -+ grub_free (initrd); -+ grub_free (src); -+ -+ if (f) -+ grub_file_close (f); -+ -+ return 0; -+} -+ -+static grub_err_t -+grub_cmd_bls_import (grub_extcmd_context_t ctxt __attribute__ ((unused)), -+ int argc __attribute__ ((unused)), -+ char **args __attribute__ ((unused))) -+{ -+ grub_fs_t fs; -+ grub_device_t dev; -+ static grub_err_t r; -+ const char *devid; -+ -+ devid = grub_env_get ("root"); -+ if (!devid) -+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "root"); -+ -+ dev = grub_device_open (devid); -+ if (!dev) -+ return grub_errno; -+ -+ fs = grub_fs_probe (dev); -+ if (!fs) -+ { -+ r = grub_errno; -+ goto finish; -+ } -+ -+ r = fs->dir (dev, GRUB_BLS_CONFIG_PATH, parse_entry, NULL); -+ -+finish: -+ if (dev) -+ grub_device_close (dev); -+ -+ return r; -+} -+ -+static grub_extcmd_t cmd; -+ -+GRUB_MOD_INIT(bls) -+{ -+ cmd = grub_register_extcmd ("bls_import", -+ grub_cmd_bls_import, -+ 0, -+ NULL, -+ N_("Import Boot Loader Specification snippets."), -+ NULL); -+} -+ -+GRUB_MOD_FINI(bls) -+{ -+ grub_unregister_extcmd (cmd); -+} diff --git a/0030-Don-t-write-messages-to-the-screen.patch b/0029-Don-t-write-messages-to-the-screen.patch similarity index 94% rename from 0030-Don-t-write-messages-to-the-screen.patch rename to 0029-Don-t-write-messages-to-the-screen.patch index e96a23404635ac1bd91d8951e8b16e81f62fcea8..61673d8a5adde6970c48b69682ddf8fe30f63307 100644 --- a/0030-Don-t-write-messages-to-the-screen.patch +++ b/0029-Don-t-write-messages-to-the-screen.patch @@ -1,21 +1,51 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 88cba3a10617ef55989762a4195599a399dca957 Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Wed, 15 May 2013 13:30:20 -0400 -Subject: [PATCH] Don't write messages to the screen +Subject: [PATCH 029/220] Don't write messages to the screen Writing messages to the screen before the menus or boot splash happens so quickly it looks like something is wrong and isn't very appealing. --- - grub-core/gettext/gettext.c | 25 +++++-------------------- - grub-core/kern/main.c | 5 ----- grub-core/boot/i386/pc/boot.S | 3 --- grub-core/boot/i386/pc/diskboot.S | 5 ----- + grub-core/gettext/gettext.c | 25 +++++-------------------- + grub-core/kern/main.c | 5 ----- util/grub.d/10_linux.in | 7 ------- 5 files changed, 5 insertions(+), 40 deletions(-) +diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S +index 2bd0b2d..ea167fe 100644 +--- a/grub-core/boot/i386/pc/boot.S ++++ b/grub-core/boot/i386/pc/boot.S +@@ -249,9 +249,6 @@ real_start: + /* save drive reference first thing! */ + pushw %dx + +- /* print a notification message on the screen */ +- MSG(notification_string) +- + /* set %si to the disk address packet */ + movw $disk_address_packet, %si + +diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S +index c1addc0..68d31de 100644 +--- a/grub-core/boot/i386/pc/diskboot.S ++++ b/grub-core/boot/i386/pc/diskboot.S +@@ -50,11 +50,6 @@ _start: + /* save drive reference first thing! */ + pushw %dx + +- /* print a notification message on the screen */ +- pushw %si +- MSG(notification_string) +- popw %si +- + /* this sets up for the first run through "bootloop" */ + movw $LOCAL(firstlist), %di + diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c -index 4880cefe3f8..b22e1bcc94b 100644 +index 4d02e62..84d520c 100644 --- a/grub-core/gettext/gettext.c +++ b/grub-core/gettext/gettext.c @@ -434,16 +434,12 @@ static char * @@ -97,7 +127,7 @@ index 4880cefe3f8..b22e1bcc94b 100644 grub_register_variable_hook ("locale_dir", NULL, read_main); grub_register_variable_hook ("secondary_locale_dir", NULL, read_secondary); diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index 8ab7794c47b..da47b18b50e 100644 +index 8ab7794..da47b18 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c @@ -268,11 +268,6 @@ grub_main (void) @@ -112,38 +142,8 @@ index 8ab7794c47b..da47b18b50e 100644 grub_load_config (); grub_boot_time ("Before loading embedded modules."); -diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S -index 2bd0b2d2866..ea167fe1206 100644 ---- a/grub-core/boot/i386/pc/boot.S -+++ b/grub-core/boot/i386/pc/boot.S -@@ -249,9 +249,6 @@ real_start: - /* save drive reference first thing! */ - pushw %dx - -- /* print a notification message on the screen */ -- MSG(notification_string) -- - /* set %si to the disk address packet */ - movw $disk_address_packet, %si - -diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S -index c1addc0df29..68d31de0c4c 100644 ---- a/grub-core/boot/i386/pc/diskboot.S -+++ b/grub-core/boot/i386/pc/diskboot.S -@@ -50,11 +50,6 @@ _start: - /* save drive reference first thing! */ - pushw %dx - -- /* print a notification message on the screen */ -- pushw %si -- MSG(notification_string) -- popw %si -- - /* this sets up for the first run through "bootloop" */ - movw $LOCAL(firstlist), %di - diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 233754ff296..3a5aa0f8dc9 100644 +index dd31284..ceb413f 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -138,27 +138,20 @@ linux_entry () @@ -174,3 +174,6 @@ index 233754ff296..3a5aa0f8dc9 100644 devicetree ${rel_dirname}/${fdt} EOF fi +-- +1.8.3.1 + diff --git a/0031-Don-t-print-GNU-GRUB-header.patch b/0030-Don-t-print-GNU-GRUB-header.patch similarity index 76% rename from 0031-Don-t-print-GNU-GRUB-header.patch rename to 0030-Don-t-print-GNU-GRUB-header.patch index cdcdb13c37c8a336fbaf81d615c862372447151d..aff2b0207e133c79ecaf6c0ea3be2733baebf942 100644 --- a/0031-Don-t-print-GNU-GRUB-header.patch +++ b/0030-Don-t-print-GNU-GRUB-header.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 9af19d1f8184aad31b3094768a64722316d4f0da Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Wed, 15 May 2013 13:53:48 -0400 -Subject: [PATCH] Don't print GNU GRUB header +Subject: [PATCH 030/220] Don't print GNU GRUB header No one cares. --- @@ -9,10 +9,10 @@ No one cares. 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index b2654ef62e8..f57b7508a76 100644 +index a326b19..09d0dfe 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -202,15 +202,16 @@ read_config_file (const char *config) +@@ -208,15 +208,16 @@ read_config_file (const char *config) /* Initialize the screen. */ void grub_normal_init_page (struct grub_term_output *term, @@ -32,7 +32,7 @@ index b2654ef62e8..f57b7508a76 100644 msg_formatted = grub_xasprintf (_("GNU GRUB version %s"), PACKAGE_VERSION); if (!msg_formatted) -@@ -235,6 +236,7 @@ grub_normal_init_page (struct grub_term_output *term, +@@ -241,6 +242,7 @@ grub_normal_init_page (struct grub_term_output *term, grub_putcode ('\n', term); grub_putcode ('\n', term); grub_free (unicode_msg); @@ -40,3 +40,6 @@ index b2654ef62e8..f57b7508a76 100644 } static void +-- +1.8.3.1 + diff --git a/0032-Don-t-add-to-highlighted-row.patch b/0031-Don-t-add-to-highlighted-row.patch similarity index 80% rename from 0032-Don-t-add-to-highlighted-row.patch rename to 0031-Don-t-add-to-highlighted-row.patch index b2d55757b09f94686ec6f73f6c0505118ddd0fc7..1f36a149386a1a93ca349905aed4d48757f3b91f 100644 --- a/0032-Don-t-add-to-highlighted-row.patch +++ b/0031-Don-t-add-to-highlighted-row.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From fc5204f8800ecfa4f00fab8ab8cd2720a6d5b55e Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Wed, 15 May 2013 17:49:45 -0400 -Subject: [PATCH] Don't add '*' to highlighted row +Subject: [PATCH 031/220] Don't add '*' to highlighted row It is already highlighted. --- @@ -9,7 +9,7 @@ It is already highlighted. 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index e22bb91f6e8..a3d1f23f68f 100644 +index e22bb91..a3d1f23 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -242,7 +242,7 @@ print_entry (int y, int highlight, grub_menu_entry_t entry, @@ -21,3 +21,6 @@ index e22bb91f6e8..a3d1f23f68f 100644 grub_print_ucs4_menu (unicode_title, unicode_title + len, +-- +1.8.3.1 + diff --git a/0033-Message-string-cleanups.patch b/0032-Message-string-cleanups.patch similarity index 94% rename from 0033-Message-string-cleanups.patch rename to 0032-Message-string-cleanups.patch index 9b6208e9f0a313d96662c8b802cad7044efa82a5..c9c0b6f9d6cd07d56b2293325835b7beaab05680 100644 --- a/0033-Message-string-cleanups.patch +++ b/0032-Message-string-cleanups.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From cc62054bce6fc5f00f4e302d8fa7615d263f1f5b Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Fri, 7 Jun 2013 11:09:04 -0400 -Subject: [PATCH] Message string cleanups +Subject: [PATCH 032/220] Message string cleanups Make use of terminology consistent. Remove jargon. --- @@ -9,7 +9,7 @@ Make use of terminology consistent. Remove jargon. 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index a3d1f23f68f..64a83862f66 100644 +index a3d1f23..64a8386 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -157,9 +157,8 @@ print_message (int nested, int edit, struct grub_term_output *term, int dry_run) @@ -66,3 +66,6 @@ index a3d1f23f68f..64a83862f66 100644 if (!msg_translated) { grub_print_error (); +-- +1.8.3.1 + diff --git a/0034-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch b/0033-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch similarity index 82% rename from 0034-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch rename to 0033-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch index 504f27358d04cdfe54dc93f5df3d907df5b569a8..cb207c7c81811d2043cc3250d4d02e16e5c93bd7 100644 --- a/0034-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch +++ b/0033-Fix-border-spacing-now-that-we-aren-t-displaying-it.patch @@ -1,14 +1,14 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 9330deb86a791da573563dc319e1874af72eb97c Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Fri, 7 Jun 2013 14:08:23 -0400 -Subject: [PATCH] Fix border spacing now that we aren't displaying it +Subject: [PATCH 033/220] Fix border spacing now that we aren't displaying it --- grub-core/normal/menu_text.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 64a83862f66..1062d64ee29 100644 +index 64a8386..1062d64 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -331,12 +331,12 @@ grub_menu_init_page (int nested, int edit, @@ -27,3 +27,6 @@ index 64a83862f66..1062d64ee29 100644 geo->timeout_lines = 2; +-- +1.8.3.1 + diff --git a/0035-Use-the-correct-indentation-for-the-term-help-text.patch b/0034-Use-the-correct-indentation-for-the-term-help-text.patch similarity index 77% rename from 0035-Use-the-correct-indentation-for-the-term-help-text.patch rename to 0034-Use-the-correct-indentation-for-the-term-help-text.patch index d2bf366ede6d5c3595474fe4f274ee27b22885bf..f7fae87f7185b493a5212f4741bbc04da775160c 100644 --- a/0035-Use-the-correct-indentation-for-the-term-help-text.patch +++ b/0034-Use-the-correct-indentation-for-the-term-help-text.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 5e6cef121ba76d88608e6c124ff60e73cf057fe4 Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Fri, 7 Jun 2013 14:08:49 -0400 -Subject: [PATCH] Use the correct indentation for the term help text +Subject: [PATCH 034/220] Use the correct indentation for the term help text That is consistent with the menu help text --- @@ -9,10 +9,10 @@ That is consistent with the menu help text 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index f57b7508a76..0ce59fdc3f0 100644 +index 09d0dfe..7f61c5b 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -426,8 +426,8 @@ grub_normal_reader_init (int nested) +@@ -432,8 +432,8 @@ grub_normal_reader_init (int nested) grub_normal_init_page (term, 1); grub_term_setcursor (term, 1); @@ -23,3 +23,6 @@ index f57b7508a76..0ce59fdc3f0 100644 else grub_print_message_indented (msg_formatted, 0, 0, term); grub_putcode ('\n', term); +-- +1.8.3.1 + diff --git a/0036-Indent-menu-entries.patch b/0035-Indent-menu-entries.patch similarity index 81% rename from 0036-Indent-menu-entries.patch rename to 0035-Indent-menu-entries.patch index 7a843ec03ec98404e1f357b86dce8f310c12a7e6..fde8f7edf770a53a1dae88c5261dc469c83f998c 100644 --- a/0036-Indent-menu-entries.patch +++ b/0035-Indent-menu-entries.patch @@ -1,14 +1,14 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 7d70ca36c17e14361284f986e4c62e6523bf6b98 Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Fri, 7 Jun 2013 14:30:55 -0400 -Subject: [PATCH] Indent menu entries +Subject: [PATCH 035/220] Indent menu entries --- grub-core/normal/menu_text.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 1062d64ee29..ecc60f99fc3 100644 +index 1062d64..ecc60f9 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -239,7 +239,8 @@ print_entry (int y, int highlight, grub_menu_entry_t entry, @@ -21,3 +21,6 @@ index 1062d64ee29..ecc60f99fc3 100644 grub_print_ucs4_menu (unicode_title, unicode_title + len, +-- +1.8.3.1 + diff --git a/0037-Fix-margins.patch b/0036-Fix-margins.patch similarity index 88% rename from 0037-Fix-margins.patch rename to 0036-Fix-margins.patch index 9be173185379ba6007f753c73296082b4b15a6a8..6c91ecd4e8b6b292d1843f62dfaab54b5b86e989 100644 --- a/0037-Fix-margins.patch +++ b/0036-Fix-margins.patch @@ -1,14 +1,14 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 61f83fac37fb9bacac50f75e0aa7d304bfabf410 Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Fri, 7 Jun 2013 14:59:36 -0400 -Subject: [PATCH] Fix margins +Subject: [PATCH 036/220] Fix margins --- grub-core/normal/menu_text.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index ecc60f99fc3..0e43f2c10cc 100644 +index ecc60f9..0e43f2c 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -333,17 +333,15 @@ grub_menu_init_page (int nested, int edit, @@ -32,3 +32,6 @@ index ecc60f99fc3..0e43f2c10cc 100644 - 1 /* empty line before info message*/ - geo->timeout_lines /* timeout */ - 1 /* empty final line */; +-- +1.8.3.1 + diff --git a/0038-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch b/0037-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch similarity index 78% rename from 0038-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch rename to 0037-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch index 3a37839898732e0e9f65c402b59cc642f0654e16..ed79a3ee558dc1ae765ddbfdccd36b89f74a87e7 100644 --- a/0038-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch +++ b/0037-Use-2-instead-of-1-for-our-right-hand-margin-so-line.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 10fe905b3b3364436fe5328724b21def775aec60 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Fri, 21 Jun 2013 14:44:08 -0400 -Subject: [PATCH] Use -2 instead of -1 for our right-hand margin, so +Subject: [PATCH 037/220] Use -2 instead of -1 for our right-hand margin, so linewrapping works (#976643). Signed-off-by: Peter Jones @@ -10,7 +10,7 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 0e43f2c10cc..537d4bf86ff 100644 +index 0e43f2c..537d4bf 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -334,7 +334,7 @@ grub_menu_init_page (int nested, int edit, @@ -22,3 +22,6 @@ index 0e43f2c10cc..537d4bf86ff 100644 geo->first_entry_y = 3; /* three empty lines*/ +-- +1.8.3.1 + diff --git a/0039-Enable-pager-by-default.-985860.patch b/0038-Enable-pager-by-default.-985860.patch similarity index 78% rename from 0039-Enable-pager-by-default.-985860.patch rename to 0038-Enable-pager-by-default.-985860.patch index d92fbcc79a6b59f5b28483289647757b5e880c5b..f9031b2c93085b37e0f8b613f6fd12152ed6cc26 100644 --- a/0039-Enable-pager-by-default.-985860.patch +++ b/0038-Enable-pager-by-default.-985860.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 29aa9344700bc787778391d6176c2b3b220838e6 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 28 Oct 2013 10:09:27 -0400 -Subject: [PATCH] Enable pager by default. (#985860) +Subject: [PATCH 038/220] Enable pager by default. (#985860) Signed-off-by: Peter Jones --- @@ -9,7 +9,7 @@ Signed-off-by: Peter Jones 1 file changed, 2 insertions(+) diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in -index 93a90233ead..858b526c925 100644 +index 93a9023..858b526 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -43,6 +43,8 @@ if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_ @@ -21,3 +21,6 @@ index 93a90233ead..858b526c925 100644 if [ -s \$prefix/grubenv ]; then load_env fi +-- +1.8.3.1 + diff --git a/0040-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch b/0039-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch similarity index 80% rename from 0040-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch rename to 0039-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch index 93233bc95d1c486c51f90c692bf56b342248b62c..6507767840db4c2d89d1a48aa6fdef470d36e5c8 100644 --- a/0040-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch +++ b/0039-F10-doesn-t-work-on-serial-so-don-t-tell-the-user-to.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 72ffa52429b18c75f461c5dfa339c05b4bed2788 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 28 Oct 2013 10:13:27 -0400 -Subject: [PATCH] F10 doesn't work on serial, so don't tell the user to hit it - (#987443) +Subject: [PATCH 039/220] F10 doesn't work on serial, so don't tell the user to + hit it (#987443) Signed-off-by: Peter Jones --- @@ -10,7 +10,7 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 537d4bf86ff..452d55bf9ff 100644 +index 537d4bf..452d55b 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -157,7 +157,7 @@ print_message (int nested, int edit, struct grub_term_output *term, int dry_run) @@ -22,3 +22,6 @@ index 537d4bf86ff..452d55bf9ff 100644 command prompt or Escape to discard edits and return to the menu. Pressing Tab lists possible completions."), STANDARD_MARGIN, STANDARD_MARGIN, term, dry_run); +-- +1.8.3.1 + diff --git a/0041-Don-t-say-GNU-Linux-in-generated-menus.patch b/0040-Don-t-say-GNU-Linux-in-generated-menus.patch similarity index 86% rename from 0041-Don-t-say-GNU-Linux-in-generated-menus.patch rename to 0040-Don-t-say-GNU-Linux-in-generated-menus.patch index 85b0cde724cb844195b651ee7fe2a9de2d544fd6..b8593392462d93cc0a2a1d6df5034cb8dfec5c64 100644 --- a/0041-Don-t-say-GNU-Linux-in-generated-menus.patch +++ b/0040-Don-t-say-GNU-Linux-in-generated-menus.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From b2d841ee307560bbc0a3c4fe4a5516fb8e00dd65 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 14 Mar 2011 14:27:42 -0400 -Subject: [PATCH] Don't say "GNU/Linux" in generated menus. +Subject: [PATCH 040/220] Don't say "GNU/Linux" in generated menus. --- util/grub.d/10_linux.in | 4 ++-- @@ -9,7 +9,7 @@ Subject: [PATCH] Don't say "GNU/Linux" in generated menus. 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 3a5aa0f8dc9..6299836b5cd 100644 +index ceb413f..2b402d8 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -29,9 +29,9 @@ export TEXTDOMAINDIR="@localedir@" @@ -25,7 +25,7 @@ index 3a5aa0f8dc9..6299836b5cd 100644 fi diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in -index e8143b079dc..972a4b5a03d 100644 +index 96179ea..47e0d3f 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -29,9 +29,9 @@ export TEXTDOMAINDIR="@localedir@" @@ -40,3 +40,6 @@ index e8143b079dc..972a4b5a03d 100644 CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}" fi +-- +1.8.3.1 + diff --git a/0042-Don-t-draw-a-border-around-the-menu.patch b/0041-Don-t-draw-a-border-around-the-menu.patch similarity index 93% rename from 0042-Don-t-draw-a-border-around-the-menu.patch rename to 0041-Don-t-draw-a-border-around-the-menu.patch index e5d11ac1f7cd17f5e6187b104e0393e43c2b9c78..e77973aa8c47adb2a1ccdaedb953fb073e17a999 100644 --- a/0042-Don-t-draw-a-border-around-the-menu.patch +++ b/0041-Don-t-draw-a-border-around-the-menu.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 6d92979792752de9af962a75f399768c655ce92e Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Wed, 15 May 2013 16:47:33 -0400 -Subject: [PATCH] Don't draw a border around the menu +Subject: [PATCH 041/220] Don't draw a border around the menu It looks cleaner without it. --- @@ -9,7 +9,7 @@ It looks cleaner without it. 1 file changed, 43 deletions(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 452d55bf9ff..1ed2bd92cf8 100644 +index 452d55b..1ed2bd9 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -108,47 +108,6 @@ grub_print_message_indented (const char *msg, int margin_left, int margin_right, @@ -69,3 +69,6 @@ index 452d55bf9ff..1ed2bd92cf8 100644 grub_term_normal_color = old_color_normal; grub_term_highlight_color = old_color_highlight; geo->timeout_y = geo->first_entry_y + geo->num_entries +-- +1.8.3.1 + diff --git a/0043-Use-the-standard-margin-for-the-timeout-string.patch b/0042-Use-the-standard-margin-for-the-timeout-string.patch similarity index 88% rename from 0043-Use-the-standard-margin-for-the-timeout-string.patch rename to 0042-Use-the-standard-margin-for-the-timeout-string.patch index c6c770c8df3fd270e2dc733a5454421fdaff842d..315c176f77facf92d2d25b6188160e6a528b4014 100644 --- a/0043-Use-the-standard-margin-for-the-timeout-string.patch +++ b/0042-Use-the-standard-margin-for-the-timeout-string.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From ead897508b29261ccf87aa46e778863a351737b2 Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Fri, 7 Jun 2013 10:52:32 -0400 -Subject: [PATCH] Use the standard margin for the timeout string +Subject: [PATCH 042/220] Use the standard margin for the timeout string So that it aligns with the other messages --- @@ -9,7 +9,7 @@ So that it aligns with the other messages 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c -index 1ed2bd92cf8..7681f7d2893 100644 +index 1ed2bd9..7681f7d 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -372,7 +372,7 @@ grub_menu_init_page (int nested, int edit, @@ -38,3 +38,6 @@ index 1ed2bd92cf8..7681f7d2893 100644 } } +-- +1.8.3.1 + diff --git a/0044-Add-.eh_frame-to-list-of-relocations-stripped.patch b/0043-Add-.eh_frame-to-list-of-relocations-stripped.patch similarity index 84% rename from 0044-Add-.eh_frame-to-list-of-relocations-stripped.patch rename to 0043-Add-.eh_frame-to-list-of-relocations-stripped.patch index d837061d048831b025176e5925d570190d841379..8b83ed5da947d530eee281182b7f0173a77398b9 100644 --- a/0044-Add-.eh_frame-to-list-of-relocations-stripped.patch +++ b/0043-Add-.eh_frame-to-list-of-relocations-stripped.patch @@ -1,14 +1,14 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From dcfc32257387a45d41600d52f2393fee402b7271 Mon Sep 17 00:00:00 2001 From: Fedora Ninjas Date: Mon, 13 Jan 2014 21:50:59 -0500 -Subject: [PATCH] Add .eh_frame to list of relocations stripped +Subject: [PATCH 043/220] Add .eh_frame to list of relocations stripped --- conf/Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/Makefile.common b/conf/Makefile.common -index 311da61c6c5..044ab3abe88 100644 +index 6cd71cb..4ba729e 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -38,7 +38,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding @@ -20,3 +20,6 @@ index 311da61c6c5..044ab3abe88 100644 CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d +-- +1.8.3.1 + diff --git a/0045-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch b/0044-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch similarity index 70% rename from 0045-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch rename to 0044-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch index 33bdad26fe4991b060c1b793b56b7a6d7206d875..5e886d4fc8f3e6996d02d6ac950117d187c240c3 100644 --- a/0045-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch +++ b/0044-Don-t-munge-raw-spaces-when-we-re-doing-our-cmdline-.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 6fa778275c0765f9d2535118ba0a37065dded86f Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 30 Jun 2014 14:16:46 -0400 -Subject: [PATCH] Don't munge raw spaces when we're doing our cmdline escaping - (#923374) +Subject: [PATCH 044/220] Don't munge raw spaces when we're doing our cmdline + escaping (#923374) Signed-off-by: Peter Jones --- @@ -10,10 +10,10 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c -index 0a5b2afb94b..970ea868c14 100644 +index e0fb0a9..8e2294d 100644 --- a/grub-core/lib/cmdline.c +++ b/grub-core/lib/cmdline.c -@@ -97,16 +97,7 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, +@@ -98,16 +98,7 @@ grub_create_loader_cmdline (int argc, char *argv[], char *buf, while (*c) { @@ -31,3 +31,6 @@ index 0a5b2afb94b..970ea868c14 100644 is_hex(*(c+2)) && is_hex(*(c+3))) { *buf++ = *c++; +-- +1.8.3.1 + diff --git a/0046-Don-t-require-a-password-to-boot-entries-generated-b.patch b/0045-Don-t-require-a-password-to-boot-entries-generated-b.patch similarity index 80% rename from 0046-Don-t-require-a-password-to-boot-entries-generated-b.patch rename to 0045-Don-t-require-a-password-to-boot-entries-generated-b.patch index b0b2b0efde3a5738b5fe3ec40a7d3a7144b64524..85e461b9185fb45aec6c851d3294ce5c09eb1927 100644 --- a/0046-Don-t-require-a-password-to-boot-entries-generated-b.patch +++ b/0045-Don-t-require-a-password-to-boot-entries-generated-b.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 226cdd8a7722f5e1a60f21c5a2aea74f458d612d Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 11 Feb 2014 11:14:50 -0500 -Subject: [PATCH] Don't require a password to boot entries generated by +Subject: [PATCH 045/220] Don't require a password to boot entries generated by grub-mkconfig. When we set a password, we just want that to mean you can't /edit/ an entry. @@ -14,7 +14,7 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 6299836b5cd..b744438e04a 100644 +index 2b402d8..d35b0f4 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -26,7 +26,7 @@ datarootdir="@datarootdir@" @@ -26,3 +26,6 @@ index 6299836b5cd..b744438e04a 100644 if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then OS="$(sed 's, release .*$,,g' /etc/system-release)" +-- +1.8.3.1 + diff --git a/0047-Don-t-emit-Booting-.-message.patch b/0046-Don-t-emit-Booting-.-message.patch similarity index 83% rename from 0047-Don-t-emit-Booting-.-message.patch rename to 0046-Don-t-emit-Booting-.-message.patch index 725ae0986a06aa9bea347882290f440dae3df28e..0eef6ad6f9a038e72f484891d43af76c9f762964 100644 --- a/0047-Don-t-emit-Booting-.-message.patch +++ b/0046-Don-t-emit-Booting-.-message.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From a71ee9f8f976cc09c301c8c1ceb8ca0859880130 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 18 Feb 2014 09:37:49 -0500 -Subject: [PATCH] Don't emit "Booting ..." message. +Subject: [PATCH 046/220] Don't emit "Booting ..." message. UI team still hates this stuff, so we're disabling it for RHEL 7. @@ -14,10 +14,10 @@ Signed-off-by: Peter Jones 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index d2f64b05e0a..5e2f5283d3d 100644 +index 9175ad2..783bde5 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c -@@ -838,12 +838,14 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) +@@ -839,12 +839,14 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) /* Callback invoked immediately before a menu entry is executed. */ static void @@ -34,7 +34,7 @@ index d2f64b05e0a..5e2f5283d3d 100644 /* Callback invoked when a default menu entry executed because of a timeout diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c -index cdf3590a364..5785f67ee1c 100644 +index cdf3590..5785f67 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -1167,9 +1167,6 @@ run (struct screen *screen) @@ -47,3 +47,6 @@ index cdf3590a364..5785f67ee1c 100644 errs_before = grub_err_printed_errors; +-- +1.8.3.1 + diff --git a/0048-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch b/0047-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch similarity index 95% rename from 0048-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch rename to 0047-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch index d6169aa7b8143678fff5c049cb658536cd4bbf37..774428bd1b40ba88f7049c7c2484a3488fef2ba6 100644 --- a/0048-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch +++ b/0047-Replace-a-lot-of-man-pages-with-slightly-nicer-ones.patch @@ -1,12 +1,12 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 4e27eb84b310a600b89481245735a7b053f2250c Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 4 Mar 2014 11:00:23 -0500 -Subject: [PATCH] Replace a lot of man pages with slightly nicer ones. +Subject: [PATCH 047/220] Replace a lot of man pages with slightly nicer ones. Replace a bunch of machine generated ones with ones that look nicer. --- - configure.ac | 23 ++++++ conf/Makefile.extra-dist | 1 - + configure.ac | 23 ++++++ docs/Makefile.am | 2 - docs/man/grub-bios-setup.h2m | 6 -- docs/man/grub-editenv.h2m | 5 -- @@ -121,11 +121,23 @@ Replace a bunch of machine generated ones with ones that look nicer. create mode 100644 util/grub-set-default.8 create mode 100644 util/grub-sparc64-setup.8 +diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist +index 46c4e95..58d7d95 100644 +--- a/conf/Makefile.extra-dist ++++ b/conf/Makefile.extra-dist +@@ -11,7 +11,6 @@ EXTRA_DIST += unicode + EXTRA_DIST += util/import_gcry.py + EXTRA_DIST += util/import_unicode.py + +-EXTRA_DIST += docs/man + EXTRA_DIST += docs/autoiso.cfg + EXTRA_DIST += docs/grub.cfg + EXTRA_DIST += docs/osdetect.cfg diff --git a/configure.ac b/configure.ac -index 783118ccdcd..d5db2803ec4 100644 +index d283af6..8df400e 100644 --- a/configure.ac +++ b/configure.ac -@@ -70,6 +70,29 @@ grub_TRANSFORM([grub-set-default]) +@@ -74,6 +74,29 @@ grub_TRANSFORM([grub-set-default]) grub_TRANSFORM([grub-sparc64-setup]) grub_TRANSFORM([grub-render-label]) grub_TRANSFORM([grub-file]) @@ -155,20 +167,8 @@ index 783118ccdcd..d5db2803ec4 100644 # Optimization flag. Allow user to override. if test "x$TARGET_CFLAGS" = x; then -diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist -index b16bd925320..39eb94bded6 100644 ---- a/conf/Makefile.extra-dist -+++ b/conf/Makefile.extra-dist -@@ -11,7 +11,6 @@ EXTRA_DIST += unicode - EXTRA_DIST += util/import_gcry.py - EXTRA_DIST += util/import_unicode.py - --EXTRA_DIST += docs/man - EXTRA_DIST += docs/autoiso.cfg - EXTRA_DIST += docs/grub.cfg - EXTRA_DIST += docs/osdetect.cfg diff --git a/docs/Makefile.am b/docs/Makefile.am -index 93eb3962765..ab28f199694 100644 +index 93eb396..ab28f19 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -5,5 +5,3 @@ info_TEXINFOS = grub.texi grub-dev.texi @@ -179,7 +179,7 @@ index 93eb3962765..ab28f199694 100644 - diff --git a/docs/man/grub-bios-setup.h2m b/docs/man/grub-bios-setup.h2m deleted file mode 100644 -index ac6ede36296..00000000000 +index ac6ede3..0000000 --- a/docs/man/grub-bios-setup.h2m +++ /dev/null @@ -1,6 +0,0 @@ @@ -191,7 +191,7 @@ index ac6ede36296..00000000000 -.BR grub-mkrescue (1) diff --git a/docs/man/grub-editenv.h2m b/docs/man/grub-editenv.h2m deleted file mode 100644 -index 3859d3d4c4f..00000000000 +index 3859d3d..0000000 --- a/docs/man/grub-editenv.h2m +++ /dev/null @@ -1,5 +0,0 @@ @@ -202,7 +202,7 @@ index 3859d3d4c4f..00000000000 -.BR grub-set-default (8) diff --git a/docs/man/grub-emu.h2m b/docs/man/grub-emu.h2m deleted file mode 100644 -index ef1c000656a..00000000000 +index ef1c000..0000000 --- a/docs/man/grub-emu.h2m +++ /dev/null @@ -1,6 +0,0 @@ @@ -214,7 +214,7 @@ index ef1c000656a..00000000000 -rather than this program. diff --git a/docs/man/grub-file.h2m b/docs/man/grub-file.h2m deleted file mode 100644 -index e09bb4d3101..00000000000 +index e09bb4d..0000000 --- a/docs/man/grub-file.h2m +++ /dev/null @@ -1,2 +0,0 @@ @@ -222,7 +222,7 @@ index e09bb4d3101..00000000000 -grub-file \- check file type diff --git a/docs/man/grub-fstest.h2m b/docs/man/grub-fstest.h2m deleted file mode 100644 -index 9676b159afd..00000000000 +index 9676b15..0000000 --- a/docs/man/grub-fstest.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -232,7 +232,7 @@ index 9676b159afd..00000000000 -.BR grub-probe (8) diff --git a/docs/man/grub-glue-efi.h2m b/docs/man/grub-glue-efi.h2m deleted file mode 100644 -index c1c6ded49ff..00000000000 +index c1c6ded..0000000 --- a/docs/man/grub-glue-efi.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -242,7 +242,7 @@ index c1c6ded49ff..00000000000 -grub-glue-efi processes ia32 and amd64 EFI images and glues them according to Apple format. diff --git a/docs/man/grub-install.h2m b/docs/man/grub-install.h2m deleted file mode 100644 -index 8cbbc87a0f2..00000000000 +index 8cbbc87..0000000 --- a/docs/man/grub-install.h2m +++ /dev/null @@ -1,6 +0,0 @@ @@ -254,7 +254,7 @@ index 8cbbc87a0f2..00000000000 -.BR grub-mkrescue (1) diff --git a/docs/man/grub-kbdcomp.h2m b/docs/man/grub-kbdcomp.h2m deleted file mode 100644 -index d81f9157e01..00000000000 +index d81f915..0000000 --- a/docs/man/grub-kbdcomp.h2m +++ /dev/null @@ -1,10 +0,0 @@ @@ -270,7 +270,7 @@ index d81f9157e01..00000000000 -.BR grub-mklayout (8) diff --git a/docs/man/grub-macbless.h2m b/docs/man/grub-macbless.h2m deleted file mode 100644 -index 0197c0087d7..00000000000 +index 0197c00..0000000 --- a/docs/man/grub-macbless.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -280,7 +280,7 @@ index 0197c0087d7..00000000000 -.BR grub-install (1) diff --git a/docs/man/grub-macho2img.h2m b/docs/man/grub-macho2img.h2m deleted file mode 100644 -index d79aaeed8f9..00000000000 +index d79aaee..0000000 --- a/docs/man/grub-macho2img.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -290,7 +290,7 @@ index d79aaeed8f9..00000000000 -.BR grub-mkimage (1) diff --git a/docs/man/grub-menulst2cfg.h2m b/docs/man/grub-menulst2cfg.h2m deleted file mode 100644 -index c2e0055ed7e..00000000000 +index c2e0055..0000000 --- a/docs/man/grub-menulst2cfg.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -300,7 +300,7 @@ index c2e0055ed7e..00000000000 -.BR grub-mkconfig (8) diff --git a/docs/man/grub-mkconfig.h2m b/docs/man/grub-mkconfig.h2m deleted file mode 100644 -index 9b42f813010..00000000000 +index 9b42f81..0000000 --- a/docs/man/grub-mkconfig.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -310,7 +310,7 @@ index 9b42f813010..00000000000 -.BR grub-install (8) diff --git a/docs/man/grub-mkfont.h2m b/docs/man/grub-mkfont.h2m deleted file mode 100644 -index d46fe600eca..00000000000 +index d46fe60..0000000 --- a/docs/man/grub-mkfont.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -320,7 +320,7 @@ index d46fe600eca..00000000000 -.BR grub-mkconfig (8) diff --git a/docs/man/grub-mkimage.h2m b/docs/man/grub-mkimage.h2m deleted file mode 100644 -index f0fbc2bb197..00000000000 +index f0fbc2b..0000000 --- a/docs/man/grub-mkimage.h2m +++ /dev/null @@ -1,6 +0,0 @@ @@ -332,7 +332,7 @@ index f0fbc2bb197..00000000000 -.BR grub-mknetdir (8) diff --git a/docs/man/grub-mklayout.h2m b/docs/man/grub-mklayout.h2m deleted file mode 100644 -index 1e43409c0ab..00000000000 +index 1e43409..0000000 --- a/docs/man/grub-mklayout.h2m +++ /dev/null @@ -1,10 +0,0 @@ @@ -348,7 +348,7 @@ index 1e43409c0ab..00000000000 -.BR grub-mkconfig (8) diff --git a/docs/man/grub-mknetdir.h2m b/docs/man/grub-mknetdir.h2m deleted file mode 100644 -index a2ef13ec111..00000000000 +index a2ef13e..0000000 --- a/docs/man/grub-mknetdir.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -358,7 +358,7 @@ index a2ef13ec111..00000000000 -.BR grub-mkimage (1) diff --git a/docs/man/grub-mkpasswd-pbkdf2.h2m b/docs/man/grub-mkpasswd-pbkdf2.h2m deleted file mode 100644 -index 4d202f3da7e..00000000000 +index 4d202f3..0000000 --- a/docs/man/grub-mkpasswd-pbkdf2.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -368,7 +368,7 @@ index 4d202f3da7e..00000000000 -.BR grub-mkconfig (8) diff --git a/docs/man/grub-mkrelpath.h2m b/docs/man/grub-mkrelpath.h2m deleted file mode 100644 -index d01f3961e3f..00000000000 +index d01f396..0000000 --- a/docs/man/grub-mkrelpath.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -378,7 +378,7 @@ index d01f3961e3f..00000000000 -.BR grub-probe (8) diff --git a/docs/man/grub-mkrescue.h2m b/docs/man/grub-mkrescue.h2m deleted file mode 100644 -index a427f02e3c6..00000000000 +index a427f02..0000000 --- a/docs/man/grub-mkrescue.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -388,7 +388,7 @@ index a427f02e3c6..00000000000 -.BR grub-mkimage (1) diff --git a/docs/man/grub-mkstandalone.h2m b/docs/man/grub-mkstandalone.h2m deleted file mode 100644 -index c77313978ad..00000000000 +index c773139..0000000 --- a/docs/man/grub-mkstandalone.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -398,7 +398,7 @@ index c77313978ad..00000000000 -.BR grub-mkimage (1) diff --git a/docs/man/grub-mount.h2m b/docs/man/grub-mount.h2m deleted file mode 100644 -index 8d168982d72..00000000000 +index 8d16898..0000000 --- a/docs/man/grub-mount.h2m +++ /dev/null @@ -1,2 +0,0 @@ @@ -406,7 +406,7 @@ index 8d168982d72..00000000000 -grub-mount \- export GRUB filesystem with FUSE diff --git a/docs/man/grub-ofpathname.h2m b/docs/man/grub-ofpathname.h2m deleted file mode 100644 -index 74b43eea039..00000000000 +index 74b43ee..0000000 --- a/docs/man/grub-ofpathname.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -416,7 +416,7 @@ index 74b43eea039..00000000000 -.BR grub-probe (8) diff --git a/docs/man/grub-pe2elf.h2m b/docs/man/grub-pe2elf.h2m deleted file mode 100644 -index 7ca29bd703c..00000000000 +index 7ca29bd..0000000 --- a/docs/man/grub-pe2elf.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -426,7 +426,7 @@ index 7ca29bd703c..00000000000 -.BR grub-mkimage (1) diff --git a/docs/man/grub-probe.h2m b/docs/man/grub-probe.h2m deleted file mode 100644 -index 6e1ffdcf937..00000000000 +index 6e1ffdc..0000000 --- a/docs/man/grub-probe.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -436,7 +436,7 @@ index 6e1ffdcf937..00000000000 -.BR grub-fstest (1) diff --git a/docs/man/grub-reboot.h2m b/docs/man/grub-reboot.h2m deleted file mode 100644 -index e4acace65ce..00000000000 +index e4acace..0000000 --- a/docs/man/grub-reboot.h2m +++ /dev/null @@ -1,5 +0,0 @@ @@ -447,7 +447,7 @@ index e4acace65ce..00000000000 -.BR grub-editenv (1) diff --git a/docs/man/grub-render-label.h2m b/docs/man/grub-render-label.h2m deleted file mode 100644 -index 50ae5247c05..00000000000 +index 50ae524..0000000 --- a/docs/man/grub-render-label.h2m +++ /dev/null @@ -1,3 +0,0 @@ @@ -456,7 +456,7 @@ index 50ae5247c05..00000000000 - diff --git a/docs/man/grub-script-check.h2m b/docs/man/grub-script-check.h2m deleted file mode 100644 -index 3653682671a..00000000000 +index 3653682..0000000 --- a/docs/man/grub-script-check.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -466,7 +466,7 @@ index 3653682671a..00000000000 -.BR grub-mkconfig (8) diff --git a/docs/man/grub-set-default.h2m b/docs/man/grub-set-default.h2m deleted file mode 100644 -index 7945001c154..00000000000 +index 7945001..0000000 --- a/docs/man/grub-set-default.h2m +++ /dev/null @@ -1,5 +0,0 @@ @@ -477,7 +477,7 @@ index 7945001c154..00000000000 -.BR grub-editenv (1) diff --git a/docs/man/grub-sparc64-setup.h2m b/docs/man/grub-sparc64-setup.h2m deleted file mode 100644 -index 18f803a50db..00000000000 +index 18f803a..0000000 --- a/docs/man/grub-sparc64-setup.h2m +++ /dev/null @@ -1,6 +0,0 @@ @@ -489,7 +489,7 @@ index 18f803a50db..00000000000 -.BR grub-mkrescue (1) diff --git a/docs/man/grub-syslinux2cfg.h2m b/docs/man/grub-syslinux2cfg.h2m deleted file mode 100644 -index ad25c8ab753..00000000000 +index ad25c8a..0000000 --- a/docs/man/grub-syslinux2cfg.h2m +++ /dev/null @@ -1,4 +0,0 @@ @@ -498,10 +498,10 @@ index ad25c8ab753..00000000000 -[SEE ALSO] -.BR grub-menulst2cfg (8) diff --git a/gentpl.py b/gentpl.py -index da67965a41a..bf8439fa743 100644 +index 387588c..f05812e 100644 --- a/gentpl.py +++ b/gentpl.py -@@ -802,10 +802,7 @@ def manpage(defn, adddeps): +@@ -805,10 +805,7 @@ def manpage(defn, adddeps): output("if COND_MAN_PAGES\n") gvar_add("man_MANS", name + "." + mansection) @@ -515,7 +515,7 @@ index da67965a41a..bf8439fa743 100644 diff --git a/util/grub-bios-setup.8 b/util/grub-bios-setup.8 new file mode 100644 -index 00000000000..56f582b3d75 +index 0000000..56f582b --- /dev/null +++ b/util/grub-bios-setup.8 @@ -0,0 +1,54 @@ @@ -575,7 +575,7 @@ index 00000000000..56f582b3d75 +.BR "info grub" diff --git a/util/grub-editenv.1 b/util/grub-editenv.1 new file mode 100644 -index 00000000000..d28ba03ba42 +index 0000000..d28ba03 --- /dev/null +++ b/util/grub-editenv.1 @@ -0,0 +1,46 @@ @@ -627,7 +627,7 @@ index 00000000000..d28ba03ba42 +.BR "info grub" diff --git a/util/grub-file.1 b/util/grub-file.1 new file mode 100644 -index 00000000000..b29cb327889 +index 0000000..b29cb32 --- /dev/null +++ b/util/grub-file.1 @@ -0,0 +1,165 @@ @@ -798,7 +798,7 @@ index 00000000000..b29cb327889 +.BR "info grub" diff --git a/util/grub-fstest.1 b/util/grub-fstest.1 new file mode 100644 -index 00000000000..792fa78634c +index 0000000..792fa78 --- /dev/null +++ b/util/grub-fstest.1 @@ -0,0 +1,99 @@ @@ -903,7 +903,7 @@ index 00000000000..792fa78634c +.BR "info grub" diff --git a/util/grub-glue-efi.1 b/util/grub-glue-efi.1 new file mode 100644 -index 00000000000..72bd555d577 +index 0000000..72bd555 --- /dev/null +++ b/util/grub-glue-efi.1 @@ -0,0 +1,31 @@ @@ -940,7 +940,7 @@ index 00000000000..72bd555d577 +.BR "info grub" diff --git a/util/grub-install.8 b/util/grub-install.8 new file mode 100644 -index 00000000000..76272a39d2e +index 0000000..76272a3 --- /dev/null +++ b/util/grub-install.8 @@ -0,0 +1,129 @@ @@ -1075,7 +1075,7 @@ index 00000000000..76272a39d2e +.BR "info grub" diff --git a/util/grub-kbdcomp.1 b/util/grub-kbdcomp.1 new file mode 100644 -index 00000000000..0bb969a5b43 +index 0000000..0bb969a --- /dev/null +++ b/util/grub-kbdcomp.1 @@ -0,0 +1,19 @@ @@ -1100,7 +1100,7 @@ index 00000000000..0bb969a5b43 +.BR "info grub" diff --git a/util/grub-macbless.1 b/util/grub-macbless.1 new file mode 100644 -index 00000000000..41a96186f70 +index 0000000..41a9618 --- /dev/null +++ b/util/grub-macbless.1 @@ -0,0 +1,22 @@ @@ -1128,7 +1128,7 @@ index 00000000000..41a96186f70 +.BR "info grub" diff --git a/util/grub-menulst2cfg.1 b/util/grub-menulst2cfg.1 new file mode 100644 -index 00000000000..91e2ef87113 +index 0000000..91e2ef8 --- /dev/null +++ b/util/grub-menulst2cfg.1 @@ -0,0 +1,12 @@ @@ -1146,7 +1146,7 @@ index 00000000000..91e2ef87113 +.BR "info grub" diff --git a/util/grub-mkconfig.8 b/util/grub-mkconfig.8 new file mode 100644 -index 00000000000..a2d1f577b9b +index 0000000..a2d1f57 --- /dev/null +++ b/util/grub-mkconfig.8 @@ -0,0 +1,17 @@ @@ -1169,7 +1169,7 @@ index 00000000000..a2d1f577b9b +.BR "info grub" diff --git a/util/grub-mkfont.1 b/util/grub-mkfont.1 new file mode 100644 -index 00000000000..3494857987d +index 0000000..3494857 --- /dev/null +++ b/util/grub-mkfont.1 @@ -0,0 +1,87 @@ @@ -1262,7 +1262,7 @@ index 00000000000..3494857987d +.BR "info grub" diff --git a/util/grub-mkimage.1 b/util/grub-mkimage.1 new file mode 100644 -index 00000000000..4dea4f54597 +index 0000000..4dea4f5 --- /dev/null +++ b/util/grub-mkimage.1 @@ -0,0 +1,95 @@ @@ -1363,7 +1363,7 @@ index 00000000000..4dea4f54597 +.BR "info grub" diff --git a/util/grub-mklayout.1 b/util/grub-mklayout.1 new file mode 100644 -index 00000000000..d1bbc2ec515 +index 0000000..d1bbc2e --- /dev/null +++ b/util/grub-mklayout.1 @@ -0,0 +1,27 @@ @@ -1396,7 +1396,7 @@ index 00000000000..d1bbc2ec515 +.BR "info grub" diff --git a/util/grub-mknetdir.1 b/util/grub-mknetdir.1 new file mode 100644 -index 00000000000..fa7e8d4ef0d +index 0000000..fa7e8d4 --- /dev/null +++ b/util/grub-mknetdir.1 @@ -0,0 +1,12 @@ @@ -1414,7 +1414,7 @@ index 00000000000..fa7e8d4ef0d +.BR "info grub" diff --git a/util/grub-mkpasswd-pbkdf2.1 b/util/grub-mkpasswd-pbkdf2.1 new file mode 100644 -index 00000000000..73c437c15d8 +index 0000000..73c437c --- /dev/null +++ b/util/grub-mkpasswd-pbkdf2.1 @@ -0,0 +1,27 @@ @@ -1447,7 +1447,7 @@ index 00000000000..73c437c15d8 +.BR "info grub" diff --git a/util/grub-mkrelpath.1 b/util/grub-mkrelpath.1 new file mode 100644 -index 00000000000..85f1113621d +index 0000000..85f1113 --- /dev/null +++ b/util/grub-mkrelpath.1 @@ -0,0 +1,12 @@ @@ -1465,7 +1465,7 @@ index 00000000000..85f1113621d +.BR "info grub" diff --git a/util/grub-mkrescue.1 b/util/grub-mkrescue.1 new file mode 100644 -index 00000000000..4ed9fc723fd +index 0000000..4ed9fc7 --- /dev/null +++ b/util/grub-mkrescue.1 @@ -0,0 +1,123 @@ @@ -1594,7 +1594,7 @@ index 00000000000..4ed9fc723fd +.BR "info grub" diff --git a/util/grub-mkstandalone.1 b/util/grub-mkstandalone.1 new file mode 100644 -index 00000000000..ba2d2bdf279 +index 0000000..ba2d2bd --- /dev/null +++ b/util/grub-mkstandalone.1 @@ -0,0 +1,100 @@ @@ -1700,7 +1700,7 @@ index 00000000000..ba2d2bdf279 +.BR "info grub" diff --git a/util/grub-ofpathname.8 b/util/grub-ofpathname.8 new file mode 100644 -index 00000000000..bf3743aeba1 +index 0000000..bf3743a --- /dev/null +++ b/util/grub-ofpathname.8 @@ -0,0 +1,12 @@ @@ -1718,7 +1718,7 @@ index 00000000000..bf3743aeba1 +.BR "info grub" diff --git a/util/grub-probe.8 b/util/grub-probe.8 new file mode 100644 -index 00000000000..04e26c832bb +index 0000000..04e26c8 --- /dev/null +++ b/util/grub-probe.8 @@ -0,0 +1,80 @@ @@ -1804,7 +1804,7 @@ index 00000000000..04e26c832bb +.BR "info grub" diff --git a/util/grub-reboot.8 b/util/grub-reboot.8 new file mode 100644 -index 00000000000..faa5e4eece2 +index 0000000..faa5e4e --- /dev/null +++ b/util/grub-reboot.8 @@ -0,0 +1,21 @@ @@ -1831,7 +1831,7 @@ index 00000000000..faa5e4eece2 +.BR "info grub" diff --git a/util/grub-render-label.1 b/util/grub-render-label.1 new file mode 100644 -index 00000000000..4d51c8abf01 +index 0000000..4d51c8a --- /dev/null +++ b/util/grub-render-label.1 @@ -0,0 +1,51 @@ @@ -1888,7 +1888,7 @@ index 00000000000..4d51c8abf01 +.BR "info grub" diff --git a/util/grub-script-check.1 b/util/grub-script-check.1 new file mode 100644 -index 00000000000..0f1f625b05d +index 0000000..0f1f625 --- /dev/null +++ b/util/grub-script-check.1 @@ -0,0 +1,21 @@ @@ -1915,7 +1915,7 @@ index 00000000000..0f1f625b05d +.BR "info grub" diff --git a/util/grub-set-default.8 b/util/grub-set-default.8 new file mode 100644 -index 00000000000..a96265a1509 +index 0000000..a96265a --- /dev/null +++ b/util/grub-set-default.8 @@ -0,0 +1,21 @@ @@ -1942,7 +1942,7 @@ index 00000000000..a96265a1509 +.BR "info grub" diff --git a/util/grub-sparc64-setup.8 b/util/grub-sparc64-setup.8 new file mode 100644 -index 00000000000..37ea2dd5eaa +index 0000000..37ea2dd --- /dev/null +++ b/util/grub-sparc64-setup.8 @@ -0,0 +1,12 @@ @@ -1958,3 +1958,6 @@ index 00000000000..37ea2dd5eaa + +.SH SEE ALSO +.BR "info grub" +-- +1.8.3.1 + diff --git a/0049-use-fw_path-prefix-when-fallback-searching-for-grub-.patch b/0048-use-fw_path-prefix-when-fallback-searching-for-grub-.patch similarity index 80% rename from 0049-use-fw_path-prefix-when-fallback-searching-for-grub-.patch rename to 0048-use-fw_path-prefix-when-fallback-searching-for-grub-.patch index 0035e62e3540277747d5f9eb6e53ba4c72d0de61..5928cfb9461d9f8f14e6882f5b9a90317574f7dd 100644 --- a/0049-use-fw_path-prefix-when-fallback-searching-for-grub-.patch +++ b/0048-use-fw_path-prefix-when-fallback-searching-for-grub-.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 612e9b3820efe48896ba9faf320e4f042d053dc2 Mon Sep 17 00:00:00 2001 From: Fedora Ninjas Date: Wed, 19 Feb 2014 15:58:43 -0500 -Subject: [PATCH] use fw_path prefix when fallback searching for grub config +Subject: [PATCH 048/220] use fw_path prefix when fallback searching for grub + config When PXE booting via UEFI firmware, grub was searching for grub.cfg in the fw_path directory where the grub application was found. If @@ -17,10 +18,10 @@ Signed-off-by: Mark Salter 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 0ce59fdc3f0..a3713efcd90 100644 +index 7f61c5b..8add30e 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -343,7 +343,7 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), +@@ -349,7 +349,7 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), char *config; const char *prefix, *fw_path; @@ -29,7 +30,7 @@ index 0ce59fdc3f0..a3713efcd90 100644 if (fw_path) { config = grub_xasprintf ("%s/grub.cfg", fw_path); -@@ -366,7 +366,8 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), +@@ -372,7 +372,8 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), } } @@ -39,3 +40,6 @@ index 0ce59fdc3f0..a3713efcd90 100644 if (prefix) { grub_size_t config_len; +-- +1.8.3.1 + diff --git a/0050-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch b/0049-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch similarity index 51% rename from 0050-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch rename to 0049-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch index 84b8d7a2aa136406492bc071b0a8cf485f0ec26a..57f8ce248f9e12a918be3a298ee13433a6928696 100644 --- a/0050-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch +++ b/0049-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 03c186bcadb3cae7a86d1674de33c6a2b8d81089 Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Thu, 6 Mar 2014 11:51:33 -0500 -Subject: [PATCH] Try mac/guid/etc before grub.cfg on tftp config files. +Date: Mon, 8 Jul 2019 17:33:22 +0200 +Subject: [PATCH 049/220] Try mac/guid/etc before grub.cfg on tftp config + files. Signed-off-by: Peter Jones --- @@ -9,10 +10,10 @@ Signed-off-by: Peter Jones 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index a3713efcd90..7d9c4f09b9b 100644 +index 8add30e..d93bee6 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -341,53 +341,59 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), +@@ -347,53 +347,59 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), /* Guess the config filename. It is necessary to make CONFIG static, so that it won't get broken by longjmp. */ char *config; @@ -26,7 +27,7 @@ index a3713efcd90..7d9c4f09b9b 100644 - { - grub_file_t file; - -- file = grub_file_open (config); +- file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG); - if (file) - { - grub_file_close (file); @@ -47,65 +48,68 @@ index a3713efcd90..7d9c4f09b9b 100644 prefix = grub_env_get ("prefix"); + if (prefix) -- { + { - grub_size_t config_len; - config_len = grub_strlen (prefix) + - sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); - config = grub_malloc (config_len); -+ { -+ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) -+ { -+ grub_size_t config_len; -+ config_len = grub_strlen (prefix) + -+ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); -+ config = grub_malloc (config_len); ++ if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) ++ { ++ grub_size_t config_len; ++ config_len = grub_strlen (prefix) + ++ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); ++ config = grub_malloc (config_len); - if (! config) - goto quit; -+ if (! config) -+ goto quit; ++ if (! config) ++ goto quit; - grub_snprintf (config, config_len, "%s/grub.cfg", prefix); -+ grub_snprintf (config, config_len, "%s/grub.cfg", prefix); ++ grub_snprintf (config, config_len, "%s/grub.cfg", prefix); - if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) - grub_net_search_configfile (config); -+ grub_net_search_configfile (config); ++ grub_net_search_configfile (config); - grub_enter_normal_mode (config); - grub_free (config); -+ grub_enter_normal_mode (config); -+ grub_free (config); -+ config = NULL; -+ } +- } ++ grub_enter_normal_mode (config); ++ grub_free (config); ++ config = NULL; ++ } + -+ if (!config) -+ { -+ config = grub_xasprintf ("%s/grub.cfg", prefix); -+ if (config) -+ { -+ grub_file_t file; ++ if (!config) ++ { ++ config = grub_xasprintf ("%s/grub.cfg", prefix); ++ if (config) ++ { ++ grub_file_t file; + -+ file = grub_file_open (config); -+ if (file) -+ { -+ grub_file_close (file); -+ grub_enter_normal_mode (config); -+ } -+ else -+ { -+ /* Ignore all errors. */ -+ grub_errno = 0; -+ } -+ grub_free (config); -+ } -+ } - } ++ file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG); ++ if (file) ++ { ++ grub_file_close (file); ++ grub_enter_normal_mode (config); ++ } ++ else ++ { ++ /* Ignore all errors. */ ++ grub_errno = 0; ++ } ++ grub_free (config); ++ } ++ } ++ } else - grub_enter_normal_mode (0); -+ { -+ grub_enter_normal_mode (0); -+ } ++ { ++ grub_enter_normal_mode (0); ++ } } else grub_enter_normal_mode (argv[0]); +-- +1.8.3.1 + diff --git a/0051-Fix-convert-function-to-support-NVMe-devices.patch b/0050-Fix-convert-function-to-support-NVMe-devices.patch similarity index 88% rename from 0051-Fix-convert-function-to-support-NVMe-devices.patch rename to 0050-Fix-convert-function-to-support-NVMe-devices.patch index 0fb66161ad2c8ffdfb4f1925ae78c82adb276464..f9b998273e23126f53d4bbd77540684baa93fd15 100644 --- a/0051-Fix-convert-function-to-support-NVMe-devices.patch +++ b/0050-Fix-convert-function-to-support-NVMe-devices.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From d876203ac9bfea1f5f0cea015dfa70ba3988d08a Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 18 Feb 2014 11:34:00 -0500 -Subject: [PATCH] Fix convert function to support NVMe devices +Subject: [PATCH 050/220] Fix convert function to support NVMe devices This is adapted from the patch at https://bugzilla.redhat.com/show_bug.cgi?id=1019660 , which is against @@ -18,7 +18,7 @@ Signed-off-by: Peter Jones 1 file changed, 19 insertions(+) diff --git a/util/getroot.c b/util/getroot.c -index 847406fbab0..fa3460d6cd8 100644 +index 847406f..fa3460d 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -153,6 +153,7 @@ convert_system_partition_to_system_disk (const char *os_dev, int *is_part) @@ -54,3 +54,6 @@ index 847406fbab0..fa3460d6cd8 100644 if (grub_util_device_is_mapped_stat (&st)) return grub_util_devmapper_part_to_disk (&st, is_part, os_dev); +-- +1.8.3.1 + diff --git a/0051-Add-grub_util_readlink.patch b/0051-Add-grub_util_readlink.patch new file mode 100644 index 0000000000000000000000000000000000000000..e73c6c8123bf7bc8b413ba73ca2aa6f3fdbb5b2a --- /dev/null +++ b/0051-Add-grub_util_readlink.patch @@ -0,0 +1,85 @@ +From a2099170d2f7e9cca6a743c15b6cb649b88fd873 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 8 Jul 2019 21:46:52 +0200 +Subject: [PATCH 051/220] Add grub_util_readlink() + +Add grub_util_readlink(). This requires pulling in stat and readlink from +gnulib, which pulls in stat and related headers, but after that the +implementation is straightforward. + +Signed-off-by: Peter Jones +Reviewed-by: Adam Jackson +--- + grub-core/osdep/windows/hostdisk.c | 6 ++++++ + include/grub/osdep/hostfile_aros.h | 6 ++++++ + include/grub/osdep/hostfile_unix.h | 6 ++++++ + include/grub/osdep/hostfile_windows.h | 2 ++ + 4 files changed, 20 insertions(+) + +diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c +index 3551007..87a106c 100644 +--- a/grub-core/osdep/windows/hostdisk.c ++++ b/grub-core/osdep/windows/hostdisk.c +@@ -365,6 +365,12 @@ grub_util_mkdir (const char *dir) + free (windows_name); + } + ++ssize_t ++grub_util_readlink (const char *name, char *buf, size_t bufsize) ++{ ++ return readlink(name, buf, bufsize); ++} ++ + int + grub_util_rename (const char *from, const char *to) + { +diff --git a/include/grub/osdep/hostfile_aros.h b/include/grub/osdep/hostfile_aros.h +index a059c0f..161fbb7 100644 +--- a/include/grub/osdep/hostfile_aros.h ++++ b/include/grub/osdep/hostfile_aros.h +@@ -68,6 +68,12 @@ grub_util_rename (const char *from, const char *to) + return rename (from, to); + } + ++static inline ssize_t ++grub_util_readlink (const char *name, char *buf, size_t bufsize) ++{ ++ return readlink(name, buf, bufsize); ++} ++ + #define grub_util_mkdir(a) mkdir ((a), 0755) + + struct grub_util_fd +diff --git a/include/grub/osdep/hostfile_unix.h b/include/grub/osdep/hostfile_unix.h +index 9ffe46f..17cd3aa 100644 +--- a/include/grub/osdep/hostfile_unix.h ++++ b/include/grub/osdep/hostfile_unix.h +@@ -71,6 +71,12 @@ grub_util_rename (const char *from, const char *to) + return rename (from, to); + } + ++static inline ssize_t ++grub_util_readlink (const char *name, char *buf, size_t bufsize) ++{ ++ return readlink(name, buf, bufsize); ++} ++ + #define grub_util_mkdir(a) mkdir ((a), 0755) + + #if defined (__NetBSD__) +diff --git a/include/grub/osdep/hostfile_windows.h b/include/grub/osdep/hostfile_windows.h +index bf6451b..8c92d05 100644 +--- a/include/grub/osdep/hostfile_windows.h ++++ b/include/grub/osdep/hostfile_windows.h +@@ -41,6 +41,8 @@ typedef struct grub_util_fd_dir *grub_util_fd_dir_t; + + int + grub_util_rename (const char *from, const char *to); ++ssize_t ++grub_util_readlink (const char *name, char *buf, size_t bufsize); + int + grub_util_unlink (const char *name); + void +-- +1.8.3.1 + diff --git a/0055-Make-editenv-chase-symlinks-including-those-across-d.patch b/0052-Make-editenv-chase-symlinks-including-those-across-d.patch similarity index 84% rename from 0055-Make-editenv-chase-symlinks-including-those-across-d.patch rename to 0052-Make-editenv-chase-symlinks-including-those-across-d.patch index 73e316e646a77169717a7dacfc4e76d3df338a76..b00645570340b775504f4895fd6aae202b553066 100644 --- a/0055-Make-editenv-chase-symlinks-including-those-across-d.patch +++ b/0052-Make-editenv-chase-symlinks-including-those-across-d.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 33c5ef791304cd9c320dd0e6ec67e2bd5e7e8d30 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 3 Sep 2014 10:38:00 -0400 -Subject: [PATCH] Make editenv chase symlinks including those across devices. +Subject: [PATCH 052/220] Make editenv chase symlinks including those across + devices. This lets us make /boot/grub2/grubenv a symlink to /boot/efi/EFI/fedora/grubenv even though they're different mount points, @@ -11,15 +12,15 @@ which allows /usr/bin/grub2-editenv to be the same across platforms Signed-off-by: Peter Jones Reviewed-by: Adam Jackson --- - Makefile.util.def | 9 +++++++++ + Makefile.util.def | 11 +++++++++++ util/editenv.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- - 2 files changed, 53 insertions(+), 2 deletions(-) + 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/Makefile.util.def b/Makefile.util.def -index c7b775bce73..d08713b5500 100644 +index 8717774..1f298d0 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -231,8 +231,17 @@ program = { +@@ -240,8 +240,19 @@ program = { common = util/grub-editenv.c; common = util/editenv.c; @@ -29,6 +30,8 @@ index c7b775bce73..d08713b5500 100644 + extra_dist = grub-core/osdep/unix/compress.c; + extra_dist = grub-core/osdep/basic/compress.c; + common = util/mkimage.c; ++ common = util/grub-mkimage32.c; ++ common = util/grub-mkimage64.c; + common = grub-core/osdep/config.c; + common = util/config.c; + common = util/resolve.c; @@ -38,7 +41,7 @@ index c7b775bce73..d08713b5500 100644 ldadd = libgrubgcry.a; ldadd = libgrubkern.a; diff --git a/util/editenv.c b/util/editenv.c -index c6f8d2298c3..d8d1dad6ab9 100644 +index eb2d0c0..e61dc12 100644 --- a/util/editenv.c +++ b/util/editenv.c @@ -37,6 +37,7 @@ grub_util_create_envblk_file (const char *name) @@ -49,7 +52,7 @@ index c6f8d2298c3..d8d1dad6ab9 100644 buf = xmalloc (DEFAULT_ENVBLK_SIZE); -@@ -59,7 +60,48 @@ grub_util_create_envblk_file (const char *name) +@@ -60,7 +61,48 @@ grub_util_create_envblk_file (const char *name) free (buf); fclose (fp); @@ -100,3 +103,6 @@ index c6f8d2298c3..d8d1dad6ab9 100644 free (namenew); + free (rename_target); } +-- +1.8.3.1 + diff --git a/0052-reopen-SNP-protocol-for-exclusive-use-by-grub.patch b/0052-reopen-SNP-protocol-for-exclusive-use-by-grub.patch deleted file mode 100644 index fb2875bac2b515b898300f3083dd9ce6341e9fb0..0000000000000000000000000000000000000000 --- a/0052-reopen-SNP-protocol-for-exclusive-use-by-grub.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Fedora Ninjas -Date: Sat, 15 Feb 2014 15:10:22 -0500 -Subject: [PATCH] reopen SNP protocol for exclusive use by grub - ---- - grub-core/net/drivers/efi/efinet.c | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 5388f952ba9..ea0e0ca360e 100644 ---- a/grub-core/net/drivers/efi/efinet.c -+++ b/grub-core/net/drivers/efi/efinet.c -@@ -330,6 +330,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - { - struct grub_net_card *card; - grub_efi_device_path_t *dp; -+ grub_efi_simple_network_t *net; - - dp = grub_efi_get_device_path (hnd); - if (! dp) -@@ -383,6 +384,21 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - &pxe_mode->dhcp_ack, - sizeof (pxe_mode->dhcp_ack), - 1, device, path); -+ net = grub_efi_open_protocol (card->efi_handle, &net_io_guid, -+ GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE); -+ if (net) { -+ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED -+ && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) -+ continue; -+ -+ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED) -+ continue; -+ -+ if (net->mode->state == GRUB_EFI_NETWORK_STARTED -+ && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS) -+ continue; -+ card->efi_net = net; -+ } - return; - } - } diff --git a/0056-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch b/0053-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch similarity index 84% rename from 0056-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch rename to 0053-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch index 81e0e527fc734517636d4723f630ed89bce01a0b..a234d805e256f381f7e8342b5519942dec4bfcbb 100644 --- a/0056-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch +++ b/0053-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 708e24f2d6ffadfa2d1b6638538ddc03a82dbbd6 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 4 Sep 2014 14:23:23 -0400 -Subject: [PATCH] Generate OS and CLASS in 10_linux from /etc/os-release +Subject: [PATCH 053/220] Generate OS and CLASS in 10_linux from + /etc/os-release This makes us use pretty names in the titles we generate in grub2-mkconfig when GRUB_DISTRIBUTOR isn't set. @@ -14,7 +15,7 @@ Signed-off-by: Peter Jones 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index b744438e04a..43d98476b88 100644 +index d35b0f4..d12d2d7 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -29,7 +29,8 @@ export TEXTDOMAINDIR="@localedir@" @@ -27,3 +28,6 @@ index b744438e04a..43d98476b88 100644 else OS="${GRUB_DISTRIBUTOR}" CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}" +-- +1.8.3.1 + diff --git a/0053-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch b/0053-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch deleted file mode 100644 index 4238b7ded045183aa8b44f478a06c526b60584aa..0000000000000000000000000000000000000000 --- a/0053-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 4 Mar 2016 15:13:59 -0500 -Subject: [PATCH] Revert "reopen SNP protocol for exclusive use by grub" - -This reverts commit a3f2c756ce34c9666bddef35e3b3b85ccecdcffc , which is -obsoleted by these: - -49426e9 efinet: open Simple Network Protocol exclusively -f348aee efinet: enable hardware filters when opening interface -c52ae40 efinet: skip virtual IPv4 and IPv6 devices when enumerating cards - -Signed-off-by: Peter Jones ---- - grub-core/net/drivers/efi/efinet.c | 16 ---------------- - 1 file changed, 16 deletions(-) - -diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index ea0e0ca360e..5388f952ba9 100644 ---- a/grub-core/net/drivers/efi/efinet.c -+++ b/grub-core/net/drivers/efi/efinet.c -@@ -330,7 +330,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - { - struct grub_net_card *card; - grub_efi_device_path_t *dp; -- grub_efi_simple_network_t *net; - - dp = grub_efi_get_device_path (hnd); - if (! dp) -@@ -384,21 +383,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - &pxe_mode->dhcp_ack, - sizeof (pxe_mode->dhcp_ack), - 1, device, path); -- net = grub_efi_open_protocol (card->efi_handle, &net_io_guid, -- GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE); -- if (net) { -- if (net->mode->state == GRUB_EFI_NETWORK_STOPPED -- && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) -- continue; -- -- if (net->mode->state == GRUB_EFI_NETWORK_STOPPED) -- continue; -- -- if (net->mode->state == GRUB_EFI_NETWORK_STARTED -- && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS) -- continue; -- card->efi_net = net; -- } - return; - } - } diff --git a/0054-Add-grub_util_readlink.patch b/0054-Add-grub_util_readlink.patch deleted file mode 100644 index 6ea7df1549d966a454a18726424695c203eb954c..0000000000000000000000000000000000000000 --- a/0054-Add-grub_util_readlink.patch +++ /dev/null @@ -1,3731 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 3 Sep 2014 10:01:03 -0400 -Subject: [PATCH] Add grub_util_readlink() - -Add grub_util_readlink(). This requires pulling in stat and readlink from -gnulib, which pulls in stat and related headers, but after that the -implementation is straightforward. - -Signed-off-by: Peter Jones -Reviewed-by: Adam Jackson ---- - grub-core/gnulib/gettimeofday.c | 154 +++++++ - grub-core/gnulib/readlink.c | 74 ++++ - grub-core/gnulib/stat.c | 138 +++++++ - grub-core/osdep/windows/hostdisk.c | 6 + - grub-core/gnulib/pathmax.h | 83 ++++ - grub-core/gnulib/sys_stat.in.h | 732 ++++++++++++++++++++++++++++++++++ - grub-core/gnulib/sys_time.in.h | 213 ++++++++++ - grub-core/gnulib/sys_types.in.h | 2 + - grub-core/gnulib/time.h | 586 +++++++++++++++++++++++++++ - grub-core/gnulib/time.in.h | 274 +++++++++++++ - include/grub/osdep/hostfile_aros.h | 6 + - include/grub/osdep/hostfile_unix.h | 6 + - include/grub/osdep/hostfile_windows.h | 2 + - grub-core/gnulib/Makefile.am | 177 +++++++- - m4/gettimeofday.m4 | 138 +++++++ - m4/gnulib-cache.m4 | 3 +- - m4/gnulib-comp.m4 | 49 +++ - m4/largefile.m4 | 146 +++++++ - m4/pathmax.m4 | 42 ++ - m4/readlink.m4 | 71 ++++ - m4/stat.m4 | 71 ++++ - m4/sys_stat_h.m4 | 96 +++++ - m4/sys_time_h.m4 | 110 +++++ - m4/time_h.m4 | 118 ++++++ - 24 files changed, 3295 insertions(+), 2 deletions(-) - create mode 100644 grub-core/gnulib/gettimeofday.c - create mode 100644 grub-core/gnulib/readlink.c - create mode 100644 grub-core/gnulib/stat.c - create mode 100644 grub-core/gnulib/pathmax.h - create mode 100644 grub-core/gnulib/sys_stat.in.h - create mode 100644 grub-core/gnulib/sys_time.in.h - create mode 100644 grub-core/gnulib/time.h - create mode 100644 grub-core/gnulib/time.in.h - create mode 100644 m4/gettimeofday.m4 - create mode 100644 m4/largefile.m4 - create mode 100644 m4/pathmax.m4 - create mode 100644 m4/readlink.m4 - create mode 100644 m4/stat.m4 - create mode 100644 m4/sys_stat_h.m4 - create mode 100644 m4/sys_time_h.m4 - create mode 100644 m4/time_h.m4 - -diff --git a/grub-core/gnulib/gettimeofday.c b/grub-core/gnulib/gettimeofday.c -new file mode 100644 -index 00000000000..8b2058e8c87 ---- /dev/null -+++ b/grub-core/gnulib/gettimeofday.c -@@ -0,0 +1,154 @@ -+/* Provide gettimeofday for systems that don't have it or for which it's broken. -+ -+ Copyright (C) 2001-2003, 2005-2007, 2009-2014 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, see . */ -+ -+/* written by Jim Meyering */ -+ -+#include -+ -+/* Specification. */ -+#include -+ -+#include -+ -+#if HAVE_SYS_TIMEB_H -+# include -+#endif -+ -+#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME -+ -+/* Work around the bug in some systems whereby gettimeofday clobbers -+ the static buffer that localtime uses for its return value. The -+ gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has -+ this problem. The tzset replacement is necessary for at least -+ Solaris 2.5, 2.5.1, and 2.6. */ -+ -+static struct tm tm_zero_buffer; -+static struct tm *localtime_buffer_addr = &tm_zero_buffer; -+ -+# undef localtime -+extern struct tm *localtime (time_t const *); -+ -+# undef gmtime -+extern struct tm *gmtime (time_t const *); -+ -+/* This is a wrapper for localtime. It is used only on systems for which -+ gettimeofday clobbers the static buffer used for localtime's result. -+ -+ On the first call, record the address of the static buffer that -+ localtime uses for its result. */ -+ -+struct tm * -+rpl_localtime (time_t const *timep) -+{ -+ struct tm *tm = localtime (timep); -+ -+ if (localtime_buffer_addr == &tm_zero_buffer) -+ localtime_buffer_addr = tm; -+ -+ return tm; -+} -+ -+/* Same as above, since gmtime and localtime use the same buffer. */ -+struct tm * -+rpl_gmtime (time_t const *timep) -+{ -+ struct tm *tm = gmtime (timep); -+ -+ if (localtime_buffer_addr == &tm_zero_buffer) -+ localtime_buffer_addr = tm; -+ -+ return tm; -+} -+ -+#endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */ -+ -+#if TZSET_CLOBBERS_LOCALTIME -+ -+# undef tzset -+extern void tzset (void); -+ -+/* This is a wrapper for tzset, for systems on which tzset may clobber -+ the static buffer used for localtime's result. */ -+void -+rpl_tzset (void) -+{ -+ /* Save and restore the contents of the buffer used for localtime's -+ result around the call to tzset. */ -+ struct tm save = *localtime_buffer_addr; -+ tzset (); -+ *localtime_buffer_addr = save; -+} -+#endif -+ -+/* This is a wrapper for gettimeofday. It is used only on systems -+ that lack this function, or whose implementation of this function -+ causes problems. */ -+ -+int -+gettimeofday (struct timeval *restrict tv, void *restrict tz) -+{ -+#undef gettimeofday -+#if HAVE_GETTIMEOFDAY -+# if GETTIMEOFDAY_CLOBBERS_LOCALTIME -+ /* Save and restore the contents of the buffer used for localtime's -+ result around the call to gettimeofday. */ -+ struct tm save = *localtime_buffer_addr; -+# endif -+ -+# if defined timeval /* 'struct timeval' overridden by gnulib? */ -+# undef timeval -+ struct timeval otv; -+ int result = gettimeofday (&otv, (struct timezone *) tz); -+ if (result == 0) -+ { -+ tv->tv_sec = otv.tv_sec; -+ tv->tv_usec = otv.tv_usec; -+ } -+# else -+ int result = gettimeofday (tv, (struct timezone *) tz); -+# endif -+ -+# if GETTIMEOFDAY_CLOBBERS_LOCALTIME -+ *localtime_buffer_addr = save; -+# endif -+ -+ return result; -+ -+#else -+ -+# if HAVE__FTIME -+ -+ struct _timeb timebuf; -+ _ftime (&timebuf); -+ tv->tv_sec = timebuf.time; -+ tv->tv_usec = timebuf.millitm * 1000; -+ -+# else -+ -+# if !defined OK_TO_USE_1S_CLOCK -+# error "Only 1-second nominal clock resolution found. Is that intended?" \ -+ "If so, compile with the -DOK_TO_USE_1S_CLOCK option." -+# endif -+ tv->tv_sec = time (NULL); -+ tv->tv_usec = 0; -+ -+# endif -+ -+ return 0; -+ -+#endif -+} -diff --git a/grub-core/gnulib/readlink.c b/grub-core/gnulib/readlink.c -new file mode 100644 -index 00000000000..4c496395176 ---- /dev/null -+++ b/grub-core/gnulib/readlink.c -@@ -0,0 +1,74 @@ -+/* Stub for readlink(). -+ Copyright (C) 2003-2007, 2009-2014 Free Software Foundation, Inc. -+ -+ This program is free software: you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+#include -+ -+/* Specification. */ -+#include -+ -+#include -+#include -+#include -+ -+#if !HAVE_READLINK -+ -+/* readlink() substitute for systems that don't have a readlink() function, -+ such as DJGPP 2.03 and mingw32. */ -+ -+ssize_t -+readlink (const char *name, char *buf _GL_UNUSED, -+ size_t bufsize _GL_UNUSED) -+{ -+ struct stat statbuf; -+ -+ /* In general we should use lstat() here, not stat(). But on platforms -+ without symbolic links, lstat() - if it exists - would be equivalent to -+ stat(), therefore we can use stat(). This saves us a configure check. */ -+ if (stat (name, &statbuf) >= 0) -+ errno = EINVAL; -+ return -1; -+} -+ -+#else /* HAVE_READLINK */ -+ -+# undef readlink -+ -+/* readlink() wrapper that uses correct types, for systems like cygwin -+ 1.5.x where readlink returns int, and which rejects trailing slash, -+ for Solaris 9. */ -+ -+ssize_t -+rpl_readlink (const char *name, char *buf, size_t bufsize) -+{ -+# if READLINK_TRAILING_SLASH_BUG -+ size_t len = strlen (name); -+ if (len && name[len - 1] == '/') -+ { -+ /* Even if name without the slash is a symlink to a directory, -+ both lstat() and stat() must resolve the trailing slash to -+ the directory rather than the symlink. We can therefore -+ safely use stat() to distinguish between EINVAL and -+ ENOTDIR/ENOENT, avoiding extra overhead of rpl_lstat(). */ -+ struct stat st; -+ if (stat (name, &st) == 0) -+ errno = EINVAL; -+ return -1; -+ } -+# endif /* READLINK_TRAILING_SLASH_BUG */ -+ return readlink (name, buf, bufsize); -+} -+ -+#endif /* HAVE_READLINK */ -diff --git a/grub-core/gnulib/stat.c b/grub-core/gnulib/stat.c -new file mode 100644 -index 00000000000..35f4b0b1a51 ---- /dev/null -+++ b/grub-core/gnulib/stat.c -@@ -0,0 +1,138 @@ -+/* Work around platform bugs in stat. -+ Copyright (C) 2009-2014 Free Software Foundation, Inc. -+ -+ This program is free software: you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program. If not, see . */ -+ -+/* written by Eric Blake */ -+ -+/* If the user's config.h happens to include , let it include only -+ the system's here, so that orig_stat doesn't recurse to -+ rpl_stat. */ -+#define __need_system_sys_stat_h -+#include -+ -+/* Get the original definition of stat. It might be defined as a macro. */ -+#include -+#include -+#undef __need_system_sys_stat_h -+ -+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -+# if _GL_WINDOWS_64_BIT_ST_SIZE -+# undef stat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */ -+# define stat _stati64 -+# define REPLACE_FUNC_STAT_DIR 1 -+# undef REPLACE_FUNC_STAT_FILE -+# elif REPLACE_FUNC_STAT_FILE -+/* mingw64 has a broken stat() function, based on _stat(), in libmingwex.a. -+ Bypass it. */ -+# define stat _stat -+# define REPLACE_FUNC_STAT_DIR 1 -+# undef REPLACE_FUNC_STAT_FILE -+# endif -+#endif -+ -+static int -+orig_stat (const char *filename, struct stat *buf) -+{ -+ return stat (filename, buf); -+} -+ -+/* Specification. */ -+/* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc -+ eliminates this include because of the preliminary #include -+ above. */ -+#include "sys/stat.h" -+ -+#include -+#include -+#include -+#include -+#include "dosname.h" -+#include "verify.h" -+ -+#if REPLACE_FUNC_STAT_DIR -+# include "pathmax.h" -+ /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also -+ have a constant PATH_MAX. */ -+# ifndef PATH_MAX -+# error "Please port this replacement to your platform" -+# endif -+#endif -+ -+/* Store information about NAME into ST. Work around bugs with -+ trailing slashes. Mingw has other bugs (such as st_ino always -+ being 0 on success) which this wrapper does not work around. But -+ at least this implementation provides the ability to emulate fchdir -+ correctly. */ -+ -+int -+rpl_stat (char const *name, struct stat *st) -+{ -+ int result = orig_stat (name, st); -+#if REPLACE_FUNC_STAT_FILE -+ /* Solaris 9 mistakenly succeeds when given a non-directory with a -+ trailing slash. */ -+ if (result == 0 && !S_ISDIR (st->st_mode)) -+ { -+ size_t len = strlen (name); -+ if (ISSLASH (name[len - 1])) -+ { -+ errno = ENOTDIR; -+ return -1; -+ } -+ } -+#endif /* REPLACE_FUNC_STAT_FILE */ -+#if REPLACE_FUNC_STAT_DIR -+ -+ if (result == -1 && errno == ENOENT) -+ { -+ /* Due to mingw's oddities, there are some directories (like -+ c:\) where stat() only succeeds with a trailing slash, and -+ other directories (like c:\windows) where stat() only -+ succeeds without a trailing slash. But we want the two to be -+ synonymous, since chdir() manages either style. Likewise, Mingw also -+ reports ENOENT for names longer than PATH_MAX, when we want -+ ENAMETOOLONG, and for stat("file/"), when we want ENOTDIR. -+ Fortunately, mingw PATH_MAX is small enough for stack -+ allocation. */ -+ char fixed_name[PATH_MAX + 1] = {0}; -+ size_t len = strlen (name); -+ bool check_dir = false; -+ verify (PATH_MAX <= 4096); -+ if (PATH_MAX <= len) -+ errno = ENAMETOOLONG; -+ else if (len) -+ { -+ strcpy (fixed_name, name); -+ if (ISSLASH (fixed_name[len - 1])) -+ { -+ check_dir = true; -+ while (len && ISSLASH (fixed_name[len - 1])) -+ fixed_name[--len] = '\0'; -+ if (!len) -+ fixed_name[0] = '/'; -+ } -+ else -+ fixed_name[len++] = '/'; -+ result = orig_stat (fixed_name, st); -+ if (result == 0 && check_dir && !S_ISDIR (st->st_mode)) -+ { -+ result = -1; -+ errno = ENOTDIR; -+ } -+ } -+ } -+#endif /* REPLACE_FUNC_STAT_DIR */ -+ return result; -+} -diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c -index 85507af88e3..6f49df465d7 100644 ---- a/grub-core/osdep/windows/hostdisk.c -+++ b/grub-core/osdep/windows/hostdisk.c -@@ -353,6 +353,12 @@ grub_util_mkdir (const char *dir) - free (windows_name); - } - -+ssize_t -+grub_util_readlink (const char *name, char *buf, size_t bufsize) -+{ -+ return readlink(name, buf, bufsize); -+} -+ - int - grub_util_rename (const char *from, const char *to) - { -diff --git a/grub-core/gnulib/pathmax.h b/grub-core/gnulib/pathmax.h -new file mode 100644 -index 00000000000..33fc3553d75 ---- /dev/null -+++ b/grub-core/gnulib/pathmax.h -@@ -0,0 +1,83 @@ -+/* Define PATH_MAX somehow. Requires sys/types.h. -+ Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2014 Free Software -+ Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, see . */ -+ -+#ifndef _PATHMAX_H -+# define _PATHMAX_H -+ -+/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename, -+ including the terminating NUL byte. -+ -+ PATH_MAX is not defined on systems which have no limit on filename length, -+ such as GNU/Hurd. -+ -+ This file does *not* define PATH_MAX always. Programs that use this file -+ can handle the GNU/Hurd case in several ways: -+ - Either with a package-wide handling, or with a per-file handling, -+ - Either through a -+ #ifdef PATH_MAX -+ or through a fallback like -+ #ifndef PATH_MAX -+ # define PATH_MAX 8192 -+ #endif -+ or through a fallback like -+ #ifndef PATH_MAX -+ # define PATH_MAX pathconf ("/", _PC_PATH_MAX) -+ #endif -+ */ -+ -+# include -+ -+# include -+ -+# ifndef _POSIX_PATH_MAX -+# define _POSIX_PATH_MAX 256 -+# endif -+ -+/* Don't include sys/param.h if it already has been. */ -+# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN -+# include -+# endif -+ -+# if !defined PATH_MAX && defined MAXPATHLEN -+# define PATH_MAX MAXPATHLEN -+# endif -+ -+# ifdef __hpux -+/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename, -+ *not* including the terminating NUL byte, and is set to 1023. -+ Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is -+ not defined at all any more. */ -+# undef PATH_MAX -+# define PATH_MAX 1024 -+# endif -+ -+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -+/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com, -+ section "Maximum Path Length Limitation", -+ -+ explains that the maximum size of a filename, including the terminating -+ NUL byte, is 260 = 3 + 256 + 1. -+ This is the same value as -+ - FILENAME_MAX in , -+ - _MAX_PATH in , -+ - MAX_PATH in . -+ Undefine the original value, because mingw's gets it wrong. */ -+# undef PATH_MAX -+# define PATH_MAX 260 -+# endif -+ -+#endif /* _PATHMAX_H */ -diff --git a/grub-core/gnulib/sys_stat.in.h b/grub-core/gnulib/sys_stat.in.h -new file mode 100644 -index 00000000000..b47a7ff0ae7 ---- /dev/null -+++ b/grub-core/gnulib/sys_stat.in.h -@@ -0,0 +1,732 @@ -+/* Provide a more complete sys/stat header file. -+ Copyright (C) 2005-2014 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, see . */ -+ -+/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */ -+ -+/* This file is supposed to be used on platforms where is -+ incomplete. It is intended to provide definitions and prototypes -+ needed by an application. Start with what the system provides. */ -+ -+#if __GNUC__ >= 3 -+@PRAGMA_SYSTEM_HEADER@ -+#endif -+@PRAGMA_COLUMNS@ -+ -+#if defined __need_system_sys_stat_h -+/* Special invocation convention. */ -+ -+#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ -+ -+#else -+/* Normal invocation convention. */ -+ -+#ifndef _@GUARD_PREFIX@_SYS_STAT_H -+ -+/* Get nlink_t. -+ May also define off_t to a 64-bit type on native Windows. */ -+#include -+ -+/* Get struct timespec. */ -+#include -+ -+/* The include_next requires a split double-inclusion guard. */ -+#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ -+ -+#ifndef _@GUARD_PREFIX@_SYS_STAT_H -+#define _@GUARD_PREFIX@_SYS_STAT_H -+ -+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ -+ -+/* The definition of _GL_ARG_NONNULL is copied here. */ -+ -+/* The definition of _GL_WARN_ON_USE is copied here. */ -+ -+/* Before doing "#define mkdir rpl_mkdir" below, we need to include all -+ headers that may declare mkdir(). Native Windows platforms declare mkdir -+ in and/or , not in . */ -+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -+# include /* mingw32, mingw64 */ -+# include /* mingw64, MSVC 9 */ -+#endif -+ -+/* Native Windows platforms declare umask() in . */ -+#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) -+# include -+#endif -+ -+/* Large File Support on native Windows. */ -+#if @WINDOWS_64_BIT_ST_SIZE@ -+# define stat _stati64 -+#endif -+ -+#ifndef S_IFIFO -+# ifdef _S_IFIFO -+# define S_IFIFO _S_IFIFO -+# endif -+#endif -+ -+#ifndef S_IFMT -+# define S_IFMT 0170000 -+#endif -+ -+#if STAT_MACROS_BROKEN -+# undef S_ISBLK -+# undef S_ISCHR -+# undef S_ISDIR -+# undef S_ISFIFO -+# undef S_ISLNK -+# undef S_ISNAM -+# undef S_ISMPB -+# undef S_ISMPC -+# undef S_ISNWK -+# undef S_ISREG -+# undef S_ISSOCK -+#endif -+ -+#ifndef S_ISBLK -+# ifdef S_IFBLK -+# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) -+# else -+# define S_ISBLK(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISCHR -+# ifdef S_IFCHR -+# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) -+# else -+# define S_ISCHR(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISDIR -+# ifdef S_IFDIR -+# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -+# else -+# define S_ISDIR(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISDOOR /* Solaris 2.5 and up */ -+# define S_ISDOOR(m) 0 -+#endif -+ -+#ifndef S_ISFIFO -+# ifdef S_IFIFO -+# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) -+# else -+# define S_ISFIFO(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISLNK -+# ifdef S_IFLNK -+# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) -+# else -+# define S_ISLNK(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISMPB /* V7 */ -+# ifdef S_IFMPB -+# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) -+# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) -+# else -+# define S_ISMPB(m) 0 -+# define S_ISMPC(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISMPX /* AIX */ -+# define S_ISMPX(m) 0 -+#endif -+ -+#ifndef S_ISNAM /* Xenix */ -+# ifdef S_IFNAM -+# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM) -+# else -+# define S_ISNAM(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISNWK /* HP/UX */ -+# ifdef S_IFNWK -+# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) -+# else -+# define S_ISNWK(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISPORT /* Solaris 10 and up */ -+# define S_ISPORT(m) 0 -+#endif -+ -+#ifndef S_ISREG -+# ifdef S_IFREG -+# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -+# else -+# define S_ISREG(m) 0 -+# endif -+#endif -+ -+#ifndef S_ISSOCK -+# ifdef S_IFSOCK -+# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) -+# else -+# define S_ISSOCK(m) 0 -+# endif -+#endif -+ -+ -+#ifndef S_TYPEISMQ -+# define S_TYPEISMQ(p) 0 -+#endif -+ -+#ifndef S_TYPEISTMO -+# define S_TYPEISTMO(p) 0 -+#endif -+ -+ -+#ifndef S_TYPEISSEM -+# ifdef S_INSEM -+# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM) -+# else -+# define S_TYPEISSEM(p) 0 -+# endif -+#endif -+ -+#ifndef S_TYPEISSHM -+# ifdef S_INSHD -+# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD) -+# else -+# define S_TYPEISSHM(p) 0 -+# endif -+#endif -+ -+/* high performance ("contiguous data") */ -+#ifndef S_ISCTG -+# define S_ISCTG(p) 0 -+#endif -+ -+/* Cray DMF (data migration facility): off line, with data */ -+#ifndef S_ISOFD -+# define S_ISOFD(p) 0 -+#endif -+ -+/* Cray DMF (data migration facility): off line, with no data */ -+#ifndef S_ISOFL -+# define S_ISOFL(p) 0 -+#endif -+ -+/* 4.4BSD whiteout */ -+#ifndef S_ISWHT -+# define S_ISWHT(m) 0 -+#endif -+ -+/* If any of the following are undefined, -+ define them to their de facto standard values. */ -+#if !S_ISUID -+# define S_ISUID 04000 -+#endif -+#if !S_ISGID -+# define S_ISGID 02000 -+#endif -+ -+/* S_ISVTX is a common extension to POSIX. */ -+#ifndef S_ISVTX -+# define S_ISVTX 01000 -+#endif -+ -+#if !S_IRUSR && S_IREAD -+# define S_IRUSR S_IREAD -+#endif -+#if !S_IRUSR -+# define S_IRUSR 00400 -+#endif -+#if !S_IRGRP -+# define S_IRGRP (S_IRUSR >> 3) -+#endif -+#if !S_IROTH -+# define S_IROTH (S_IRUSR >> 6) -+#endif -+ -+#if !S_IWUSR && S_IWRITE -+# define S_IWUSR S_IWRITE -+#endif -+#if !S_IWUSR -+# define S_IWUSR 00200 -+#endif -+#if !S_IWGRP -+# define S_IWGRP (S_IWUSR >> 3) -+#endif -+#if !S_IWOTH -+# define S_IWOTH (S_IWUSR >> 6) -+#endif -+ -+#if !S_IXUSR && S_IEXEC -+# define S_IXUSR S_IEXEC -+#endif -+#if !S_IXUSR -+# define S_IXUSR 00100 -+#endif -+#if !S_IXGRP -+# define S_IXGRP (S_IXUSR >> 3) -+#endif -+#if !S_IXOTH -+# define S_IXOTH (S_IXUSR >> 6) -+#endif -+ -+#if !S_IRWXU -+# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) -+#endif -+#if !S_IRWXG -+# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) -+#endif -+#if !S_IRWXO -+# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) -+#endif -+ -+/* S_IXUGO is a common extension to POSIX. */ -+#if !S_IXUGO -+# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) -+#endif -+ -+#ifndef S_IRWXUGO -+# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) -+#endif -+ -+/* Macros for futimens and utimensat. */ -+#ifndef UTIME_NOW -+# define UTIME_NOW (-1) -+# define UTIME_OMIT (-2) -+#endif -+ -+ -+#if @GNULIB_FCHMODAT@ -+# if !@HAVE_FCHMODAT@ -+_GL_FUNCDECL_SYS (fchmodat, int, -+ (int fd, char const *file, mode_t mode, int flag) -+ _GL_ARG_NONNULL ((2))); -+# endif -+_GL_CXXALIAS_SYS (fchmodat, int, -+ (int fd, char const *file, mode_t mode, int flag)); -+_GL_CXXALIASWARN (fchmodat); -+#elif defined GNULIB_POSIXCHECK -+# undef fchmodat -+# if HAVE_RAW_DECL_FCHMODAT -+_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - " -+ "use gnulib module openat for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_FSTAT@ -+# if @REPLACE_FSTAT@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef fstat -+# define fstat rpl_fstat -+# endif -+_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2))); -+_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf)); -+# else -+_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); -+# endif -+_GL_CXXALIASWARN (fstat); -+#elif @WINDOWS_64_BIT_ST_SIZE@ -+/* Above, we define stat to _stati64. */ -+# define fstat _fstati64 -+#elif defined GNULIB_POSIXCHECK -+# undef fstat -+# if HAVE_RAW_DECL_FSTAT -+_GL_WARN_ON_USE (fstat, "fstat has portability problems - " -+ "use gnulib module fstat for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_FSTATAT@ -+# if @REPLACE_FSTATAT@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef fstatat -+# define fstatat rpl_fstatat -+# endif -+_GL_FUNCDECL_RPL (fstatat, int, -+ (int fd, char const *name, struct stat *st, int flags) -+ _GL_ARG_NONNULL ((2, 3))); -+_GL_CXXALIAS_RPL (fstatat, int, -+ (int fd, char const *name, struct stat *st, int flags)); -+# else -+# if !@HAVE_FSTATAT@ -+_GL_FUNCDECL_SYS (fstatat, int, -+ (int fd, char const *name, struct stat *st, int flags) -+ _GL_ARG_NONNULL ((2, 3))); -+# endif -+_GL_CXXALIAS_SYS (fstatat, int, -+ (int fd, char const *name, struct stat *st, int flags)); -+# endif -+_GL_CXXALIASWARN (fstatat); -+#elif defined GNULIB_POSIXCHECK -+# undef fstatat -+# if HAVE_RAW_DECL_FSTATAT -+_GL_WARN_ON_USE (fstatat, "fstatat is not portable - " -+ "use gnulib module openat for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_FUTIMENS@ -+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens -+ implementation relies on futimesat, which on Solaris 10 makes an invocation -+ to futimens that is meant to invoke the libc's futimens(), not gnulib's -+ futimens(). */ -+# if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun) -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef futimens -+# define futimens rpl_futimens -+# endif -+_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2])); -+_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2])); -+# else -+# if !@HAVE_FUTIMENS@ -+_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2])); -+# endif -+_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2])); -+# endif -+# if @HAVE_FUTIMENS@ -+_GL_CXXALIASWARN (futimens); -+# endif -+#elif defined GNULIB_POSIXCHECK -+# undef futimens -+# if HAVE_RAW_DECL_FUTIMENS -+_GL_WARN_ON_USE (futimens, "futimens is not portable - " -+ "use gnulib module futimens for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_LCHMOD@ -+/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME -+ denotes a symbolic link. */ -+# if !@HAVE_LCHMOD@ -+/* The lchmod replacement follows symbolic links. Callers should take -+ this into account; lchmod should be applied only to arguments that -+ are known to not be symbolic links. On hosts that lack lchmod, -+ this can lead to race conditions between the check and the -+ invocation of lchmod, but we know of no workarounds that are -+ reliable in general. You might try requesting support for lchmod -+ from your operating system supplier. */ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# define lchmod chmod -+# endif -+/* Need to cast, because on mingw, the second parameter of chmod is -+ int mode. */ -+_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int, -+ (const char *filename, mode_t mode)); -+# else -+# if 0 /* assume already declared */ -+_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode) -+ _GL_ARG_NONNULL ((1))); -+# endif -+_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode)); -+# endif -+# if @HAVE_LCHMOD@ -+_GL_CXXALIASWARN (lchmod); -+# endif -+#elif defined GNULIB_POSIXCHECK -+# undef lchmod -+# if HAVE_RAW_DECL_LCHMOD -+_GL_WARN_ON_USE (lchmod, "lchmod is unportable - " -+ "use gnulib module lchmod for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_LSTAT@ -+# if ! @HAVE_LSTAT@ -+/* mingw does not support symlinks, therefore it does not have lstat. But -+ without links, stat does just fine. */ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# define lstat stat -+# endif -+_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf)); -+# elif @REPLACE_LSTAT@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef lstat -+# define lstat rpl_lstat -+# endif -+_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf) -+ _GL_ARG_NONNULL ((1, 2))); -+_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf)); -+# else -+_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf)); -+# endif -+# if @HAVE_LSTAT@ -+_GL_CXXALIASWARN (lstat); -+# endif -+#elif defined GNULIB_POSIXCHECK -+# undef lstat -+# if HAVE_RAW_DECL_LSTAT -+_GL_WARN_ON_USE (lstat, "lstat is unportable - " -+ "use gnulib module lstat for portability"); -+# endif -+#endif -+ -+ -+#if @REPLACE_MKDIR@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef mkdir -+# define mkdir rpl_mkdir -+# endif -+_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); -+#else -+/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. -+ Additionally, it declares _mkdir (and depending on compile flags, an -+ alias mkdir), only in the nonstandard includes and , -+ which are included above. */ -+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -+ -+# if !GNULIB_defined_rpl_mkdir -+static int -+rpl_mkdir (char const *name, mode_t mode) -+{ -+ return _mkdir (name); -+} -+# define GNULIB_defined_rpl_mkdir 1 -+# endif -+ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# define mkdir rpl_mkdir -+# endif -+_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); -+# else -+_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode)); -+# endif -+#endif -+_GL_CXXALIASWARN (mkdir); -+ -+ -+#if @GNULIB_MKDIRAT@ -+# if !@HAVE_MKDIRAT@ -+_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode) -+ _GL_ARG_NONNULL ((2))); -+# endif -+_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)); -+_GL_CXXALIASWARN (mkdirat); -+#elif defined GNULIB_POSIXCHECK -+# undef mkdirat -+# if HAVE_RAW_DECL_MKDIRAT -+_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - " -+ "use gnulib module openat for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_MKFIFO@ -+# if @REPLACE_MKFIFO@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef mkfifo -+# define mkfifo rpl_mkfifo -+# endif -+_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode)); -+# else -+# if !@HAVE_MKFIFO@ -+_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode) -+ _GL_ARG_NONNULL ((1))); -+# endif -+_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode)); -+# endif -+_GL_CXXALIASWARN (mkfifo); -+#elif defined GNULIB_POSIXCHECK -+# undef mkfifo -+# if HAVE_RAW_DECL_MKFIFO -+_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - " -+ "use gnulib module mkfifo for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_MKFIFOAT@ -+# if !@HAVE_MKFIFOAT@ -+_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode) -+ _GL_ARG_NONNULL ((2))); -+# endif -+_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)); -+_GL_CXXALIASWARN (mkfifoat); -+#elif defined GNULIB_POSIXCHECK -+# undef mkfifoat -+# if HAVE_RAW_DECL_MKFIFOAT -+_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - " -+ "use gnulib module mkfifoat for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_MKNOD@ -+# if @REPLACE_MKNOD@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef mknod -+# define mknod rpl_mknod -+# endif -+_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)); -+# else -+# if !@HAVE_MKNOD@ -+_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev) -+ _GL_ARG_NONNULL ((1))); -+# endif -+/* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */ -+_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev)); -+# endif -+_GL_CXXALIASWARN (mknod); -+#elif defined GNULIB_POSIXCHECK -+# undef mknod -+# if HAVE_RAW_DECL_MKNOD -+_GL_WARN_ON_USE (mknod, "mknod is not portable - " -+ "use gnulib module mknod for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_MKNODAT@ -+# if !@HAVE_MKNODAT@ -+_GL_FUNCDECL_SYS (mknodat, int, -+ (int fd, char const *file, mode_t mode, dev_t dev) -+ _GL_ARG_NONNULL ((2))); -+# endif -+_GL_CXXALIAS_SYS (mknodat, int, -+ (int fd, char const *file, mode_t mode, dev_t dev)); -+_GL_CXXALIASWARN (mknodat); -+#elif defined GNULIB_POSIXCHECK -+# undef mknodat -+# if HAVE_RAW_DECL_MKNODAT -+_GL_WARN_ON_USE (mknodat, "mknodat is not portable - " -+ "use gnulib module mkfifoat for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_STAT@ -+# if @REPLACE_STAT@ -+/* We can't use the object-like #define stat rpl_stat, because of -+ struct stat. This means that rpl_stat will not be used if the user -+ does (stat)(a,b). Oh well. */ -+# if defined _AIX && defined stat && defined _LARGE_FILES -+ /* With _LARGE_FILES defined, AIX (only) defines stat to stat64, -+ so we have to replace stat64() instead of stat(). */ -+# undef stat64 -+# define stat64(name, st) rpl_stat (name, st) -+# elif @WINDOWS_64_BIT_ST_SIZE@ -+ /* Above, we define stat to _stati64. */ -+# if defined __MINGW32__ && defined _stati64 -+# ifndef _USE_32BIT_TIME_T -+ /* The system headers define _stati64 to _stat64. */ -+# undef _stat64 -+# define _stat64(name, st) rpl_stat (name, st) -+# endif -+# elif defined _MSC_VER && defined _stati64 -+# ifdef _USE_32BIT_TIME_T -+ /* The system headers define _stati64 to _stat32i64. */ -+# undef _stat32i64 -+# define _stat32i64(name, st) rpl_stat (name, st) -+# else -+ /* The system headers define _stati64 to _stat64. */ -+# undef _stat64 -+# define _stat64(name, st) rpl_stat (name, st) -+# endif -+# else -+# undef _stati64 -+# define _stati64(name, st) rpl_stat (name, st) -+# endif -+# elif defined __MINGW32__ && defined stat -+# ifdef _USE_32BIT_TIME_T -+ /* The system headers define stat to _stat32i64. */ -+# undef _stat32i64 -+# define _stat32i64(name, st) rpl_stat (name, st) -+# else -+ /* The system headers define stat to _stat64. */ -+# undef _stat64 -+# define _stat64(name, st) rpl_stat (name, st) -+# endif -+# elif defined _MSC_VER && defined stat -+# ifdef _USE_32BIT_TIME_T -+ /* The system headers define stat to _stat32. */ -+# undef _stat32 -+# define _stat32(name, st) rpl_stat (name, st) -+# else -+ /* The system headers define stat to _stat64i32. */ -+# undef _stat64i32 -+# define _stat64i32(name, st) rpl_stat (name, st) -+# endif -+# else /* !(_AIX ||__MINGW32__ || _MSC_VER) */ -+# undef stat -+# define stat(name, st) rpl_stat (name, st) -+# endif /* !_LARGE_FILES */ -+_GL_EXTERN_C int stat (const char *name, struct stat *buf) -+ _GL_ARG_NONNULL ((1, 2)); -+# endif -+#elif defined GNULIB_POSIXCHECK -+# undef stat -+# if HAVE_RAW_DECL_STAT -+_GL_WARN_ON_USE (stat, "stat is unportable - " -+ "use gnulib module stat for portability"); -+# endif -+#endif -+ -+ -+#if @GNULIB_UTIMENSAT@ -+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat -+ implementation relies on futimesat, which on Solaris 10 makes an invocation -+ to utimensat that is meant to invoke the libc's utimensat(), not gnulib's -+ utimensat(). */ -+# if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun) -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef utimensat -+# define utimensat rpl_utimensat -+# endif -+_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name, -+ struct timespec const times[2], int flag) -+ _GL_ARG_NONNULL ((2))); -+_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name, -+ struct timespec const times[2], int flag)); -+# else -+# if !@HAVE_UTIMENSAT@ -+_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name, -+ struct timespec const times[2], int flag) -+ _GL_ARG_NONNULL ((2))); -+# endif -+_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name, -+ struct timespec const times[2], int flag)); -+# endif -+# if @HAVE_UTIMENSAT@ -+_GL_CXXALIASWARN (utimensat); -+# endif -+#elif defined GNULIB_POSIXCHECK -+# undef utimensat -+# if HAVE_RAW_DECL_UTIMENSAT -+_GL_WARN_ON_USE (utimensat, "utimensat is not portable - " -+ "use gnulib module utimensat for portability"); -+# endif -+#endif -+ -+ -+#endif /* _@GUARD_PREFIX@_SYS_STAT_H */ -+#endif /* _@GUARD_PREFIX@_SYS_STAT_H */ -+#endif -diff --git a/grub-core/gnulib/sys_time.in.h b/grub-core/gnulib/sys_time.in.h -new file mode 100644 -index 00000000000..30057ad49fd ---- /dev/null -+++ b/grub-core/gnulib/sys_time.in.h -@@ -0,0 +1,213 @@ -+/* Provide a more complete sys/time.h. -+ -+ Copyright (C) 2007-2014 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, see . */ -+ -+/* Written by Paul Eggert. */ -+ -+#ifndef _@GUARD_PREFIX@_SYS_TIME_H -+ -+#if __GNUC__ >= 3 -+@PRAGMA_SYSTEM_HEADER@ -+#endif -+@PRAGMA_COLUMNS@ -+ -+/* On Cygwin and on many BSDish systems, includes itself -+ recursively via . -+ Simply delegate to the system's header in this case; it is a no-op. -+ Without this extra ifdef, the C++ gettimeofday declaration below -+ would be a forward declaration in gnulib's nested . */ -+#if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_ -+# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@ -+#else -+ -+/* The include_next requires a split double-inclusion guard. */ -+#if @HAVE_SYS_TIME_H@ -+# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@ -+#endif -+ -+#ifndef _@GUARD_PREFIX@_SYS_TIME_H -+#define _@GUARD_PREFIX@_SYS_TIME_H -+ -+#if ! @HAVE_SYS_TIME_H@ -+# include -+#endif -+ -+/* On native Windows with MSVC, get the 'struct timeval' type. -+ Also, on native Windows with a 64-bit time_t, where we are overriding the -+ 'struct timeval' type, get all declarations of system functions whose -+ signature contains 'struct timeval'. */ -+#if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H -+# define _GL_INCLUDING_WINSOCK2_H -+# include -+# undef _GL_INCLUDING_WINSOCK2_H -+#endif -+ -+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ -+ -+/* The definition of _GL_ARG_NONNULL is copied here. */ -+ -+/* The definition of _GL_WARN_ON_USE is copied here. */ -+ -+#ifdef __cplusplus -+extern "C" { -+#endif -+ -+#if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@ -+ -+# if @REPLACE_STRUCT_TIMEVAL@ -+# define timeval rpl_timeval -+# endif -+ -+# if !GNULIB_defined_struct_timeval -+struct timeval -+{ -+ time_t tv_sec; -+ long int tv_usec; -+}; -+# define GNULIB_defined_struct_timeval 1 -+# endif -+ -+#endif -+ -+#ifdef __cplusplus -+} -+#endif -+ -+#if @GNULIB_GETTIMEOFDAY@ -+# if @REPLACE_GETTIMEOFDAY@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef gettimeofday -+# define gettimeofday rpl_gettimeofday -+# endif -+_GL_FUNCDECL_RPL (gettimeofday, int, -+ (struct timeval *restrict, void *restrict) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (gettimeofday, int, -+ (struct timeval *restrict, void *restrict)); -+# else -+# if !@HAVE_GETTIMEOFDAY@ -+_GL_FUNCDECL_SYS (gettimeofday, int, -+ (struct timeval *restrict, void *restrict) -+ _GL_ARG_NONNULL ((1))); -+# endif -+/* Need to cast, because on glibc systems, by default, the second argument is -+ struct timezone *. */ -+_GL_CXXALIAS_SYS_CAST (gettimeofday, int, -+ (struct timeval *restrict, void *restrict)); -+# endif -+_GL_CXXALIASWARN (gettimeofday); -+#elif defined GNULIB_POSIXCHECK -+# undef gettimeofday -+# if HAVE_RAW_DECL_GETTIMEOFDAY -+_GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - " -+ "use gnulib module gettimeofday for portability"); -+# endif -+#endif -+ -+/* Hide some function declarations from . */ -+ -+#if defined _MSC_VER && @HAVE_WINSOCK2_H@ -+# if !defined _@GUARD_PREFIX@_UNISTD_H -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef close -+# define close close_used_without_including_unistd_h -+# else -+ _GL_WARN_ON_USE (close, -+ "close() used without including "); -+# endif -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef gethostname -+# define gethostname gethostname_used_without_including_unistd_h -+# else -+ _GL_WARN_ON_USE (gethostname, -+ "gethostname() used without including "); -+# endif -+# endif -+# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef socket -+# define socket socket_used_without_including_sys_socket_h -+# undef connect -+# define connect connect_used_without_including_sys_socket_h -+# undef accept -+# define accept accept_used_without_including_sys_socket_h -+# undef bind -+# define bind bind_used_without_including_sys_socket_h -+# undef getpeername -+# define getpeername getpeername_used_without_including_sys_socket_h -+# undef getsockname -+# define getsockname getsockname_used_without_including_sys_socket_h -+# undef getsockopt -+# define getsockopt getsockopt_used_without_including_sys_socket_h -+# undef listen -+# define listen listen_used_without_including_sys_socket_h -+# undef recv -+# define recv recv_used_without_including_sys_socket_h -+# undef send -+# define send send_used_without_including_sys_socket_h -+# undef recvfrom -+# define recvfrom recvfrom_used_without_including_sys_socket_h -+# undef sendto -+# define sendto sendto_used_without_including_sys_socket_h -+# undef setsockopt -+# define setsockopt setsockopt_used_without_including_sys_socket_h -+# undef shutdown -+# define shutdown shutdown_used_without_including_sys_socket_h -+# else -+ _GL_WARN_ON_USE (socket, -+ "socket() used without including "); -+ _GL_WARN_ON_USE (connect, -+ "connect() used without including "); -+ _GL_WARN_ON_USE (accept, -+ "accept() used without including "); -+ _GL_WARN_ON_USE (bind, -+ "bind() used without including "); -+ _GL_WARN_ON_USE (getpeername, -+ "getpeername() used without including "); -+ _GL_WARN_ON_USE (getsockname, -+ "getsockname() used without including "); -+ _GL_WARN_ON_USE (getsockopt, -+ "getsockopt() used without including "); -+ _GL_WARN_ON_USE (listen, -+ "listen() used without including "); -+ _GL_WARN_ON_USE (recv, -+ "recv() used without including "); -+ _GL_WARN_ON_USE (send, -+ "send() used without including "); -+ _GL_WARN_ON_USE (recvfrom, -+ "recvfrom() used without including "); -+ _GL_WARN_ON_USE (sendto, -+ "sendto() used without including "); -+ _GL_WARN_ON_USE (setsockopt, -+ "setsockopt() used without including "); -+ _GL_WARN_ON_USE (shutdown, -+ "shutdown() used without including "); -+# endif -+# endif -+# if !defined _@GUARD_PREFIX@_SYS_SELECT_H -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef select -+# define select select_used_without_including_sys_select_h -+# else -+ _GL_WARN_ON_USE (select, -+ "select() used without including "); -+# endif -+# endif -+#endif -+ -+#endif /* _@GUARD_PREFIX@_SYS_TIME_H */ -+#endif /* _CYGWIN_SYS_TIME_H */ -+#endif /* _@GUARD_PREFIX@_SYS_TIME_H */ -diff --git a/grub-core/gnulib/sys_types.in.h b/grub-core/gnulib/sys_types.in.h -index d7da35623b1..9520c09030c 100644 ---- a/grub-core/gnulib/sys_types.in.h -+++ b/grub-core/gnulib/sys_types.in.h -@@ -23,7 +23,9 @@ - #ifndef _@GUARD_PREFIX@_SYS_TYPES_H - - /* The include_next requires a split double-inclusion guard. */ -+# define _GL_INCLUDING_SYS_TYPES_H - #@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@ -+# undef _GL_INCLUDING_SYS_TYPES_H - - #ifndef _@GUARD_PREFIX@_SYS_TYPES_H - #define _@GUARD_PREFIX@_SYS_TYPES_H -diff --git a/grub-core/gnulib/time.h b/grub-core/gnulib/time.h -new file mode 100644 -index 00000000000..b9203d5569a ---- /dev/null -+++ b/grub-core/gnulib/time.h -@@ -0,0 +1,586 @@ -+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ -+/* A more-standard . -+ -+ Copyright (C) 2007-2014 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, see . */ -+ -+#if __GNUC__ >= 3 -+#pragma GCC system_header -+#endif -+ -+ -+/* Don't get in the way of glibc when it includes time.h merely to -+ declare a few standard symbols, rather than to declare all the -+ symbols. Also, Solaris 8 eventually includes itself -+ recursively; if that is happening, just include the system -+ without adding our own declarations. */ -+#if (defined __need_time_t || defined __need_clock_t \ -+ || defined __need_timespec \ -+ || defined _GL_TIME_H) -+ -+# include_next -+ -+#else -+ -+# define _GL_TIME_H -+ -+# include_next -+ -+/* NetBSD 5.0 mis-defines NULL. */ -+# include -+ -+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ -+#ifndef _GL_CXXDEFS_H -+#define _GL_CXXDEFS_H -+ -+/* The three most frequent use cases of these macros are: -+ -+ * For providing a substitute for a function that is missing on some -+ platforms, but is declared and works fine on the platforms on which -+ it exists: -+ -+ #if @GNULIB_FOO@ -+ # if !@HAVE_FOO@ -+ _GL_FUNCDECL_SYS (foo, ...); -+ # endif -+ _GL_CXXALIAS_SYS (foo, ...); -+ _GL_CXXALIASWARN (foo); -+ #elif defined GNULIB_POSIXCHECK -+ ... -+ #endif -+ -+ * For providing a replacement for a function that exists on all platforms, -+ but is broken/insufficient and needs to be replaced on some platforms: -+ -+ #if @GNULIB_FOO@ -+ # if @REPLACE_FOO@ -+ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+ # undef foo -+ # define foo rpl_foo -+ # endif -+ _GL_FUNCDECL_RPL (foo, ...); -+ _GL_CXXALIAS_RPL (foo, ...); -+ # else -+ _GL_CXXALIAS_SYS (foo, ...); -+ # endif -+ _GL_CXXALIASWARN (foo); -+ #elif defined GNULIB_POSIXCHECK -+ ... -+ #endif -+ -+ * For providing a replacement for a function that exists on some platforms -+ but is broken/insufficient and needs to be replaced on some of them and -+ is additionally either missing or undeclared on some other platforms: -+ -+ #if @GNULIB_FOO@ -+ # if @REPLACE_FOO@ -+ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+ # undef foo -+ # define foo rpl_foo -+ # endif -+ _GL_FUNCDECL_RPL (foo, ...); -+ _GL_CXXALIAS_RPL (foo, ...); -+ # else -+ # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ -+ _GL_FUNCDECL_SYS (foo, ...); -+ # endif -+ _GL_CXXALIAS_SYS (foo, ...); -+ # endif -+ _GL_CXXALIASWARN (foo); -+ #elif defined GNULIB_POSIXCHECK -+ ... -+ #endif -+*/ -+ -+/* _GL_EXTERN_C declaration; -+ performs the declaration with C linkage. */ -+#if defined __cplusplus -+# define _GL_EXTERN_C extern "C" -+#else -+# define _GL_EXTERN_C extern -+#endif -+ -+/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); -+ declares a replacement function, named rpl_func, with the given prototype, -+ consisting of return type, parameters, and attributes. -+ Example: -+ _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) -+ _GL_ARG_NONNULL ((1))); -+ */ -+#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ -+ _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) -+#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ -+ _GL_EXTERN_C rettype rpl_func parameters_and_attributes -+ -+/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); -+ declares the system function, named func, with the given prototype, -+ consisting of return type, parameters, and attributes. -+ Example: -+ _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) -+ _GL_ARG_NONNULL ((1))); -+ */ -+#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ -+ _GL_EXTERN_C rettype func parameters_and_attributes -+ -+/* _GL_CXXALIAS_RPL (func, rettype, parameters); -+ declares a C++ alias called GNULIB_NAMESPACE::func -+ that redirects to rpl_func, if GNULIB_NAMESPACE is defined. -+ Example: -+ _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); -+ */ -+#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ -+ _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) -+#if defined __cplusplus && defined GNULIB_NAMESPACE -+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ -+ namespace GNULIB_NAMESPACE \ -+ { \ -+ rettype (*const func) parameters = ::rpl_func; \ -+ } \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#else -+# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#endif -+ -+/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); -+ is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); -+ except that the C function rpl_func may have a slightly different -+ declaration. A cast is used to silence the "invalid conversion" error -+ that would otherwise occur. */ -+#if defined __cplusplus && defined GNULIB_NAMESPACE -+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ -+ namespace GNULIB_NAMESPACE \ -+ { \ -+ rettype (*const func) parameters = \ -+ reinterpret_cast(::rpl_func); \ -+ } \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#else -+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#endif -+ -+/* _GL_CXXALIAS_SYS (func, rettype, parameters); -+ declares a C++ alias called GNULIB_NAMESPACE::func -+ that redirects to the system provided function func, if GNULIB_NAMESPACE -+ is defined. -+ Example: -+ _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); -+ */ -+#if defined __cplusplus && defined GNULIB_NAMESPACE -+ /* If we were to write -+ rettype (*const func) parameters = ::func; -+ like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls -+ better (remove an indirection through a 'static' pointer variable), -+ but then the _GL_CXXALIASWARN macro below would cause a warning not only -+ for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ -+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ -+ namespace GNULIB_NAMESPACE \ -+ { \ -+ static rettype (*func) parameters = ::func; \ -+ } \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#else -+# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#endif -+ -+/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); -+ is like _GL_CXXALIAS_SYS (func, rettype, parameters); -+ except that the C function func may have a slightly different declaration. -+ A cast is used to silence the "invalid conversion" error that would -+ otherwise occur. */ -+#if defined __cplusplus && defined GNULIB_NAMESPACE -+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ -+ namespace GNULIB_NAMESPACE \ -+ { \ -+ static rettype (*func) parameters = \ -+ reinterpret_cast(::func); \ -+ } \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#else -+# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#endif -+ -+/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); -+ is like _GL_CXXALIAS_SYS (func, rettype, parameters); -+ except that the C function is picked among a set of overloaded functions, -+ namely the one with rettype2 and parameters2. Two consecutive casts -+ are used to silence the "cannot find a match" and "invalid conversion" -+ errors that would otherwise occur. */ -+#if defined __cplusplus && defined GNULIB_NAMESPACE -+ /* The outer cast must be a reinterpret_cast. -+ The inner cast: When the function is defined as a set of overloaded -+ functions, it works as a static_cast<>, choosing the designated variant. -+ When the function is defined as a single variant, it works as a -+ reinterpret_cast<>. The parenthesized cast syntax works both ways. */ -+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ -+ namespace GNULIB_NAMESPACE \ -+ { \ -+ static rettype (*func) parameters = \ -+ reinterpret_cast( \ -+ (rettype2(*)parameters2)(::func)); \ -+ } \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#else -+# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#endif -+ -+/* _GL_CXXALIASWARN (func); -+ causes a warning to be emitted when ::func is used but not when -+ GNULIB_NAMESPACE::func is used. func must be defined without overloaded -+ variants. */ -+#if defined __cplusplus && defined GNULIB_NAMESPACE -+# define _GL_CXXALIASWARN(func) \ -+ _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) -+# define _GL_CXXALIASWARN_1(func,namespace) \ -+ _GL_CXXALIASWARN_2 (func, namespace) -+/* To work around GCC bug , -+ we enable the warning only when not optimizing. */ -+# if !__OPTIMIZE__ -+# define _GL_CXXALIASWARN_2(func,namespace) \ -+ _GL_WARN_ON_USE (func, \ -+ "The symbol ::" #func " refers to the system function. " \ -+ "Use " #namespace "::" #func " instead.") -+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -+# define _GL_CXXALIASWARN_2(func,namespace) \ -+ extern __typeof__ (func) func -+# else -+# define _GL_CXXALIASWARN_2(func,namespace) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+# endif -+#else -+# define _GL_CXXALIASWARN(func) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#endif -+ -+/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); -+ causes a warning to be emitted when the given overloaded variant of ::func -+ is used but not when GNULIB_NAMESPACE::func is used. */ -+#if defined __cplusplus && defined GNULIB_NAMESPACE -+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ -+ _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ -+ GNULIB_NAMESPACE) -+# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ -+ _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) -+/* To work around GCC bug , -+ we enable the warning only when not optimizing. */ -+# if !__OPTIMIZE__ -+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ -+ _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ -+ "The symbol ::" #func " refers to the system function. " \ -+ "Use " #namespace "::" #func " instead.") -+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ -+ extern __typeof__ (func) func -+# else -+# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+# endif -+#else -+# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ -+ _GL_EXTERN_C int _gl_cxxalias_dummy -+#endif -+ -+#endif /* _GL_CXXDEFS_H */ -+ -+/* The definition of _GL_ARG_NONNULL is copied here. */ -+/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools -+ that the values passed as arguments n, ..., m must be non-NULL pointers. -+ n = 1 stands for the first argument, n = 2 for the second argument etc. */ -+#ifndef _GL_ARG_NONNULL -+# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 -+# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) -+# else -+# define _GL_ARG_NONNULL(params) -+# endif -+#endif -+ -+/* The definition of _GL_WARN_ON_USE is copied here. */ -+#ifndef _GL_WARN_ON_USE -+ -+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) -+/* A compiler attribute is available in gcc versions 4.3.0 and later. */ -+# define _GL_WARN_ON_USE(function, message) \ -+extern __typeof__ (function) function __attribute__ ((__warning__ (message))) -+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -+/* Verify the existence of the function. */ -+# define _GL_WARN_ON_USE(function, message) \ -+extern __typeof__ (function) function -+# else /* Unsupported. */ -+# define _GL_WARN_ON_USE(function, message) \ -+_GL_WARN_EXTERN_C int _gl_warn_on_use -+# endif -+#endif -+ -+/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") -+ is like _GL_WARN_ON_USE (function, "string"), except that the function is -+ declared with the given prototype, consisting of return type, parameters, -+ and attributes. -+ This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does -+ not work in this case. */ -+#ifndef _GL_WARN_ON_USE_CXX -+# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) -+# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -+extern rettype function parameters_and_attributes \ -+ __attribute__ ((__warning__ (msg))) -+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING -+/* Verify the existence of the function. */ -+# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -+extern rettype function parameters_and_attributes -+# else /* Unsupported. */ -+# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -+_GL_WARN_EXTERN_C int _gl_warn_on_use -+# endif -+#endif -+ -+/* _GL_WARN_EXTERN_C declaration; -+ performs the declaration with C linkage. */ -+#ifndef _GL_WARN_EXTERN_C -+# if defined __cplusplus -+# define _GL_WARN_EXTERN_C extern "C" -+# else -+# define _GL_WARN_EXTERN_C extern -+# endif -+#endif -+ -+/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). -+ Or they define it with the wrong member names or define it in -+ (e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 does not define it, -+ but the pthreads-win32 library defines it in . */ -+# if ! 1 -+# if 0 -+# include -+# elif 0 -+# include -+# else -+ -+# ifdef __cplusplus -+extern "C" { -+# endif -+ -+# if !GNULIB_defined_struct_timespec -+# undef timespec -+# define timespec rpl_timespec -+struct timespec -+{ -+ time_t tv_sec; -+ long int tv_nsec; -+}; -+# define GNULIB_defined_struct_timespec 1 -+# endif -+ -+# ifdef __cplusplus -+} -+# endif -+ -+# endif -+# endif -+ -+# if !GNULIB_defined_struct_time_t_must_be_integral -+/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires -+ time_t to be an integer type, even though C99 permits floating -+ point. We don't know of any implementation that uses floating -+ point, and it is much easier to write code that doesn't have to -+ worry about that corner case, so we force the issue. */ -+struct __time_t_must_be_integral { -+ unsigned int __floating_time_t_unsupported : (time_t) 1; -+}; -+# define GNULIB_defined_struct_time_t_must_be_integral 1 -+# endif -+ -+/* Sleep for at least RQTP seconds unless interrupted, If interrupted, -+ return -1 and store the remaining time into RMTP. See -+ . */ -+# if 0 -+# if GNULIB_PORTCHECK -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# define nanosleep rpl_nanosleep -+# endif -+_GL_FUNCDECL_RPL (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp)); -+# else -+# if ! 1 -+_GL_FUNCDECL_SYS (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp) -+ _GL_ARG_NONNULL ((1))); -+# endif -+_GL_CXXALIAS_SYS (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp)); -+# endif -+_GL_CXXALIASWARN (nanosleep); -+# endif -+ -+/* Return the 'time_t' representation of TP and normalize TP. */ -+# if 0 -+# if GNULIB_PORTCHECK -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# define mktime rpl_mktime -+# endif -+_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp)); -+# else -+_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); -+# endif -+_GL_CXXALIASWARN (mktime); -+# endif -+ -+/* Convert TIMER to RESULT, assuming local time and UTC respectively. See -+ and -+ . */ -+# if 0 -+# if GNULIB_PORTCHECK -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef localtime_r -+# define localtime_r rpl_localtime_r -+# endif -+_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# else -+# if ! 1 -+_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+# endif -+_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# endif -+# if 1 -+_GL_CXXALIASWARN (localtime_r); -+# endif -+# if GNULIB_PORTCHECK -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef gmtime_r -+# define gmtime_r rpl_gmtime_r -+# endif -+_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# else -+# if ! 1 -+_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+# endif -+_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# endif -+# if 1 -+_GL_CXXALIASWARN (gmtime_r); -+# endif -+# endif -+ -+/* Convert TIMER to RESULT, assuming local time and UTC respectively. See -+ and -+ . */ -+# if 1 -+# if 0 -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef localtime -+# define localtime rpl_localtime -+# endif -+_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); -+# else -+_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer)); -+# endif -+_GL_CXXALIASWARN (localtime); -+# endif -+ -+# if 1 -+# if 0 -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef gmtime -+# define gmtime rpl_gmtime -+# endif -+_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer)); -+# else -+_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer)); -+# endif -+_GL_CXXALIASWARN (gmtime); -+# endif -+ -+/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store -+ the resulting broken-down time into TM. See -+ . */ -+# if 0 -+# if ! 1 -+_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, -+ char const *restrict __format, -+ struct tm *restrict __tm) -+ _GL_ARG_NONNULL ((1, 2, 3))); -+# endif -+_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, -+ char const *restrict __format, -+ struct tm *restrict __tm)); -+_GL_CXXALIASWARN (strptime); -+# endif -+ -+/* Convert TM to a time_t value, assuming UTC. */ -+# if 0 -+# if GNULIB_PORTCHECK -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef timegm -+# define timegm rpl_timegm -+# endif -+_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); -+# else -+# if ! 1 -+_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); -+# endif -+_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); -+# endif -+_GL_CXXALIASWARN (timegm); -+# endif -+ -+/* Encourage applications to avoid unsafe functions that can overrun -+ buffers when given outlandish struct tm values. Portable -+ applications should use strftime (or even sprintf) instead. */ -+# if defined GNULIB_POSIXCHECK -+# undef asctime -+_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+# if defined GNULIB_POSIXCHECK -+# undef asctime_r -+_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+# if defined GNULIB_POSIXCHECK -+# undef ctime -+_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+# if defined GNULIB_POSIXCHECK -+# undef ctime_r -+_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+ -+#endif -diff --git a/grub-core/gnulib/time.in.h b/grub-core/gnulib/time.in.h -new file mode 100644 -index 00000000000..81abdf46e0b ---- /dev/null -+++ b/grub-core/gnulib/time.in.h -@@ -0,0 +1,274 @@ -+/* A more-standard . -+ -+ Copyright (C) 2007-2014 Free Software Foundation, Inc. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, see . */ -+ -+#if __GNUC__ >= 3 -+@PRAGMA_SYSTEM_HEADER@ -+#endif -+@PRAGMA_COLUMNS@ -+ -+/* Don't get in the way of glibc when it includes time.h merely to -+ declare a few standard symbols, rather than to declare all the -+ symbols. Also, Solaris 8 eventually includes itself -+ recursively; if that is happening, just include the system -+ without adding our own declarations. */ -+#if (defined __need_time_t || defined __need_clock_t \ -+ || defined __need_timespec \ -+ || defined _@GUARD_PREFIX@_TIME_H) -+ -+# @INCLUDE_NEXT@ @NEXT_TIME_H@ -+ -+#else -+ -+# define _@GUARD_PREFIX@_TIME_H -+ -+# @INCLUDE_NEXT@ @NEXT_TIME_H@ -+ -+/* NetBSD 5.0 mis-defines NULL. */ -+# include -+ -+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ -+ -+/* The definition of _GL_ARG_NONNULL is copied here. */ -+ -+/* The definition of _GL_WARN_ON_USE is copied here. */ -+ -+/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). -+ Or they define it with the wrong member names or define it in -+ (e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 does not define it, -+ but the pthreads-win32 library defines it in . */ -+# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ -+# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ -+# include -+# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ -+# include -+# else -+ -+# ifdef __cplusplus -+extern "C" { -+# endif -+ -+# if !GNULIB_defined_struct_timespec -+# undef timespec -+# define timespec rpl_timespec -+struct timespec -+{ -+ time_t tv_sec; -+ long int tv_nsec; -+}; -+# define GNULIB_defined_struct_timespec 1 -+# endif -+ -+# ifdef __cplusplus -+} -+# endif -+ -+# endif -+# endif -+ -+# if !GNULIB_defined_struct_time_t_must_be_integral -+/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires -+ time_t to be an integer type, even though C99 permits floating -+ point. We don't know of any implementation that uses floating -+ point, and it is much easier to write code that doesn't have to -+ worry about that corner case, so we force the issue. */ -+struct __time_t_must_be_integral { -+ unsigned int __floating_time_t_unsupported : (time_t) 1; -+}; -+# define GNULIB_defined_struct_time_t_must_be_integral 1 -+# endif -+ -+/* Sleep for at least RQTP seconds unless interrupted, If interrupted, -+ return -1 and store the remaining time into RMTP. See -+ . */ -+# if @GNULIB_NANOSLEEP@ -+# if @REPLACE_NANOSLEEP@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# define nanosleep rpl_nanosleep -+# endif -+_GL_FUNCDECL_RPL (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp)); -+# else -+# if ! @HAVE_NANOSLEEP@ -+_GL_FUNCDECL_SYS (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp) -+ _GL_ARG_NONNULL ((1))); -+# endif -+_GL_CXXALIAS_SYS (nanosleep, int, -+ (struct timespec const *__rqtp, struct timespec *__rmtp)); -+# endif -+_GL_CXXALIASWARN (nanosleep); -+# endif -+ -+/* Return the 'time_t' representation of TP and normalize TP. */ -+# if @GNULIB_MKTIME@ -+# if @REPLACE_MKTIME@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# define mktime rpl_mktime -+# endif -+_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp)); -+# else -+_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); -+# endif -+_GL_CXXALIASWARN (mktime); -+# endif -+ -+/* Convert TIMER to RESULT, assuming local time and UTC respectively. See -+ and -+ . */ -+# if @GNULIB_TIME_R@ -+# if @REPLACE_LOCALTIME_R@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef localtime_r -+# define localtime_r rpl_localtime_r -+# endif -+_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# else -+# if ! @HAVE_DECL_LOCALTIME_R@ -+_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+# endif -+_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# endif -+# if @HAVE_DECL_LOCALTIME_R@ -+_GL_CXXALIASWARN (localtime_r); -+# endif -+# if @REPLACE_LOCALTIME_R@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef gmtime_r -+# define gmtime_r rpl_gmtime_r -+# endif -+_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# else -+# if ! @HAVE_DECL_LOCALTIME_R@ -+_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result) -+ _GL_ARG_NONNULL ((1, 2))); -+# endif -+_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, -+ struct tm *restrict __result)); -+# endif -+# if @HAVE_DECL_LOCALTIME_R@ -+_GL_CXXALIASWARN (gmtime_r); -+# endif -+# endif -+ -+/* Convert TIMER to RESULT, assuming local time and UTC respectively. See -+ and -+ . */ -+# if @GNULIB_GETTIMEOFDAY@ -+# if @REPLACE_LOCALTIME@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef localtime -+# define localtime rpl_localtime -+# endif -+_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer)); -+# else -+_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer)); -+# endif -+_GL_CXXALIASWARN (localtime); -+# endif -+ -+# if @GNULIB_GETTIMEOFDAY@ -+# if @REPLACE_GMTIME@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef gmtime -+# define gmtime rpl_gmtime -+# endif -+_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer) -+ _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer)); -+# else -+_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer)); -+# endif -+_GL_CXXALIASWARN (gmtime); -+# endif -+ -+/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store -+ the resulting broken-down time into TM. See -+ . */ -+# if @GNULIB_STRPTIME@ -+# if ! @HAVE_STRPTIME@ -+_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, -+ char const *restrict __format, -+ struct tm *restrict __tm) -+ _GL_ARG_NONNULL ((1, 2, 3))); -+# endif -+_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, -+ char const *restrict __format, -+ struct tm *restrict __tm)); -+_GL_CXXALIASWARN (strptime); -+# endif -+ -+/* Convert TM to a time_t value, assuming UTC. */ -+# if @GNULIB_TIMEGM@ -+# if @REPLACE_TIMEGM@ -+# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -+# undef timegm -+# define timegm rpl_timegm -+# endif -+_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); -+_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); -+# else -+# if ! @HAVE_TIMEGM@ -+_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); -+# endif -+_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); -+# endif -+_GL_CXXALIASWARN (timegm); -+# endif -+ -+/* Encourage applications to avoid unsafe functions that can overrun -+ buffers when given outlandish struct tm values. Portable -+ applications should use strftime (or even sprintf) instead. */ -+# if defined GNULIB_POSIXCHECK -+# undef asctime -+_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+# if defined GNULIB_POSIXCHECK -+# undef asctime_r -+_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+# if defined GNULIB_POSIXCHECK -+# undef ctime -+_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+# if defined GNULIB_POSIXCHECK -+# undef ctime_r -+_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - " -+ "better use strftime (or even sprintf) instead"); -+# endif -+ -+#endif -diff --git a/include/grub/osdep/hostfile_aros.h b/include/grub/osdep/hostfile_aros.h -index a059c0fa40a..161fbb7bdfd 100644 ---- a/include/grub/osdep/hostfile_aros.h -+++ b/include/grub/osdep/hostfile_aros.h -@@ -68,6 +68,12 @@ grub_util_rename (const char *from, const char *to) - return rename (from, to); - } - -+static inline ssize_t -+grub_util_readlink (const char *name, char *buf, size_t bufsize) -+{ -+ return readlink(name, buf, bufsize); -+} -+ - #define grub_util_mkdir(a) mkdir ((a), 0755) - - struct grub_util_fd -diff --git a/include/grub/osdep/hostfile_unix.h b/include/grub/osdep/hostfile_unix.h -index 9ffe46fa3ca..17cd3aa8b30 100644 ---- a/include/grub/osdep/hostfile_unix.h -+++ b/include/grub/osdep/hostfile_unix.h -@@ -71,6 +71,12 @@ grub_util_rename (const char *from, const char *to) - return rename (from, to); - } - -+static inline ssize_t -+grub_util_readlink (const char *name, char *buf, size_t bufsize) -+{ -+ return readlink(name, buf, bufsize); -+} -+ - #define grub_util_mkdir(a) mkdir ((a), 0755) - - #if defined (__NetBSD__) -diff --git a/include/grub/osdep/hostfile_windows.h b/include/grub/osdep/hostfile_windows.h -index bf6451b6db4..8c92d0591bb 100644 ---- a/include/grub/osdep/hostfile_windows.h -+++ b/include/grub/osdep/hostfile_windows.h -@@ -41,6 +41,8 @@ typedef struct grub_util_fd_dir *grub_util_fd_dir_t; - - int - grub_util_rename (const char *from, const char *to); -+ssize_t -+grub_util_readlink (const char *name, char *buf, size_t bufsize); - int - grub_util_unlink (const char *name); - void -diff --git a/grub-core/gnulib/Makefile.am b/grub-core/gnulib/Makefile.am -index 3444397fe37..b7c5e60e1c3 100644 ---- a/grub-core/gnulib/Makefile.am -+++ b/grub-core/gnulib/Makefile.am -@@ -21,7 +21,7 @@ - # the same distribution terms as the rest of that program. - # - # Generated by gnulib-tool. --# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname regex -+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname readlink regex - - AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects - -@@ -326,6 +326,15 @@ libgnu_a_SOURCES += gettext.h - - ## end gnulib module gettext-h - -+## begin gnulib module gettimeofday -+ -+ -+EXTRA_DIST += gettimeofday.c -+ -+EXTRA_libgnu_a_SOURCES += gettimeofday.c -+ -+## end gnulib module gettimeofday -+ - ## begin gnulib module havelib - - -@@ -596,6 +605,13 @@ EXTRA_libgnu_a_SOURCES += nl_langinfo.c - - ## end gnulib module nl_langinfo - -+## begin gnulib module pathmax -+ -+ -+EXTRA_DIST += pathmax.h -+ -+## end gnulib module pathmax -+ - ## begin gnulib module progname - - libgnu_a_SOURCES += progname.h progname.c -@@ -611,6 +627,15 @@ EXTRA_libgnu_a_SOURCES += rawmemchr.c - - ## end gnulib module rawmemchr - -+## begin gnulib module readlink -+ -+ -+EXTRA_DIST += readlink.c -+ -+EXTRA_libgnu_a_SOURCES += readlink.c -+ -+## end gnulib module readlink -+ - ## begin gnulib module realloc-posix - - -@@ -725,6 +750,15 @@ EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h - - ## end gnulib module snippet/warn-on-use - -+## begin gnulib module stat -+ -+ -+EXTRA_DIST += stat.c -+ -+EXTRA_libgnu_a_SOURCES += stat.c -+ -+## end gnulib module stat -+ - ## begin gnulib module stdalign - - BUILT_SOURCES += $(STDALIGN_H) -@@ -1280,6 +1314,102 @@ libgnu_a_SOURCES += strnlen1.h strnlen1.c - - ## end gnulib module strnlen1 - -+## begin gnulib module sys_stat -+ -+BUILT_SOURCES += sys/stat.h -+ -+# We need the following in order to create when the system -+# has one that is incomplete. -+sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -+ $(AM_V_at)$(MKDIR_P) sys -+ $(AM_V_GEN)rm -f $@-t $@ && \ -+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ -+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -+ -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ -+ -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \ -+ -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \ -+ -e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \ -+ -e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \ -+ -e 's/@''GNULIB_FUTIMENS''@/$(GNULIB_FUTIMENS)/g' \ -+ -e 's/@''GNULIB_LCHMOD''@/$(GNULIB_LCHMOD)/g' \ -+ -e 's/@''GNULIB_LSTAT''@/$(GNULIB_LSTAT)/g' \ -+ -e 's/@''GNULIB_MKDIRAT''@/$(GNULIB_MKDIRAT)/g' \ -+ -e 's/@''GNULIB_MKFIFO''@/$(GNULIB_MKFIFO)/g' \ -+ -e 's/@''GNULIB_MKFIFOAT''@/$(GNULIB_MKFIFOAT)/g' \ -+ -e 's/@''GNULIB_MKNOD''@/$(GNULIB_MKNOD)/g' \ -+ -e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \ -+ -e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \ -+ -e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \ -+ -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \ -+ -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \ -+ -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \ -+ -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \ -+ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ -+ -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \ -+ -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \ -+ -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \ -+ -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \ -+ -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \ -+ -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \ -+ -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \ -+ -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \ -+ -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \ -+ -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \ -+ -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \ -+ -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \ -+ -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \ -+ -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \ -+ -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \ -+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ -+ < $(srcdir)/sys_stat.in.h; \ -+ } > $@-t && \ -+ mv $@-t $@ -+MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t -+MOSTLYCLEANDIRS += sys -+ -+EXTRA_DIST += sys_stat.in.h -+ -+## end gnulib module sys_stat -+ -+## begin gnulib module sys_time -+ -+BUILT_SOURCES += sys/time.h -+ -+# We need the following in order to create when the system -+# doesn't have one that works with the given compiler. -+sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -+ $(AM_V_at)$(MKDIR_P) sys -+ $(AM_V_GEN)rm -f $@-t $@ && \ -+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ -+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -+ -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \ -+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -+ -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \ -+ -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \ -+ -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ -+ -e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \ -+ -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ -+ -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \ -+ -e 's/@''REPLACE_STRUCT_TIMEVAL''@/$(REPLACE_STRUCT_TIMEVAL)/g' \ -+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ -+ < $(srcdir)/sys_time.in.h; \ -+ } > $@-t && \ -+ mv $@-t $@ -+MOSTLYCLEANFILES += sys/time.h sys/time.h-t -+ -+EXTRA_DIST += sys_time.in.h -+ -+## end gnulib module sys_time -+ - ## begin gnulib module sys_types - - BUILT_SOURCES += sys/types.h -@@ -1334,6 +1464,51 @@ EXTRA_DIST += sysexits.in.h - - ## end gnulib module sysexits - -+## begin gnulib module time -+ -+BUILT_SOURCES += time.h -+ -+# We need the following in order to create when the system -+# doesn't have one that works with the given compiler. -+time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -+ $(AM_V_GEN)rm -f $@-t $@ && \ -+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ -+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \ -+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -+ -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \ -+ -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \ -+ -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \ -+ -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \ -+ -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \ -+ -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \ -+ -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \ -+ -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \ -+ -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \ -+ -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ -+ -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ -+ -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \ -+ -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \ -+ -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \ -+ -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ -+ -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ -+ -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ -+ -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ -+ -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -+ -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ -+ < $(srcdir)/time.in.h; \ -+ } > $@-t && \ -+ mv $@-t $@ -+MOSTLYCLEANFILES += time.h time.h-t -+ -+EXTRA_DIST += time.in.h -+ -+## end gnulib module time -+ - ## begin gnulib module unistd - - BUILT_SOURCES += unistd.h -diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4 -new file mode 100644 -index 00000000000..1c2d66ee261 ---- /dev/null -+++ b/m4/gettimeofday.m4 -@@ -0,0 +1,138 @@ -+# serial 21 -+ -+# Copyright (C) 2001-2003, 2005, 2007, 2009-2014 Free Software Foundation, Inc. -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. -+ -+dnl From Jim Meyering. -+ -+AC_DEFUN([gl_FUNC_GETTIMEOFDAY], -+[ -+ AC_REQUIRE([AC_C_RESTRICT]) -+ AC_REQUIRE([gl_HEADER_SYS_TIME_H]) -+ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) -+ AC_CHECK_FUNCS_ONCE([gettimeofday]) -+ -+ gl_gettimeofday_timezone=void -+ if test $ac_cv_func_gettimeofday != yes; then -+ HAVE_GETTIMEOFDAY=0 -+ else -+ gl_FUNC_GETTIMEOFDAY_CLOBBER -+ AC_CACHE_CHECK([for gettimeofday with POSIX signature], -+ [gl_cv_func_gettimeofday_posix_signature], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+ struct timeval c; -+ int gettimeofday (struct timeval *restrict, void *restrict); -+ ]], -+ [[/* glibc uses struct timezone * rather than the POSIX void * -+ if _GNU_SOURCE is defined. However, since the only portable -+ use of gettimeofday uses NULL as the second parameter, and -+ since the glibc definition is actually more typesafe, it is -+ not worth wrapping this to get a compliant signature. */ -+ int (*f) (struct timeval *restrict, void *restrict) -+ = gettimeofday; -+ int x = f (&c, 0); -+ return !(x | c.tv_sec | c.tv_usec); -+ ]])], -+ [gl_cv_func_gettimeofday_posix_signature=yes], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+int gettimeofday (struct timeval *restrict, struct timezone *restrict); -+ ]])], -+ [gl_cv_func_gettimeofday_posix_signature=almost], -+ [gl_cv_func_gettimeofday_posix_signature=no])])]) -+ if test $gl_cv_func_gettimeofday_posix_signature = almost; then -+ gl_gettimeofday_timezone='struct timezone' -+ elif test $gl_cv_func_gettimeofday_posix_signature != yes; then -+ REPLACE_GETTIMEOFDAY=1 -+ fi -+ dnl If we override 'struct timeval', we also have to override gettimeofday. -+ if test $REPLACE_STRUCT_TIMEVAL = 1; then -+ REPLACE_GETTIMEOFDAY=1 -+ fi -+ m4_ifdef([gl_FUNC_TZSET_CLOBBER], [ -+ gl_FUNC_TZSET_CLOBBER -+ case "$gl_cv_func_tzset_clobber" in -+ *yes) -+ REPLACE_GETTIMEOFDAY=1 -+ gl_GETTIMEOFDAY_REPLACE_LOCALTIME -+ AC_DEFINE([tzset], [rpl_tzset], -+ [Define to rpl_tzset if the wrapper function should be used.]) -+ AC_DEFINE([TZSET_CLOBBERS_LOCALTIME], [1], -+ [Define if tzset clobbers localtime's static buffer.]) -+ ;; -+ esac -+ ]) -+ fi -+ AC_DEFINE_UNQUOTED([GETTIMEOFDAY_TIMEZONE], [$gl_gettimeofday_timezone], -+ [Define this to 'void' or 'struct timezone' to match the system's -+ declaration of the second argument to gettimeofday.]) -+]) -+ -+ -+dnl See if gettimeofday clobbers the static buffer that localtime uses -+dnl for its return value. The gettimeofday function from Mac OS X 10.0.4 -+dnl (i.e., Darwin 1.3.7) has this problem. -+dnl -+dnl If it does, then arrange to use gettimeofday and localtime only via -+dnl the wrapper functions that work around the problem. -+ -+AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER], -+[ -+ AC_REQUIRE([gl_HEADER_SYS_TIME_H]) -+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles -+ -+ AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer], -+ [gl_cv_func_gettimeofday_clobber], -+ [AC_RUN_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+ #include -+ #include -+ #include -+ ]], -+ [[ -+ time_t t = 0; -+ struct tm *lt; -+ struct tm saved_lt; -+ struct timeval tv; -+ lt = localtime (&t); -+ saved_lt = *lt; -+ gettimeofday (&tv, NULL); -+ return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0; -+ ]])], -+ [gl_cv_func_gettimeofday_clobber=no], -+ [gl_cv_func_gettimeofday_clobber=yes], -+ [# When cross-compiling: -+ case "$host_os" in -+ # Guess all is fine on glibc systems. -+ *-gnu*) gl_cv_func_gettimeofday_clobber="guessing no" ;; -+ # If we don't know, assume the worst. -+ *) gl_cv_func_gettimeofday_clobber="guessing yes" ;; -+ esac -+ ])]) -+ -+ case "$gl_cv_func_gettimeofday_clobber" in -+ *yes) -+ REPLACE_GETTIMEOFDAY=1 -+ gl_GETTIMEOFDAY_REPLACE_LOCALTIME -+ AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], [1], -+ [Define if gettimeofday clobbers the localtime buffer.]) -+ ;; -+ esac -+]) -+ -+AC_DEFUN([gl_GETTIMEOFDAY_REPLACE_LOCALTIME], [ -+ REPLACE_GMTIME=1 -+ REPLACE_LOCALTIME=1 -+]) -+ -+# Prerequisites of lib/gettimeofday.c. -+AC_DEFUN([gl_PREREQ_GETTIMEOFDAY], [ -+ AC_CHECK_HEADERS([sys/timeb.h]) -+ AC_CHECK_FUNCS([_ftime]) -+]) -diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 -index 408918440b6..ef2ec5bcce0 100644 ---- a/m4/gnulib-cache.m4 -+++ b/m4/gnulib-cache.m4 -@@ -27,7 +27,7 @@ - - - # Specification in the form of a command-line invocation: --# gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname regex -+# gnulib-tool --import --dir=. --lib=libgnu --source-base=grub-core/gnulib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp error fnmatch getdelim getline gettext progname readlink regex - - # Specification in the form of a few gnulib-tool.m4 macro invocations: - gl_LOCAL_DIR([]) -@@ -39,6 +39,7 @@ gl_MODULES([ - getline - gettext - progname -+ readlink - regex - ]) - gl_AVOID([]) -diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 -index 7a19f60d85e..66fd0eda901 100644 ---- a/m4/gnulib-comp.m4 -+++ b/m4/gnulib-comp.m4 -@@ -60,10 +60,13 @@ AC_DEFUN([gl_EARLY], - # Code from module getopt-posix: - # Code from module gettext: - # Code from module gettext-h: -+ # Code from module gettimeofday: - # Code from module havelib: - # Code from module include_next: - # Code from module intprops: - # Code from module langinfo: -+ # Code from module largefile: -+ AC_REQUIRE([AC_SYS_LARGEFILE]) - # Code from module localcharset: - # Code from module locale: - # Code from module localeconv: -@@ -81,8 +84,10 @@ AC_DEFUN([gl_EARLY], - # Code from module multiarch: - # Code from module nl_langinfo: - # Code from module nocrash: -+ # Code from module pathmax: - # Code from module progname: - # Code from module rawmemchr: -+ # Code from module readlink: - # Code from module realloc-posix: - # Code from module regex: - # Code from module size_max: -@@ -92,6 +97,7 @@ AC_DEFUN([gl_EARLY], - # Code from module snippet/c++defs: - # Code from module snippet/warn-on-use: - # Code from module ssize_t: -+ # Code from module stat: - # Code from module stdalign: - # Code from module stdbool: - # Code from module stddef: -@@ -108,8 +114,11 @@ AC_DEFUN([gl_EARLY], - # Code from module strndup: - # Code from module strnlen: - # Code from module strnlen1: -+ # Code from module sys_stat: -+ # Code from module sys_time: - # Code from module sys_types: - # Code from module sysexits: -+ # Code from module time: - # Code from module unistd: - # Code from module unitypes: - # Code from module uniwidth/base: -@@ -211,7 +220,14 @@ AC_DEFUN([gl_INIT], - AM_GNU_GETTEXT_VERSION([0.18.1]) - AC_SUBST([LIBINTL]) - AC_SUBST([LTLIBINTL]) -+ gl_FUNC_GETTIMEOFDAY -+ if test $HAVE_GETTIMEOFDAY = 0 || test $REPLACE_GETTIMEOFDAY = 1; then -+ AC_LIBOBJ([gettimeofday]) -+ gl_PREREQ_GETTIMEOFDAY -+ fi -+ gl_SYS_TIME_MODULE_INDICATOR([gettimeofday]) - gl_LANGINFO_H -+ AC_REQUIRE([gl_LARGEFILE]) - gl_LOCALCHARSET - LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(abs_top_builddir)/$gl_source_base\"" - AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT]) -@@ -284,6 +300,7 @@ AC_DEFUN([gl_INIT], - AC_LIBOBJ([nl_langinfo]) - fi - gl_LANGINFO_MODULE_INDICATOR([nl_langinfo]) -+ gl_PATHMAX - AC_CHECK_DECLS([program_invocation_name], [], [], [#include ]) - AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include ]) - gl_FUNC_RAWMEMCHR -@@ -292,6 +309,12 @@ AC_DEFUN([gl_INIT], - gl_PREREQ_RAWMEMCHR - fi - gl_STRING_MODULE_INDICATOR([rawmemchr]) -+ gl_FUNC_READLINK -+ if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then -+ AC_LIBOBJ([readlink]) -+ gl_PREREQ_READLINK -+ fi -+ gl_UNISTD_MODULE_INDICATOR([readlink]) - gl_FUNC_REALLOC_POSIX - if test $REPLACE_REALLOC = 1; then - AC_LIBOBJ([realloc]) -@@ -309,6 +332,12 @@ AC_DEFUN([gl_INIT], - fi - gl_UNISTD_MODULE_INDICATOR([sleep]) - gt_TYPE_SSIZE_T -+ gl_FUNC_STAT -+ if test $REPLACE_STAT = 1; then -+ AC_LIBOBJ([stat]) -+ gl_PREREQ_STAT -+ fi -+ gl_SYS_STAT_MODULE_INDICATOR([stat]) - gl_STDALIGN_H - AM_STDBOOL_H - gl_STDDEF_H -@@ -355,9 +384,14 @@ AC_DEFUN([gl_INIT], - gl_PREREQ_STRNLEN - fi - gl_STRING_MODULE_INDICATOR([strnlen]) -+ gl_HEADER_SYS_STAT_H -+ AC_PROG_MKDIR_P -+ gl_HEADER_SYS_TIME_H -+ AC_PROG_MKDIR_P - gl_SYS_TYPES_H - AC_PROG_MKDIR_P - gl_SYSEXITS -+ gl_HEADER_TIME_H - gl_UNISTD_H - gl_LIBUNISTRING_LIBHEADER([0.9], [unitypes.h]) - gl_LIBUNISTRING_LIBHEADER([0.9], [uniwidth.h]) -@@ -562,6 +596,7 @@ AC_DEFUN([gl_FILE_LIST], [ - lib/getopt1.c - lib/getopt_int.h - lib/gettext.h -+ lib/gettimeofday.c - lib/intprops.h - lib/itold.c - lib/langinfo.in.h -@@ -587,6 +622,7 @@ AC_DEFUN([gl_FILE_LIST], [ - lib/msvc-nothrow.c - lib/msvc-nothrow.h - lib/nl_langinfo.c -+ lib/pathmax.h - lib/printf-args.c - lib/printf-args.h - lib/printf-parse.c -@@ -595,6 +631,7 @@ AC_DEFUN([gl_FILE_LIST], [ - lib/progname.h - lib/rawmemchr.c - lib/rawmemchr.valgrind -+ lib/readlink.c - lib/realloc.c - lib/ref-add.sin - lib/ref-del.sin -@@ -606,6 +643,7 @@ AC_DEFUN([gl_FILE_LIST], [ - lib/regexec.c - lib/size_max.h - lib/sleep.c -+ lib/stat.c - lib/stdalign.in.h - lib/stdbool.in.h - lib/stddef.in.h -@@ -627,8 +665,11 @@ AC_DEFUN([gl_FILE_LIST], [ - lib/strnlen.c - lib/strnlen1.c - lib/strnlen1.h -+ lib/sys_stat.in.h -+ lib/sys_time.in.h - lib/sys_types.in.h - lib/sysexits.in.h -+ lib/time.in.h - lib/unistd.c - lib/unistd.in.h - lib/unitypes.in.h -@@ -667,6 +708,7 @@ AC_DEFUN([gl_FILE_LIST], [ - m4/getline.m4 - m4/getopt.m4 - m4/gettext.m4 -+ m4/gettimeofday.m4 - m4/glibc2.m4 - m4/glibc21.m4 - m4/gnulib-common.m4 -@@ -681,6 +723,7 @@ AC_DEFUN([gl_FILE_LIST], [ - m4/inttypes-pri.m4 - m4/inttypes_h.m4 - m4/langinfo_h.m4 -+ m4/largefile.m4 - m4/lcmessage.m4 - m4/lib-ld.m4 - m4/lib-link.m4 -@@ -712,16 +755,19 @@ AC_DEFUN([gl_FILE_LIST], [ - m4/nls.m4 - m4/nocrash.m4 - m4/off_t.m4 -+ m4/pathmax.m4 - m4/po.m4 - m4/printf-posix.m4 - m4/printf.m4 - m4/progtest.m4 - m4/rawmemchr.m4 -+ m4/readlink.m4 - m4/realloc.m4 - m4/regex.m4 - m4/size_max.m4 - m4/sleep.m4 - m4/ssize_t.m4 -+ m4/stat.m4 - m4/stdalign.m4 - m4/stdbool.m4 - m4/stddef_h.m4 -@@ -737,9 +783,12 @@ AC_DEFUN([gl_FILE_LIST], [ - m4/strndup.m4 - m4/strnlen.m4 - m4/sys_socket_h.m4 -+ m4/sys_stat_h.m4 -+ m4/sys_time_h.m4 - m4/sys_types_h.m4 - m4/sysexits.m4 - m4/threadlib.m4 -+ m4/time_h.m4 - m4/uintmax_t.m4 - m4/unistd_h.m4 - m4/vasnprintf.m4 -diff --git a/m4/largefile.m4 b/m4/largefile.m4 -new file mode 100644 -index 00000000000..a1b564ad9af ---- /dev/null -+++ b/m4/largefile.m4 -@@ -0,0 +1,146 @@ -+# Enable large files on systems where this is not the default. -+ -+# Copyright 1992-1996, 1998-2014 Free Software Foundation, Inc. -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. -+ -+# The following implementation works around a problem in autoconf <= 2.69; -+# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5, -+# or configures them incorrectly in some cases. -+m4_version_prereq([2.70], [] ,[ -+ -+# _AC_SYS_LARGEFILE_TEST_INCLUDES -+# ------------------------------- -+m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], -+[@%:@include -+ /* Check that off_t can represent 2**63 - 1 correctly. -+ We can't simply define LARGE_OFF_T to be 9223372036854775807, -+ since some C++ compilers masquerading as C compilers -+ incorrectly reject 9223372036854775807. */ -+@%:@define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) -+ int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721 -+ && LARGE_OFF_T % 2147483647 == 1) -+ ? 1 : -1]];[]dnl -+]) -+ -+ -+# _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, -+# CACHE-VAR, -+# DESCRIPTION, -+# PROLOGUE, [FUNCTION-BODY]) -+# -------------------------------------------------------- -+m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE], -+[AC_CACHE_CHECK([for $1 value needed for large files], [$3], -+[while :; do -+ m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])( -+ [AC_LANG_PROGRAM([$5], [$6])], -+ [$3=no; break]) -+ m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])( -+ [AC_LANG_PROGRAM([@%:@define $1 $2 -+$5], [$6])], -+ [$3=$2; break]) -+ $3=unknown -+ break -+done]) -+case $$3 in #( -+ no | unknown) ;; -+ *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);; -+esac -+rm -rf conftest*[]dnl -+])# _AC_SYS_LARGEFILE_MACRO_VALUE -+ -+ -+# AC_SYS_LARGEFILE -+# ---------------- -+# By default, many hosts won't let programs access large files; -+# one must use special compiler options to get large-file access to work. -+# For more details about this brain damage please see: -+# http://www.unix-systems.org/version2/whatsnew/lfs20mar.html -+AC_DEFUN([AC_SYS_LARGEFILE], -+[AC_ARG_ENABLE(largefile, -+ [ --disable-largefile omit support for large files]) -+if test "$enable_largefile" != no; then -+ -+ AC_CACHE_CHECK([for special C compiler options needed for large files], -+ ac_cv_sys_largefile_CC, -+ [ac_cv_sys_largefile_CC=no -+ if test "$GCC" != yes; then -+ ac_save_CC=$CC -+ while :; do -+ # IRIX 6.2 and later do not support large files by default, -+ # so use the C compiler's -n32 option if that helps. -+ AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])]) -+ AC_COMPILE_IFELSE([], [break]) -+ CC="$CC -n32" -+ AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break]) -+ break -+ done -+ CC=$ac_save_CC -+ rm -f conftest.$ac_ext -+ fi]) -+ if test "$ac_cv_sys_largefile_CC" != no; then -+ CC=$CC$ac_cv_sys_largefile_CC -+ fi -+ -+ _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, -+ ac_cv_sys_file_offset_bits, -+ [Number of bits in a file offset, on hosts where this is settable.], -+ [_AC_SYS_LARGEFILE_TEST_INCLUDES]) -+ if test $ac_cv_sys_file_offset_bits = unknown; then -+ _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, -+ ac_cv_sys_large_files, -+ [Define for large files, on AIX-style hosts.], -+ [_AC_SYS_LARGEFILE_TEST_INCLUDES]) -+ fi -+ -+ AC_DEFINE([_DARWIN_USE_64_BIT_INODE], [1], -+ [Enable large inode numbers on Mac OS X 10.5.]) -+fi -+])# AC_SYS_LARGEFILE -+])# m4_version_prereq 2.70 -+ -+# Enable large files on systems where this is implemented by Gnulib, not by the -+# system headers. -+# Set the variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE if Gnulib -+# overrides ensure that off_t or 'struct size.st_size' are 64-bit, respectively. -+AC_DEFUN([gl_LARGEFILE], -+[ -+ AC_REQUIRE([AC_CANONICAL_HOST]) -+ case "$host_os" in -+ mingw*) -+ dnl Native Windows. -+ dnl mingw64 defines off_t to a 64-bit type already, if -+ dnl _FILE_OFFSET_BITS=64, which is ensured by AC_SYS_LARGEFILE. -+ AC_CACHE_CHECK([for 64-bit off_t], [gl_cv_type_off_t_64], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+ int verify_off_t_size[sizeof (off_t) >= 8 ? 1 : -1]; -+ ]], -+ [[]])], -+ [gl_cv_type_off_t_64=yes], [gl_cv_type_off_t_64=no]) -+ ]) -+ if test $gl_cv_type_off_t_64 = no; then -+ WINDOWS_64_BIT_OFF_T=1 -+ else -+ WINDOWS_64_BIT_OFF_T=0 -+ fi -+ dnl But all native Windows platforms (including mingw64) have a 32-bit -+ dnl st_size member in 'struct stat'. -+ WINDOWS_64_BIT_ST_SIZE=1 -+ ;; -+ *) -+ dnl Nothing to do on gnulib's side. -+ dnl A 64-bit off_t is -+ dnl - already the default on Mac OS X, FreeBSD, NetBSD, OpenBSD, IRIX, -+ dnl OSF/1, Cygwin, -+ dnl - enabled by _FILE_OFFSET_BITS=64 (ensured by AC_SYS_LARGEFILE) on -+ dnl glibc, HP-UX, Solaris, -+ dnl - enabled by _LARGE_FILES=1 (ensured by AC_SYS_LARGEFILE) on AIX, -+ dnl - impossible to achieve on Minix 3.1.8. -+ WINDOWS_64_BIT_OFF_T=0 -+ WINDOWS_64_BIT_ST_SIZE=0 -+ ;; -+ esac -+]) -diff --git a/m4/pathmax.m4 b/m4/pathmax.m4 -new file mode 100644 -index 00000000000..114f91f04b5 ---- /dev/null -+++ b/m4/pathmax.m4 -@@ -0,0 +1,42 @@ -+# pathmax.m4 serial 10 -+dnl Copyright (C) 2002-2003, 2005-2006, 2009-2014 Free Software Foundation, -+dnl Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+ -+AC_DEFUN([gl_PATHMAX], -+[ -+ dnl Prerequisites of lib/pathmax.h. -+ AC_CHECK_HEADERS_ONCE([sys/param.h]) -+]) -+ -+# Expands to a piece of C program that defines PATH_MAX in the same way as -+# "pathmax.h" will do. -+AC_DEFUN([gl_PATHMAX_SNIPPET], [[ -+/* Arrange to define PATH_MAX, like "pathmax.h" does. */ -+#if HAVE_UNISTD_H -+# include -+#endif -+#include -+#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN -+# include -+#endif -+#if !defined PATH_MAX && defined MAXPATHLEN -+# define PATH_MAX MAXPATHLEN -+#endif -+#ifdef __hpux -+# undef PATH_MAX -+# define PATH_MAX 1024 -+#endif -+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -+# undef PATH_MAX -+# define PATH_MAX 260 -+#endif -+]]) -+ -+# Prerequisites of gl_PATHMAX_SNIPPET. -+AC_DEFUN([gl_PATHMAX_SNIPPET_PREREQ], -+[ -+ AC_CHECK_HEADERS_ONCE([unistd.h sys/param.h]) -+]) -diff --git a/m4/readlink.m4 b/m4/readlink.m4 -new file mode 100644 -index 00000000000..f9ce868c2e4 ---- /dev/null -+++ b/m4/readlink.m4 -@@ -0,0 +1,71 @@ -+# readlink.m4 serial 12 -+dnl Copyright (C) 2003, 2007, 2009-2014 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+ -+AC_DEFUN([gl_FUNC_READLINK], -+[ -+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) -+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles -+ AC_CHECK_FUNCS_ONCE([readlink]) -+ if test $ac_cv_func_readlink = no; then -+ HAVE_READLINK=0 -+ else -+ AC_CACHE_CHECK([whether readlink signature is correct], -+ [gl_cv_decl_readlink_works], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+ /* Cause compilation failure if original declaration has wrong type. */ -+ ssize_t readlink (const char *, char *, size_t);]])], -+ [gl_cv_decl_readlink_works=yes], [gl_cv_decl_readlink_works=no])]) -+ dnl Solaris 9 ignores trailing slash. -+ dnl FreeBSD 7.2 dereferences only one level of links with trailing slash. -+ AC_CACHE_CHECK([whether readlink handles trailing slash correctly], -+ [gl_cv_func_readlink_works], -+ [# We have readlink, so assume ln -s works. -+ ln -s conftest.no-such conftest.link -+ ln -s conftest.link conftest.lnk2 -+ AC_RUN_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+]], [[char buf[20]; -+ return readlink ("conftest.lnk2/", buf, sizeof buf) != -1;]])], -+ [gl_cv_func_readlink_works=yes], [gl_cv_func_readlink_works=no], -+ [case "$host_os" in -+ # Guess yes on glibc systems. -+ *-gnu*) gl_cv_func_readlink_works="guessing yes" ;; -+ # If we don't know, assume the worst. -+ *) gl_cv_func_readlink_works="guessing no" ;; -+ esac -+ ]) -+ rm -f conftest.link conftest.lnk2]) -+ case "$gl_cv_func_readlink_works" in -+ *yes) -+ if test "$gl_cv_decl_readlink_works" != yes; then -+ REPLACE_READLINK=1 -+ fi -+ ;; -+ *) -+ AC_DEFINE([READLINK_TRAILING_SLASH_BUG], [1], [Define to 1 if readlink -+ fails to recognize a trailing slash.]) -+ REPLACE_READLINK=1 -+ ;; -+ esac -+ fi -+]) -+ -+# Like gl_FUNC_READLINK, except prepare for separate compilation -+# (no REPLACE_READLINK, no AC_LIBOBJ). -+AC_DEFUN([gl_FUNC_READLINK_SEPARATE], -+[ -+ AC_CHECK_FUNCS_ONCE([readlink]) -+ gl_PREREQ_READLINK -+]) -+ -+# Prerequisites of lib/readlink.c. -+AC_DEFUN([gl_PREREQ_READLINK], -+[ -+ : -+]) -diff --git a/m4/stat.m4 b/m4/stat.m4 -new file mode 100644 -index 00000000000..1ae327b3684 ---- /dev/null -+++ b/m4/stat.m4 -@@ -0,0 +1,71 @@ -+# serial 11 -+ -+# Copyright (C) 2009-2014 Free Software Foundation, Inc. -+# -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. -+ -+AC_DEFUN([gl_FUNC_STAT], -+[ -+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles -+ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) -+ AC_CHECK_FUNCS_ONCE([lstat]) -+ dnl mingw is the only known platform where stat(".") and stat("./") differ -+ AC_CACHE_CHECK([whether stat handles trailing slashes on directories], -+ [gl_cv_func_stat_dir_slash], -+ [AC_RUN_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+]], [[struct stat st; return stat (".", &st) != stat ("./", &st);]])], -+ [gl_cv_func_stat_dir_slash=yes], [gl_cv_func_stat_dir_slash=no], -+ [case $host_os in -+ mingw*) gl_cv_func_stat_dir_slash="guessing no";; -+ *) gl_cv_func_stat_dir_slash="guessing yes";; -+ esac])]) -+ dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/"). -+ dnl (For mingw, this is due to a broken stat() override in libmingwex.a.) -+ dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/"). -+ AC_CACHE_CHECK([whether stat handles trailing slashes on files], -+ [gl_cv_func_stat_file_slash], -+ [touch conftest.tmp -+ # Assume that if we have lstat, we can also check symlinks. -+ if test $ac_cv_func_lstat = yes; then -+ ln -s conftest.tmp conftest.lnk -+ fi -+ AC_RUN_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+]], [[int result = 0; -+ struct stat st; -+ if (!stat ("conftest.tmp/", &st)) -+ result |= 1; -+#if HAVE_LSTAT -+ if (!stat ("conftest.lnk/", &st)) -+ result |= 2; -+#endif -+ return result; -+ ]])], -+ [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no], -+ [case "$host_os" in -+ # Guess yes on glibc systems. -+ *-gnu*) gl_cv_func_stat_file_slash="guessing yes" ;; -+ # If we don't know, assume the worst. -+ *) gl_cv_func_stat_file_slash="guessing no" ;; -+ esac -+ ]) -+ rm -f conftest.tmp conftest.lnk]) -+ case $gl_cv_func_stat_dir_slash in -+ *no) REPLACE_STAT=1 -+ AC_DEFINE([REPLACE_FUNC_STAT_DIR], [1], [Define to 1 if stat needs -+ help when passed a directory name with a trailing slash]);; -+ esac -+ case $gl_cv_func_stat_file_slash in -+ *no) REPLACE_STAT=1 -+ AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs -+ help when passed a file name with a trailing slash]);; -+ esac -+]) -+ -+# Prerequisites of lib/stat.c. -+AC_DEFUN([gl_PREREQ_STAT], [:]) -diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4 -new file mode 100644 -index 00000000000..eaa7642ba31 ---- /dev/null -+++ b/m4/sys_stat_h.m4 -@@ -0,0 +1,96 @@ -+# sys_stat_h.m4 serial 28 -*- Autoconf -*- -+dnl Copyright (C) 2006-2014 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+ -+dnl From Eric Blake. -+dnl Provide a GNU-like . -+ -+AC_DEFUN([gl_HEADER_SYS_STAT_H], -+[ -+ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) -+ -+ dnl Check for broken stat macros. -+ AC_REQUIRE([AC_HEADER_STAT]) -+ -+ gl_CHECK_NEXT_HEADERS([sys/stat.h]) -+ -+ dnl Ensure the type mode_t gets defined. -+ AC_REQUIRE([AC_TYPE_MODE_T]) -+ -+ dnl Whether to override 'struct stat'. -+ m4_ifdef([gl_LARGEFILE], [ -+ AC_REQUIRE([gl_LARGEFILE]) -+ ], [ -+ WINDOWS_64_BIT_ST_SIZE=0 -+ ]) -+ AC_SUBST([WINDOWS_64_BIT_ST_SIZE]) -+ if test $WINDOWS_64_BIT_ST_SIZE = 1; then -+ AC_DEFINE([_GL_WINDOWS_64_BIT_ST_SIZE], [1], -+ [Define to 1 if Gnulib overrides 'struct stat' on Windows so that -+ struct stat.st_size becomes 64-bit.]) -+ fi -+ -+ dnl Define types that are supposed to be defined in or -+ dnl . -+ AC_CHECK_TYPE([nlink_t], [], -+ [AC_DEFINE([nlink_t], [int], -+ [Define to the type of st_nlink in struct stat, or a supertype.])], -+ [#include -+ #include ]) -+ -+ dnl Check for declarations of anything we want to poison if the -+ dnl corresponding gnulib module is not in use. -+ gl_WARN_ON_USE_PREPARE([[#include -+ ]], [fchmodat fstat fstatat futimens lchmod lstat mkdirat mkfifo mkfifoat -+ mknod mknodat stat utimensat]) -+]) # gl_HEADER_SYS_STAT_H -+ -+AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR], -+[ -+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. -+ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) -+ gl_MODULE_INDICATOR_SET_VARIABLE([$1]) -+ dnl Define it also as a C macro, for the benefit of the unit tests. -+ gl_MODULE_INDICATOR_FOR_TESTS([$1]) -+]) -+ -+AC_DEFUN([gl_SYS_STAT_H_DEFAULTS], -+[ -+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR -+ GNULIB_FCHMODAT=0; AC_SUBST([GNULIB_FCHMODAT]) -+ GNULIB_FSTAT=0; AC_SUBST([GNULIB_FSTAT]) -+ GNULIB_FSTATAT=0; AC_SUBST([GNULIB_FSTATAT]) -+ GNULIB_FUTIMENS=0; AC_SUBST([GNULIB_FUTIMENS]) -+ GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD]) -+ GNULIB_LSTAT=0; AC_SUBST([GNULIB_LSTAT]) -+ GNULIB_MKDIRAT=0; AC_SUBST([GNULIB_MKDIRAT]) -+ GNULIB_MKFIFO=0; AC_SUBST([GNULIB_MKFIFO]) -+ GNULIB_MKFIFOAT=0; AC_SUBST([GNULIB_MKFIFOAT]) -+ GNULIB_MKNOD=0; AC_SUBST([GNULIB_MKNOD]) -+ GNULIB_MKNODAT=0; AC_SUBST([GNULIB_MKNODAT]) -+ GNULIB_STAT=0; AC_SUBST([GNULIB_STAT]) -+ GNULIB_UTIMENSAT=0; AC_SUBST([GNULIB_UTIMENSAT]) -+ dnl Assume proper GNU behavior unless another module says otherwise. -+ HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT]) -+ HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT]) -+ HAVE_FUTIMENS=1; AC_SUBST([HAVE_FUTIMENS]) -+ HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD]) -+ HAVE_LSTAT=1; AC_SUBST([HAVE_LSTAT]) -+ HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT]) -+ HAVE_MKFIFO=1; AC_SUBST([HAVE_MKFIFO]) -+ HAVE_MKFIFOAT=1; AC_SUBST([HAVE_MKFIFOAT]) -+ HAVE_MKNOD=1; AC_SUBST([HAVE_MKNOD]) -+ HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT]) -+ HAVE_UTIMENSAT=1; AC_SUBST([HAVE_UTIMENSAT]) -+ REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT]) -+ REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT]) -+ REPLACE_FUTIMENS=0; AC_SUBST([REPLACE_FUTIMENS]) -+ REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT]) -+ REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR]) -+ REPLACE_MKFIFO=0; AC_SUBST([REPLACE_MKFIFO]) -+ REPLACE_MKNOD=0; AC_SUBST([REPLACE_MKNOD]) -+ REPLACE_STAT=0; AC_SUBST([REPLACE_STAT]) -+ REPLACE_UTIMENSAT=0; AC_SUBST([REPLACE_UTIMENSAT]) -+]) -diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4 -new file mode 100644 -index 00000000000..5c79300f8ec ---- /dev/null -+++ b/m4/sys_time_h.m4 -@@ -0,0 +1,110 @@ -+# Configure a replacement for . -+# serial 8 -+ -+# Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc. -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. -+ -+# Written by Paul Eggert and Martin Lambers. -+ -+AC_DEFUN([gl_HEADER_SYS_TIME_H], -+[ -+ dnl Use AC_REQUIRE here, so that the REPLACE_GETTIMEOFDAY=0 statement -+ dnl below is expanded once only, before all REPLACE_GETTIMEOFDAY=1 -+ dnl statements that occur in other macros. -+ AC_REQUIRE([gl_HEADER_SYS_TIME_H_BODY]) -+]) -+ -+AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY], -+[ -+ AC_REQUIRE([AC_C_RESTRICT]) -+ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) -+ AC_CHECK_HEADERS_ONCE([sys/time.h]) -+ gl_CHECK_NEXT_HEADERS([sys/time.h]) -+ -+ if test $ac_cv_header_sys_time_h != yes; then -+ HAVE_SYS_TIME_H=0 -+ fi -+ -+ dnl On native Windows with MSVC, 'struct timeval' is defined in -+ dnl only. So include that header in the list. -+ gl_PREREQ_SYS_H_WINSOCK2 -+ AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#if HAVE_SYS_TIME_H -+ #include -+ #endif -+ #include -+ #if HAVE_WINSOCK2_H -+ # include -+ #endif -+ ]], -+ [[static struct timeval x; x.tv_sec = x.tv_usec;]])], -+ [gl_cv_sys_struct_timeval=yes], -+ [gl_cv_sys_struct_timeval=no]) -+ ]) -+ if test $gl_cv_sys_struct_timeval != yes; then -+ HAVE_STRUCT_TIMEVAL=0 -+ else -+ dnl On native Windows with a 64-bit 'time_t', 'struct timeval' is defined -+ dnl (in and for mingw64, in only -+ dnl for MSVC) with a tv_sec field of type 'long' (32-bit!), which is -+ dnl smaller than the 'time_t' type mandated by POSIX. -+ dnl On OpenBSD 5.1 amd64, tv_sec is 64 bits and time_t 32 bits, but -+ dnl that is good enough. -+ AC_CACHE_CHECK([for wide-enough struct timeval.tv_sec member], -+ [gl_cv_sys_struct_timeval_tv_sec], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#if HAVE_SYS_TIME_H -+ #include -+ #endif -+ #include -+ #if HAVE_WINSOCK2_H -+ # include -+ #endif -+ ]], -+ [[static struct timeval x; -+ typedef int verify_tv_sec_type[ -+ sizeof (time_t) <= sizeof x.tv_sec ? 1 : -1 -+ ]; -+ ]])], -+ [gl_cv_sys_struct_timeval_tv_sec=yes], -+ [gl_cv_sys_struct_timeval_tv_sec=no]) -+ ]) -+ if test $gl_cv_sys_struct_timeval_tv_sec != yes; then -+ REPLACE_STRUCT_TIMEVAL=1 -+ fi -+ fi -+ -+ dnl Check for declarations of anything we want to poison if the -+ dnl corresponding gnulib module is not in use. -+ gl_WARN_ON_USE_PREPARE([[ -+#if HAVE_SYS_TIME_H -+# include -+#endif -+#include -+ ]], [gettimeofday]) -+]) -+ -+AC_DEFUN([gl_SYS_TIME_MODULE_INDICATOR], -+[ -+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. -+ AC_REQUIRE([gl_HEADER_SYS_TIME_H_DEFAULTS]) -+ gl_MODULE_INDICATOR_SET_VARIABLE([$1]) -+ dnl Define it also as a C macro, for the benefit of the unit tests. -+ gl_MODULE_INDICATOR_FOR_TESTS([$1]) -+]) -+ -+AC_DEFUN([gl_HEADER_SYS_TIME_H_DEFAULTS], -+[ -+ GNULIB_GETTIMEOFDAY=0; AC_SUBST([GNULIB_GETTIMEOFDAY]) -+ dnl Assume POSIX behavior unless another module says otherwise. -+ HAVE_GETTIMEOFDAY=1; AC_SUBST([HAVE_GETTIMEOFDAY]) -+ HAVE_STRUCT_TIMEVAL=1; AC_SUBST([HAVE_STRUCT_TIMEVAL]) -+ HAVE_SYS_TIME_H=1; AC_SUBST([HAVE_SYS_TIME_H]) -+ REPLACE_GETTIMEOFDAY=0; AC_SUBST([REPLACE_GETTIMEOFDAY]) -+ REPLACE_STRUCT_TIMEVAL=0; AC_SUBST([REPLACE_STRUCT_TIMEVAL]) -+]) -diff --git a/m4/time_h.m4 b/m4/time_h.m4 -new file mode 100644 -index 00000000000..9852778f9a5 ---- /dev/null -+++ b/m4/time_h.m4 -@@ -0,0 +1,118 @@ -+# Configure a more-standard replacement for . -+ -+# Copyright (C) 2000-2001, 2003-2007, 2009-2014 Free Software Foundation, Inc. -+ -+# serial 8 -+ -+# This file is free software; the Free Software Foundation -+# gives unlimited permission to copy and/or distribute it, -+# with or without modifications, as long as this notice is preserved. -+ -+# Written by Paul Eggert and Jim Meyering. -+ -+AC_DEFUN([gl_HEADER_TIME_H], -+[ -+ dnl Use AC_REQUIRE here, so that the default behavior below is expanded -+ dnl once only, before all statements that occur in other macros. -+ AC_REQUIRE([gl_HEADER_TIME_H_BODY]) -+]) -+ -+AC_DEFUN([gl_HEADER_TIME_H_BODY], -+[ -+ AC_REQUIRE([AC_C_RESTRICT]) -+ AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) -+ gl_NEXT_HEADERS([time.h]) -+ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC]) -+]) -+ -+dnl Check whether 'struct timespec' is declared -+dnl in time.h, sys/time.h, or pthread.h. -+ -+AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], -+[ -+ AC_CHECK_HEADERS_ONCE([sys/time.h]) -+ AC_CACHE_CHECK([for struct timespec in ], -+ [gl_cv_sys_struct_timespec_in_time_h], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+ ]], -+ [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], -+ [gl_cv_sys_struct_timespec_in_time_h=yes], -+ [gl_cv_sys_struct_timespec_in_time_h=no])]) -+ -+ TIME_H_DEFINES_STRUCT_TIMESPEC=0 -+ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 -+ PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 -+ if test $gl_cv_sys_struct_timespec_in_time_h = yes; then -+ TIME_H_DEFINES_STRUCT_TIMESPEC=1 -+ else -+ AC_CACHE_CHECK([for struct timespec in ], -+ [gl_cv_sys_struct_timespec_in_sys_time_h], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+ ]], -+ [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], -+ [gl_cv_sys_struct_timespec_in_sys_time_h=yes], -+ [gl_cv_sys_struct_timespec_in_sys_time_h=no])]) -+ if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then -+ SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1 -+ else -+ AC_CACHE_CHECK([for struct timespec in ], -+ [gl_cv_sys_struct_timespec_in_pthread_h], -+ [AC_COMPILE_IFELSE( -+ [AC_LANG_PROGRAM( -+ [[#include -+ ]], -+ [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], -+ [gl_cv_sys_struct_timespec_in_pthread_h=yes], -+ [gl_cv_sys_struct_timespec_in_pthread_h=no])]) -+ if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then -+ PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 -+ fi -+ fi -+ fi -+ AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) -+ AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) -+ AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC]) -+]) -+ -+AC_DEFUN([gl_TIME_MODULE_INDICATOR], -+[ -+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. -+ AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) -+ gl_MODULE_INDICATOR_SET_VARIABLE([$1]) -+ dnl Define it also as a C macro, for the benefit of the unit tests. -+ gl_MODULE_INDICATOR_FOR_TESTS([$1]) -+]) -+ -+AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], -+[ -+ GNULIB_MKTIME=0; AC_SUBST([GNULIB_MKTIME]) -+ GNULIB_NANOSLEEP=0; AC_SUBST([GNULIB_NANOSLEEP]) -+ GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME]) -+ GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM]) -+ GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R]) -+ dnl Assume proper GNU behavior unless another module says otherwise. -+ HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R]) -+ HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) -+ HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) -+ HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) -+ dnl If another module says to replace or to not replace, do that. -+ dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; -+ dnl this lets maintainers check for portability. -+ REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R]) -+ REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME]) -+ REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) -+ REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) -+ -+ dnl Hack so that the time module doesn't depend on the sys_time module. -+ dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent. -+ : ${GNULIB_GETTIMEOFDAY=0}; AC_SUBST([GNULIB_GETTIMEOFDAY]) -+ dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME -+ dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier -+ dnl is no longer a big deal. -+ REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME]) -+ REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME]) -+]) diff --git a/0057-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch b/0054-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch similarity index 83% rename from 0057-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch rename to 0054-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch index fc296338fd0965aa24b731dbeabc49e66805039f..b34aed433eb108ce5ae8fd4be9376a34bcfef63b 100644 --- a/0057-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch +++ b/0054-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 0fe1927a2ff37806bcdca1243dd2df9cba116091 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 4 Sep 2014 15:52:08 -0400 -Subject: [PATCH] Minimize the sort ordering for .debug and -rescue- kernels. +Subject: [PATCH 054/220] Minimize the sort ordering for .debug and -rescue- + kernels. Resolves: rhbz#1065360 Signed-off-by: Peter Jones @@ -10,7 +11,7 @@ Signed-off-by: Peter Jones 1 file changed, 8 insertions(+) diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 1001a12232b..1a4a57898f9 100644 +index 1001a12..1a4a578 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -249,6 +249,14 @@ version_test_gt () @@ -28,3 +29,6 @@ index 1001a12232b..1a4a57898f9 100644 esac version_test_numeric "$version_test_gt_a" "$version_test_gt_cmp" "$version_test_gt_b" return "$?" +-- +1.8.3.1 + diff --git a/0058-Try-prefix-if-fw_path-doesn-t-work.patch b/0055-Try-prefix-if-fw_path-doesn-t-work.patch similarity index 54% rename from 0058-Try-prefix-if-fw_path-doesn-t-work.patch rename to 0055-Try-prefix-if-fw_path-doesn-t-work.patch index 1ded908949b58826b1d48342fade3ac878bd8f72..ff684db40404ab27ffd596aa8c5677fea53e34b6 100644 --- a/0058-Try-prefix-if-fw_path-doesn-t-work.patch +++ b/0055-Try-prefix-if-fw_path-doesn-t-work.patch @@ -1,22 +1,22 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 75f23ba5e4f8e84b595b0b13f5f7ed744a866099 Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Fri, 3 Oct 2014 11:08:03 -0400 -Subject: [PATCH] Try $prefix if $fw_path doesn't work. +Date: Tue, 9 Jul 2019 10:35:16 +0200 +Subject: [PATCH 055/220] Try $prefix if $fw_path doesn't work. Related: rhbz#1148652 Signed-off-by: Peter Jones --- - grub-core/kern/ieee1275/init.c | 28 +++++----- + grub-core/kern/ieee1275/init.c | 30 ++++++----- grub-core/net/net.c | 2 +- - grub-core/normal/main.c | 120 ++++++++++++++++++++--------------------- + grub-core/normal/main.c | 118 ++++++++++++++++++++--------------------- 3 files changed, 75 insertions(+), 75 deletions(-) diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index f5423ce27d9..e01bc6eab19 100644 +index e71d158..0cd2a62 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c -@@ -124,23 +124,25 @@ grub_machine_get_bootlocation (char **device, char **path) +@@ -127,23 +127,25 @@ grub_machine_get_bootlocation (char **device, char **path) grub_free (canon); } else @@ -35,10 +35,11 @@ index f5423ce27d9..e01bc6eab19 100644 { - *lastslash = '\0'; - grub_translate_ieee1275_path (filename); -+ char *lastslash = grub_strrchr (filename, '\\'); - +- - *path = filename; - } ++ char *lastslash = grub_strrchr (filename, '\\'); ++ + /* Truncate at last directory. */ + if (lastslash) + { @@ -56,7 +57,7 @@ index f5423ce27d9..e01bc6eab19 100644 } diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 0769bf850d3..16d2ce06d5a 100644 +index 0645456..4b7972b 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -1850,7 +1850,7 @@ grub_net_search_configfile (char *config) @@ -69,10 +70,10 @@ index 0769bf850d3..16d2ce06d5a 100644 static struct grub_preboot *fini_hnd; diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 7d9c4f09b9b..b69f9e738fa 100644 +index d93bee6..2fe6743 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -331,74 +331,72 @@ grub_enter_normal_mode (const char *config) +@@ -337,74 +337,72 @@ grub_enter_normal_mode (const char *config) grub_boot_time ("Exiting normal mode"); } @@ -89,31 +90,31 @@ index 7d9c4f09b9b..b69f9e738fa 100644 + + if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) + { -+ grub_size_t config_len; -+ config_len = grub_strlen (prefix) + -+ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); -+ config = grub_malloc (config_len); ++ grub_size_t config_len; ++ config_len = grub_strlen (prefix) + ++ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); ++ config = grub_malloc (config_len); + -+ if (! config) -+ return GRUB_ERR_FILE_NOT_FOUND; ++ if (! config) ++ return GRUB_ERR_FILE_NOT_FOUND; + -+ grub_snprintf (config, config_len, "%s/grub.cfg", prefix); -+ err = grub_net_search_configfile (config); ++ grub_snprintf (config, config_len, "%s/grub.cfg", prefix); ++ err = grub_net_search_configfile (config); + } + + if (err != GRUB_ERR_NONE) + { -+ config = grub_xasprintf ("%s/grub.cfg", prefix); -+ if (config) -+ { -+ grub_file_t file; -+ file = grub_file_open (config); -+ if (file) -+ { -+ grub_file_close (file); -+ err = GRUB_ERR_NONE; -+ } -+ } ++ config = grub_xasprintf ("%s/grub.cfg", prefix); ++ if (config) ++ { ++ grub_file_t file; ++ file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG); ++ if (file) ++ { ++ grub_file_close (file); ++ err = GRUB_ERR_NONE; ++ } ++ } + } + + if (err == GRUB_ERR_NONE) @@ -130,7 +131,10 @@ index 7d9c4f09b9b..b69f9e738fa 100644 int argc, char *argv[]) { - if (argc == 0) -- { ++ if (argc) ++ grub_enter_normal_mode (argv[0]); ++ else + { - /* Guess the config filename. It is necessary to make CONFIG static, - so that it won't get broken by longjmp. */ - char *config; @@ -141,58 +145,52 @@ index 7d9c4f09b9b..b69f9e738fa 100644 - prefix = grub_env_get ("prefix"); - - if (prefix) -- { -- if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) -- { -- grub_size_t config_len; -- config_len = grub_strlen (prefix) + -- sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); -- config = grub_malloc (config_len); +- { +- if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0) +- { +- grub_size_t config_len; +- config_len = grub_strlen (prefix) + +- sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"); +- config = grub_malloc (config_len); - -- if (! config) -- goto quit; +- if (! config) +- goto quit; - -- grub_snprintf (config, config_len, "%s/grub.cfg", prefix); +- grub_snprintf (config, config_len, "%s/grub.cfg", prefix); - -- grub_net_search_configfile (config); +- grub_net_search_configfile (config); - -- grub_enter_normal_mode (config); -- grub_free (config); -- config = NULL; -- } +- grub_enter_normal_mode (config); +- grub_free (config); +- config = NULL; +- } - -- if (!config) -- { -- config = grub_xasprintf ("%s/grub.cfg", prefix); -- if (config) -- { -- grub_file_t file; +- if (!config) +- { +- config = grub_xasprintf ("%s/grub.cfg", prefix); +- if (config) +- { +- grub_file_t file; - -- file = grub_file_open (config); -- if (file) -- { -- grub_file_close (file); -- grub_enter_normal_mode (config); -- } -- else -- { -- /* Ignore all errors. */ -- grub_errno = 0; -- } -- grub_free (config); -- } -- } -- } +- file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG); +- if (file) +- { +- grub_file_close (file); +- grub_enter_normal_mode (config); +- } +- else +- { +- /* Ignore all errors. */ +- grub_errno = 0; +- } +- grub_free (config); +- } +- } +- } - else -- { -- grub_enter_normal_mode (0); -- } -- } -- else -+ if (argc) - grub_enter_normal_mode (argv[0]); -+ else -+ { +- { +- grub_enter_normal_mode (0); +- } + /* Guess the config filename. */ + grub_err_t err; + err = grub_try_normal ("fw_path"); @@ -200,9 +198,14 @@ index 7d9c4f09b9b..b69f9e738fa 100644 + err = grub_try_normal ("prefix"); + if (err == GRUB_ERR_FILE_NOT_FOUND) + grub_enter_normal_mode (0); -+ } + } +- else +- grub_enter_normal_mode (argv[0]); -quit: return 0; } +-- +1.8.3.1 + diff --git a/0059-Update-info-with-grub.cfg-netboot-selection-order-11.patch b/0056-Update-info-with-grub.cfg-netboot-selection-order-11.patch similarity index 91% rename from 0059-Update-info-with-grub.cfg-netboot-selection-order-11.patch rename to 0056-Update-info-with-grub.cfg-netboot-selection-order-11.patch index 26de3f42bfd3d7c7459dd437de93ddfc8447362c..d5421e8bc19705d542c6a4fed3de3b2344e2659f 100644 --- a/0059-Update-info-with-grub.cfg-netboot-selection-order-11.patch +++ b/0056-Update-info-with-grub.cfg-netboot-selection-order-11.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From c2361e2d8c4b0d15eb78605097a9d2fa38c06d76 Mon Sep 17 00:00:00 2001 From: Robert Marshall Date: Mon, 16 Mar 2015 16:34:51 -0400 -Subject: [PATCH] Update info with grub.cfg netboot selection order (#1148650) +Subject: [PATCH 056/220] Update info with grub.cfg netboot selection order + (#1148650) Added documentation to the grub info page that specifies the order netboot clients will use to select a grub configuration file. @@ -12,7 +13,7 @@ Resolves rhbz#1148650 1 file changed, 42 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi -index 2fd32608c01..a7155c22ffe 100644 +index 6f52430..221064b 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -2493,6 +2493,48 @@ grub-mknetdir --net-directory=/srv/tftp --subdir=/boot/grub -d /usr/lib/grub/i38 @@ -64,3 +65,6 @@ index 2fd32608c01..a7155c22ffe 100644 After GRUB has started, files on the TFTP server will be accessible via the @samp{(tftp)} device. +-- +1.8.3.1 + diff --git a/0060-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch b/0057-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch similarity index 90% rename from 0060-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch rename to 0057-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch index d686cf37332ccf2c99e748f36b5424bf50eb6ac3..579266ac8ccdfc341d5902a714b3c20039e28711 100644 --- a/0060-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch +++ b/0057-Use-Distribution-Package-Sort-for-grub2-mkconfig-112.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From e8cf594751f7bbce4ff01504197ebc25c71c2dc2 Mon Sep 17 00:00:00 2001 From: Robert Marshall Date: Mon, 16 Mar 2015 14:14:19 -0400 -Subject: [PATCH] Use Distribution Package Sort for grub2-mkconfig (#1124074) +Subject: [PATCH 057/220] Use Distribution Package Sort for grub2-mkconfig + (#1124074) Users reported that newly installed kernels on their systems installed with grub-mkconfig would not appear on the grub boot list in order @@ -9,22 +10,52 @@ starting with the most recent. Added an option for rpm-based systems to use the rpm-sort library to sort kernels instead. Resolves rhbz#1124074 + +Signed-off-by: Robert Marshall +[pjones: fix --enable-rpm-sort configure option] +Signed-off-by: Peter Jones --- - configure.ac | 29 +++++ Makefile.util.def | 16 +++ - util/grub-rpm-sort.c | 281 ++++++++++++++++++++++++++++++++++++++++++++++ - .gitignore | 2 + - util/grub-mkconfig_lib.in | 8 +- + configure.ac | 29 +++++ + util/grub-mkconfig_lib.in | 11 +- util/grub-rpm-sort.8 | 12 ++ - 6 files changed, 347 insertions(+), 1 deletion(-) - create mode 100644 util/grub-rpm-sort.c + util/grub-rpm-sort.c | 281 ++++++++++++++++++++++++++++++++++++++++++++++ + 5 files changed, 348 insertions(+), 1 deletion(-) create mode 100644 util/grub-rpm-sort.8 + create mode 100644 util/grub-rpm-sort.c +diff --git a/Makefile.util.def b/Makefile.util.def +index 1f298d0..843ce09 100644 +--- a/Makefile.util.def ++++ b/Makefile.util.def +@@ -696,6 +696,22 @@ program = { + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; + }; + ++program = { ++ name = grub-rpm-sort; ++ mansection = 8; ++ installdir = sbin; ++ ++ common = grub-core/kern/emu/misc.c; ++ common = grub-core/kern/emu/argp_common.c; ++ common = grub-core/osdep/init.c; ++ common = util/misc.c; ++ common = util/grub-rpm-sort.c; ++ ++ ldadd = libgrubkern.a; ++ ldadd = grub-core/lib/gnulib/libgnu.a; ++ ldadd = '$(LIBDEVMAPPER) $(LIBRPM)'; ++}; ++ + script = { + name = grub-mkconfig; + common = util/grub-mkconfig.in; diff --git a/configure.ac b/configure.ac -index d5db2803ec4..056df1cbaf9 100644 +index 8df400e..6927615 100644 --- a/configure.ac +++ b/configure.ac -@@ -65,6 +65,7 @@ grub_TRANSFORM([grub-mkrelpath]) +@@ -69,6 +69,7 @@ grub_TRANSFORM([grub-mkrelpath]) grub_TRANSFORM([grub-mkrescue]) grub_TRANSFORM([grub-probe]) grub_TRANSFORM([grub-reboot]) @@ -32,7 +63,7 @@ index d5db2803ec4..056df1cbaf9 100644 grub_TRANSFORM([grub-script-check]) grub_TRANSFORM([grub-set-default]) grub_TRANSFORM([grub-sparc64-setup]) -@@ -88,6 +89,7 @@ grub_TRANSFORM([grub-mkrescue.1]) +@@ -92,6 +93,7 @@ grub_TRANSFORM([grub-mkrescue.1]) grub_TRANSFORM([grub-mkstandalone.3]) grub_TRANSFORM([grub-ofpathname.3]) grub_TRANSFORM([grub-probe.3]) @@ -40,14 +71,14 @@ index d5db2803ec4..056df1cbaf9 100644 grub_TRANSFORM([grub-reboot.3]) grub_TRANSFORM([grub-render-label.3]) grub_TRANSFORM([grub-script-check.3]) -@@ -1790,6 +1792,33 @@ fi +@@ -1802,6 +1804,33 @@ fi AC_SUBST([LIBDEVMAPPER]) +AC_ARG_ENABLE([rpm-sort], + [AS_HELP_STRING([--enable-rpm-sort], + [enable native rpm sorting of kernels in grub (default=guessed)])]) -+if test x"$enable_rpm-sort" = xno ; then ++if test x"$enable_rpm_sort" = xno ; then + rpm_sort_excuse="explicitly disabled" +fi + @@ -74,36 +105,63 @@ index d5db2803ec4..056df1cbaf9 100644 LIBGEOM= if test x$host_kernel = xkfreebsd; then AC_CHECK_LIB([geom], [geom_gettree], [], -diff --git a/Makefile.util.def b/Makefile.util.def -index d08713b5500..406d96861b6 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -685,6 +685,22 @@ program = { - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; - }; +diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in +index 1a4a578..113a41f 100644 +--- a/util/grub-mkconfig_lib.in ++++ b/util/grub-mkconfig_lib.in +@@ -33,6 +33,9 @@ fi + if test "x$grub_mkrelpath" = x; then + grub_mkrelpath="${bindir}/@grub_mkrelpath@" + fi ++if test "x$grub_rpm_sort" = x; then ++ grub_rpm_sort="${sbindir}/@grub_rpm_sort@" ++fi -+program = { -+ name = grub-rpm-sort; -+ mansection = 8; -+ installdir = sbin; + if which gettext >/dev/null 2>/dev/null; then + : +@@ -214,6 +217,12 @@ version_sort () + esac + } + ++if [ "x$grub_rpm_sort" != x -a -x "$grub_rpm_sort" ]; then ++ kernel_sort="$grub_rpm_sort" ++else ++ kernel_sort=version_sort ++fi + -+ common = grub-core/kern/emu/misc.c; -+ common = grub-core/kern/emu/argp_common.c; -+ common = grub-core/osdep/init.c; -+ common = util/misc.c; -+ common = util/grub-rpm-sort.c; + version_test_numeric () + { + version_test_numeric_a="$1" +@@ -230,7 +239,7 @@ version_test_numeric () + version_test_numeric_a="$version_test_numeric_b" + version_test_numeric_b="$version_test_numeric_c" + fi +- if (echo "$version_test_numeric_a" ; echo "$version_test_numeric_b") | version_sort | head -n 1 | grep -qx "$version_test_numeric_b" ; then ++ if (echo "$version_test_numeric_a" ; echo "$version_test_numeric_b") | "$kernel_sort" | head -n 1 | grep -qx "$version_test_numeric_b" ; then + return 0 + else + return 1 +diff --git a/util/grub-rpm-sort.8 b/util/grub-rpm-sort.8 +new file mode 100644 +index 0000000..8ce2148 +--- /dev/null ++++ b/util/grub-rpm-sort.8 +@@ -0,0 +1,12 @@ ++.TH GRUB-RPM-SORT 8 "Wed Feb 26 2014" ++.SH NAME ++\fBgrub-rpm-sort\fR \(em Sort input according to RPM version compare. + -+ ldadd = grub-core/gnulib/libgnu.a; -+ ldadd = libgrubkern.a; -+ ldadd = '$(LIBDEVMAPPER) $(LIBRPM)'; -+}; ++.SH SYNOPSIS ++\fBgrub-rpm-sort\fR [OPTIONS]. + - script = { - name = grub-mkconfig; - common = util/grub-mkconfig.in; ++.SH DESCRIPTION ++You should not normally run this program directly. Use grub-mkconfig instead. ++ ++.SH SEE ALSO ++.BR "info grub" diff --git a/util/grub-rpm-sort.c b/util/grub-rpm-sort.c new file mode 100644 -index 00000000000..f33bd1ed568 +index 0000000..f33bd1e --- /dev/null +++ b/util/grub-rpm-sort.c @@ -0,0 +1,281 @@ @@ -388,60 +446,6 @@ index 00000000000..f33bd1ed568 + + return 0; +} -diff --git a/.gitignore b/.gitignore -index 43f04d47277..fa2e5b609b1 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -105,6 +105,8 @@ grub-*.tar.* - /grub*-reboot.8 - /grub*-render-label - /grub*-render-label.1 -+/grub*-rpm-sort -+/grub*-rpm-sort.8 - /grub*-script-check - /grub*-script-check.1 - /grub*-set-default -diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 1a4a57898f9..7fe3598435c 100644 ---- a/util/grub-mkconfig_lib.in -+++ b/util/grub-mkconfig_lib.in -@@ -214,6 +214,12 @@ version_sort () - esac - } - -+if [ "x$RPMLIB" = x ]; then -+ kernel_sort=version_sort -+else -+ kernel_sort="${sbindir}/grub-rpm-sort" -+fi -+ - version_test_numeric () - { - version_test_numeric_a="$1" -@@ -230,7 +236,7 @@ version_test_numeric () - version_test_numeric_a="$version_test_numeric_b" - version_test_numeric_b="$version_test_numeric_c" - fi -- if (echo "$version_test_numeric_a" ; echo "$version_test_numeric_b") | version_sort | head -n 1 | grep -qx "$version_test_numeric_b" ; then -+ if (echo "$version_test_numeric_a" ; echo "$version_test_numeric_b") | "$kernel_sort" | head -n 1 | grep -qx "$version_test_numeric_b" ; then - return 0 - else - return 1 -diff --git a/util/grub-rpm-sort.8 b/util/grub-rpm-sort.8 -new file mode 100644 -index 00000000000..8ce21488448 ---- /dev/null -+++ b/util/grub-rpm-sort.8 -@@ -0,0 +1,12 @@ -+.TH GRUB-RPM-SORT 8 "Wed Feb 26 2014" -+.SH NAME -+\fBgrub-rpm-sort\fR \(em Sort input according to RPM version compare. -+ -+.SH SYNOPSIS -+\fBgrub-rpm-sort\fR [OPTIONS]. -+ -+.SH DESCRIPTION -+You should not normally run this program directly. Use grub-mkconfig instead. -+ -+.SH SEE ALSO -+.BR "info grub" +-- +1.8.3.1 + diff --git a/0061-Handle-rssd-storage-devices.patch b/0058-Handle-rssd-storage-devices.patch similarity index 84% rename from 0061-Handle-rssd-storage-devices.patch rename to 0058-Handle-rssd-storage-devices.patch index 8f25692a52d41fcc6f9eafcc40e193189602f2e5..600655506f791d614a1764801676bb96d844f6e2 100644 --- a/0061-Handle-rssd-storage-devices.patch +++ b/0058-Handle-rssd-storage-devices.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 186a94f0f82bbebcbf607573ba792647acebf9cd Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 30 Jun 2015 15:50:41 -0400 -Subject: [PATCH] Handle rssd storage devices. +Subject: [PATCH 058/220] Handle rssd storage devices. Resolves: rhbz#1087962 @@ -11,7 +11,7 @@ Signed-off-by: Peter Jones 1 file changed, 13 insertions(+) diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c -index 90d92d3ad5c..6d9f4e5faa2 100644 +index 90d92d3..6d9f4e5 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -921,6 +921,19 @@ grub_util_part_to_disk (const char *os_dev, struct stat *st, @@ -34,3 +34,6 @@ index 90d92d3ad5c..6d9f4e5faa2 100644 /* If this is a loop device */ if ((strncmp ("loop", p, 4) == 0) && p[4] >= '0' && p[4] <= '9') { +-- +1.8.3.1 + diff --git a/0062-Make-grub2-mkconfig-construct-titles-that-look-like-.patch b/0059-Make-grub2-mkconfig-construct-titles-that-look-like-.patch similarity index 91% rename from 0062-Make-grub2-mkconfig-construct-titles-that-look-like-.patch rename to 0059-Make-grub2-mkconfig-construct-titles-that-look-like-.patch index 3bbaa1d98c966497d98e0067520dfa72b9f6b142..10f709cb44d1b690abf229c24763e22f33238a07 100644 --- a/0062-Make-grub2-mkconfig-construct-titles-that-look-like-.patch +++ b/0059-Make-grub2-mkconfig-construct-titles-that-look-like-.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 95e793ef45a127c800525d629b2fdec583ae8266 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 28 Apr 2015 11:15:03 -0400 -Subject: [PATCH] Make grub2-mkconfig construct titles that look like the ones - we want elsewhere. +Subject: [PATCH 059/220] Make grub2-mkconfig construct titles that look like + the ones we want elsewhere. Resolves: rhbz#1215839 @@ -12,7 +12,7 @@ Signed-off-by: Peter Jones 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 43d98476b88..a8a8e2cf325 100644 +index d12d2d7..12a20c9 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -78,6 +78,32 @@ case x"$GRUB_FS" in @@ -67,3 +67,6 @@ index 43d98476b88..a8a8e2cf325 100644 fi echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" else +-- +1.8.3.1 + diff --git a/0063-Add-friendly-grub2-password-config-tool-985962.patch b/0060-Add-friendly-grub2-password-config-tool-985962.patch similarity index 63% rename from 0063-Add-friendly-grub2-password-config-tool-985962.patch rename to 0060-Add-friendly-grub2-password-config-tool-985962.patch index 49ebfa7123f4b1f4e8ff2cd0c9ceb3c5427369e1..8ac50f28d796734c95f3ee57c360605cc08f10a2 100644 --- a/0063-Add-friendly-grub2-password-config-tool-985962.patch +++ b/0060-Add-friendly-grub2-password-config-tool-985962.patch @@ -1,84 +1,76 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From a524d461543f57da4f36a9c9c12b329ea8b6629c Mon Sep 17 00:00:00 2001 From: Robert Marshall Date: Thu, 25 Jun 2015 11:13:11 -0400 -Subject: [PATCH] Add friendly grub2 password config tool (#985962) +Subject: [PATCH 060/220] Add friendly grub2 password config tool (#985962) Provided a tool for users to reset the grub2 root user password without having to alter the grub.cfg. The hashed password now lives in a root-only-readable configuration file. Resolves: rhbz#985962 + +Signed-off-by: Robert Marshall +[pjones: fix the efidir in grub-setpassword and rename tool] +Signed-off-by: Peter Jones +[luto: fix grub-setpassword -o's output path] +Andy Lutomirski --- - configure.ac | 1 + - Makefile.util.def | 13 +++++ - .gitignore | 2 + - util/grub-mkconfig.in | 2 + - util/grub-setpassword.8 | 28 +++++++++++ - util/grub-setpassword.in | 123 +++++++++++++++++++++++++++++++++++++++++++++++ - util/grub.d/01_users.in | 11 +++++ - 7 files changed, 180 insertions(+) - create mode 100644 util/grub-setpassword.8 - create mode 100644 util/grub-setpassword.in + Makefile.util.def | 13 +++++ + configure.ac | 1 + + util/grub-mkconfig.in | 2 + + util/grub-set-password.8 | 28 ++++++++++ + util/grub-set-password.in | 128 ++++++++++++++++++++++++++++++++++++++++++++++ + util/grub.d/01_users.in | 11 ++++ + 6 files changed, 183 insertions(+) + create mode 100644 util/grub-set-password.8 + create mode 100644 util/grub-set-password.in create mode 100644 util/grub.d/01_users.in -diff --git a/configure.ac b/configure.ac -index 056df1cbaf9..679f634ce4c 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -65,6 +65,7 @@ grub_TRANSFORM([grub-mkrelpath]) - grub_TRANSFORM([grub-mkrescue]) - grub_TRANSFORM([grub-probe]) - grub_TRANSFORM([grub-reboot]) -+grub_TRANSFORM([grub-setpassword]) - grub_TRANSFORM([grub-rpm-sort]) - grub_TRANSFORM([grub-script-check]) - grub_TRANSFORM([grub-set-default]) diff --git a/Makefile.util.def b/Makefile.util.def -index 406d96861b6..fd91045bd6d 100644 +index 843ce09..e50436a 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -440,6 +440,12 @@ script = { - installdir = grubconf; +@@ -452,6 +452,12 @@ script = { }; -+script = { + script = { + name = '01_users'; + common = util/grub.d/01_users.in; + installdir = grubconf; +}; + - script = { ++script = { name = '10_windows'; common = util/grub.d/10_windows.in; -@@ -722,6 +728,13 @@ script = { - installdir = sbin; + installdir = grubconf; +@@ -734,6 +740,13 @@ script = { }; -+script = { -+ name = grub-setpassword; -+ common = util/grub-setpassword.in; + script = { ++ name = grub-set-password; ++ common = util/grub-set-password.in; + mansection = 8; + installdir = sbin; +}; + - script = { ++script = { name = grub-mkconfig_lib; common = util/grub-mkconfig_lib.in; -diff --git a/.gitignore b/.gitignore -index fa2e5b609b1..5066689bc0a 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -111,6 +111,8 @@ grub-*.tar.* - /grub*-script-check.1 - /grub*-set-default - /grub*-set-default.8 -+/grub*-setsetpassword -+/grub*-setsetpassword.8 - /grub*-shell - /grub*-shell-tester - /grub*-sparc64-setup + installdir = noinst; +diff --git a/configure.ac b/configure.ac +index 6927615..6850166 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -69,6 +69,7 @@ grub_TRANSFORM([grub-mkrelpath]) + grub_TRANSFORM([grub-mkrescue]) + grub_TRANSFORM([grub-probe]) + grub_TRANSFORM([grub-reboot]) ++grub_TRANSFORM([grub-set-password]) + grub_TRANSFORM([grub-rpm-sort]) + grub_TRANSFORM([grub-script-check]) + grub_TRANSFORM([grub-set-default]) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index f68d4925ee6..bdb9982aefb 100644 +index c645351..4e7a875 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -282,6 +282,8 @@ for i in "${grub_mkconfig_dir}"/* ; do @@ -90,21 +82,21 @@ index f68d4925ee6..bdb9982aefb 100644 *) if grub_file_is_not_garbage "$i" && test -x "$i" ; then echo -diff --git a/util/grub-setpassword.8 b/util/grub-setpassword.8 +diff --git a/util/grub-set-password.8 b/util/grub-set-password.8 new file mode 100644 -index 00000000000..49200a848b7 +index 0000000..9646546 --- /dev/null -+++ b/util/grub-setpassword.8 ++++ b/util/grub-set-password.8 @@ -0,0 +1,28 @@ -+.TH GRUB-SETPASSWORD 3 "Thu Jun 25 2015" ++.TH GRUB-SET-PASSWORD 3 "Thu Jun 25 2015" +.SH NAME -+\fBgrub-setpassword\fR \(em Generate the user.cfg file containing the hashed grub bootloader password. ++\fBgrub-set-password\fR \(em Generate the user.cfg file containing the hashed grub bootloader password. + +.SH SYNOPSIS -+\fBgrub-setpassword\fR [OPTION] ++\fBgrub-set-password\fR [OPTION] + +.SH DESCRIPTION -+\fBgrub-setpassword\fR outputs the user.cfg file which contains the hashed GRUB bootloader password. This utility only supports configurations where there is a single root user. ++\fBgrub-set-password\fR outputs the user.cfg file which contains the hashed GRUB bootloader password. This utility only supports configurations where there is a single root user. + +The file has the format: +GRUB2_PASSWORD=<\fIhashed password\fR>. @@ -117,23 +109,24 @@ index 00000000000..49200a848b7 +-v, --version +Display the current version. +.TP -+-o, --output[=\fIDIRECTORY PATH\fR] ++-o, --output=<\fIDIRECTORY\fR> +Choose the file path to which user.cfg will be written. + +.SH SEE ALSO +.BR "info grub" + +.BR "info grub2-mkpasswd-pbkdf2" -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in +diff --git a/util/grub-set-password.in b/util/grub-set-password.in new file mode 100644 -index 00000000000..dd76f00fc0e +index 0000000..5ebf505 --- /dev/null -+++ b/util/grub-setpassword.in -@@ -0,0 +1,123 @@ ++++ b/util/grub-set-password.in +@@ -0,0 +1,128 @@ +#!/bin/sh -e + ++EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') +if [ -d /sys/firmware/efi/efivars/ ]; then -+ grubdir=`echo "/@bootdirname@/efi/EFI/redhat/" | sed 's,//*,/,g'` ++ grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'` +else + grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'` +fi @@ -148,15 +141,14 @@ index 00000000000..dd76f00fc0e +# Print the usage. +usage () { + cat < put user.cfg in a user-selected directory + +Report bugs at https://bugzilla.redhat.com. +EOF @@ -237,7 +229,7 @@ index 00000000000..dd76f00fc0e + P1="$1" && shift + + ( echo ${P0} ; echo ${P1} ) | \ -+ ${grub_mkpasswd} | \ ++ LC_ALL=C ${grub_mkpasswd} | \ + grep -v '[eE]nter password:' | \ + sed -e "s/PBKDF2 hash of your password is //" +} @@ -250,12 +242,17 @@ index 00000000000..dd76f00fc0e + +# on the ESP, these will fail to set the permissions, but it's okay because +# the directory is protected. -+install -m 0600 /dev/null "${grubdir}/user.cfg" 2>/dev/null || : -+chmod 0600 "${grubdir}/user.cfg" 2>/dev/null || : -+echo "GRUB2_PASSWORD=${MYPASS}" > "${grubdir}/user.cfg" ++install -m 0600 /dev/null "${OUTPUT_PATH}/user.cfg" 2>/dev/null || : ++chmod 0600 "${OUTPUT_PATH}/user.cfg" 2>/dev/null || : ++echo "GRUB2_PASSWORD=${MYPASS}" > "${OUTPUT_PATH}/user.cfg" ++ ++if ! grep -q "^### BEGIN /etc/grub.d/01_users ###$" "${OUTPUT_PATH}/grub.cfg"; then ++ echo "WARNING: The current configuration lacks password support!" ++ echo "Update your configuration with @grub_mkconfig@ to support this feature." ++fi diff --git a/util/grub.d/01_users.in b/util/grub.d/01_users.in new file mode 100644 -index 00000000000..db2f44bfb78 +index 0000000..db2f44b --- /dev/null +++ b/util/grub.d/01_users.in @@ -0,0 +1,11 @@ @@ -270,3 +267,6 @@ index 00000000000..db2f44bfb78 + fi +fi +EOF +-- +1.8.3.1 + diff --git a/0065-tcp-add-window-scaling-support.patch b/0061-tcp-add-window-scaling-support.patch similarity index 94% rename from 0065-tcp-add-window-scaling-support.patch rename to 0061-tcp-add-window-scaling-support.patch index 7d1996c8fc233ece5afa67588ee79e6f95bd45bd..6cf2d79a8b26fe911e0224a101f3944c9b6ea50c 100644 --- a/0065-tcp-add-window-scaling-support.patch +++ b/0061-tcp-add-window-scaling-support.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 685960c950e661dec0d57a353ca01304b94a7092 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Wed, 12 Aug 2015 08:57:55 -0700 -Subject: [PATCH] tcp: add window scaling support +Subject: [PATCH 061/220] tcp: add window scaling support Sometimes we have to provision boxes across regions, such as California to Sweden. The http server has a 10 minute timeout, so if we can't get our 250mb @@ -17,7 +17,7 @@ Signed-off-by: Josef Bacik 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/grub-core/net/tcp.c b/grub-core/net/tcp.c -index e8ad34b84d4..7d4b822626d 100644 +index e8ad34b..7d4b822 100644 --- a/grub-core/net/tcp.c +++ b/grub-core/net/tcp.c @@ -106,6 +106,18 @@ struct tcphdr @@ -85,3 +85,6 @@ index e8ad34b84d4..7d4b822626d 100644 tcp_socket_register (socket); +-- +1.8.3.1 + diff --git a/0069-Fix-security-issue-when-reading-username-and-passwor.patch b/0062-Fix-security-issue-when-reading-username-and-passwor.patch similarity index 83% rename from 0069-Fix-security-issue-when-reading-username-and-passwor.patch rename to 0062-Fix-security-issue-when-reading-username-and-passwor.patch index 11bc4340c08d559ec00c8303740d4512f3cb1a12..489d4908f0019cda5eb709b48c1eb7aa8944585f 100644 --- a/0069-Fix-security-issue-when-reading-username-and-passwor.patch +++ b/0062-Fix-security-issue-when-reading-username-and-passwor.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 8483464867a872744a2c40a3b4016d3b81033a5d Mon Sep 17 00:00:00 2001 From: Hector Marco-Gisbert Date: Fri, 13 Nov 2015 16:21:09 +0100 -Subject: [PATCH] Fix security issue when reading username and password +Subject: [PATCH 062/220] Fix security issue when reading username and password This patch fixes two integer underflows at: * grub-core/lib/crypto.c @@ -17,7 +17,7 @@ Signed-off-by: Ismael Ripoll-Ripoll 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c -index ca334d5a40e..e6c78d16d39 100644 +index ca334d5..e6c78d1 100644 --- a/grub-core/lib/crypto.c +++ b/grub-core/lib/crypto.c @@ -468,7 +468,7 @@ grub_password_get (char buf[], unsigned buf_size) @@ -30,7 +30,7 @@ index ca334d5a40e..e6c78d16d39 100644 if (cur_len) cur_len--; diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c -index 6be678c0de1..c35ce972473 100644 +index 6be678c..c35ce97 100644 --- a/grub-core/normal/auth.c +++ b/grub-core/normal/auth.c @@ -172,7 +172,7 @@ grub_username_get (char buf[], unsigned buf_size) @@ -42,3 +42,6 @@ index 6be678c0de1..c35ce972473 100644 { if (cur_len) { +-- +1.8.3.1 + diff --git a/0076-Add-a-url-parser.patch b/0063-Add-a-url-parser.patch similarity index 98% rename from 0076-Add-a-url-parser.patch rename to 0063-Add-a-url-parser.patch index 2697fd2858d1b31f3c4335e039aa0c4b507e270c..ec773a7d399b62f5e4c3cde3cbd90e0de7a8ef0d 100644 --- a/0076-Add-a-url-parser.patch +++ b/0063-Add-a-url-parser.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From eb8bcbb4845d6b87f16774ee62de3e5a11ccd6f1 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 14 Jun 2016 16:18:44 -0400 -Subject: [PATCH] Add a url parser. +Subject: [PATCH 063/220] Add a url parser. This patch adds a url parser that can parse http, https, tftp, and tftps urls, and is easily extensible to handle more types. @@ -20,10 +20,10 @@ Signed-off-by: Peter Jones create mode 100644 include/grub/net/url.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index cd0902b46b8..991891a6e09 100644 +index 57e253a..99466b1 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -2185,6 +2185,7 @@ module = { +@@ -2284,6 +2284,7 @@ module = { common = net/ethernet.c; common = net/arp.c; common = net/netbuff.c; @@ -32,7 +32,7 @@ index cd0902b46b8..991891a6e09 100644 module = { diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 8344526be7f..f1fab700048 100644 +index 2656a67..1c560ea 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -296,6 +296,19 @@ grub_strrchr (const char *s, int c) @@ -57,7 +57,7 @@ index 8344526be7f..f1fab700048 100644 { diff --git a/grub-core/net/url.c b/grub-core/net/url.c new file mode 100644 -index 00000000000..146858284cd +index 0000000..1468582 --- /dev/null +++ b/grub-core/net/url.c @@ -0,0 +1,861 @@ @@ -923,7 +923,7 @@ index 00000000000..146858284cd +} +#endif diff --git a/include/grub/misc.h b/include/grub/misc.h -index 83fd69f4ada..fcaf1201e39 100644 +index f9135b6..b433922 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -85,6 +85,7 @@ int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n); @@ -987,7 +987,7 @@ index 83fd69f4ada..fcaf1201e39 100644 { diff --git a/include/grub/net/url.h b/include/grub/net/url.h new file mode 100644 -index 00000000000..a215fa27d0a +index 0000000..a215fa2 --- /dev/null +++ b/include/grub/net/url.h @@ -0,0 +1,28 @@ @@ -1019,3 +1019,6 @@ index 00000000000..a215fa27d0a + char **host, int *port, char **file); + +#endif /* GRUB_URL_HEADER */ +-- +1.8.3.1 + diff --git a/0064-Try-to-make-sure-configure.ac-and-grub-rpm-sort-play.patch b/0064-Try-to-make-sure-configure.ac-and-grub-rpm-sort-play.patch deleted file mode 100644 index 09061ce98c73d7df8a54e87cd8ac448ad8580d3d..0000000000000000000000000000000000000000 --- a/0064-Try-to-make-sure-configure.ac-and-grub-rpm-sort-play.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 3 Aug 2015 11:46:42 -0400 -Subject: [PATCH] Try to make sure configure.ac and grub-rpm-sort play nice. - -Apparently the test for whether to use grub-rpm-sort and also the -renaming of it to grub2-rpm-sort on the runtime side weren't right. - -Related: rhbz#1124074 - -Signed-off-by: Peter Jones ---- - configure.ac | 2 +- - util/grub-mkconfig_lib.in | 9 ++++++--- - 2 files changed, 7 insertions(+), 4 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 679f634ce4c..71d1056969e 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1796,7 +1796,7 @@ AC_SUBST([LIBDEVMAPPER]) - AC_ARG_ENABLE([rpm-sort], - [AS_HELP_STRING([--enable-rpm-sort], - [enable native rpm sorting of kernels in grub (default=guessed)])]) --if test x"$enable_rpm-sort" = xno ; then -+if test x"$enable_rpm_sort" = xno ; then - rpm_sort_excuse="explicitly disabled" - fi - -diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 7fe3598435c..113a41f9409 100644 ---- a/util/grub-mkconfig_lib.in -+++ b/util/grub-mkconfig_lib.in -@@ -33,6 +33,9 @@ fi - if test "x$grub_mkrelpath" = x; then - grub_mkrelpath="${bindir}/@grub_mkrelpath@" - fi -+if test "x$grub_rpm_sort" = x; then -+ grub_rpm_sort="${sbindir}/@grub_rpm_sort@" -+fi - - if which gettext >/dev/null 2>/dev/null; then - : -@@ -214,10 +217,10 @@ version_sort () - esac - } - --if [ "x$RPMLIB" = x ]; then -+if [ "x$grub_rpm_sort" != x -a -x "$grub_rpm_sort" ]; then -+ kernel_sort="$grub_rpm_sort" -+else - kernel_sort=version_sort --else -- kernel_sort="${sbindir}/grub-rpm-sort" - fi - - version_test_numeric () diff --git a/0077-efinet-and-bootp-add-support-for-dhcpv6.patch b/0064-efinet-and-bootp-add-support-for-dhcpv6.patch similarity index 93% rename from 0077-efinet-and-bootp-add-support-for-dhcpv6.patch rename to 0064-efinet-and-bootp-add-support-for-dhcpv6.patch index 924bfa33187da9801f4c43f6ceb60576ad9ef8df..a23b63ebe33939eaeffcaea85004f9ee104da054 100644 --- a/0077-efinet-and-bootp-add-support-for-dhcpv6.patch +++ b/0064-efinet-and-bootp-add-support-for-dhcpv6.patch @@ -1,20 +1,20 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From af6fa4f3b319c6d71badfba50fcb16619c38605a Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Wed, 8 Jun 2016 21:03:37 -0400 -Subject: [PATCH] efinet and bootp: add support for dhcpv6 +Date: Tue, 9 Jul 2019 11:47:37 +0200 +Subject: [PATCH 064/220] efinet and bootp: add support for dhcpv6 Signed-off-by: Peter Jones --- grub-core/net/bootp.c | 174 +++++++++++++++++++++++++++++++++++++ - grub-core/net/drivers/efi/efinet.c | 55 ++++++++++-- + grub-core/net/drivers/efi/efinet.c | 54 ++++++++++-- grub-core/net/net.c | 72 +++++++++++++++ grub-core/net/tftp.c | 4 + include/grub/efi/api.h | 129 +++++++++++++++++++++++++-- include/grub/net.h | 60 +++++++++++++ - 6 files changed, 480 insertions(+), 14 deletions(-) + 6 files changed, 479 insertions(+), 14 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index f03eeab2fb4..da3e454466b 100644 +index 0e6e41a..8c96959 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -23,6 +23,7 @@ @@ -24,10 +24,10 @@ index f03eeab2fb4..da3e454466b 100644 +#include #include - static char * -@@ -349,6 +350,179 @@ grub_net_configure_by_dhcp_ack (const char *name, - return inter; - } + struct grub_dhcp_discover_options +@@ -935,6 +936,179 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), + + static grub_command_t cmd_getdhcp, cmd_bootp, cmd_dhcp; +struct grub_net_network_level_interface * +grub_net_configure_by_dhcpv6_ack (const char *name, @@ -203,10 +203,10 @@ index f03eeab2fb4..da3e454466b 100644 + + void - grub_net_process_dhcp (struct grub_net_buff *nb, - struct grub_net_card *card) + grub_bootp_init (void) + { diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index a3ce4c67cce..329024b6f2c 100644 +index 5388f95..a57189e 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -18,11 +18,15 @@ @@ -225,7 +225,7 @@ index a3ce4c67cce..329024b6f2c 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -409,7 +413,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -329,7 +333,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, char **path) { struct grub_net_card *card; @@ -234,16 +234,13 @@ index a3ce4c67cce..329024b6f2c 100644 dp = grub_efi_get_device_path (hnd); if (! dp) -@@ -420,16 +424,22 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -340,14 +344,19 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, grub_efi_device_path_t *cdp; struct grub_efi_pxe *pxe; struct grub_efi_pxe_mode *pxe_mode; + if (card->driver != &efidriver) continue; -+ - if (hnd != card->efi_handle) - continue; + cdp = grub_efi_get_device_path (card->efi_handle); if (! cdp) @@ -258,7 +255,7 @@ index a3ce4c67cce..329024b6f2c 100644 int match; /* EDK2 UEFI PXE driver creates pseudo devices with type IPv4/IPv6 -@@ -438,7 +448,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -356,7 +365,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, devices. We skip them when enumerating cards, so here we need to find matching MAC device. */ @@ -266,7 +263,7 @@ index a3ce4c67cce..329024b6f2c 100644 if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE)) -@@ -455,16 +464,46 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -373,16 +381,46 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, if (!match) continue; } @@ -319,7 +316,7 @@ index a3ce4c67cce..329024b6f2c 100644 } } diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 16d2ce06d5a..4be228d9576 100644 +index 4b7972b..f24f1fd 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -955,6 +955,78 @@ grub_net_network_level_interface_register (struct grub_net_network_level_interfa @@ -402,7 +399,7 @@ index 16d2ce06d5a..4be228d9576 100644 grub_err_t grub_net_add_ipv4_local (struct grub_net_network_level_interface *inter, diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index 7d90bf66e76..1157524fc50 100644 +index 7d90bf6..1157524 100644 --- a/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c @@ -379,19 +379,23 @@ tftp_open (struct grub_file *file, const char *filename) @@ -430,7 +427,7 @@ index 7d90bf66e76..1157524fc50 100644 grub_free (data); return grub_errno; diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 97b9aa7a4d7..02488ec35ae 100644 +index addcbfa..d97cdf9 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -572,10 +572,16 @@ typedef void *grub_efi_handle_t; @@ -454,7 +451,7 @@ index 97b9aa7a4d7..02488ec35ae 100644 typedef grub_efi_uint64_t grub_efi_physical_address_t; typedef grub_efi_uint64_t grub_efi_virtual_address_t; -@@ -1454,16 +1460,127 @@ struct grub_efi_simple_text_output_interface +@@ -1450,16 +1456,127 @@ struct grub_efi_simple_text_output_interface }; typedef struct grub_efi_simple_text_output_interface grub_efi_simple_text_output_interface_t; @@ -585,10 +582,10 @@ index 97b9aa7a4d7..02488ec35ae 100644 typedef struct grub_efi_pxe diff --git a/include/grub/net.h b/include/grub/net.h -index 50d62ab0c8c..f8f3ec13acc 100644 +index ff6d347..3647012 100644 --- a/include/grub/net.h +++ b/include/grub/net.h -@@ -442,6 +442,51 @@ struct grub_net_bootp_packet +@@ -447,6 +447,51 @@ struct grub_net_bootp_packet grub_uint8_t vendor[0]; } GRUB_PACKED; @@ -640,7 +637,7 @@ index 50d62ab0c8c..f8f3ec13acc 100644 #define GRUB_NET_BOOTP_RFC1048_MAGIC_0 0x63 #define GRUB_NET_BOOTP_RFC1048_MAGIC_1 0x82 #define GRUB_NET_BOOTP_RFC1048_MAGIC_2 0x53 -@@ -470,6 +515,21 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -482,6 +527,21 @@ grub_net_configure_by_dhcp_ack (const char *name, grub_size_t size, int is_def, char **device, char **path); @@ -662,3 +659,6 @@ index 50d62ab0c8c..f8f3ec13acc 100644 grub_err_t grub_net_add_ipv4_local (struct grub_net_network_level_interface *inf, int mask); +-- +1.8.3.1 + diff --git a/0078-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch b/0065-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch similarity index 86% rename from 0078-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch rename to 0065-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch index 7ea79d1f284acd69d25aa1f14be769bca9bdb3e2..8837b09ec33daee58e404985541b333266968d96 100644 --- a/0078-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch +++ b/0065-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 6f9c2df8b9b7905038bab5f3627806c00199ae25 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 23 Jun 2016 11:01:39 -0400 -Subject: [PATCH] Add grub-get-kernel-settings and use it in 10_linux +Subject: [PATCH 065/220] Add grub-get-kernel-settings and use it in 10_linux This patch adds grub-get-kernel-settings, which reads the system kernel installation configuration from /etc/sysconfig/kernel, and outputs @@ -11,23 +11,40 @@ debug stanzas. Resolves: rhbz#1226325 --- + Makefile.util.def | 7 ++ configure.ac | 2 + - Makefile.util.def | 7 +++ - .gitignore | 2 + - util/bash-completion.d/grub-completion.bash.in | 22 ++++++++ - util/grub-get-kernel-settings.3 | 20 +++++++ - util/grub-get-kernel-settings.in | 78 ++++++++++++++++++++++++++ + util/bash-completion.d/grub-completion.bash.in | 22 +++++++ + util/grub-get-kernel-settings.3 | 20 ++++++ + util/grub-get-kernel-settings.in | 88 ++++++++++++++++++++++++++ util/grub-mkconfig.in | 3 + - util/grub.d/10_linux.in | 23 ++++++-- - 8 files changed, 152 insertions(+), 5 deletions(-) + util/grub.d/10_linux.in | 23 +++++-- + 7 files changed, 160 insertions(+), 5 deletions(-) create mode 100644 util/grub-get-kernel-settings.3 create mode 100644 util/grub-get-kernel-settings.in +diff --git a/Makefile.util.def b/Makefile.util.def +index e50436a..2215cc7 100644 +--- a/Makefile.util.def ++++ b/Makefile.util.def +@@ -726,6 +726,13 @@ script = { + }; + + script = { ++ name = grub-get-kernel-settings; ++ common = util/grub-get-kernel-settings.in; ++ mansection = 3; ++ installdir = sbin; ++}; ++ ++script = { + name = grub-set-default; + common = util/grub-set-default.in; + mansection = 8; diff --git a/configure.ac b/configure.ac -index 71d1056969e..aa06ed59c8d 100644 +index 6850166..fc3c2b4 100644 --- a/configure.ac +++ b/configure.ac -@@ -58,6 +58,7 @@ grub_TRANSFORM([grub-install]) +@@ -62,6 +62,7 @@ grub_TRANSFORM([grub-install]) grub_TRANSFORM([grub-mkconfig]) grub_TRANSFORM([grub-mkfont]) grub_TRANSFORM([grub-mkimage]) @@ -35,7 +52,7 @@ index 71d1056969e..aa06ed59c8d 100644 grub_TRANSFORM([grub-glue-efi]) grub_TRANSFORM([grub-mklayout]) grub_TRANSFORM([grub-mkpasswd-pbkdf2]) -@@ -75,6 +76,7 @@ grub_TRANSFORM([grub-file]) +@@ -79,6 +80,7 @@ grub_TRANSFORM([grub-file]) grub_TRANSFORM([grub-bios-setup.3]) grub_TRANSFORM([grub-editenv.1]) grub_TRANSFORM([grub-fstest.3]) @@ -43,46 +60,14 @@ index 71d1056969e..aa06ed59c8d 100644 grub_TRANSFORM([grub-glue-efi.3]) grub_TRANSFORM([grub-install.1]) grub_TRANSFORM([grub-kbdcomp.3]) -diff --git a/Makefile.util.def b/Makefile.util.def -index fd91045bd6d..2d032643de7 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -714,6 +714,13 @@ script = { - installdir = sbin; - }; - -+script = { -+ name = grub-get-kernel-settings; -+ common = util/grub-get-kernel-settings.in; -+ mansection = 3; -+ installdir = sbin; -+}; -+ - script = { - name = grub-set-default; - common = util/grub-set-default.in; -diff --git a/.gitignore b/.gitignore -index 5066689bc0a..54795fa60be 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -68,6 +68,8 @@ grub-*.tar.* - /grub*-fs-tester - /grub*-fstest - /grub*-fstest.1 -+/grub*-get-kernel-settings -+/grub*-get-kernel-settings.3 - /grub*-glue-efi - /grub*-glue-efi.1 - /grub*-install diff --git a/util/bash-completion.d/grub-completion.bash.in b/util/bash-completion.d/grub-completion.bash.in -index 44bf135b9f8..5c4acd496d4 100644 +index 44bf135..5c4acd4 100644 --- a/util/bash-completion.d/grub-completion.bash.in +++ b/util/bash-completion.d/grub-completion.bash.in -@@ -264,6 +264,28 @@ have ${__grub_sparc64_setup_program} && \ - unset __grub_sparc64_setup_program +@@ -265,6 +265,28 @@ unset __grub_sparc64_setup_program -+# + # +# grub-get-kernel-settings +# +_grub_get_kernel_settings () { @@ -104,12 +89,13 @@ index 44bf135b9f8..5c4acd496d4 100644 +unset __grub_get_kernel_settings_program + + - # ++# # grub-install # + _grub_install () { diff --git a/util/grub-get-kernel-settings.3 b/util/grub-get-kernel-settings.3 new file mode 100644 -index 00000000000..ba33330e28d +index 0000000..ba33330 --- /dev/null +++ b/util/grub-get-kernel-settings.3 @@ -0,0 +1,20 @@ @@ -135,10 +121,10 @@ index 00000000000..ba33330e28d +.BR "info grub" diff --git a/util/grub-get-kernel-settings.in b/util/grub-get-kernel-settings.in new file mode 100644 -index 00000000000..12046219878 +index 0000000..7e87dfc --- /dev/null +++ b/util/grub-get-kernel-settings.in -@@ -0,0 +1,78 @@ +@@ -0,0 +1,88 @@ +#!/bin/sh +set -e + @@ -217,8 +203,18 @@ index 00000000000..12046219878 + echo GRUB_LINUX_DEBUG_TITLE_POSTFIX=\" with debugging\" + echo export GRUB_LINUX_DEBUG_TITLE_POSTFIX +fi ++if [ "$DEFAULTDEBUG" = "yes" ]; then ++ echo GRUB_DEFAULT_TO_DEBUG=true ++else ++ echo GRUB_DEFAULT_TO_DEBUG=false ++fi ++echo export GRUB_DEFAULT_TO_DEBUG ++if [ "$UPDATEDEFAULT" = "yes" ]; then ++ echo GRUB_UPDATE_DEFAULT_KERNEL=true ++ echo export GRUB_UPDATE_DEFAULT_KERNEL ++fi diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index bdb9982aefb..8218f3d477f 100644 +index 4e7a875..6247a0b 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -45,6 +45,7 @@ grub_probe="${sbindir}/@grub_probe@" @@ -239,7 +235,7 @@ index bdb9982aefb..8218f3d477f 100644 if [ -z "$GRUB_DEVICE_UUID" ]; then GRUB_DEVICE_UUID="$GRUB_DEVICE_UUID_GENERATED" diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index a8a8e2cf325..4e49ccdf742 100644 +index 12a20c9..55f4aa7 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -111,7 +111,8 @@ linux_entry () @@ -298,3 +294,6 @@ index a8a8e2cf325..4e49ccdf742 100644 "single ${GRUB_CMDLINE_LINUX}" fi +-- +1.8.3.1 + diff --git a/0079-Normalize-slashes-in-tftp-paths.patch b/0066-Normalize-slashes-in-tftp-paths.patch similarity index 64% rename from 0079-Normalize-slashes-in-tftp-paths.patch rename to 0066-Normalize-slashes-in-tftp-paths.patch index 5ea5afa50b24ee4b3c9009d26ae9cd6638c33437..4c4c84e5d31871482b05e4099dc7ff68d9f99925 100644 --- a/0079-Normalize-slashes-in-tftp-paths.patch +++ b/0066-Normalize-slashes-in-tftp-paths.patch @@ -1,18 +1,20 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From be6b7ff630f73fe21b797d5396a29944262d3805 Mon Sep 17 00:00:00 2001 From: Lenny Szubowicz Date: Mon, 29 Aug 2016 11:04:48 -0400 -Subject: [PATCH] Normalize slashes in tftp paths. +Subject: [PATCH 066/220] Normalize slashes in tftp paths. Some tftp servers do not handle multiple consecutive slashes correctly; this patch avoids sending tftp requests with non-normalized paths. -Signed-off-by: Peter Jones +Signed-off-by: Lenny Szubowicz +[msalter: fix malformed tftp packets] +Signed-off-by: Mark Salter --- - grub-core/net/tftp.c | 24 +++++++++++++++++++++++- - 1 file changed, 23 insertions(+), 1 deletion(-) + grub-core/net/tftp.c | 28 +++++++++++++++++++++++++--- + 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index 1157524fc50..5ca0a96a6f6 100644 +index 1157524..dcd8249 100644 --- a/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c @@ -300,6 +300,25 @@ destroy_pq (tftp_data_t data) @@ -41,15 +43,22 @@ index 1157524fc50..5ca0a96a6f6 100644 static grub_err_t tftp_open (struct grub_file *file, const char *filename) { -@@ -337,7 +356,10 @@ tftp_open (struct grub_file *file, const char *filename) +@@ -337,9 +356,12 @@ tftp_open (struct grub_file *file, const char *filename) rrqlen = 0; tftph->opcode = grub_cpu_to_be16_compile_time (TFTP_RRQ); - grub_strcpy (rrq, filename); +- rrqlen += grub_strlen (filename) + 1; +- rrq += grub_strlen (filename) + 1; + + /* Copy and normalize the filename to work-around issues on some tftp + servers when file names are being matched for remapping. */ + grub_normalize_filename (rrq, filename); - rrqlen += grub_strlen (filename) + 1; - rrq += grub_strlen (filename) + 1; ++ rrqlen += grub_strlen (rrq) + 1; ++ rrq += grub_strlen (rrq) + 1; + grub_strcpy (rrq, "octet"); + rrqlen += grub_strlen ("octet") + 1; +-- +1.8.3.1 + diff --git a/0066-efinet-retransmit-if-our-device-is-busy.patch b/0066-efinet-retransmit-if-our-device-is-busy.patch deleted file mode 100644 index 5bbc00ba836d301e32061f8505c6721dc4e68d32..0000000000000000000000000000000000000000 --- a/0066-efinet-retransmit-if-our-device-is-busy.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Josef Bacik -Date: Mon, 31 Aug 2015 13:34:35 -0400 -Subject: [PATCH] efinet: retransmit if our device is busy - -When I fixed the txbuf handling I ripped out the retransmission code since it -was flooding our network when we had the buggy behavior. Turns out this was too -heavy handed as we can still have transient tx timeouts. So instead make sure -we retry our transmission once per timeout. This way we can deal with transient -transmission problems without flooding the box. This fixes an issue we were -seeing in production. Thanks, - -Signed-off-by: Josef Bacik ---- - grub-core/net/drivers/efi/efinet.c | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 5388f952ba9..3f112438a93 100644 ---- a/grub-core/net/drivers/efi/efinet.c -+++ b/grub-core/net/drivers/efi/efinet.c -@@ -38,6 +38,7 @@ send_card_buffer (struct grub_net_card *dev, - grub_efi_simple_network_t *net = dev->efi_net; - grub_uint64_t limit_time = grub_get_time_ms () + 4000; - void *txbuf; -+ int retry = 0; - - if (dev->txbusy) - while (1) -@@ -60,6 +61,15 @@ send_card_buffer (struct grub_net_card *dev, - dev->txbusy = 0; - break; - } -+ if (!retry) -+ { -+ st = efi_call_7 (net->transmit, net, 0, dev->last_pkt_size, -+ dev->txbuf, NULL, NULL, NULL); -+ if (st != GRUB_EFI_SUCCESS) -+ return grub_error (GRUB_ERR_IO, -+ N_("couldn't send network packet")); -+ retry = 1; -+ } - if (limit_time < grub_get_time_ms ()) - return grub_error (GRUB_ERR_TIMEOUT, - N_("couldn't send network packet")); diff --git a/0067-Be-more-aggro-about-actually-using-the-configured-ne.patch b/0067-Be-more-aggro-about-actually-using-the-configured-ne.patch deleted file mode 100644 index 79e234807bc872411581bd5a42d33b2568f324f8..0000000000000000000000000000000000000000 --- a/0067-Be-more-aggro-about-actually-using-the-configured-ne.patch +++ /dev/null @@ -1,221 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 11 Sep 2015 17:30:49 -0400 -Subject: [PATCH] Be more aggro about actually using the *configured* network - device. - -Right now we use any SNP device with the same mac+IP block, but when -it's discovered there will be more than one of them. We need to pick -the same one we were loaded with, so that it'll be configured the same -way as it was before, and won't be re-used by the system firmware later. - -Resolves: rhbz#1257475 - -Signed-off-by: Peter Jones ---- - grub-core/net/drivers/efi/efinet.c | 124 +++++++++++++++++++++++++++++-------- - include/grub/efi/api.h | 4 ++ - 2 files changed, 102 insertions(+), 26 deletions(-) - -diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 3f112438a93..a3ce4c67cce 100644 ---- a/grub-core/net/drivers/efi/efinet.c -+++ b/grub-core/net/drivers/efi/efinet.c -@@ -239,46 +239,85 @@ grub_efinet_get_device_handle (struct grub_net_card *card) - return card->efi_handle; - } - --static void --grub_efinet_findcards (void) -+static int -+grub_efinet_find_snp_cards (int preferred_only, grub_efi_handle_t preferred, -+ int *i) - { -- grub_efi_uintn_t num_handles; -- grub_efi_handle_t *handles; -+ grub_efi_uintn_t num_handles = 0; -+ grub_efi_handle_t *handles = NULL; - grub_efi_handle_t *handle; -- int i = 0; -+ grub_efi_device_path_t *pdp = NULL, *pp = NULL, *pc = NULL; -+ int ret = 0; - -- /* Find handles which support the disk io interface. */ -+ if (preferred) -+ { -+ grub_efi_device_path_t *pdpc; -+ pdpc = pdp = grub_efi_get_device_path (preferred); -+ if (pdp == NULL) -+ { -+ grub_print_error (); -+ return -1; -+ } -+ -+ for (; ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (pdpc); -+ pdpc = GRUB_EFI_NEXT_DEVICE_PATH (pdpc)) -+ { -+ pp = pc; -+ pc = pdpc; -+ } -+ } -+ -+ /* Find handles which support the SNP interface. */ - handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &net_io_guid, - 0, &num_handles); -- if (! handles) -- return; -- for (handle = handles; num_handles--; handle++) -+ -+ for (handle = handles; handle && num_handles--; handle++) - { - grub_efi_simple_network_t *net; - struct grub_net_card *card; - grub_efi_device_path_t *dp, *parent = NULL, *child = NULL; - -- /* EDK2 UEFI PXE driver creates IPv4 and IPv6 messaging devices as -- children of main MAC messaging device. We only need one device with -- bound SNP per physical card, otherwise they compete with each other -- when polling for incoming packets. -- */ -+ /* if we're looking for only the preferred handle, skip anything that -+ isn't it. */ -+ if (preferred_only && preferred != NULL && *handle != preferred) -+ continue; -+ -+ /* if we're not looking for the preferred handle, skip it if it's -+ found. */ -+ if (!preferred_only && *handle == preferred) -+ continue; -+ - dp = grub_efi_get_device_path (*handle); - if (!dp) - continue; -- for (; ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp); dp = GRUB_EFI_NEXT_DEVICE_PATH (dp)) -+ -+ for (; ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp); -+ dp = GRUB_EFI_NEXT_DEVICE_PATH (dp)) - { - parent = child; - child = dp; - } -- if (child -- && GRUB_EFI_DEVICE_PATH_TYPE (child) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE -- && (GRUB_EFI_DEVICE_PATH_SUBTYPE (child) == GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE -- || GRUB_EFI_DEVICE_PATH_SUBTYPE (child) == GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE) -- && parent -- && GRUB_EFI_DEVICE_PATH_TYPE (parent) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE -- && GRUB_EFI_DEVICE_PATH_SUBTYPE (parent) == GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE) -- continue; -+ -+ if (!preferred_only) -+ { -+ if (pp && pc -+ && grub_efi_compare_device_paths (pp, parent) == 0 -+ && grub_efi_compare_device_paths (pc, child) == 0) -+ continue; -+ -+ if (child -+ && (GRUB_EFI_DEVICE_PATH_IS_TYPE(child, -+ GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE, -+ GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE) || -+ GRUB_EFI_DEVICE_PATH_IS_TYPE(child, -+ GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE, -+ GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE)) -+ && parent -+ && (GRUB_EFI_DEVICE_PATH_IS_TYPE(parent, -+ GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE, -+ GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE))) -+ continue; -+ } - - net = grub_efi_open_protocol (*handle, &net_io_guid, - GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); -@@ -302,7 +341,7 @@ grub_efinet_findcards (void) - { - grub_print_error (); - grub_free (handles); -- return; -+ return -1; - } - - card->mtu = net->mode->max_packet_size; -@@ -313,13 +352,14 @@ grub_efinet_findcards (void) - grub_print_error (); - grub_free (handles); - grub_free (card); -- return; -+ return -1; - } - card->txbusy = 0; - - card->rcvbufsize = ALIGN_UP (card->mtu, 64) + 256; - -- card->name = grub_xasprintf ("efinet%d", i++); -+ card->name = grub_xasprintf ("efinet%d", *i); -+ *i = (*i)+1; - card->driver = &efidriver; - card->flags = 0; - card->default_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; -@@ -330,8 +370,38 @@ grub_efinet_findcards (void) - card->efi_handle = *handle; - - grub_net_card_register (card); -+ ret++; - } - grub_free (handles); -+ -+ return ret; -+} -+ -+static void -+grub_efinet_findcards (void) -+{ -+ grub_efi_loaded_image_t *image = NULL; -+ int rc; -+ int efinet_number = 0; -+ -+ image = grub_efi_get_loaded_image (grub_efi_image_handle); -+ -+ if (image && image->device_handle) -+ { -+ rc = grub_efinet_find_snp_cards (1, image->device_handle, &efinet_number); -+ if (rc < 0) -+ return; -+ -+ rc = grub_efinet_find_snp_cards (0, image->device_handle, &efinet_number); -+ if (rc < 0) -+ return; -+ } -+ else -+ { -+ rc = grub_efinet_find_snp_cards (0, NULL, &efinet_number); -+ if (rc < 0) -+ return; -+ } - } - - static void -@@ -352,6 +422,8 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - struct grub_efi_pxe_mode *pxe_mode; - if (card->driver != &efidriver) - continue; -+ if (hnd != card->efi_handle) -+ continue; - cdp = grub_efi_get_device_path (card->efi_handle); - if (! cdp) - continue; -diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index c7c9f0e1db1..97b9aa7a4d7 100644 ---- a/include/grub/efi/api.h -+++ b/include/grub/efi/api.h -@@ -622,6 +622,10 @@ typedef struct grub_efi_device_path grub_efi_device_path_t; - It seems to be identical to EFI_DEVICE_PATH. */ - typedef struct grub_efi_device_path grub_efi_device_path_protocol_t; - -+#define GRUB_EFI_DEVICE_PATH_IS_TYPE(dp, type, subtype) \ -+ ((GRUB_EFI_DEVICE_PATH_TYPE(dp) == (type)) && \ -+ (GRUB_EFI_DEVICE_PATH_SUBTYPE(dp) == (subtype))) -+ - #define GRUB_EFI_DEVICE_PATH_TYPE(dp) ((dp)->type & 0x7f) - #define GRUB_EFI_DEVICE_PATH_SUBTYPE(dp) ((dp)->subtype) - #define GRUB_EFI_DEVICE_PATH_LENGTH(dp) ((dp)->length) diff --git a/0081-bz1374141-fix-incorrect-mask-for-ppc64.patch b/0067-bz1374141-fix-incorrect-mask-for-ppc64.patch similarity index 92% rename from 0081-bz1374141-fix-incorrect-mask-for-ppc64.patch rename to 0067-bz1374141-fix-incorrect-mask-for-ppc64.patch index 628ff7e9092995509e474134589b57027a275f1b..bf2455abb03d4491e28d1e3f9462e9cf77190ffa 100644 --- a/0081-bz1374141-fix-incorrect-mask-for-ppc64.patch +++ b/0067-bz1374141-fix-incorrect-mask-for-ppc64.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 293c75639a43d2ff06fe4824cb306ed81e1aa5af Mon Sep 17 00:00:00 2001 From: Masahiro Matsuya Date: Sat, 29 Oct 2016 08:35:26 +0900 -Subject: [PATCH] bz1374141 fix incorrect mask for ppc64 +Subject: [PATCH 067/220] bz1374141 fix incorrect mask for ppc64 The netmask configured in firmware is not respected on ppc64 (big endian). When 255.255.252.0 is set as netmask in firmware, the following is the value of bootpath string in grub_ieee1275_parse_bootpath(). @@ -30,7 +30,7 @@ The count of zero with __builtin_clz can be 22. (clz counts the number of one bi 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c -index 002446be1c3..3df75357a70 100644 +index ac4e62a..3860b6f 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -220,8 +220,7 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, @@ -43,3 +43,6 @@ index 002446be1c3..3df75357a70 100644 } if (gateway_addr.ipv4 != 0) +-- +1.8.3.1 + diff --git a/0082-Make-grub_fatal-also-backtrace.patch b/0068-Make-grub_fatal-also-backtrace.patch similarity index 92% rename from 0082-Make-grub_fatal-also-backtrace.patch rename to 0068-Make-grub_fatal-also-backtrace.patch index a9af32962f797bb132bd6723acef0ca30965c26d..29cac5004d5905c98249f2e09cece3aa11bea565 100644 --- a/0082-Make-grub_fatal-also-backtrace.patch +++ b/0068-Make-grub_fatal-also-backtrace.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From fc5bc8610eb9e556ced1f1b91f9c4f34a51f3852 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 27 Jan 2016 09:22:42 -0500 -Subject: [PATCH] Make grub_fatal() also backtrace. +Subject: [PATCH 068/220] Make grub_fatal() also backtrace. --- grub-core/Makefile.core.def | 3 ++ @@ -13,10 +13,10 @@ Subject: [PATCH] Make grub_fatal() also backtrace. create mode 100644 grub-core/lib/arm64/backtrace.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 991891a6e09..27563743ba9 100644 +index 99466b1..ebc5580 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -175,6 +175,9 @@ kernel = { +@@ -186,6 +186,9 @@ kernel = { softdiv = lib/division.c; @@ -25,9 +25,9 @@ index 991891a6e09..27563743ba9 100644 + i386 = kern/i386/dl.c; i386_xen = kern/i386/dl.c; - + i386_xen_pvh = kern/i386/dl.c; diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index f1fab700048..5ce89a40c68 100644 +index 1c560ea..04371ac 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -24,6 +24,7 @@ @@ -55,7 +55,7 @@ index f1fab700048..5ce89a40c68 100644 #endif diff --git a/grub-core/lib/arm64/backtrace.c b/grub-core/lib/arm64/backtrace.c new file mode 100644 -index 00000000000..1079b5380e1 +index 0000000..1079b53 --- /dev/null +++ b/grub-core/lib/arm64/backtrace.c @@ -0,0 +1,62 @@ @@ -122,7 +122,7 @@ index 00000000000..1079b5380e1 +} + diff --git a/grub-core/lib/backtrace.c b/grub-core/lib/backtrace.c -index 825a8800e25..c0ad6ab8be1 100644 +index 825a880..c0ad6ab 100644 --- a/grub-core/lib/backtrace.c +++ b/grub-core/lib/backtrace.c @@ -29,6 +29,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); @@ -142,7 +142,7 @@ index 825a8800e25..c0ad6ab8be1 100644 } diff --git a/grub-core/lib/i386/backtrace.c b/grub-core/lib/i386/backtrace.c -index c3e03c7275c..c67273db3ae 100644 +index c3e03c7..c67273d 100644 --- a/grub-core/lib/i386/backtrace.c +++ b/grub-core/lib/i386/backtrace.c @@ -15,11 +15,23 @@ @@ -170,3 +170,6 @@ index c3e03c7275c..c67273db3ae 100644 #include #include #include +-- +1.8.3.1 + diff --git a/0068-efinet-add-filter-for-the-first-exclusive-reopen-of-.patch b/0068-efinet-add-filter-for-the-first-exclusive-reopen-of-.patch deleted file mode 100644 index f337c7442535a503c7b75770ef10b1e2cc1bc59b..0000000000000000000000000000000000000000 --- a/0068-efinet-add-filter-for-the-first-exclusive-reopen-of-.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: RHEL Ninjas -Date: Fri, 25 Sep 2015 16:24:23 +0900 -Subject: [PATCH] efinet: add filter for the first exclusive reopen of SNP - ---- - grub-core/net/drivers/efi/efinet.c | 39 ++++++++++++++++++++++++++++++++++++++ - 1 file changed, 39 insertions(+) - -diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index a3ce4c67cce..b870d3f1938 100644 ---- a/grub-core/net/drivers/efi/efinet.c -+++ b/grub-core/net/drivers/efi/efinet.c -@@ -465,6 +465,45 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - &pxe_mode->dhcp_ack, - sizeof (pxe_mode->dhcp_ack), - 1, device, path); -+ net = grub_efi_open_protocol (card->efi_handle, &net_io_guid, -+ GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE); -+ if (net) { -+ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED -+ && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) -+ continue; -+ -+ if (net->mode->state == GRUB_EFI_NETWORK_STOPPED) -+ continue; -+ -+ if (net->mode->state == GRUB_EFI_NETWORK_STARTED -+ && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS) -+ continue; -+ -+ /* Enable hardware receive filters if driver declares support for it. -+ We need unicast and broadcast and additionaly all nodes and -+ solicited multicast for IPv6. Solicited multicast is per-IPv6 -+ address and we currently do not have API to do it so simply -+ try to enable receive of all multicast packets or evertyhing in -+ the worst case (i386 PXE driver always enables promiscuous too). -+ -+ This does trust firmware to do what it claims to do. -+ */ -+ if (net->mode->receive_filter_mask) -+ { -+ grub_uint32_t filters = GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST | -+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST | -+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST; -+ -+ filters &= net->mode->receive_filter_mask; -+ if (!(filters & GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST)) -+ filters |= (net->mode->receive_filter_mask & -+ GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS); -+ -+ efi_call_6 (net->receive_filters, net, filters, 0, 0, 0, NULL); -+ } -+ -+ card->efi_net = net; -+ } - return; - } - } diff --git a/0084-Fix-up-some-man-pages-rpmdiff-noticed.patch b/0069-Fix-up-some-man-pages-rpmdiff-noticed.patch similarity index 90% rename from 0084-Fix-up-some-man-pages-rpmdiff-noticed.patch rename to 0069-Fix-up-some-man-pages-rpmdiff-noticed.patch index 71b0a22981f75be1abaeae6d3d5e2fa634be0ebd..c079cdc4f0924d828e8ae745142a131857fbc70a 100644 --- a/0084-Fix-up-some-man-pages-rpmdiff-noticed.patch +++ b/0069-Fix-up-some-man-pages-rpmdiff-noticed.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From b059bbecd37f4111fa514a6b7bbda9910325a0f5 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 23 Sep 2014 09:58:49 -0400 -Subject: [PATCH] Fix up some man pages rpmdiff noticed. +Subject: [PATCH 069/220] Fix up some man pages rpmdiff noticed. --- configure.ac | 2 ++ @@ -13,10 +13,10 @@ Subject: [PATCH] Fix up some man pages rpmdiff noticed. create mode 100644 util/grub-syslinux2cfg.1 diff --git a/configure.ac b/configure.ac -index aa06ed59c8d..f69f8986791 100644 +index fc3c2b4..eb851b8 100644 --- a/configure.ac +++ b/configure.ac -@@ -80,6 +80,7 @@ grub_TRANSFORM([grub-get-kernel-settings.3]) +@@ -84,6 +84,7 @@ grub_TRANSFORM([grub-get-kernel-settings.3]) grub_TRANSFORM([grub-glue-efi.3]) grub_TRANSFORM([grub-install.1]) grub_TRANSFORM([grub-kbdcomp.3]) @@ -24,7 +24,7 @@ index aa06ed59c8d..f69f8986791 100644 grub_TRANSFORM([grub-menulst2cfg.1]) grub_TRANSFORM([grub-mkconfig.1]) grub_TRANSFORM([grub-mkfont.3]) -@@ -98,6 +99,7 @@ grub_TRANSFORM([grub-render-label.3]) +@@ -102,6 +103,7 @@ grub_TRANSFORM([grub-render-label.3]) grub_TRANSFORM([grub-script-check.3]) grub_TRANSFORM([grub-set-default.1]) grub_TRANSFORM([grub-sparc64-setup.3]) @@ -34,7 +34,7 @@ index aa06ed59c8d..f69f8986791 100644 if test "x$TARGET_CFLAGS" = x; then diff --git a/util/grub-macbless.8 b/util/grub-macbless.8 new file mode 100644 -index 00000000000..ae842f3a606 +index 0000000..ae842f3 --- /dev/null +++ b/util/grub-macbless.8 @@ -0,0 +1,26 @@ @@ -65,7 +65,7 @@ index 00000000000..ae842f3a606 +.SH SEE ALSO +.BR "info grub" diff --git a/util/grub-mkimage.1 b/util/grub-mkimage.1 -index 4dea4f54597..0eaaafe505b 100644 +index 4dea4f5..0eaaafe 100644 --- a/util/grub-mkimage.1 +++ b/util/grub-mkimage.1 @@ -17,7 +17,7 @@ @@ -79,7 +79,7 @@ index 4dea4f54597..0eaaafe505b 100644 .TP diff --git a/util/grub-syslinux2cfg.1 b/util/grub-syslinux2cfg.1 new file mode 100644 -index 00000000000..85309482718 +index 0000000..8530948 --- /dev/null +++ b/util/grub-syslinux2cfg.1 @@ -0,0 +1,65 @@ @@ -148,3 +148,6 @@ index 00000000000..85309482718 + +.SH SEE ALSO +.BR "info grub" +-- +1.8.3.1 + diff --git a/0070-Warn-if-grub-password-will-not-be-read-1290803.patch b/0070-Warn-if-grub-password-will-not-be-read-1290803.patch deleted file mode 100644 index de4a6aea3a03c9ceb81eb6861e0d5613ce97175e..0000000000000000000000000000000000000000 --- a/0070-Warn-if-grub-password-will-not-be-read-1290803.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robert Marshall -Date: Mon, 22 Feb 2016 15:30:05 -0500 -Subject: [PATCH] Warn if grub password will not be read (#1290803) - -It is possible for a system to have never run grub-mkconfig and add the -section that reads the user.cfg file which contains a user set GRUB -password. Users in that scenario will now be warned that grub-mkconfig -must be run prior to their newly set password taking effect. - -Resolves: rhbz#1290803 ---- - util/grub-setpassword.in | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in -index dd76f00fc0e..fb9d3a3b6f9 100644 ---- a/util/grub-setpassword.in -+++ b/util/grub-setpassword.in -@@ -121,3 +121,8 @@ fi - install -m 0600 /dev/null "${grubdir}/user.cfg" 2>/dev/null || : - chmod 0600 "${grubdir}/user.cfg" 2>/dev/null || : - echo "GRUB2_PASSWORD=${MYPASS}" > "${grubdir}/user.cfg" -+ -+if ! grep -q "^### BEGIN /etc/grub.d/01_users ###$" "${grubdir}/grub.cfg"; then -+ echo "WARNING: The current configuration lacks password support!" -+ echo "Update your configuration with @grub_mkconfig@ to support this feature." -+fi diff --git a/0086-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch b/0070-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch similarity index 82% rename from 0086-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch rename to 0070-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch index e8323376be96ddc79cf92a1b5f405f228beb68ff..1bbd05c262fd3a3cf54981fa58287fa9ba1e2762 100644 --- a/0086-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch +++ b/0070-arm64-make-sure-fdt-has-address-cells-and-size-cells.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 32025dc603bdf22bdb60ebbd881a4b43b587a1a0 Mon Sep 17 00:00:00 2001 From: Mark Salter Date: Mon, 17 Apr 2017 08:44:29 -0400 -Subject: [PATCH] arm64: make sure fdt has #address-cells and #size-cells - properties +Subject: [PATCH 070/220] arm64: make sure fdt has #address-cells and + #size-cells properties Recent upstream changes to kexec-tools relies on #address-cells and #size-cells properties in the FDT. If grub2 needs to create @@ -14,10 +14,10 @@ make sure they exist. 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index a1ac7a38867..93b5cd306eb 100644 +index 04994d5..4c0a09c 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c -@@ -80,7 +80,21 @@ finalize_params_linux (void) +@@ -81,7 +81,21 @@ finalize_params_linux (void) node = grub_fdt_find_subnode (fdt, 0, "chosen"); if (node < 0) @@ -40,3 +40,6 @@ index a1ac7a38867..93b5cd306eb 100644 if (node < 1) goto failure; +-- +1.8.3.1 + diff --git a/0071-Clean-up-grub-setpassword-documentation-1290799.patch b/0071-Clean-up-grub-setpassword-documentation-1290799.patch deleted file mode 100644 index a405e8862f808e6371bb52c526ffba5d10aa143c..0000000000000000000000000000000000000000 --- a/0071-Clean-up-grub-setpassword-documentation-1290799.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robert Marshall -Date: Tue, 26 Jan 2016 10:28:35 -0500 -Subject: [PATCH] Clean up grub-setpassword documentation (#1290799) - -The output for --help had some errors. Corrected those and polished the -text to be a little easier to follow. Carried verbage over to man page -to maintain internal consistency. - -Resolves: rhbz#1290799 ---- - util/grub-setpassword.8 | 2 +- - util/grub-setpassword.in | 15 +++++++-------- - 2 files changed, 8 insertions(+), 9 deletions(-) - -diff --git a/util/grub-setpassword.8 b/util/grub-setpassword.8 -index 49200a848b7..dc91dd6697b 100644 ---- a/util/grub-setpassword.8 -+++ b/util/grub-setpassword.8 -@@ -19,7 +19,7 @@ Display program usage and exit. - -v, --version - Display the current version. - .TP ---o, --output[=\fIDIRECTORY PATH\fR] -+-o, --output=<\fIDIRECTORY\fR> - Choose the file path to which user.cfg will be written. - - .SH SEE ALSO -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in -index fb9d3a3b6f9..c8c0fa4199d 100644 ---- a/util/grub-setpassword.in -+++ b/util/grub-setpassword.in -@@ -16,15 +16,14 @@ grub_mkpasswd="${bindir}/@grub_mkpasswd_pbkdf2@" - # Print the usage. - usage () { - cat < put user.cfg in a user-selected directory - - Report bugs at https://bugzilla.redhat.com. - EOF diff --git a/0087-Make-our-info-pages-say-grub2-where-appropriate.patch b/0071-Make-our-info-pages-say-grub2-where-appropriate.patch similarity index 96% rename from 0087-Make-our-info-pages-say-grub2-where-appropriate.patch rename to 0071-Make-our-info-pages-say-grub2-where-appropriate.patch index 800f7f1b2ba99e60a7b49666b0dd796483e6c439..2c199076749ac96a1ea71945c5f91c5d9a6e401d 100644 --- a/0087-Make-our-info-pages-say-grub2-where-appropriate.patch +++ b/0071-Make-our-info-pages-say-grub2-where-appropriate.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 13afb4d63420d8e1578efc8f5a3fe66c9c14e88a Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Fri, 6 May 2016 18:43:08 -0400 -Subject: [PATCH] Make our info pages say "grub2" where appropriate. +Date: Tue, 9 Jul 2019 12:59:58 +0200 +Subject: [PATCH 071/220] Make our info pages say "grub2" where appropriate. This needs to be hooked up to --program-transform=, but I haven't had time. @@ -13,7 +13,7 @@ Signed-off-by: Peter Jones 2 files changed, 161 insertions(+), 161 deletions(-) diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi -index a9f4de6318c..3ce827ab726 100644 +index ee389fd..e3fed73 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -1,7 +1,7 @@ @@ -35,7 +35,7 @@ index a9f4de6318c..3ce827ab726 100644 @setchapternewpage odd diff --git a/docs/grub.texi b/docs/grub.texi -index a7155c22ffe..2b7b7faf847 100644 +index 221064b..960e5f3 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1,7 +1,7 @@ @@ -609,7 +609,7 @@ index a7155c22ffe..2b7b7faf847 100644 @samp{GRUB_SAVEDEFAULT} (@pxref{Simple configuration}). -@@ -4396,7 +4396,7 @@ Translate @var{string} into the current language. +@@ -4398,7 +4398,7 @@ Translate @var{string} into the current language. The current language code is stored in the @samp{lang} variable in GRUB's environment (@pxref{lang}). Translation files in MO format are read from @@ -618,7 +618,7 @@ index a7155c22ffe..2b7b7faf847 100644 @end deffn -@@ -4791,7 +4791,7 @@ Define a user named @var{user} with password @var{clear-password}. +@@ -4793,7 +4793,7 @@ Define a user named @var{user} with password @var{clear-password}. @deffn Command password_pbkdf2 user hashed-password Define a user named @var{user} with password hash @var{hashed-password}. @@ -627,7 +627,7 @@ index a7155c22ffe..2b7b7faf847 100644 to generate password hashes. @xref{Security}. @end deffn -@@ -5614,8 +5614,8 @@ The @samp{password} (@pxref{password}) and @samp{password_pbkdf2} +@@ -5651,8 +5651,8 @@ The @samp{password} (@pxref{password}) and @samp{password_pbkdf2} which has an associated password. @samp{password} sets the password in plain text, requiring @file{grub.cfg} to be secure; @samp{password_pbkdf2} sets the password hashed using the Password-Based Key Derivation Function @@ -638,7 +638,7 @@ index a7155c22ffe..2b7b7faf847 100644 In order to enable authentication support, the @samp{superusers} environment variable must be set to a list of usernames, separated by any of spaces, -@@ -5659,7 +5659,7 @@ menuentry "May be run by user1 or a superuser" --users user1 @{ +@@ -5696,7 +5696,7 @@ menuentry "May be run by user1 or a superuser" --users user1 @{ @end group @end example @@ -647,7 +647,7 @@ index a7155c22ffe..2b7b7faf847 100644 generating configuration files with authentication. You can use @file{/etc/grub.d/40_custom} to add simple superuser authentication, by adding @kbd{set superusers=} and @kbd{password} or @kbd{password_pbkdf2} -@@ -5684,15 +5684,15 @@ verified with a public key currently trusted by GRUB +@@ -5721,15 +5721,15 @@ verified with a public key currently trusted by GRUB validation fails, then file @file{foo} cannot be opened. This failure may halt or otherwise impact the boot process. @@ -668,7 +668,7 @@ index a7155c22ffe..2b7b7faf847 100644 GRUB uses GPG-style detached signatures (meaning that a file @file{foo.sig} will be produced when file @file{foo} is signed), and -@@ -5712,8 +5712,8 @@ gpg --detach-sign /path/to/file +@@ -5749,8 +5749,8 @@ gpg --detach-sign /path/to/file For successful validation of all of GRUB's subcomponents and the loaded OS kernel, they must all be signed. One way to accomplish this is the following (after having already produced the desired @@ -679,7 +679,7 @@ index a7155c22ffe..2b7b7faf847 100644 @example @group -@@ -5735,7 +5735,7 @@ See also: @ref{check_signatures}, @ref{verify_detached}, @ref{trust}, +@@ -5772,7 +5772,7 @@ See also: @ref{check_signatures}, @ref{verify_detached}, @ref{trust}, Note that internally signature enforcement is controlled by setting the environment variable @code{check_signatures} equal to @code{enforce}. Passing one or more @code{--pubkey} options to @@ -688,7 +688,7 @@ index a7155c22ffe..2b7b7faf847 100644 equal to @code{enforce} in @file{core.img} prior to processing any configuration files. -@@ -6092,10 +6092,10 @@ Required files are: +@@ -6189,10 +6189,10 @@ Required files are: GRUB's normal start-up procedure involves setting the @samp{prefix} environment variable to a value set in the core image by @@ -701,7 +701,7 @@ index a7155c22ffe..2b7b7faf847 100644 things GRUB is supposed to do. If, instead, you only get a rescue shell, this usually means that GRUB -@@ -6121,8 +6121,8 @@ normal +@@ -6218,8 +6218,8 @@ normal However, any problem that leaves you in the rescue shell probably means that GRUB was not correctly installed. It may be more useful to try to reinstall @@ -712,7 +712,7 @@ index a7155c22ffe..2b7b7faf847 100644 @itemize @bullet{} @item -@@ -6134,7 +6134,7 @@ is usually better to use UUIDs or file system labels and avoid depending on +@@ -6231,7 +6231,7 @@ is usually better to use UUIDs or file system labels and avoid depending on drive ordering entirely. @item @@ -721,8 +721,8 @@ index a7155c22ffe..2b7b7faf847 100644 to a partition but GRUB has already been installed in the master boot record, then the GRUB installation in the partition will be ignored. -@@ -6154,21 +6154,21 @@ support has not yet been added to GRUB. - @end itemize +@@ -6262,21 +6262,21 @@ entry which claims partition start at block 0. This change will not hamper + bootability on other machines. -@node Invoking grub-install @@ -749,7 +749,7 @@ index a7155c22ffe..2b7b7faf847 100644 @table @option @item --help -@@ -6184,13 +6184,13 @@ separate partition or a removable disk. +@@ -6292,13 +6292,13 @@ separate partition or a removable disk. If this option is not specified then it defaults to @file{/boot}, so @example @@ -765,7 +765,7 @@ index a7155c22ffe..2b7b7faf847 100644 @end example Here is an example in which you have a separate @dfn{boot} partition which is -@@ -6198,16 +6198,16 @@ mounted on +@@ -6306,16 +6306,16 @@ mounted on @file{/mnt/boot}: @example @@ -785,7 +785,7 @@ index a7155c22ffe..2b7b7faf847 100644 extra space in the bootloader embedding area for Reed-Solomon error-correcting codes. This enables GRUB to still boot successfully if some blocks are corrupted. The exact amount of protection offered -@@ -6220,17 +6220,17 @@ installation}) where GRUB does not reside in any unpartitioned space +@@ -6328,17 +6328,17 @@ installation}) where GRUB does not reside in any unpartitioned space outside of the MBR. Disable the Reed-Solomon codes with this option. @end table @@ -808,7 +808,7 @@ index a7155c22ffe..2b7b7faf847 100644 @table @option @item --help -@@ -6246,17 +6246,17 @@ it to standard output. +@@ -6354,17 +6354,17 @@ it to standard output. @end table @@ -830,7 +830,7 @@ index a7155c22ffe..2b7b7faf847 100644 @table @option @item -c @var{number} -@@ -6274,23 +6274,23 @@ Length of the salt. Defaults to 64. +@@ -6382,23 +6382,23 @@ Length of the salt. Defaults to 64. @end table @@ -860,7 +860,7 @@ index a7155c22ffe..2b7b7faf847 100644 @table @option @item --help -@@ -6301,17 +6301,17 @@ Print the version number of GRUB and exit. +@@ -6409,17 +6409,17 @@ Print the version number of GRUB and exit. @end table @@ -882,7 +882,7 @@ index a7155c22ffe..2b7b7faf847 100644 passed on directly to @command{xorriso} in @command{mkisofs} emulation mode. Options passed to @command{xorriso} will normally be interpreted as @command{mkisofs} options; if the option @samp{--} is used, then anything -@@ -6326,7 +6326,7 @@ mkdir -p disk/boot/grub +@@ -6434,7 +6434,7 @@ mkdir -p disk/boot/grub grub-mkrescue -o grub.iso disk @end example @@ -891,7 +891,7 @@ index a7155c22ffe..2b7b7faf847 100644 @table @option @item --help -@@ -6354,15 +6354,15 @@ Use @var{file} as the @command{xorriso} program, rather than the built-in +@@ -6462,15 +6462,15 @@ Use @var{file} as the @command{xorriso} program, rather than the built-in default. @item --grub-mkimage=@var{file} @@ -911,7 +911,7 @@ index a7155c22ffe..2b7b7faf847 100644 system or file system image that GRUB understands, using GRUB's file system drivers via FUSE. (It is only available if FUSE development files were present when GRUB was built.) This has a number of uses: -@@ -6394,13 +6394,13 @@ even if nobody has yet written a FUSE module specifically for that file +@@ -6502,13 +6502,13 @@ even if nobody has yet written a FUSE module specifically for that file system type. @end itemize @@ -927,7 +927,7 @@ index a7155c22ffe..2b7b7faf847 100644 non-option arguments (if it is given more than one image, it will treat them as a RAID set), and also accepts the following options: -@@ -6422,13 +6422,13 @@ Show debugging output for conditions matching @var{string}. +@@ -6530,13 +6530,13 @@ Show debugging output for conditions matching @var{string}. @item -K prompt|@var{file} @itemx --zfs-key=prompt|@var{file} Load a ZFS encryption key. If you use @samp{prompt} as the argument, @@ -943,7 +943,7 @@ index a7155c22ffe..2b7b7faf847 100644 root of the supplied file system. If @var{device} is just a number, then it will be treated as a partition -@@ -6446,10 +6446,10 @@ Print verbose messages. +@@ -6554,10 +6554,10 @@ Print verbose messages. @end table @@ -957,7 +957,7 @@ index a7155c22ffe..2b7b7faf847 100644 or device. @example -@@ -6457,7 +6457,7 @@ grub-probe --target=fs /boot/grub +@@ -6565,7 +6565,7 @@ grub-probe --target=fs /boot/grub grub-probe --target=drive --device /dev/sda1 @end example @@ -966,7 +966,7 @@ index a7155c22ffe..2b7b7faf847 100644 argument, and also accepts the following options: @table @option -@@ -6470,16 +6470,16 @@ Print the version number of GRUB and exit. +@@ -6578,16 +6578,16 @@ Print the version number of GRUB and exit. @item -d @itemx --device If this option is given, then the non-option argument is a system device @@ -986,7 +986,7 @@ index a7155c22ffe..2b7b7faf847 100644 @item -t @var{target} @itemx --target=@var{target} -@@ -6532,19 +6532,19 @@ Print verbose messages. +@@ -6640,19 +6640,19 @@ Print verbose messages. @end table @@ -1011,3 +1011,6 @@ index a7155c22ffe..2b7b7faf847 100644 @table @option @item --help +-- +1.8.3.1 + diff --git a/0072-Fix-locale-issue-in-grub-setpassword-1294243.patch b/0072-Fix-locale-issue-in-grub-setpassword-1294243.patch deleted file mode 100644 index 9b315cc54ad8344c31b31fb188a3e5c868959510..0000000000000000000000000000000000000000 --- a/0072-Fix-locale-issue-in-grub-setpassword-1294243.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robert Marshall -Date: Fri, 29 Jan 2016 16:56:11 -0500 -Subject: [PATCH] Fix locale issue in grub-setpassword (#1294243) - -A shell substitution was expecting non-translated output to grab the -hashed password and put it in the user.cfg file. Modified code to force -the generic C locale when this particular piece of code is run. - -Resolves: rhbz#1294243 ---- - util/grub-setpassword.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in -index c8c0fa4199d..d7924af5192 100644 ---- a/util/grub-setpassword.in -+++ b/util/grub-setpassword.in -@@ -104,7 +104,7 @@ getpass() { - P1="$1" && shift - - ( echo ${P0} ; echo ${P1} ) | \ -- ${grub_mkpasswd} | \ -+ LC_ALL=C ${grub_mkpasswd} | \ - grep -v '[eE]nter password:' | \ - sed -e "s/PBKDF2 hash of your password is //" - } diff --git a/0088-print-more-debug-info-in-our-module-loader.patch b/0072-print-more-debug-info-in-our-module-loader.patch similarity index 86% rename from 0088-print-more-debug-info-in-our-module-loader.patch rename to 0072-print-more-debug-info-in-our-module-loader.patch index bf2c42f982c46a49d0fecc1e7b0cc2b8e4d10596..2c2a738709e405b4b6b2b2af8abcd69b92ed4467 100644 --- a/0088-print-more-debug-info-in-our-module-loader.patch +++ b/0072-print-more-debug-info-in-our-module-loader.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 2b61111bf5f5fa076faa6c7ad1066823b16b1474 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 1 May 2017 11:19:40 -0400 -Subject: [PATCH] print more debug info in our module loader. +Subject: [PATCH 072/220] print more debug info in our module loader. Signed-off-by: Peter Jones --- @@ -9,7 +9,7 @@ Signed-off-by: Peter Jones 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index e339f264b3a..562d6887e0e 100644 +index 370ce03..a1af9b4 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -313,13 +313,23 @@ grub_efi_modules_addr (void) @@ -39,3 +39,6 @@ index e339f264b3a..562d6887e0e 100644 return (grub_addr_t) info; } +-- +1.8.3.1 + diff --git a/0073-efiemu-Handle-persistent-RAM-and-unknown-possible-fu.patch b/0073-efiemu-Handle-persistent-RAM-and-unknown-possible-fu.patch deleted file mode 100644 index 0891f8f955a8a46dde34db7eb794a4b9cf4e21d1..0000000000000000000000000000000000000000 --- a/0073-efiemu-Handle-persistent-RAM-and-unknown-possible-fu.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robert Elliott -Date: Fri, 22 Jan 2016 13:32:30 +0100 -Subject: [PATCH] efiemu: Handle persistent RAM and unknown possible future - additions. - -(cherry picked from commit ae3b83a4d4df75a01198a2fed7542391e7c449e0) - -Resolves: rhbz#1288608 ---- - grub-core/efiemu/mm.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c -index 52a032f7b2e..92e7df7e501 100644 ---- a/grub-core/efiemu/mm.c -+++ b/grub-core/efiemu/mm.c -@@ -410,8 +410,8 @@ fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, - return grub_efiemu_add_to_mmap (addr, size, - GRUB_EFI_ACPI_MEMORY_NVS); - -- case GRUB_MEMORY_PERSISTENT: -- case GRUB_MEMORY_PERSISTENT_LEGACY: -+ case GRUB_MEMORY_PRAM: -+ case GRUB_MEMORY_PMEM: - return grub_efiemu_add_to_mmap (addr, size, - GRUB_EFI_PERSISTENT_MEMORY); - default: diff --git a/0089-macos-just-build-chainloader-entries-don-t-try-any-x.patch b/0073-macos-just-build-chainloader-entries-don-t-try-any-x.patch similarity index 95% rename from 0089-macos-just-build-chainloader-entries-don-t-try-any-x.patch rename to 0073-macos-just-build-chainloader-entries-don-t-try-any-x.patch index 3a761c0cd1af410e28304f54faa26adb9a7047d8..daf186ff0e980061c056bda45fe300bd72f4a82a 100644 --- a/0089-macos-just-build-chainloader-entries-don-t-try-any-x.patch +++ b/0073-macos-just-build-chainloader-entries-don-t-try-any-x.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 86b5e0f596cd6266c48dd1829d97f0debb5dc5c6 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 24 May 2017 12:42:32 -0400 -Subject: [PATCH] macos: just build chainloader entries, don't try any xnu xnu. +Subject: [PATCH 073/220] macos: just build chainloader entries, don't try any + xnu xnu. Since our bugs tell us that the xnu boot entries really just don't work most of the time, and they create piles of extra boot entries, because @@ -20,7 +21,7 @@ Signed-off-by: Peter Jones 1 file changed, 18 insertions(+), 60 deletions(-) diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in -index 9b8f5968e2d..13a3a6bc752 100644 +index 9b8f596..13a3a6b 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -42,68 +42,25 @@ if [ -z "${OSPROBED}" ] ; then @@ -122,3 +123,6 @@ index 9b8f5968e2d..13a3a6bc752 100644 ;; hurd) onstr="$(gettext_printf "(on %s)" "${DEVICE}")" +-- +1.8.3.1 + diff --git a/0074-efiemu-Fix-compilation-failure.patch b/0074-efiemu-Fix-compilation-failure.patch deleted file mode 100644 index 0c1c10f883be0b55d1d17865087f58238dcfe80d..0000000000000000000000000000000000000000 --- a/0074-efiemu-Fix-compilation-failure.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Vladimir Serbinenko -Date: Fri, 22 Jan 2016 14:10:30 +0100 -Subject: [PATCH] efiemu: Fix compilation failure - -(cherry picked from commit b6a03dfd327489d53ee07c6d7d593b99c7b7cb62) - -Resolves: rhbz#1288608 ---- - grub-core/efiemu/mm.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c -index 92e7df7e501..52a032f7b2e 100644 ---- a/grub-core/efiemu/mm.c -+++ b/grub-core/efiemu/mm.c -@@ -410,8 +410,8 @@ fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, - return grub_efiemu_add_to_mmap (addr, size, - GRUB_EFI_ACPI_MEMORY_NVS); - -- case GRUB_MEMORY_PRAM: -- case GRUB_MEMORY_PMEM: -+ case GRUB_MEMORY_PERSISTENT: -+ case GRUB_MEMORY_PERSISTENT_LEGACY: - return grub_efiemu_add_to_mmap (addr, size, - GRUB_EFI_PERSISTENT_MEMORY); - default: diff --git a/0090-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch b/0074-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch similarity index 88% rename from 0090-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch rename to 0074-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch index eafb894f28175c6ad7c499a1b4a8f7803dd028bc..fecc1f65dff91e817982dda0242e93693c246b7a 100644 --- a/0090-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch +++ b/0074-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 4f25cd0b089dadc0be92e9226fd1eb9e2dda594f Mon Sep 17 00:00:00 2001 From: Jeff Mahoney -Date: Wed, 18 Dec 2013 09:57:04 +0000 -Subject: [PATCH] grub2/btrfs: Add ability to boot from subvolumes +Date: Tue, 9 Jul 2019 13:39:45 +0200 +Subject: [PATCH 074/220] grub2/btrfs: Add ability to boot from subvolumes This patch adds the ability to specify a different root on a btrfs filesystem too boot from other than the default one. @@ -19,25 +19,25 @@ variable and loading the config file from the subvolume. Signed-off-by: Jeff Mahoney --- - grub-core/fs/btrfs.c | 552 +++++++++++++++++++++++++++++++++++++++++++++++++-- + grub-core/fs/btrfs.c | 548 +++++++++++++++++++++++++++++++++++++++++++++++++-- include/grub/btrfs.h | 1 + - 2 files changed, 533 insertions(+), 20 deletions(-) + 2 files changed, 531 insertions(+), 18 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index be195448dbe..51ed63d429b 100644 +index 48bd3d0..6823d97 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -29,6 +29,9 @@ - #include +@@ -38,6 +38,9 @@ + #include #include #include +#include +#include +#include + #include + #include - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -64,9 +67,11 @@ struct grub_btrfs_superblock +@@ -78,9 +81,11 @@ struct grub_btrfs_superblock grub_uint64_t generation; grub_uint64_t root_tree; grub_uint64_t chunk_tree; @@ -51,7 +51,7 @@ index be195448dbe..51ed63d429b 100644 struct grub_btrfs_device this_device; char label[0x100]; grub_uint8_t dummy4[0x100]; -@@ -105,6 +110,7 @@ struct grub_btrfs_data +@@ -120,6 +125,7 @@ struct grub_btrfs_data grub_uint64_t exttree; grub_size_t extsize; struct grub_btrfs_extent_data *extent; @@ -59,7 +59,7 @@ index be195448dbe..51ed63d429b 100644 }; struct grub_btrfs_chunk_item -@@ -171,6 +177,14 @@ struct grub_btrfs_leaf_descriptor +@@ -188,6 +194,14 @@ struct grub_btrfs_leaf_descriptor } *data; }; @@ -74,7 +74,7 @@ index be195448dbe..51ed63d429b 100644 struct grub_btrfs_time { grub_int64_t sec; -@@ -215,6 +229,14 @@ struct grub_btrfs_extent_data +@@ -233,6 +247,14 @@ struct grub_btrfs_extent_data #define GRUB_BTRFS_OBJECT_ID_CHUNK 0x100 @@ -89,7 +89,7 @@ index be195448dbe..51ed63d429b 100644 static grub_disk_addr_t superblock_sectors[] = { 64 * 2, 64 * 1024 * 2, 256 * 1048576 * 2, 1048576ULL * 1048576ULL * 2 }; -@@ -837,6 +859,62 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, +@@ -1153,6 +1175,62 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, return GRUB_ERR_NONE; } @@ -152,7 +152,7 @@ index be195448dbe..51ed63d429b 100644 static struct grub_btrfs_data * grub_btrfs_mount (grub_device_t dev) { -@@ -872,6 +950,13 @@ grub_btrfs_mount (grub_device_t dev) +@@ -1188,6 +1266,13 @@ grub_btrfs_mount (grub_device_t dev) data->devices_attached[0].dev = dev; data->devices_attached[0].id = data->sblock.this_device.device_id; @@ -166,11 +166,10 @@ index be195448dbe..51ed63d429b 100644 return data; } -@@ -1232,6 +1317,91 @@ get_root (struct grub_btrfs_data *data, struct grub_btrfs_key *key, - return GRUB_ERR_NONE; +@@ -1654,6 +1739,91 @@ get_root (struct grub_btrfs_data *data, struct grub_btrfs_key *key, } -+static grub_err_t + static grub_err_t +find_pathname(struct grub_btrfs_data *data, grub_uint64_t objectid, + grub_uint64_t fs_root, const char *name, char **pathname) +{ @@ -255,10 +254,11 @@ index be195448dbe..51ed63d429b 100644 + return 0; +} + - static grub_err_t ++static grub_err_t find_path (struct grub_btrfs_data *data, const char *path, struct grub_btrfs_key *key, -@@ -1250,14 +1420,26 @@ find_path (struct grub_btrfs_data *data, + grub_uint64_t *tree, grub_uint8_t *type) +@@ -1671,14 +1841,26 @@ find_path (struct grub_btrfs_data *data, char *origpath = NULL; unsigned symlinks_max = 32; @@ -289,7 +289,7 @@ index be195448dbe..51ed63d429b 100644 while (1) { while (path[0] == '/') -@@ -1430,9 +1612,21 @@ find_path (struct grub_btrfs_data *data, +@@ -1851,9 +2033,21 @@ find_path (struct grub_btrfs_data *data, path = path_alloc = tmp; if (path[0] == '/') { @@ -314,50 +314,45 @@ index be195448dbe..51ed63d429b 100644 } continue; } -@@ -1673,18 +1867,10 @@ grub_btrfs_read (grub_file_t file, char *buf, grub_size_t len) +@@ -2094,6 +2288,20 @@ grub_btrfs_read (grub_file_t file, char *buf, grub_size_t len) data->tree, file->offset, buf, len); } --static grub_err_t --grub_btrfs_uuid (grub_device_t device, char **uuid) +static char * +btrfs_unparse_uuid(struct grub_btrfs_data *data) - { -- struct grub_btrfs_data *data; -- -- *uuid = NULL; -- -- data = grub_btrfs_mount (device); -- if (!data) -- return grub_errno; -- -- *uuid = grub_xasprintf ("%04x%04x-%04x-%04x-%04x-%04x%04x%04x", ++{ + return grub_xasprintf ("%04x%04x-%04x-%04x-%04x-%04x%04x%04x", - grub_be_to_cpu16 (data->sblock.uuid[0]), - grub_be_to_cpu16 (data->sblock.uuid[1]), - grub_be_to_cpu16 (data->sblock.uuid[2]), -@@ -1693,6 +1879,20 @@ grub_btrfs_uuid (grub_device_t device, char **uuid) - grub_be_to_cpu16 (data->sblock.uuid[5]), - grub_be_to_cpu16 (data->sblock.uuid[6]), - grub_be_to_cpu16 (data->sblock.uuid[7])); ++ grub_be_to_cpu16 (data->sblock.uuid[0]), ++ grub_be_to_cpu16 (data->sblock.uuid[1]), ++ grub_be_to_cpu16 (data->sblock.uuid[2]), ++ grub_be_to_cpu16 (data->sblock.uuid[3]), ++ grub_be_to_cpu16 (data->sblock.uuid[4]), ++ grub_be_to_cpu16 (data->sblock.uuid[5]), ++ grub_be_to_cpu16 (data->sblock.uuid[6]), ++ grub_be_to_cpu16 (data->sblock.uuid[7])); +} + -+static grub_err_t -+grub_btrfs_uuid (grub_device_t device, char **uuid) -+{ -+ struct grub_btrfs_data *data; -+ -+ *uuid = NULL; -+ -+ data = grub_btrfs_mount (device); -+ if (!data) -+ return grub_errno; -+ + static grub_err_t + grub_btrfs_uuid (grub_device_t device, char **uuid) + { +@@ -2105,15 +2313,7 @@ grub_btrfs_uuid (grub_device_t device, char **uuid) + if (!data) + return grub_errno; + +- *uuid = grub_xasprintf ("%04x%04x-%04x-%04x-%04x-%04x%04x%04x", +- grub_be_to_cpu16 (data->sblock.uuid[0]), +- grub_be_to_cpu16 (data->sblock.uuid[1]), +- grub_be_to_cpu16 (data->sblock.uuid[2]), +- grub_be_to_cpu16 (data->sblock.uuid[3]), +- grub_be_to_cpu16 (data->sblock.uuid[4]), +- grub_be_to_cpu16 (data->sblock.uuid[5]), +- grub_be_to_cpu16 (data->sblock.uuid[6]), +- grub_be_to_cpu16 (data->sblock.uuid[7])); + *uuid = btrfs_unparse_uuid(data); grub_btrfs_unmount (data); -@@ -1749,6 +1949,242 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)), +@@ -2170,6 +2370,242 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)), } #endif @@ -599,8 +594,8 @@ index be195448dbe..51ed63d429b 100644 + static struct grub_fs grub_btrfs_fs = { .name = "btrfs", - .dir = grub_btrfs_dir, -@@ -1764,12 +2200,88 @@ static struct grub_fs grub_btrfs_fs = { + .fs_dir = grub_btrfs_dir, +@@ -2185,12 +2621,88 @@ static struct grub_fs grub_btrfs_fs = { #endif }; @@ -690,7 +685,7 @@ index be195448dbe..51ed63d429b 100644 + +// vim: si et sw=2: diff --git a/include/grub/btrfs.h b/include/grub/btrfs.h -index 9d93fb6c182..234ad976771 100644 +index 9d93fb6..234ad97 100644 --- a/include/grub/btrfs.h +++ b/include/grub/btrfs.h @@ -29,6 +29,7 @@ enum @@ -701,3 +696,6 @@ index 9d93fb6c182..234ad976771 100644 GRUB_BTRFS_ITEM_TYPE_CHUNK = 0xe4 }; +-- +1.8.3.1 + diff --git a/0075-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch b/0075-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch deleted file mode 100644 index d6f026ae6192c84e41b6a24e727edcda0405cf25..0000000000000000000000000000000000000000 --- a/0075-Revert-reopen-SNP-protocol-for-exclusive-use-by-grub.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 7 Apr 2016 10:58:06 -0400 -Subject: [PATCH] Revert "reopen SNP protocol for exclusive use by grub" - -I *think* this should have been replaced by upstream's -49426e9fd2e562c73a4f1206f32eff9e424a1a73, so I'm reverting for now. - -May resolve rhbz#1273974. - -This reverts commit 147daeab22db793978f952b6f0d832919a1b0081. ---- - grub-core/net/drivers/efi/efinet.c | 39 -------------------------------------- - 1 file changed, 39 deletions(-) - -diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index b870d3f1938..a3ce4c67cce 100644 ---- a/grub-core/net/drivers/efi/efinet.c -+++ b/grub-core/net/drivers/efi/efinet.c -@@ -465,45 +465,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - &pxe_mode->dhcp_ack, - sizeof (pxe_mode->dhcp_ack), - 1, device, path); -- net = grub_efi_open_protocol (card->efi_handle, &net_io_guid, -- GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE); -- if (net) { -- if (net->mode->state == GRUB_EFI_NETWORK_STOPPED -- && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) -- continue; -- -- if (net->mode->state == GRUB_EFI_NETWORK_STOPPED) -- continue; -- -- if (net->mode->state == GRUB_EFI_NETWORK_STARTED -- && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS) -- continue; -- -- /* Enable hardware receive filters if driver declares support for it. -- We need unicast and broadcast and additionaly all nodes and -- solicited multicast for IPv6. Solicited multicast is per-IPv6 -- address and we currently do not have API to do it so simply -- try to enable receive of all multicast packets or evertyhing in -- the worst case (i386 PXE driver always enables promiscuous too). -- -- This does trust firmware to do what it claims to do. -- */ -- if (net->mode->receive_filter_mask) -- { -- grub_uint32_t filters = GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST | -- GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST | -- GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST; -- -- filters &= net->mode->receive_filter_mask; -- if (!(filters & GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST)) -- filters |= (net->mode->receive_filter_mask & -- GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS); -- -- efi_call_6 (net->receive_filters, net, filters, 0, 0, 0, NULL); -- } -- -- card->efi_net = net; -- } - return; - } - } diff --git a/0091-export-btrfs_subvol-and-btrfs_subvolid.patch b/0075-export-btrfs_subvol-and-btrfs_subvolid.patch similarity index 76% rename from 0091-export-btrfs_subvol-and-btrfs_subvolid.patch rename to 0075-export-btrfs_subvol-and-btrfs_subvolid.patch index a0989e818b57807a47a12d9f2615c2183c6823de..29258015b6f3f0ce89335bbf6b2095404fc7409f 100644 --- a/0091-export-btrfs_subvol-and-btrfs_subvolid.patch +++ b/0075-export-btrfs_subvol-and-btrfs_subvolid.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 2f9525397b30997f24ff1e9fd508839b6d149da5 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Wed, 18 Dec 2013 09:57:04 +0000 -Subject: [PATCH] export btrfs_subvol and btrfs_subvolid +Subject: [PATCH 075/220] export btrfs_subvol and btrfs_subvolid We should export btrfs_subvol and btrfs_subvolid to have both visible to subsidiary configuration files loaded using configfile. @@ -12,10 +12,10 @@ Signed-off-by: Michael Chang 1 file changed, 2 insertions(+) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 51ed63d429b..88d727d161f 100644 +index 6823d97..2d099b1 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -2273,6 +2273,8 @@ GRUB_MOD_INIT (btrfs) +@@ -2694,6 +2694,8 @@ GRUB_MOD_INIT (btrfs) subvol_set_env); grub_register_variable_hook ("btrfs_subvolid", subvolid_get_env, subvolid_set_env); @@ -24,3 +24,6 @@ index 51ed63d429b..88d727d161f 100644 } GRUB_MOD_FINI (btrfs) +-- +1.8.3.1 + diff --git a/0092-grub2-btrfs-03-follow_default.patch b/0076-grub2-btrfs-03-follow_default.patch similarity index 87% rename from 0092-grub2-btrfs-03-follow_default.patch rename to 0076-grub2-btrfs-03-follow_default.patch index 26e91f18adbb434b9b2f0e7f94d3ca110d4912d7..63ce94294ccd4b68aaccc3a54a9140d3af2c77fe 100644 --- a/0092-grub2-btrfs-03-follow_default.patch +++ b/0076-grub2-btrfs-03-follow_default.patch @@ -1,17 +1,17 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 698e60b157eaa58d81150e74a3402a38047a9314 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 21 Aug 2014 03:39:11 +0000 -Subject: [PATCH] grub2-btrfs-03-follow_default +Subject: [PATCH 076/220] grub2-btrfs-03-follow_default --- grub-core/fs/btrfs.c | 107 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 76 insertions(+), 31 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 88d727d161f..a47d297567f 100644 +index 2d099b1..2db89f7 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -920,6 +920,7 @@ grub_btrfs_mount (grub_device_t dev) +@@ -1236,6 +1236,7 @@ grub_btrfs_mount (grub_device_t dev) { struct grub_btrfs_data *data; grub_err_t err; @@ -19,7 +19,7 @@ index 88d727d161f..a47d297567f 100644 if (!dev->disk) { -@@ -950,11 +951,14 @@ grub_btrfs_mount (grub_device_t dev) +@@ -1266,11 +1267,14 @@ grub_btrfs_mount (grub_device_t dev) data->devices_attached[0].dev = dev; data->devices_attached[0].id = data->sblock.this_device.device_id; @@ -38,7 +38,7 @@ index 88d727d161f..a47d297567f 100644 } return data; -@@ -1414,24 +1418,39 @@ find_path (struct grub_btrfs_data *data, +@@ -1835,24 +1839,39 @@ find_path (struct grub_btrfs_data *data, grub_size_t allocated = 0; struct grub_btrfs_dir_item *direl = NULL; struct grub_btrfs_key key_out; @@ -85,7 +85,7 @@ index 88d727d161f..a47d297567f 100644 } else { -@@ -1442,15 +1461,23 @@ find_path (struct grub_btrfs_data *data, +@@ -1863,15 +1882,23 @@ find_path (struct grub_btrfs_data *data, while (1) { @@ -118,7 +118,7 @@ index 88d727d161f..a47d297567f 100644 if (*type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY) { -@@ -1461,7 +1488,9 @@ find_path (struct grub_btrfs_data *data, +@@ -1882,7 +1909,9 @@ find_path (struct grub_btrfs_data *data, if (ctokenlen == 1 && ctoken[0] == '.') { @@ -129,7 +129,7 @@ index 88d727d161f..a47d297567f 100644 continue; } if (ctokenlen == 2 && ctoken[0] == '.' && ctoken[1] == '.') -@@ -1492,8 +1521,9 @@ find_path (struct grub_btrfs_data *data, +@@ -1913,8 +1942,9 @@ find_path (struct grub_btrfs_data *data, *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY; key->object_id = key_out.offset; @@ -141,7 +141,7 @@ index 88d727d161f..a47d297567f 100644 continue; } -@@ -1562,7 +1592,9 @@ find_path (struct grub_btrfs_data *data, +@@ -1983,7 +2013,9 @@ find_path (struct grub_btrfs_data *data, return err; } @@ -152,7 +152,7 @@ index 88d727d161f..a47d297567f 100644 if (cdirel->type == GRUB_BTRFS_DIR_ITEM_TYPE_SYMLINK) { struct grub_btrfs_inode inode; -@@ -1612,14 +1644,26 @@ find_path (struct grub_btrfs_data *data, +@@ -2033,14 +2065,26 @@ find_path (struct grub_btrfs_data *data, path = path_alloc = tmp; if (path[0] == '/') { @@ -186,7 +186,7 @@ index 88d727d161f..a47d297567f 100644 } else { -@@ -2275,6 +2319,7 @@ GRUB_MOD_INIT (btrfs) +@@ -2696,6 +2740,7 @@ GRUB_MOD_INIT (btrfs) subvolid_set_env); grub_env_export ("btrfs_subvol"); grub_env_export ("btrfs_subvolid"); @@ -194,3 +194,6 @@ index 88d727d161f..a47d297567f 100644 } GRUB_MOD_FINI (btrfs) +-- +1.8.3.1 + diff --git a/0093-grub2-btrfs-04-grub2-install.patch b/0077-grub2-btrfs-04-grub2-install.patch similarity index 90% rename from 0093-grub2-btrfs-04-grub2-install.patch rename to 0077-grub2-btrfs-04-grub2-install.patch index af8161645dd68099b5969ae07bb1817ba89e90d1..3431a85f3b257034497d02bbe7765543917bc420 100644 --- a/0093-grub2-btrfs-04-grub2-install.patch +++ b/0077-grub2-btrfs-04-grub2-install.patch @@ -1,19 +1,19 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From d88b2fed5b13498999a6a186cf5a707ce0819f67 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 21 Aug 2014 03:39:11 +0000 -Subject: [PATCH] grub2-btrfs-04-grub2-install +Subject: [PATCH 077/220] grub2-btrfs-04-grub2-install --- grub-core/osdep/linux/getroot.c | 7 +++++++ grub-core/osdep/unix/config.c | 17 +++++++++++++++-- + include/grub/emu/config.h | 1 + util/config.c | 10 ++++++++++ util/grub-install.c | 15 +++++++++++++++ util/grub-mkrelpath.c | 6 ++++++ - include/grub/emu/config.h | 1 + 6 files changed, 54 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c -index 6d9f4e5faa2..5d50dd6f8dc 100644 +index 6d9f4e5..5d50dd6 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -376,6 +376,7 @@ get_btrfs_fs_prefix (const char *mount_path) @@ -38,7 +38,7 @@ index 6d9f4e5faa2..5d50dd6f8dc 100644 else if (!retry && grub_strcmp (entries[i].fstype, "autofs") == 0) { diff --git a/grub-core/osdep/unix/config.c b/grub-core/osdep/unix/config.c -index 65effa9f3a7..b637c58efb7 100644 +index 65effa9..b637c58 100644 --- a/grub-core/osdep/unix/config.c +++ b/grub-core/osdep/unix/config.c @@ -82,6 +82,19 @@ grub_util_load_config (struct grub_util_config *cfg) @@ -72,8 +72,20 @@ index 65effa9f3a7..b637c58efb7 100644 argv[2] = script; argv[3] = '\0'; +diff --git a/include/grub/emu/config.h b/include/grub/emu/config.h +index 875d589..c9a7e5f 100644 +--- a/include/grub/emu/config.h ++++ b/include/grub/emu/config.h +@@ -37,6 +37,7 @@ struct grub_util_config + { + int is_cryptodisk_enabled; + char *grub_distributor; ++ int is_suse_btrfs_snapshot_enabled; + }; + + void diff --git a/util/config.c b/util/config.c -index ebcdd8f5e22..f044a880a76 100644 +index ebcdd8f..f044a88 100644 --- a/util/config.c +++ b/util/config.c @@ -42,6 +42,16 @@ grub_util_parse_config (FILE *f, struct grub_util_config *cfg, int simple) @@ -94,10 +106,10 @@ index ebcdd8f5e22..f044a880a76 100644 sizeof ("GRUB_DISTRIBUTOR=") - 1) == 0) { diff --git a/util/grub-install.c b/util/grub-install.c -index 78d0138cb0a..4375c161955 100644 +index 8a55ad4..0e807b0 100644 --- a/util/grub-install.c +++ b/util/grub-install.c -@@ -816,6 +816,8 @@ fill_core_services (const char *core_services) +@@ -819,6 +819,8 @@ fill_core_services (const char *core_services) free (sysv_plist); } @@ -106,7 +118,7 @@ index 78d0138cb0a..4375c161955 100644 int main (int argc, char *argv[]) { -@@ -849,6 +851,9 @@ main (int argc, char *argv[]) +@@ -852,6 +854,9 @@ main (int argc, char *argv[]) grub_util_load_config (&config); @@ -116,7 +128,7 @@ index 78d0138cb0a..4375c161955 100644 if (!bootloader_id && config.grub_distributor) { char *ptr; -@@ -1321,6 +1326,16 @@ main (int argc, char *argv[]) +@@ -1344,6 +1349,16 @@ main (int argc, char *argv[]) fprintf (load_cfg_f, "set debug='%s'\n", debug_image); } @@ -134,7 +146,7 @@ index 78d0138cb0a..4375c161955 100644 char *install_drive = NULL; diff --git a/util/grub-mkrelpath.c b/util/grub-mkrelpath.c -index 47a241a391b..5db7a9a7d97 100644 +index 47a241a..5db7a9a 100644 --- a/util/grub-mkrelpath.c +++ b/util/grub-mkrelpath.c @@ -40,9 +40,12 @@ struct arguments @@ -160,15 +172,6 @@ index 47a241a391b..5db7a9a7d97 100644 case ARGP_KEY_ARG: if (state->arg_num == 0) arguments->pathname = xstrdup (arg); -diff --git a/include/grub/emu/config.h b/include/grub/emu/config.h -index 875d5896ce1..c9a7e5f4ade 100644 ---- a/include/grub/emu/config.h -+++ b/include/grub/emu/config.h -@@ -37,6 +37,7 @@ struct grub_util_config - { - int is_cryptodisk_enabled; - char *grub_distributor; -+ int is_suse_btrfs_snapshot_enabled; - }; - - void +-- +1.8.3.1 + diff --git a/0094-grub2-btrfs-05-grub2-mkconfig.patch b/0078-grub2-btrfs-05-grub2-mkconfig.patch similarity index 87% rename from 0094-grub2-btrfs-05-grub2-mkconfig.patch rename to 0078-grub2-btrfs-05-grub2-mkconfig.patch index d7bfb4d833118990da623e59f85298327b9ff496..02b7a84b87959ef95723ac05398b290ad9978eb1 100644 --- a/0094-grub2-btrfs-05-grub2-mkconfig.patch +++ b/0078-grub2-btrfs-05-grub2-mkconfig.patch @@ -1,18 +1,19 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 62438d289c38a88cd0d3d1efad8a52f0de44b6b3 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 21 Aug 2014 03:39:11 +0000 -Subject: [PATCH] grub2-btrfs-05-grub2-mkconfig +Subject: [PATCH 078/220] grub2-btrfs-05-grub2-mkconfig +Signed-off-by: Michael Chang --- util/grub-mkconfig.in | 3 ++- util/grub-mkconfig_lib.in | 4 ++++ - util/grub.d/00_header.in | 24 +++++++++++++++++++++++- + util/grub.d/00_header.in | 25 ++++++++++++++++++++++++- util/grub.d/10_linux.in | 4 ++++ util/grub.d/20_linux_xen.in | 4 ++++ - 5 files changed, 37 insertions(+), 2 deletions(-) + 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 8218f3d477f..4248b9341ab 100644 +index 6247a0b..4649e92 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -258,7 +258,8 @@ export GRUB_DEFAULT \ @@ -26,7 +27,7 @@ index 8218f3d477f..4248b9341ab 100644 if test "x${grub_cfg}" != "x"; then rm -f "${grub_cfg}.new" diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 113a41f9409..b3aae534ddc 100644 +index 113a41f..b3aae53 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -52,7 +52,11 @@ grub_warn () @@ -42,7 +43,7 @@ index 113a41f9409..b3aae534ddc 100644 is_path_readable_by_grub () diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in -index 858b526c925..e2a53300126 100644 +index 858b526..de727e6 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -27,6 +27,14 @@ export TEXTDOMAINDIR="@localedir@" @@ -71,12 +72,13 @@ index 858b526c925..e2a53300126 100644 load_env fi EOF -@@ -356,3 +366,15 @@ fi +@@ -356,3 +366,16 @@ fi if [ "x${GRUB_BADRAM}" != "x" ] ; then echo "badram ${GRUB_BADRAM}" fi + +if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] && ++ [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ] && + [ "x${GRUB_FS}" = "xbtrfs" ] ; then + # Note: No $snapshot_num on *read-only* rollback! (bsc#901487) + cat </dev/null || true` diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in -index 972a4b5a03d..bcdc3ceac02 100644 +index 47e0d3f..1519ec6 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -73,10 +73,14 @@ fi @@ -125,3 +127,6 @@ index 972a4b5a03d..bcdc3ceac02 100644 fi;; xzfs) rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` +-- +1.8.3.1 + diff --git a/0095-grub2-btrfs-06-subvol-mount.patch b/0079-grub2-btrfs-06-subvol-mount.patch similarity index 93% rename from 0095-grub2-btrfs-06-subvol-mount.patch rename to 0079-grub2-btrfs-06-subvol-mount.patch index 493f1331c9ba4aba1268d1d318d48db5bc6cd6bb..5ba4bf87e4c8fc9ec61bf67b6a3525f69d383025 100644 --- a/0095-grub2-btrfs-06-subvol-mount.patch +++ b/0079-grub2-btrfs-06-subvol-mount.patch @@ -1,28 +1,28 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 226e9d1f9fde6c6ccf711ba7112135bfa1c01868 Mon Sep 17 00:00:00 2001 From: Michael Chang -Date: Fri, 22 May 2015 11:45:25 +0000 -Subject: [PATCH] grub2-btrfs-06-subvol-mount +Date: Tue, 9 Jul 2019 13:56:16 +0200 +Subject: [PATCH 079/220] grub2-btrfs-06-subvol-mount --- grub-core/fs/btrfs.c | 195 +++++++++++++++++++++++++++++++++++++++- grub-core/osdep/linux/getroot.c | 148 +++++++++++++++++++++++++++++- - util/grub-install.c | 49 ++++++++++ include/grub/emu/getroot.h | 5 ++ + util/grub-install.c | 49 ++++++++++ 4 files changed, 392 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index a47d297567f..2e36ac47e8a 100644 +index 2db89f7..1627234 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -32,6 +32,7 @@ +@@ -41,6 +41,7 @@ #include #include #include +#include + #include + #include - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -245,6 +246,12 @@ static grub_err_t +@@ -263,6 +264,12 @@ static grub_err_t grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, void *buf, grub_size_t size, int recursion_depth); @@ -35,7 +35,7 @@ index a47d297567f..2e36ac47e8a 100644 static grub_err_t read_sblock (grub_disk_t disk, struct grub_btrfs_superblock *sb) -@@ -887,9 +894,26 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path) +@@ -1203,9 +1210,26 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path) grub_err_t err; grub_uint64_t tree = 0; grub_uint8_t type; @@ -62,7 +62,7 @@ index a47d297567f..2e36ac47e8a 100644 if (err) return grub_error(GRUB_ERR_FILE_NOT_FOUND, "couldn't locate %s\n", path); -@@ -1758,11 +1782,20 @@ grub_btrfs_dir (grub_device_t device, const char *path, +@@ -2179,11 +2203,20 @@ grub_btrfs_dir (grub_device_t device, const char *path, int r = 0; grub_uint64_t tree; grub_uint8_t type; @@ -84,7 +84,7 @@ index a47d297567f..2e36ac47e8a 100644 if (err) { grub_btrfs_unmount (data); -@@ -1864,11 +1897,21 @@ grub_btrfs_open (struct grub_file *file, const char *name) +@@ -2285,11 +2318,21 @@ grub_btrfs_open (struct grub_file *file, const char *name) struct grub_btrfs_inode inode; grub_uint8_t type; struct grub_btrfs_key key_in; @@ -107,7 +107,7 @@ index a47d297567f..2e36ac47e8a 100644 if (err) { grub_btrfs_unmount (data); -@@ -2039,6 +2082,150 @@ grub_cmd_btrfs_info (grub_command_t cmd __attribute__ ((unused)), int argc, +@@ -2460,6 +2503,150 @@ grub_cmd_btrfs_info (grub_command_t cmd __attribute__ ((unused)), int argc, return 0; } @@ -258,7 +258,7 @@ index a47d297567f..2e36ac47e8a 100644 static grub_err_t get_fs_root(struct grub_btrfs_data *data, grub_uint64_t tree, grub_uint64_t objectid, grub_uint64_t offset, -@@ -2245,6 +2432,7 @@ static struct grub_fs grub_btrfs_fs = { +@@ -2666,6 +2853,7 @@ static struct grub_fs grub_btrfs_fs = { }; static grub_command_t cmd_info; @@ -266,7 +266,7 @@ index a47d297567f..2e36ac47e8a 100644 static grub_extcmd_t cmd_list_subvols; static char * -@@ -2308,6 +2496,9 @@ GRUB_MOD_INIT (btrfs) +@@ -2729,6 +2917,9 @@ GRUB_MOD_INIT (btrfs) cmd_info = grub_register_command("btrfs-info", grub_cmd_btrfs_info, "DEVICE", "Print BtrFS info about DEVICE."); @@ -277,7 +277,7 @@ index a47d297567f..2e36ac47e8a 100644 grub_cmd_btrfs_list_subvols, 0, "[-p|-n] [-o var] DEVICE", diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c -index 5d50dd6f8dc..4c5a13022dc 100644 +index 5d50dd6..4c5a130 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -107,6 +107,14 @@ struct btrfs_ioctl_search_key @@ -459,11 +459,27 @@ index 5d50dd6f8dc..4c5a13022dc 100644 char * grub_make_system_path_relative_to_its_root_os (const char *path) { +diff --git a/include/grub/emu/getroot.h b/include/grub/emu/getroot.h +index 73fa2d3..9c642ae 100644 +--- a/include/grub/emu/getroot.h ++++ b/include/grub/emu/getroot.h +@@ -53,6 +53,11 @@ char ** + grub_find_root_devices_from_mountinfo (const char *dir, char **relroot); + #endif + ++#ifdef __linux__ ++char * ++grub_util_get_btrfs_subvol (const char *path, char **mount_path); ++#endif ++ + /* Devmapper functions provided by getroot_devmapper.c. */ + void + grub_util_pull_devmapper (const char *os_dev); diff --git a/util/grub-install.c b/util/grub-install.c -index 4375c161955..a0ad99729fd 100644 +index 0e807b0..3e718b9 100644 --- a/util/grub-install.c +++ b/util/grub-install.c -@@ -1535,6 +1535,55 @@ main (int argc, char *argv[]) +@@ -1561,6 +1561,55 @@ main (int argc, char *argv[]) prefix_drive = xasprintf ("(%s)", grub_drives[0]); } @@ -519,19 +535,6 @@ index 4375c161955..a0ad99729fd 100644 char mkimage_target[200]; const char *core_name = NULL; -diff --git a/include/grub/emu/getroot.h b/include/grub/emu/getroot.h -index 73fa2d34abb..9c642ae3fe3 100644 ---- a/include/grub/emu/getroot.h -+++ b/include/grub/emu/getroot.h -@@ -53,6 +53,11 @@ char ** - grub_find_root_devices_from_mountinfo (const char *dir, char **relroot); - #endif - -+#ifdef __linux__ -+char * -+grub_util_get_btrfs_subvol (const char *path, char **mount_path); -+#endif -+ - /* Devmapper functions provided by getroot_devmapper.c. */ - void - grub_util_pull_devmapper (const char *os_dev); +-- +1.8.3.1 + diff --git a/0097-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch b/0080-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch similarity index 83% rename from 0097-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch rename to 0080-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch index a413446038e14b88af497fd94e15c62ff5be2590..c56e7bb6777aaa5c586cda96de050dc7e1a52f8a 100644 --- a/0097-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch +++ b/0080-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From dea875db30d83eeed6b53c3fc72a0dbb178abb94 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 21 Jun 2016 16:44:17 +0000 -Subject: [PATCH] Fallback to old subvol name scheme to support old snapshot - config +Subject: [PATCH 080/220] Fallback to old subvol name scheme to support old + snapshot config Ref: bsc#953538 --- @@ -10,14 +10,13 @@ Ref: bsc#953538 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 2e36ac47e8a..4a31d39ee74 100644 +index 1627234..69c30e6 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -924,11 +924,41 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path) - return GRUB_ERR_NONE; +@@ -1241,10 +1241,40 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path) } -+static grub_err_t + static grub_err_t +lookup_root_by_name_fallback(struct grub_btrfs_data *data, const char *path) +{ + grub_err_t err; @@ -36,7 +35,7 @@ index 2e36ac47e8a..4a31d39ee74 100644 + return GRUB_ERR_NONE; +} + - static grub_err_t ++static grub_err_t btrfs_handle_subvol(struct grub_btrfs_data *data __attribute__ ((unused))) { if (btrfs_default_subvol) @@ -56,3 +55,6 @@ index 2e36ac47e8a..4a31d39ee74 100644 if (btrfs_default_subvolid) return lookup_root_by_id(data, btrfs_default_subvolid); +-- +1.8.3.1 + diff --git a/0080-Fix-malformed-tftp-packets.patch b/0080-Fix-malformed-tftp-packets.patch deleted file mode 100644 index 24451377d618e794795eb4b8cdc78eca22c83828..0000000000000000000000000000000000000000 --- a/0080-Fix-malformed-tftp-packets.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Mark Salter -Date: Tue, 7 Mar 2017 18:26:17 -0500 -Subject: [PATCH] Fix malformed tftp packets - -0088-Normalize-slashes-in-tftp-paths.patch collapses multiple contiguous -slashes in a filename into one slash in the tftp packet filename field. -However, the packet buffer pointer is advanced using the original name. -This leaves unitialized data between the name field and the type field -leading to tftp errors. Use the length of the normalized name to avoid -this. - -Signed-off-by: Mark Salter ---- - grub-core/net/tftp.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index 5ca0a96a6f6..dcd82494309 100644 ---- a/grub-core/net/tftp.c -+++ b/grub-core/net/tftp.c -@@ -360,8 +360,8 @@ tftp_open (struct grub_file *file, const char *filename) - /* Copy and normalize the filename to work-around issues on some tftp - servers when file names are being matched for remapping. */ - grub_normalize_filename (rrq, filename); -- rrqlen += grub_strlen (filename) + 1; -- rrq += grub_strlen (filename) + 1; -+ rrqlen += grub_strlen (rrq) + 1; -+ rrq += grub_strlen (rrq) + 1; - - grub_strcpy (rrq, "octet"); - rrqlen += grub_strlen ("octet") + 1; diff --git a/0098-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch b/0081-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch similarity index 95% rename from 0098-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch rename to 0081-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch index 0f4ce500e3e938dc6ed372c138d33693323a6493..b0342ae51a879f72da586fdf9438290bc6f54858 100644 --- a/0098-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch +++ b/0081-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch @@ -1,17 +1,18 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 0a31b397d0d3bc28e19401abe9b675fe7d3bb526 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 11 May 2017 08:56:57 +0000 -Subject: [PATCH] Grub not working correctly with btrfs snapshots (bsc#1026511) +Subject: [PATCH 081/220] Grub not working correctly with btrfs snapshots + (bsc#1026511) --- grub-core/fs/btrfs.c | 238 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 238 insertions(+) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 4a31d39ee74..7002ad81b7e 100644 +index 69c30e6..ba99d04 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -2446,6 +2446,238 @@ out: +@@ -2867,6 +2867,238 @@ out: return 0; } @@ -249,8 +250,8 @@ index 4a31d39ee74..7002ad81b7e 100644 + static struct grub_fs grub_btrfs_fs = { .name = "btrfs", - .dir = grub_btrfs_dir, -@@ -2464,6 +2696,7 @@ static struct grub_fs grub_btrfs_fs = { + .fs_dir = grub_btrfs_dir, +@@ -2885,6 +3117,7 @@ static struct grub_fs grub_btrfs_fs = { static grub_command_t cmd_info; static grub_command_t cmd_mount_subvol; static grub_extcmd_t cmd_list_subvols; @@ -258,7 +259,7 @@ index 4a31d39ee74..7002ad81b7e 100644 static char * subvolid_set_env (struct grub_env_var *var __attribute__ ((unused)), -@@ -2534,6 +2767,11 @@ GRUB_MOD_INIT (btrfs) +@@ -2955,6 +3188,11 @@ GRUB_MOD_INIT (btrfs) "[-p|-n] [-o var] DEVICE", "Print list of BtrFS subvolumes on " "DEVICE.", options); @@ -270,3 +271,6 @@ index 4a31d39ee74..7002ad81b7e 100644 grub_register_variable_hook ("btrfs_subvol", subvol_get_env, subvol_set_env); grub_register_variable_hook ("btrfs_subvolid", subvolid_get_env, +-- +1.8.3.1 + diff --git a/0099-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch b/0082-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch similarity index 92% rename from 0099-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch rename to 0082-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch index 9a4a5c2074cc1cd2ae2ac66aab8332cc4cd83b8d..051c7bacafe4d8e4b35e31446157a72a7e17d663 100644 --- a/0099-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch +++ b/0082-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 67fceb3fe4d6a167f26478fa2c3fdbac9a9bc871 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 1 Jun 2017 09:59:56 -0400 -Subject: [PATCH] Add grub_efi_allocate_pool() and grub_efi_free_pool() +Subject: [PATCH 082/220] Add grub_efi_allocate_pool() and grub_efi_free_pool() wrappers. Signed-off-by: Peter Jones @@ -10,7 +10,7 @@ Signed-off-by: Peter Jones 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 39480b38674..09a18e56302 100644 +index 090c862..5e2b479 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -24,6 +24,10 @@ @@ -70,3 +70,6 @@ index 39480b38674..09a18e56302 100644 extern int EXPORT_VAR(grub_efi_is_finished); struct grub_net_card; +-- +1.8.3.1 + diff --git a/0083-Make-grub-editenv-build-again.patch b/0083-Make-grub-editenv-build-again.patch deleted file mode 100644 index 64c001fef974a5abad1c35c4bacc2985a04cacf2..0000000000000000000000000000000000000000 --- a/0083-Make-grub-editenv-build-again.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 4 Mar 2016 16:29:13 -0500 -Subject: [PATCH] Make grub-editenv build again. - -36212460d3565b18439a3a8130b28e6c97702c6a split how some of the mkimage -utility functions are defined, and they wind up being linked into -grub-editenv. Most utilities got fixed, but this one was missed. - -Signed-off-by: Peter Jones ---- - Makefile.util.def | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/Makefile.util.def b/Makefile.util.def -index 2d032643de7..879e8eb98a4 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -237,6 +237,8 @@ program = { - extra_dist = grub-core/osdep/unix/compress.c; - extra_dist = grub-core/osdep/basic/compress.c; - common = util/mkimage.c; -+ common = util/grub-mkimage32.c; -+ common = util/grub-mkimage64.c; - common = grub-core/osdep/config.c; - common = util/config.c; - common = util/resolve.c; diff --git a/0100-Use-grub_efi_.-memory-helpers-where-reasonable.patch b/0083-Use-grub_efi_.-memory-helpers-where-reasonable.patch similarity index 85% rename from 0100-Use-grub_efi_.-memory-helpers-where-reasonable.patch rename to 0083-Use-grub_efi_.-memory-helpers-where-reasonable.patch index 0dc026f45ba9c5660a17275d846ccde68c625a85..f65956a10b6afa30fa4706d50d71dc90721ed12f 100644 --- a/0100-Use-grub_efi_.-memory-helpers-where-reasonable.patch +++ b/0083-Use-grub_efi_.-memory-helpers-where-reasonable.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 2a70ee4ec02463e5eda6137de9e3e7d9f1b2021a Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 1 Jun 2017 10:06:38 -0400 -Subject: [PATCH] Use grub_efi_...() memory helpers where reasonable. +Subject: [PATCH 083/220] Use grub_efi_...() memory helpers where reasonable. This uses grub_efi_allocate_pool(), grub_efi_free_pool(), and grub_efi_free_pages() instead of open-coded efi_call_N() calls, so we @@ -13,7 +13,7 @@ Signed-off-by: Peter Jones 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 5cd9b6e08a8..106eb10a362 100644 +index 5aa3a5d..3a724a9 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -65,7 +65,7 @@ grub_chainloader_unload (void) @@ -34,7 +34,7 @@ index 5cd9b6e08a8..106eb10a362 100644 grub_loader_unset (); -@@ -500,10 +500,9 @@ grub_efi_get_media_file_path (grub_efi_device_path_t *dp) +@@ -506,10 +506,9 @@ grub_efi_get_media_file_path (grub_efi_device_path_t *dp) static grub_efi_boolean_t handle_image (void *data, grub_efi_uint32_t datasize) { @@ -46,7 +46,7 @@ index 5cd9b6e08a8..106eb10a362 100644 char *buffer_aligned = NULL; grub_efi_uint32_t i; struct grub_pe32_section_table *section; -@@ -514,8 +513,6 @@ handle_image (void *data, grub_efi_uint32_t datasize) +@@ -520,8 +519,6 @@ handle_image (void *data, grub_efi_uint32_t datasize) int found_entry_point = 0; int rc; @@ -55,7 +55,7 @@ index 5cd9b6e08a8..106eb10a362 100644 rc = read_header (data, datasize, &context); if (rc < 0) { -@@ -555,8 +552,8 @@ handle_image (void *data, grub_efi_uint32_t datasize) +@@ -561,8 +558,8 @@ handle_image (void *data, grub_efi_uint32_t datasize) grub_dprintf ("chain", "image size is %08"PRIxGRUB_UINT64_T", datasize is %08x\n", context.image_size, datasize); @@ -66,7 +66,7 @@ index 5cd9b6e08a8..106eb10a362 100644 if (efi_status != GRUB_EFI_SUCCESS) { -@@ -788,14 +785,14 @@ handle_image (void *data, grub_efi_uint32_t datasize) +@@ -794,14 +791,14 @@ handle_image (void *data, grub_efi_uint32_t datasize) grub_dprintf ("chain", "entry_point returned %ld\n", efi_status); grub_memcpy (li, &li_bak, sizeof (grub_efi_loaded_image_t)); @@ -83,7 +83,7 @@ index 5cd9b6e08a8..106eb10a362 100644 return 0; } -@@ -803,10 +800,7 @@ error_exit: +@@ -809,10 +806,7 @@ error_exit: static grub_err_t grub_secureboot_chainloader_unload (void) { @@ -95,7 +95,7 @@ index 5cd9b6e08a8..106eb10a362 100644 grub_free (file_path); grub_free (cmdline); cmdline = 0; -@@ -1073,7 +1067,7 @@ fail: +@@ -1079,7 +1073,7 @@ fail: grub_free (file_path); if (address) @@ -104,3 +104,6 @@ index 5cd9b6e08a8..106eb10a362 100644 if (cmdline) grub_free (cmdline); +-- +1.8.3.1 + diff --git a/0101-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch b/0084-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch similarity index 85% rename from 0101-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch rename to 0084-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch index c7259543605850b01e06420114a14bc5d7196a27..8ebf61b50428b5d8ac741c769a1675b7811fd4bf 100644 --- a/0101-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch +++ b/0084-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From aa6edc58113ecb1ff34417fa4702ff10b4e32ded Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 1 Jun 2017 10:07:50 -0400 -Subject: [PATCH] Add PRIxGRUB_EFI_STATUS and use it. +Subject: [PATCH 084/220] Add PRIxGRUB_EFI_STATUS and use it. This avoids syntax checkers getting confused about if it's llx or lx. @@ -12,10 +12,10 @@ Signed-off-by: Peter Jones 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 106eb10a362..3630b0cbf2d 100644 +index 3a724a9..f4ddbed 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c -@@ -783,7 +783,8 @@ handle_image (void *data, grub_efi_uint32_t datasize) +@@ -789,7 +789,8 @@ handle_image (void *data, grub_efi_uint32_t datasize) efi_status = efi_call_2 (entry_point, grub_efi_image_handle, grub_efi_system_table); @@ -26,7 +26,7 @@ index 106eb10a362..3630b0cbf2d 100644 efi_status = grub_efi_free_pool (buffer); diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 02488ec35ae..ddc5ecfb03d 100644 +index d97cdf9..955973e 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -527,6 +527,14 @@ typedef grub_uint8_t grub_efi_char8_t; @@ -44,3 +44,6 @@ index 02488ec35ae..ddc5ecfb03d 100644 #define GRUB_EFI_ERROR_CODE(value) \ ((((grub_efi_status_t) 1) << (sizeof (grub_efi_status_t) * 8 - 1)) | (value)) +-- +1.8.3.1 + diff --git a/0102-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch b/0085-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch similarity index 86% rename from 0102-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch rename to 0085-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch index 882cf5d70b0438f983f84a7c7d46dd0335b413cf..d57c5c378cf9ce7595ef90d9c9ace84f9733672e 100644 --- a/0102-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch +++ b/0085-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch @@ -1,15 +1,15 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From a7fba153297429ab5124366aba482a462c239a3e Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 26 Jun 2017 12:42:57 -0400 -Subject: [PATCH] Don't use dynamic sized arrays since we don't build with - -std=c99 +Subject: [PATCH 085/220] Don't use dynamic sized arrays since we don't build + with -std=c99 --- grub-core/net/net.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 4be228d9576..fa3e2912643 100644 +index f24f1fd..5366e44 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -1853,14 +1853,25 @@ grub_net_search_configfile (char *config) @@ -41,3 +41,6 @@ index 4be228d9576..fa3e2912643 100644 if (client_uuid) { grub_strcpy (suffix, client_uuid); +-- +1.8.3.1 + diff --git a/0085-Make-exit-take-a-return-code.patch b/0085-Make-exit-take-a-return-code.patch deleted file mode 100644 index b886e12226b4718ad34e2514de7f6ba6b833b23b..0000000000000000000000000000000000000000 --- a/0085-Make-exit-take-a-return-code.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 26 Feb 2014 21:49:12 -0500 -Subject: [PATCH] Make "exit" take a return code. - -This adds "exit" with a return code. With this patch, any "exit" -command /may/ include a return code, and on platforms that support -returning with an exit status, we will do so. By default we return the -same exit status we did before this patch. - -Signed-off-by: Peter Jones ---- - grub-core/kern/emu/main.c | 6 ++++++ - grub-core/kern/misc.c | 9 +++++++++ - 2 files changed, 15 insertions(+) - -diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c -index 55ea5a11ccd..7e47ec81263 100644 ---- a/grub-core/kern/emu/main.c -+++ b/grub-core/kern/emu/main.c -@@ -72,6 +72,12 @@ grub_exit (int retval __attribute__((unused))) - grub_reboot (); - } - -+void -+grub_exit (int retval __attribute__((unused))) -+{ -+ grub_reboot (); -+} -+ - void - grub_machine_init (void) - { -diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 5ce89a40c68..04371ac49f2 100644 ---- a/grub-core/kern/misc.c -+++ b/grub-core/kern/misc.c -@@ -1120,6 +1120,15 @@ grub_abort (void) - grub_exit (1); - } - -+#if defined (__clang__) && !defined (GRUB_UTIL) -+/* clang emits references to abort(). */ -+void __attribute__ ((noreturn)) -+abort (void) -+{ -+ grub_abort (); -+} -+#endif -+ - void - grub_fatal (const char *fmt, ...) - { diff --git a/0103-don-t-ignore-const.patch b/0086-don-t-ignore-const.patch similarity index 76% rename from 0103-don-t-ignore-const.patch rename to 0086-don-t-ignore-const.patch index 6b4d390bef3764373ea061a07c512cdceac76991..c84fba85def44b52063e2fe971f4fbb8990f5586 100644 --- a/0103-don-t-ignore-const.patch +++ b/0086-don-t-ignore-const.patch @@ -1,14 +1,14 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From f35f4b17be40199adb6df155f208da0a33ea95e9 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 26 Jun 2017 12:43:22 -0400 -Subject: [PATCH] don't ignore const +Subject: [PATCH 086/220] don't ignore const --- grub-core/net/tftp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index dcd82494309..f90071353ad 100644 +index dcd8249..f900713 100644 --- a/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c @@ -307,7 +307,7 @@ static void @@ -20,3 +20,6 @@ index dcd82494309..f90071353ad 100644 while (*src != '\0') { +-- +1.8.3.1 + diff --git a/0104-don-t-use-int-for-efi-status.patch b/0087-don-t-use-int-for-efi-status.patch similarity index 75% rename from 0104-don-t-use-int-for-efi-status.patch rename to 0087-don-t-use-int-for-efi-status.patch index 6328df96354b59a54951d5d03c78455d84b8c54a..80782f56587454208cef377695f81398825c95a4 100644 --- a/0104-don-t-use-int-for-efi-status.patch +++ b/0087-don-t-use-int-for-efi-status.patch @@ -1,14 +1,14 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 7fba6daaf2d9cc2c96176020212dadad593c340f Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 26 Jun 2017 12:44:59 -0400 -Subject: [PATCH] don't use int for efi status +Subject: [PATCH 087/220] don't use int for efi status --- grub-core/kern/efi/efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 562d6887e0e..bcae7f4699d 100644 +index a1af9b4..2cf6a5a 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -166,7 +166,7 @@ grub_reboot (void) @@ -20,3 +20,6 @@ index 562d6887e0e..bcae7f4699d 100644 if (retval == 0) rc = GRUB_EFI_SUCCESS; +-- +1.8.3.1 + diff --git a/0105-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch b/0088-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch similarity index 81% rename from 0105-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch rename to 0088-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch index 1d6f4c4f6168d430549fc88a044bdc78d7740404..3d4575e945c55f7282e0b924f598fd42f68e95f5 100644 --- a/0105-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch +++ b/0088-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch @@ -1,14 +1,14 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From c0d5d9ca9964f2d634a25014821199e1f4ea7be1 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 26 Jun 2017 12:46:23 -0400 -Subject: [PATCH] make GRUB_MOD_INIT() declare its function prototypes. +Subject: [PATCH 088/220] make GRUB_MOD_INIT() declare its function prototypes. --- include/grub/dl.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/grub/dl.h b/include/grub/dl.h -index 2bca56ce0e8..b1ed3c33317 100644 +index f03c035..90dc9bb 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -54,6 +54,7 @@ grub_mod_fini (void) @@ -27,3 +27,6 @@ index 2bca56ce0e8..b1ed3c33317 100644 void \ grub_##name##_fini (void) { grub_mod_fini (); } \ static void \ +-- +1.8.3.1 + diff --git a/0106-editenv-handle-relative-symlinks.patch b/0089-editenv-handle-relative-symlinks.patch similarity index 83% rename from 0106-editenv-handle-relative-symlinks.patch rename to 0089-editenv-handle-relative-symlinks.patch index 20e16864dd754ff048644bf47342d319b52262fe..e0ccccc9447ec1b6dfca894178afd5aa658bc8d9 100644 --- a/0106-editenv-handle-relative-symlinks.patch +++ b/0089-editenv-handle-relative-symlinks.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From aa5c3b11994dc7b3856d7f4a3671029eb7056c66 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 14 Aug 2017 14:37:20 -0400 -Subject: [PATCH] editenv: handle relative symlinks +Subject: [PATCH 089/220] editenv: handle relative symlinks Handle symlinks with targets relative to the containing dir. This ensures that the rename operation does not depend on the cwd. @@ -14,7 +14,7 @@ Signed-off-by: Jonathan Lebon 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/util/editenv.c b/util/editenv.c -index d8d1dad6ab9..41bc7cb1c9a 100644 +index e61dc12..1f7f6f3 100644 --- a/util/editenv.c +++ b/util/editenv.c @@ -28,6 +28,7 @@ @@ -25,7 +25,7 @@ index d8d1dad6ab9..41bc7cb1c9a 100644 #define DEFAULT_ENVBLK_SIZE 1024 -@@ -87,9 +88,20 @@ grub_util_create_envblk_file (const char *name) +@@ -88,9 +89,20 @@ grub_util_create_envblk_file (const char *name) continue; } @@ -48,3 +48,6 @@ index d8d1dad6ab9..41bc7cb1c9a 100644 } int rc = grub_util_rename (namenew, rename_target); +-- +1.8.3.1 + diff --git a/0107-Make-libgrub.pp-depend-on-config-util.h.patch b/0090-Make-libgrub.pp-depend-on-config-util.h.patch similarity index 97% rename from 0107-Make-libgrub.pp-depend-on-config-util.h.patch rename to 0090-Make-libgrub.pp-depend-on-config-util.h.patch index dc24fb1278fb4aab41d3916f04c63a290bdc0eb6..58bb475f1737c2b6c07853c04d44cd519b51d802 100644 --- a/0107-Make-libgrub.pp-depend-on-config-util.h.patch +++ b/0090-Make-libgrub.pp-depend-on-config-util.h.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 6cac349f34599ab50c3c548c1832d502ae1c17d6 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 23 Aug 2017 10:37:27 -0400 -Subject: [PATCH] Make libgrub.pp depend on config-util.h +Subject: [PATCH 090/220] Make libgrub.pp depend on config-util.h If you build with "make -j48" a lot, sometimes you see: @@ -31,7 +31,7 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am -index 7795baeb654..c7b0e6a9c46 100644 +index 1f4bb9b..bf9c1ba 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,7 +37,7 @@ grub_script.yy.c: grub_script.yy.h @@ -43,3 +43,6 @@ index 7795baeb654..c7b0e6a9c46 100644 $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libgrubmods_a_CPPFLAGS) $(libgrubkern_a_CPPFLAGS) $(CPPFLAGS) \ -D'GRUB_MOD_INIT(x)=@MARKER@x@' $^ > $@ || (rm -f $@; exit 1) CLEANFILES += libgrub.pp +-- +1.8.3.1 + diff --git a/0108-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch b/0091-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch similarity index 81% rename from 0108-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch rename to 0091-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch index 51f545891fa724677d97e71a738673a13249a2ed..e33528eb6cb3d39cec312c27385421b15c87bad9 100644 --- a/0108-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch +++ b/0091-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 36ceae144ede50b60f1256e0b57ceb7ed5be8eee Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 20 Apr 2017 13:29:06 -0400 -Subject: [PATCH] Don't guess /boot/efi/ as HFS+ on ppc machines in +Subject: [PATCH 091/220] Don't guess /boot/efi/ as HFS+ on ppc machines in grub-install This should never be trying this, and since we've consolidated the @@ -16,10 +16,10 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/util/grub-install.c b/util/grub-install.c -index a0ad99729fd..16f137ca854 100644 +index 3e718b9..37fcdac 100644 --- a/util/grub-install.c +++ b/util/grub-install.c -@@ -1159,18 +1159,8 @@ main (int argc, char *argv[]) +@@ -1182,18 +1182,8 @@ main (int argc, char *argv[]) char *d; is_guess = 1; @@ -39,3 +39,6 @@ index a0ad99729fd..16f137ca854 100644 if (!grub_util_is_directory (d)) { free (d); +-- +1.8.3.1 + diff --git a/0109-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch b/0092-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch similarity index 69% rename from 0109-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch rename to 0092-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch index c26a3d562fb1e31d4f2ebb9984b104aff39f0879..7d31e7759ca02d181f33cb863dc95a7ca50a32cd 100644 --- a/0109-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch +++ b/0092-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From aef6341482706bc7a6620324795006e7209df380 Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Thu, 19 Oct 2017 11:29:11 -0400 -Subject: [PATCH] 20_linux_xen: load xen or multiboot{,2} modules as needed. +Date: Tue, 9 Jul 2019 14:31:19 +0200 +Subject: [PATCH 092/220] 20_linux_xen: load xen or multiboot{,2} modules as + needed. Signed-off-by: Peter Jones --- @@ -9,7 +10,7 @@ Signed-off-by: Peter Jones 1 file changed, 3 insertions(+) diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in -index bcdc3ceac02..2bc03fd36b9 100644 +index 1519ec6..9aa23bc 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -136,6 +136,8 @@ linux_entry () @@ -21,11 +22,14 @@ index bcdc3ceac02..2bc03fd36b9 100644 ${xen_loader} ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts} echo '$(echo "$lmessage" | grub_quote)' ${module_loader} ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args} -@@ -145,6 +147,7 @@ EOF - message="$(gettext_printf "Loading initial ramdisk ...")" +@@ -149,6 +151,7 @@ EOF + done sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' + insmod ${module_loader} - ${module_loader} --nounzip ${rel_dirname}/${initrd} + ${module_loader} --nounzip $(echo $initrd_path) EOF fi +-- +1.8.3.1 + diff --git a/0110-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch b/0093-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch similarity index 97% rename from 0110-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch rename to 0093-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch index acfb116d74f35d92a98eea43dca2cf73ed2797ff..95358a03a50110edfb0af73eb2ee9663fb063396 100644 --- a/0110-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch +++ b/0093-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 1742890ed8ea75a898f2bc7a47c61d6acacf4128 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 7 Nov 2017 17:12:17 -0500 -Subject: [PATCH] Make pmtimer tsc calibration not take 51 seconds to fail. +Subject: [PATCH 093/220] Make pmtimer tsc calibration not take 51 seconds to + fail. On my laptop running at 2.4GHz, if I run a VM where tsc calibration using pmtimer will fail presuming a broken pmtimer, it takes ~51 seconds @@ -63,7 +64,7 @@ Signed-off-by: Peter Jones 1 file changed, 89 insertions(+), 20 deletions(-) diff --git a/grub-core/kern/i386/tsc_pmtimer.c b/grub-core/kern/i386/tsc_pmtimer.c -index c9c36169978..ca15c3aacd7 100644 +index c9c3616..ca15c3a 100644 --- a/grub-core/kern/i386/tsc_pmtimer.c +++ b/grub-core/kern/i386/tsc_pmtimer.c @@ -28,40 +28,101 @@ @@ -209,3 +210,6 @@ index c9c36169978..ca15c3aacd7 100644 tsc_diff = grub_pmtimer_wait_count_tsc (pmtimer, 3580); if (tsc_diff == 0) return 0; +-- +1.8.3.1 + diff --git a/0111-align-struct-efi_variable-better.patch b/0094-align-struct-efi_variable-better.patch similarity index 81% rename from 0111-align-struct-efi_variable-better.patch rename to 0094-align-struct-efi_variable-better.patch index 65bc91b8785e9bce1592b9f0ab1072482d09d949..6ecad784bb5ec5fba9754041029f1b0776f46ac9 100644 --- a/0111-align-struct-efi_variable-better.patch +++ b/0094-align-struct-efi_variable-better.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From d49469ac1d2173db50595517e4bb8d5fe8f2a68b Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 27 Feb 2018 13:55:35 -0500 -Subject: [PATCH] align struct efi_variable better... +Subject: [PATCH 094/220] align struct efi_variable better... --- include/grub/efiemu/runtime.h | 2 +- @@ -9,7 +9,7 @@ Subject: [PATCH] align struct efi_variable better... 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/grub/efiemu/runtime.h b/include/grub/efiemu/runtime.h -index 36d2dedf47e..9d93ba88bac 100644 +index 36d2ded..9d93ba8 100644 --- a/include/grub/efiemu/runtime.h +++ b/include/grub/efiemu/runtime.h @@ -33,5 +33,5 @@ struct efi_variable @@ -20,7 +20,7 @@ index 36d2dedf47e..9d93ba88bac 100644 +} GRUB_PACKED GRUB_ALIGNED(8); #endif /* ! GRUB_EFI_EMU_RUNTIME_HEADER */ diff --git a/include/grub/types.h b/include/grub/types.h -index b93e4820194..f6a9723971d 100644 +index 035a4b5..2fc4be4 100644 --- a/include/grub/types.h +++ b/include/grub/types.h @@ -29,6 +29,7 @@ @@ -31,3 +31,6 @@ index b93e4820194..f6a9723971d 100644 #ifdef GRUB_BUILD # define GRUB_CPU_SIZEOF_VOID_P BUILD_SIZEOF_VOID_P +-- +1.8.3.1 + diff --git a/0095-Add-BLS-support-to-grub-mkconfig.patch b/0095-Add-BLS-support-to-grub-mkconfig.patch new file mode 100644 index 0000000000000000000000000000000000000000..75b0884d5ce8fd99b5d4654407fc082ba7ccb060 --- /dev/null +++ b/0095-Add-BLS-support-to-grub-mkconfig.patch @@ -0,0 +1,744 @@ +From 9a2531c2784e9d86e4f15d549dc82b37243d46e4 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 9 Dec 2016 15:40:29 -0500 +Subject: [PATCH 095/220] Add BLS support to grub-mkconfig + +GRUB now has BootLoaderSpec support, the user can choose to use this by +setting GRUB_ENABLE_BLSCFG to true in /etc/default/grub. On this setup, +the boot menu entries are not added to the grub.cfg, instead BLS config +files are parsed by blscfg command and the entries created dynamically. + +A 10_linux_bls grub.d snippet to generate menu entries from BLS files +is also added that can be used on platforms where the bootloader doesn't +have BLS support and only can parse a normal grub configuration file. + +Portions of the 10_linux_bls were taken from the ostree-grub-generator +script that's included in the OSTree project. + +Fixes to support multi-devices and generate a BLS section even if no +kernels are found in the boot directory were proposed by Yclept Nemo +and Tom Gundersen respectively. + +Signed-off-by: Peter Jones +Signed-off-by: Javier Martinez Canillas +--- + Makefile.util.def | 7 + + util/grub-mkconfig.8 | 4 + + util/grub-mkconfig.in | 9 +- + util/grub-mkconfig_lib.in | 20 +- + util/grub.d/10_linux.in | 67 ++++++- + util/grub.d/10_linux_bls.in | 478 ++++++++++++++++++++++++++++++++++++++++++++ + 6 files changed, 580 insertions(+), 5 deletions(-) + create mode 100644 util/grub.d/10_linux_bls.in + +diff --git a/Makefile.util.def b/Makefile.util.def +index 2215cc7..a616136 100644 +--- a/Makefile.util.def ++++ b/Makefile.util.def +@@ -500,6 +500,13 @@ script = { + }; + + script = { ++ name = '10_linux_bls'; ++ common = util/grub.d/10_linux_bls.in; ++ installdir = grubconf; ++ condition = COND_HOST_LINUX; ++}; ++ ++script = { + name = '10_xnu'; + common = util/grub.d/10_xnu.in; + installdir = grubconf; +diff --git a/util/grub-mkconfig.8 b/util/grub-mkconfig.8 +index a2d1f57..434fa4d 100644 +--- a/util/grub-mkconfig.8 ++++ b/util/grub-mkconfig.8 +@@ -13,5 +13,9 @@ + \fB--output\fR=\fIFILE\fR + Write generated output to \fIFILE\fR. + ++.TP ++\fB--no-grubenv-update\fR ++Do not update variables in the grubenv file. ++ + .SH SEE ALSO + .BR "info grub" +diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in +index 4649e92..2601bdc 100644 +--- a/util/grub-mkconfig.in ++++ b/util/grub-mkconfig.in +@@ -50,6 +50,8 @@ grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@" + export TEXTDOMAIN=@PACKAGE@ + export TEXTDOMAINDIR="@localedir@" + ++export GRUB_GRUBENV_UPDATE="yes" ++ + . "${pkgdatadir}/grub-mkconfig_lib" + + # Usage: usage +@@ -59,6 +61,7 @@ usage () { + gettext "Generate a grub config file"; echo + echo + print_option_help "-o, --output=$(gettext FILE)" "$(gettext "output generated config to FILE [default=stdout]")" ++ print_option_help "--no-grubenv-update" "$(gettext "do not update variables in the grubenv file")" + print_option_help "-h, --help" "$(gettext "print this message and exit")" + print_option_help "-v, --version" "$(gettext "print the version information and exit")" + echo +@@ -94,6 +97,9 @@ do + --output=*) + grub_cfg=`echo "$option" | sed 's/--output=//'` + ;; ++ --no-grubenv-update) ++ GRUB_GRUBENV_UPDATE="no" ++ ;; + -*) + gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2 + usage +@@ -259,7 +265,8 @@ export GRUB_DEFAULT \ + GRUB_OS_PROBER_SKIP_LIST \ + GRUB_DISABLE_SUBMENU \ + GRUB_DEFAULT_DTB \ +- SUSE_BTRFS_SNAPSHOT_BOOTING ++ SUSE_BTRFS_SNAPSHOT_BOOTING \ ++ GRUB_ENABLE_BLSCFG + + if test "x${grub_cfg}" != "x"; then + rm -f "${grub_cfg}.new" +diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in +index b3aae53..bc11df2 100644 +--- a/util/grub-mkconfig_lib.in ++++ b/util/grub-mkconfig_lib.in +@@ -30,6 +30,9 @@ fi + if test "x$grub_file" = x; then + grub_file="${bindir}/@grub_file@" + fi ++if test "x$grub_editenv" = x; then ++ grub_editenv="${bindir}/@grub_editenv@" ++fi + if test "x$grub_mkrelpath" = x; then + grub_mkrelpath="${bindir}/@grub_mkrelpath@" + fi +@@ -125,8 +128,19 @@ EOF + fi + } + ++prepare_grub_to_access_device_with_variable () ++{ ++ device_variable="$1" ++ shift ++ prepare_grub_to_access_device "$@" ++ unset "device_variable" ++} ++ + prepare_grub_to_access_device () + { ++ if [ -z "$device_variable" ]; then ++ device_variable="root" ++ fi + old_ifs="$IFS" + IFS=' + ' +@@ -161,14 +175,14 @@ prepare_grub_to_access_device () + # otherwise set root as per value in device.map. + fs_hint="`"${grub_probe}" --device $@ --target=compatibility_hint`" + if [ "x$fs_hint" != x ]; then +- echo "set root='$fs_hint'" ++ echo "set ${device_variable}='$fs_hint'" + fi + if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then + hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints= + echo "if [ x\$feature_platform_search_hint = xy ]; then" +- echo " search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}" ++ echo " search --no-floppy --fs-uuid --set=${device_variable} ${hints} ${fs_uuid}" + echo "else" +- echo " search --no-floppy --fs-uuid --set=root ${fs_uuid}" ++ echo " search --no-floppy --fs-uuid --set=${device_variable} ${fs_uuid}" + echo "fi" + fi + IFS="$old_ifs" +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 5cab299..301594a 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -82,6 +82,67 @@ case x"$GRUB_FS" in + ;; + esac + ++populate_header_warn() ++{ ++cat <$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then +@@ -224,6 +286,7 @@ is_top_level=true + while [ "x$list" != "x" ] ; do + linux=`version_find_latest $list` + gettext_printf "Found linux image: %s\n" "$linux" >&2 ++ + basename=`basename $linux` + dirname=`dirname $linux` + rel_dirname=`make_system_path_relative_to_its_root $dirname` +@@ -262,7 +325,9 @@ while [ "x$list" != "x" ] ; do + for i in ${initrd}; do + initrd_display="${initrd_display} ${dirname}/${i}" + done +- gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 ++ if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then ++ gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 ++ fi + fi + + fdt= +diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in +new file mode 100644 +index 0000000..1b75364 +--- /dev/null ++++ b/util/grub.d/10_linux_bls.in +@@ -0,0 +1,478 @@ ++#! /bin/sh ++set -e ++ ++# grub-mkconfig helper script. ++# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc. ++# ++# GRUB is free software: you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation, either version 3 of the License, or ++# (at your option) any later version. ++# ++# GRUB is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with GRUB. If not, see . ++ ++prefix="@prefix@" ++exec_prefix="@exec_prefix@" ++datarootdir="@datarootdir@" ++ ++. "$pkgdatadir/grub-mkconfig_lib" ++ ++export TEXTDOMAIN=@PACKAGE@ ++export TEXTDOMAINDIR="@localedir@" ++ ++CLASS="--class gnu-linux --class gnu --class os --unrestricted" ++ ++if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then ++ OS="$(eval $(grep PRETTY_NAME /etc/os-release) ; echo ${PRETTY_NAME})" ++ CLASS="--class $(eval $(grep '^ID_LIKE=\|^ID=' /etc/os-release) ; [ -n "${ID_LIKE}" ] && echo ${ID_LIKE} || echo ${ID}) ${CLASS}" ++else ++ OS="${GRUB_DISTRIBUTOR}" ++ CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}" ++fi ++ ++# loop-AES arranges things so that /dev/loop/X can be our root device, but ++# the initrds that Linux uses don't like that. ++case ${GRUB_DEVICE} in ++ /dev/loop/*|/dev/loop[0-9]) ++ GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"` ++ ;; ++esac ++ ++# Default to disabling partition uuid support to maintian compatibility with ++# older kernels. ++GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true} ++ ++# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter ++# and mounting btrfs requires user space scanning, so force UUID in this case. ++if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] ) \ ++ || ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ ++ && [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \ ++ || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ ++ && ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \ ++ || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then ++ LINUX_ROOT_DEVICE=${GRUB_DEVICE} ++elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \ ++ || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then ++ LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID} ++else ++ LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} ++fi ++ ++case x"$GRUB_FS" in ++ xbtrfs) ++ if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then ++ GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}" ++ else ++ rootsubvol="`make_system_path_relative_to_its_root /`" ++ rootsubvol="${rootsubvol#/}" ++ if [ "x${rootsubvol}" != x ]; then ++ GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" ++ fi ++ fi;; ++ xzfs) ++ rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` ++ bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`" ++ LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}" ++ ;; ++esac ++ ++mktitle () ++{ ++ local title_type ++ local version ++ local OS_NAME ++ local OS_VERS ++ ++ title_type=$1 && shift ++ version=$1 && shift ++ ++ OS_NAME="$(eval $(grep ^NAME= /etc/os-release) ; echo ${NAME})" ++ OS_VERS="$(eval $(grep ^VERSION= /etc/os-release) ; echo ${VERSION})" ++ ++ case $title_type in ++ recovery) ++ title=$(printf '%s (%s) %s (recovery mode)' \ ++ "${OS_NAME}" "${version}" "${OS_VERS}") ++ ;; ++ *) ++ title=$(printf '%s (%s) %s' \ ++ "${OS_NAME}" "${version}" "${OS_VERS}") ++ ;; ++ esac ++ echo -n ${title} ++} ++ ++title_correction_code= ++ ++populate_header_warn() ++{ ++cat <&2 ++ ++ files=($(for bls in ${blsdir}/*.conf ; do ++ if ! [[ -e "${bls}" ]] ; then ++ continue ++ fi ++ bls="${bls%.conf}" ++ bls="${bls##*/}" ++ echo "${bls}" ++ done | ${kernel_sort} | tac)) || : ++ ++ for bls in "${files[@]}" ; do ++ read_config "${blsdir}/${bls}.conf" ++ ++ menu="${menu}menuentry '${title}' --class ${grub_class} ${grub_arg} --id=${bls} {\n" ++ menu="${menu}\t linux ${linux} ${options}\n" ++ if [ -n "${initrd}" ] ; then ++ menu="${menu}\t initrd ${boot_prefix}${initrd}\n" ++ fi ++ menu="${menu}}\n\n" ++ done ++ # The printf command seems to be more reliable across shells for special character (\n, \t) evaluation ++ printf "$menu" ++} ++ ++linux_entry () ++{ ++ os="$1" ++ version="$2" ++ type="$3" ++ isdebug="$4" ++ args="$5" ++ ++ if [ -z "$boot_device_id" ]; then ++ boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" ++ fi ++ ++ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then ++ if [ x$dirname = x/ ]; then ++ if [ -z "${prepare_root_cache}" ]; then ++ prepare_grub_to_access_device ${GRUB_DEVICE} ++ fi ++ else ++ if [ -z "${prepare_boot_cache}" ]; then ++ prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} ++ fi ++ fi ++ ++ if [ -d /sys/firmware/efi ]; then ++ bootefi_device="`${grub_probe} --target=device /boot/efi/`" ++ prepare_grub_to_access_device_with_variable boot ${bootefi_device} ++ else ++ boot_device="`${grub_probe} --target=device /boot/`" ++ prepare_grub_to_access_device_with_variable boot ${boot_device} ++ fi ++ ++ populate_header_warn ++ populate_menu ++ ++ if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then ++ blsdir="/boot/loader/entries" ++ [ -d "${blsdir}" ] && GRUB_BLS_FS="$(${grub_probe} --target=fs ${blsdir})" ++ if [ "x${GRUB_BLS_FS}" = "xbtrfs" ] || [ "x${GRUB_BLS_FS}" = "xzfs" ]; then ++ blsdir=$(make_system_path_relative_to_its_root "${blsdir}") ++ if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then ++ ${grub_editenv} - set blsdir="${blsdir}" ++ fi ++ fi ++ ++ ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" ++ if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then ++ ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ++ fi ++ fi ++ ++ exit 0 ++ fi ++ ++ if [ x$type != xsimple ] ; then ++ title=$(mktitle "$type" "$version") ++ if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then ++ replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')" ++ quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)" ++ title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;" ++ fi ++ if [ x$isdebug = xdebug ]; then ++ title="$title${GRUB_LINUX_DEBUG_TITLE_POSTFIX}" ++ fi ++ echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" ++ else ++ echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" ++ fi ++ if [ x$type != xrecovery ] ; then ++ save_default_entry | grub_add_tab ++ fi ++ ++ # Use ELILO's generic "efifb" when it's known to be available. ++ # FIXME: We need an interface to select vesafb in case efifb can't be used. ++ if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then ++ echo " load_video" | sed "s/^/$submenu_indentation/" ++ if grep -qx "CONFIG_FB_EFI=y" "${config}" 2> /dev/null \ ++ && grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" "${config}" 2> /dev/null; then ++ echo " set gfxpayload=keep" | sed "s/^/$submenu_indentation/" ++ fi ++ else ++ if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then ++ echo " load_video" | sed "s/^/$submenu_indentation/" ++ fi ++ echo " set gfxpayload=$GRUB_GFXPAYLOAD_LINUX" | sed "s/^/$submenu_indentation/" ++ fi ++ ++ echo " insmod gzio" | sed "s/^/$submenu_indentation/" ++ ++ if [ x$dirname = x/ ]; then ++ if [ -z "${prepare_root_cache}" ]; then ++ prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)" ++ fi ++ printf '%s\n' "${prepare_root_cache}" | sed "s/^/$submenu_indentation/" ++ else ++ if [ -z "${prepare_boot_cache}" ]; then ++ prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)" ++ fi ++ printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" ++ fi ++ sed "s/^/$submenu_indentation/" << EOF ++ linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} ++EOF ++ if test -n "${initrd}" ; then ++ initrd_path= ++ for i in ${initrd}; do ++ initrd_path="${initrd_path} ${rel_dirname}/${i}" ++ done ++ sed "s/^/$submenu_indentation/" << EOF ++ initrd $(echo $initrd_path) ++EOF ++ fi ++ if test -n "${fdt}" ; then ++ sed "s/^/$submenu_indentation/" << EOF ++ devicetree ${rel_dirname}/${fdt} ++EOF ++ fi ++ sed "s/^/$submenu_indentation/" << EOF ++} ++EOF ++} ++ ++machine=`uname -m` ++case "x$machine" in ++ xi?86 | xx86_64) ++ list= ++ for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do ++ if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi ++ done ;; ++ *) ++ list= ++ for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do ++ if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi ++ done ;; ++esac ++ ++if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then ++ for i in /boot/ostree/*/vmlinuz-* ; do ++ if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi ++ done ++fi ++ ++case "$machine" in ++ i?86) GENKERNEL_ARCH="x86" ;; ++ mips|mips64) GENKERNEL_ARCH="mips" ;; ++ mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;; ++ arm*) GENKERNEL_ARCH="arm" ;; ++ *) GENKERNEL_ARCH="$machine" ;; ++esac ++ ++prepare_boot_cache= ++prepare_root_cache= ++boot_device_id= ++title_correction_code= ++ ++# Extra indentation to add to menu entries in a submenu. We're not in a submenu ++# yet, so it's empty. In a submenu it will be equal to '\t' (one tab). ++submenu_indentation="" ++ ++is_top_level=true ++while [ "x$list" != "x" ] ; do ++ linux=`version_find_latest $list` ++ if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then ++ gettext_printf "Found linux image: %s\n" "$linux" >&2 ++ fi ++ ++ basename=`basename $linux` ++ dirname=`dirname $linux` ++ rel_dirname=`make_system_path_relative_to_its_root $dirname` ++ version=`echo $basename | sed -e "s,^[^0-9]*-,,g"` ++ alt_version=`echo $version | sed -e "s,\.old$,,g"` ++ linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" ++ ++ initrd_early= ++ for i in ${GRUB_EARLY_INITRD_LINUX_STOCK} \ ++ ${GRUB_EARLY_INITRD_LINUX_CUSTOM}; do ++ if test -e "${dirname}/${i}" ; then ++ initrd_early="${initrd_early} ${i}" ++ fi ++ done ++ ++ 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" \ ++ "initrd-${alt_version}" "initramfs-${alt_version}.img" \ ++ "initramfs-genkernel-${version}" \ ++ "initramfs-genkernel-${alt_version}" \ ++ "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \ ++ "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do ++ if test -e "${dirname}/${i}" ; then ++ initrd_real="${i}" ++ break ++ fi ++ done ++ ++ 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 ++ if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then ++ gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 ++ fi ++ fi ++ ++ fdt= ++ for i in "dtb-${version}" "dtb-${alt_version}"; do ++ if test -f "${dirname}/${i}/${GRUB_DEFAULT_DTB}" ; then ++ fdt="${i}/${GRUB_DEFAULT_DTB}" ++ break ++ fi ++ done ++ ++ config= ++ for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do ++ if test -e "${i}" ; then ++ config="${i}" ++ break ++ fi ++ done ++ ++ initramfs= ++ if test -n "${config}" ; then ++ initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"` ++ fi ++ ++ if test -z "${initramfs}" && test -z "${initrd_real}" ; then ++ # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs. Since there's ++ # no initrd or builtin initramfs, it can't work here. ++ if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \ ++ || [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then ++ ++ linux_root_device_thisversion=${GRUB_DEVICE} ++ else ++ linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID} ++ fi ++ fi ++ ++ if [ "x${GRUB_DISABLE_SUBMENU}" = "xyes" ] || [ "x${GRUB_DISABLE_SUBMENU}" = "xy" ]; then ++ GRUB_DISABLE_SUBMENU="true" ++ fi ++ ++ if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then ++ linux_entry "${OS}" "${version}" simple standard \ ++ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ++ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then ++ linux_entry "${OS}" "${version}" simple debug \ ++ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}" ++ fi ++ ++ submenu_indentation="$grub_tab" ++ ++ if [ -z "$boot_device_id" ]; then ++ boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" ++ fi ++ # TRANSLATORS: %s is replaced with an OS name ++ echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {" ++ is_top_level=false ++ fi ++ ++ linux_entry "${OS}" "${version}" advanced standard \ ++ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ++ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then ++ linux_entry "${OS}" "${version}" advanced debug \ ++ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}" ++ fi ++ ++ if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then ++ linux_entry "${OS}" "${version}" recovery standard \ ++ "single ${GRUB_CMDLINE_LINUX}" ++ fi ++ ++ list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '` ++done ++ ++# If at least one kernel was found, then we need to ++# add a closing '}' for the submenu command. ++if [ x"$is_top_level" != xtrue ]; then ++ echo '}' ++fi ++ ++echo "$title_correction_code" +-- +1.8.3.1 + diff --git a/0116-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch b/0096-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch similarity index 80% rename from 0116-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch rename to 0096-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch index 204abbc034095ea0c3c6031625a9ed5d95f17a72..d5a0d7ff885d1242da0640af6520b90927d5e8c4 100644 --- a/0116-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch +++ b/0096-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 141eaab0d63830598e4304451e407289468968cb Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 6 Feb 2018 11:16:28 +0100 -Subject: [PATCH] Don't attempt to backtrace on grub_abort() for grub-emu +Subject: [PATCH 096/220] Don't attempt to backtrace on grub_abort() for + grub-emu The emu platform doesn't have a grub_backtrace() implementation, so this causes a build error. Don't attempt to call this when building grub-emu. @@ -12,7 +13,7 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 04371ac49f2..636f97e1ba1 100644 +index 04371ac..636f97e 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -1103,7 +1103,7 @@ static void __attribute__ ((noreturn)) @@ -24,3 +25,6 @@ index 04371ac49f2..636f97e1ba1 100644 grub_backtrace(); #endif #endif +-- +1.8.3.1 + diff --git a/0096-No-more-Bootable-Snapshot-submenu-in-grub.cfg.patch b/0096-No-more-Bootable-Snapshot-submenu-in-grub.cfg.patch deleted file mode 100644 index b51b0259662876ad596ada397d8f171b8b935416..0000000000000000000000000000000000000000 --- a/0096-No-more-Bootable-Snapshot-submenu-in-grub.cfg.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dusty Mabe -Date: Sat, 18 Jul 2015 15:38:08 +0000 -Subject: [PATCH] No more "Bootable Snapshot" submenu in grub.cfg. - -This breaks grubby (run on kernel upgrades) because grubby just -does a search for "menuentry". ---- - util/grub.d/00_header.in | 12 ------------ - 1 file changed, 12 deletions(-) - -diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in -index e2a53300126..8a16fea347e 100644 ---- a/util/grub.d/00_header.in -+++ b/util/grub.d/00_header.in -@@ -366,15 +366,3 @@ fi - if [ "x${GRUB_BADRAM}" != "x" ] ; then - echo "badram ${GRUB_BADRAM}" - fi -- --if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ] && -- [ "x${GRUB_FS}" = "xbtrfs" ] ; then -- # Note: No $snapshot_num on *read-only* rollback! (bsc#901487) -- cat < Date: Tue, 6 Feb 2018 09:09:00 +0100 -Subject: [PATCH] Add linux and initrd commands for grub-emu +Subject: [PATCH 097/220] Add linux and initrd commands for grub-emu When using grub-emu, the linux and initrd commands are used as arguments to the kexec command line tool, to allow booting the selected menu entry. --- + grub-core/Makefile.am | 1 + grub-core/Makefile.core.def | 1 - grub-core/kern/emu/main.c | 4 + grub-core/kern/emu/misc.c | 18 ++++- @@ -13,15 +14,26 @@ to the kexec command line tool, to allow booting the selected menu entry. include/grub/emu/exec.h | 4 +- include/grub/emu/hostfile.h | 3 +- include/grub/emu/misc.h | 3 + - grub-core/Makefile.am | 1 + 8 files changed, 202 insertions(+), 4 deletions(-) create mode 100644 grub-core/loader/emu/linux.c +diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am +index c6ba5b2..5ff3afd 100644 +--- a/grub-core/Makefile.am ++++ b/grub-core/Makefile.am +@@ -304,6 +304,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/net.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostdisk.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostfile.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h ++KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/exec.h + if COND_GRUB_EMU_SDL + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h + endif diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index e52d776887a..067b97a4221 100644 +index ebc5580..528f76a 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -1710,7 +1710,6 @@ module = { +@@ -1802,7 +1802,6 @@ module = { common = loader/linux.c; common = lib/cmdline.c; @@ -30,7 +42,7 @@ index e52d776887a..067b97a4221 100644 efi = loader/efi/linux.c; }; diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c -index 55ea5a11ccd..846fe9715ec 100644 +index 55ea5a1..846fe97 100644 --- a/grub-core/kern/emu/main.c +++ b/grub-core/kern/emu/main.c @@ -107,6 +107,7 @@ static struct argp_option options[] = { @@ -52,10 +64,10 @@ index 55ea5a11ccd..846fe9715ec 100644 case ARGP_KEY_ARG: { diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c -index 82012a72fcb..3d3a4a4a975 100644 +index 19cd007..245b69c 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c -@@ -37,6 +37,7 @@ +@@ -39,6 +39,7 @@ #include int verbosity; @@ -63,7 +75,7 @@ index 82012a72fcb..3d3a4a4a975 100644 void grub_util_warn (const char *fmt, ...) -@@ -80,7 +81,7 @@ grub_util_error (const char *fmt, ...) +@@ -82,7 +83,7 @@ grub_util_error (const char *fmt, ...) vfprintf (stderr, fmt, ap); va_end (ap); fprintf (stderr, ".\n"); @@ -72,7 +84,7 @@ index 82012a72fcb..3d3a4a4a975 100644 } void * -@@ -140,6 +141,9 @@ void +@@ -142,6 +143,9 @@ void __attribute__ ((noreturn)) grub_exit (int rc) { @@ -82,7 +94,7 @@ index 82012a72fcb..3d3a4a4a975 100644 exit (rc < 0 ? 1 : rc); } #endif -@@ -201,3 +205,15 @@ grub_util_load_image (const char *path, char *buf) +@@ -203,3 +207,15 @@ grub_util_load_image (const char *path, char *buf) fclose (fp); } @@ -100,7 +112,7 @@ index 82012a72fcb..3d3a4a4a975 100644 +} diff --git a/grub-core/loader/emu/linux.c b/grub-core/loader/emu/linux.c new file mode 100644 -index 00000000000..fda9e00d24c +index 0000000..fda9e00 --- /dev/null +++ b/grub-core/loader/emu/linux.c @@ -0,0 +1,172 @@ @@ -277,7 +289,7 @@ index 00000000000..fda9e00d24c + grub_unregister_command (cmd_initrd); +} diff --git a/include/grub/emu/exec.h b/include/grub/emu/exec.h -index d1073ef86af..1b61b4a2e5d 100644 +index d1073ef..1b61b4a 100644 --- a/include/grub/emu/exec.h +++ b/include/grub/emu/exec.h @@ -23,6 +23,8 @@ @@ -299,7 +311,7 @@ index d1073ef86af..1b61b4a2e5d 100644 grub_util_exec_redirect (const char *const *argv, const char *stdin_file, const char *stdout_file); diff --git a/include/grub/emu/hostfile.h b/include/grub/emu/hostfile.h -index 8e37d5acb42..12c937a1af9 100644 +index cfb1e2b..a61568e 100644 --- a/include/grub/emu/hostfile.h +++ b/include/grub/emu/hostfile.h @@ -22,6 +22,7 @@ @@ -320,12 +332,12 @@ index 8e37d5acb42..12c937a1af9 100644 char * grub_util_path_concat (size_t n, ...); diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h -index df6085bcb7c..a653132e36a 100644 +index ce464cf..5ef4f79 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h -@@ -60,6 +60,9 @@ void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format ( - void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))); - void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2), noreturn)); +@@ -56,6 +56,9 @@ void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format ( + void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))); + void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2), noreturn)); +void EXPORT_FUNC(grub_util_set_kexecute) (void); +int EXPORT_FUNC(grub_util_get_kexecute) (void) WARN_UNUSED_RESULT; @@ -333,15 +345,6 @@ index df6085bcb7c..a653132e36a 100644 grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void); #ifdef HAVE_DEVICE_MAPPER -diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am -index 9c69aa88626..0108c0d4233 100644 ---- a/grub-core/Makefile.am -+++ b/grub-core/Makefile.am -@@ -274,6 +274,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/net.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostdisk.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/hostfile.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/emu/exec.h - if COND_GRUB_EMU_SDL - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h - endif +-- +1.8.3.1 + diff --git a/0120-Add-grub2-switch-to-blscfg.patch b/0098-Add-grub2-switch-to-blscfg.patch similarity index 64% rename from 0120-Add-grub2-switch-to-blscfg.patch rename to 0098-Add-grub2-switch-to-blscfg.patch index 17984a266f96e2e25a4941ebd15594fc99ddc3b0..8f7f4e639a98dc54d18a685fe5d826ecf5e6816b 100644 --- a/0120-Add-grub2-switch-to-blscfg.patch +++ b/0098-Add-grub2-switch-to-blscfg.patch @@ -1,23 +1,26 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 2e187d17d3ffeb9a9bf4bfa3e079be7e335d8c80 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 15 Mar 2018 14:12:40 -0400 -Subject: [PATCH] Add grub2-switch-to-blscfg +Subject: [PATCH 098/220] Add grub2-switch-to-blscfg Signed-off-by: Peter Jones +Signed-off-by: Javier Martinez Canillas +[jhlavac: Use ${etcdefaultgrub} instead of /etc/default/grub] +Signed-off-by: Jan Hlavac --- - Makefile.util.def | 7 ++ - .gitignore | 2 + - util/grub-switch-to-blscfg.8 | 25 ++++ - util/grub-switch-to-blscfg.in | 262 ++++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 296 insertions(+) + Makefile.util.def | 7 + + util/grub-set-password.in | 2 +- + util/grub-switch-to-blscfg.8 | 33 +++++ + util/grub-switch-to-blscfg.in | 314 ++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 355 insertions(+), 1 deletion(-) create mode 100644 util/grub-switch-to-blscfg.8 create mode 100644 util/grub-switch-to-blscfg.in diff --git a/Makefile.util.def b/Makefile.util.def -index 879e8eb98a4..f4fbd250630 100644 +index a616136..f55473c 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -1348,6 +1348,13 @@ program = { +@@ -1364,6 +1364,13 @@ program = { ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -31,25 +34,24 @@ index 879e8eb98a4..f4fbd250630 100644 program = { name = grub-glue-efi; mansection = 1; -diff --git a/.gitignore b/.gitignore -index 54795fa60be..42475592123 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -121,6 +121,8 @@ grub-*.tar.* - /grub*-sparc64-setup.8 - /grub*-syslinux2cfg - /grub*-syslinux2cfg.1 -+/grub*-switch-to-blscfg -+/grub*-switch-to-blscfg.8 - /grub_fstest.pp - /grub_fstest_init.c - /grub_fstest_init.lst +diff --git a/util/grub-set-password.in b/util/grub-set-password.in +index 5ebf505..c0b5ebb 100644 +--- a/util/grub-set-password.in ++++ b/util/grub-set-password.in +@@ -1,6 +1,6 @@ + #!/bin/sh -e + +-EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') ++EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/' -e 's/\"//g') + if [ -d /sys/firmware/efi/efivars/ ]; then + grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'` + else diff --git a/util/grub-switch-to-blscfg.8 b/util/grub-switch-to-blscfg.8 new file mode 100644 -index 00000000000..134dfc62a7b +index 0000000..9a88628 --- /dev/null +++ b/util/grub-switch-to-blscfg.8 -@@ -0,0 +1,25 @@ +@@ -0,0 +1,33 @@ +.TH GRUB-SWITCH-TO-BLSCFG 1 "Wed Feb 26 2014" +.SH NAME +\fBgrub-switch-to-blscfg\fR \(em Switch to using BLS config files. @@ -73,14 +75,22 @@ index 00000000000..134dfc62a7b +--grub-defaults=\fIFILE\fR +The defaults file for grub-mkconfig. The default value is \fI/etc/default/grub\fR. + ++.TP ++--bls-directory=\fIDIR\fR ++Create BootLoaderSpec fragments in \fIDIR\fR. The default value is \fI/boot/loader/entries\fR. ++ ++.TP ++--backup-suffix=\fSUFFIX\fR ++The suffix to use for saved backup files. The default value is \fI.bak\fR. ++ +.SH SEE ALSO +.BR "info grub" diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in new file mode 100644 -index 00000000000..3ae5e4ea8d0 +index 0000000..49b3985 --- /dev/null +++ b/util/grub-switch-to-blscfg.in -@@ -0,0 +1,262 @@ +@@ -0,0 +1,314 @@ +#! /bin/sh +# +# Set a default boot entry for GRUB. @@ -104,6 +114,7 @@ index 00000000000..3ae5e4ea8d0 +# Initialize some variables. +prefix=@prefix@ +exec_prefix=@exec_prefix@ ++sbindir=@sbindir@ +bindir=@bindir@ +sysconfdir="@sysconfdir@" +PACKAGE_NAME=@PACKAGE_NAME@ @@ -116,22 +127,27 @@ index 00000000000..3ae5e4ea8d0 + +self=`basename $0` + ++grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@" +grub_editenv=${bindir}/@grub_editenv@ +etcdefaultgrub=/etc/default/grub + -+EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') ++eval "$("${grub_get_kernel_settings}")" || true ++ ++EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/' -e 's/\"//g') +if [ -d /sys/firmware/efi/efivars/ ]; then + startlink=/etc/grub2-efi.cfg + grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'` -+ blsdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/loader/entries" | sed 's,//*,/,g'` +else + startlink=/etc/grub2.cfg + grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'` -+ blsdir=`echo "/@bootdirname@" | sed 's,//*,/,g'` +fi + ++blsdir=`echo "/@bootdirname@/loader/entries" | sed 's,//*,/,g'` ++ +backupsuffix=.bak + ++arch="$(uname -m)" ++ +export TEXTDOMAIN=@PACKAGE@ +export TEXTDOMAINDIR="@localedir@" + @@ -230,18 +246,18 @@ index 00000000000..3ae5e4ea8d0 + +find_grub_cfg() { + local candidate="" -+ while [[ -e "${candidate}" || $# -gt 0 ]] ++ while [ -e "${candidate}" -o $# -gt 0 ] + do -+ if [[ ! -e "${candidate}" ]] ; then ++ if [ ! -e "${candidate}" ] ; then + candidate="$1" + shift + fi + -+ if [[ -L "${candidate}" ]]; then ++ if [ -L "${candidate}" ]; then + candidate="$(realpath "${candidate}")" + fi + -+ if [[ -f "${candidate}" ]]; then ++ if [ -f "${candidate}" ]; then + export GRUB_CONFIG_FILE="${candidate}" + return 0 + fi @@ -254,11 +270,11 @@ index 00000000000..3ae5e4ea8d0 + exit 1 +fi + -+if [[ ! -d "${blsdir}" ]]; then ++if [ ! -d "${blsdir}" ]; then + install -m 700 -d "${blsdir}" +fi + -+if [[ -f /etc/machine-id ]]; then ++if [ -f /etc/machine-id ]; then + MACHINE_ID=$(cat /etc/machine-id) +else + MACHINE_ID=$(dmesg | sha256sum) @@ -267,14 +283,17 @@ index 00000000000..3ae5e4ea8d0 +mkbls() { + local kernelver=$1 && shift + local datetime=$1 && shift ++ local bootprefix=$1 && shift + + local debugname="" ++ local debugid="" + local flavor="" + -+ if [[ "$kernelver" == *\+* ]] ; then ++ if [ "$kernelver" == *\+* ] ; then + local flavor=-"${kernelver##*+}" -+ if [[ "${flavor}" == "-debug" ]]; then ++ if [ "${flavor}" == "-debug" ]; then + local debugname=" with debugging" ++ local debugid="-debug" + fi + fi + ( @@ -282,8 +301,9 @@ index 00000000000..3ae5e4ea8d0 + + cat <"${bls_target}" ++copy_bls() { ++ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do ++ bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf" ++ linux="/vmlinuz-${kernelver}" ++ linux_path="/boot${linux}" ++ kernel_dir="/lib/modules/${kernelver}" ++ ++ if [ ! -d "${kernel_dir}" ] ; then ++ continue ++ fi ++ if [ ! -f "${linux_path}" ]; then ++ continue ++ fi ++ ++ linux_relpath="$("${grub_mkrelpath}" "${linux_path}")" ++ bootprefix="${linux_relpath%%"${linux}"}" ++ ++ if [ -f "${kernel_dir}/bls.conf" ] ; then ++ cp -af "${kernel_dir}/bls.conf" "${bls_target}" ++ if [ -n "${bootprefix}" ]; then ++ sed -i -e "s,^\(linux[^ \t]*[ \t]\+\).*,\1${bootprefix}${linux},g" "${bls_target}" ++ sed -i -e "/^initrd/ s,\([ \t]\+\)\([^ \t]\+\),\1${bootprefix}\2,g" "${bls_target}" ++ fi ++ else ++ mkbls "${kernelver}" \ ++ "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \ ++ "${bootprefix}" \ ++ >"${bls_target}" ++ fi ++ ++ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then ++ bls_debug="$(echo ${bls_target} | sed -e "s/${kernelver}/${kernelver}~debug/")" ++ cp -aT "${bls_target}" "${bls_debug}" ++ title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')" ++ blsid="$(grep '^id[ \t]' "${bls_debug}" | sed -e "s/\.${ARCH}/-debug.${arch}/")" ++ sed -i -e "s/^title.*/title ${title}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${bls_debug}" ++ sed -i -e "s/^id.*/${blsid}/" "${bls_debug}" ++ sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${bls_debug}" ++ fi ++ done ++ ++ if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then ++ mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" + fi -+done ++} + +GENERATE=0 +if grep '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" \ @@ -329,13 +377,27 @@ index 00000000000..3ae5e4ea8d0 + GENERATE=1 +fi + -+if [[ "${GENERATE}" -eq 1 ]] ; then ++if [ "${GENERATE}" -eq 1 ] ; then ++ copy_bls ++ ++ if [ $arch = "x86_64" ] && [ ! -d /sys/firmware/efi ]; then ++ mod_dir="i386-pc" ++ elif [ $arch = "ppc64" -o $arch = "ppc64le" ] && [ ! -d /sys/firmware/opal ]; then ++ mod_dir="powerpc-ieee1275" ++ fi ++ ++ if [ -n "${mod_dir}" ]; then ++ for mod in blscfg increment; do ++ cp ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1 ++ done ++ fi ++ + cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}" + if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then + cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}" + sed -i"${backupsuffix}" \ + -e 's,^GRUB_ENABLE_BLSCFG=.*,GRUB_ENABLE_BLSCFG=false,' \ -+ /etc/default/grub ++ "${etcdefaultgrub}" + gettext_printf "Updating %s failed\n" "${GRUB_CONFIG_FILE}" + exit 1 + fi @@ -343,3 +405,6 @@ index 00000000000..3ae5e4ea8d0 + +# Bye. +exit 0 +-- +1.8.3.1 + diff --git a/0121-Add-grub_debug_enabled.patch b/0099-Add-grub_debug_enabled.patch similarity index 89% rename from 0121-Add-grub_debug_enabled.patch rename to 0099-Add-grub_debug_enabled.patch index d8e4bde9103114ccd8fa888e5279ed7942948b43..1cd52b20c59f4f96fbf1e736a958cd2e90761494 100644 --- a/0121-Add-grub_debug_enabled.patch +++ b/0099-Add-grub_debug_enabled.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 211d314fd314f2cced175de112ddc418ab763d23 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 30 Nov 2017 15:11:39 -0500 -Subject: [PATCH] Add grub_debug_enabled() +Subject: [PATCH 099/220] Add grub_debug_enabled() --- grub-core/kern/misc.c | 21 ++++++++++++++++----- @@ -9,7 +9,7 @@ Subject: [PATCH] Add grub_debug_enabled() 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 636f97e1ba1..e758ab3416d 100644 +index 636f97e..e758ab3 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -159,17 +159,28 @@ int grub_err_printf (const char *fmt, ...) @@ -37,17 +37,17 @@ index 636f97e1ba1..e758ab3416d 100644 { va_list args; - const char *debug = grub_env_get ("debug"); - +- - if (! debug) - return; -- + - if (grub_strword (debug, "all") || grub_strword (debug, condition)) + if (grub_debug_enabled (condition)) { grub_printf ("%s:%d: ", file, line); va_start (args, fmt); diff --git a/include/grub/misc.h b/include/grub/misc.h -index cbfae75a1b4..f7473c154f0 100644 +index b433922..4a4f485 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -367,6 +367,7 @@ grub_puts (const char *s) @@ -58,3 +58,6 @@ index cbfae75a1b4..f7473c154f0 100644 void EXPORT_FUNC(grub_real_dprintf) (const char *file, const int line, const char *condition, +-- +1.8.3.1 + diff --git a/0122-make-better-backtraces.patch b/0100-make-better-backtraces.patch similarity index 76% rename from 0122-make-better-backtraces.patch rename to 0100-make-better-backtraces.patch index e017c775b53547b5f5ec72f68d3e392320ac1b43..d76b4fe091067df2a5a2ecf4e3b4ab7192187455 100644 --- a/0122-make-better-backtraces.patch +++ b/0100-make-better-backtraces.patch @@ -1,44 +1,46 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 69fbc18e0758e780236f713b579a951551d7e829 Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Mon, 6 Nov 2017 18:31:56 -0500 -Subject: [PATCH] make better backtraces +Date: Tue, 9 Jul 2019 17:05:03 +0200 +Subject: [PATCH 100/220] make better backtraces Signed-off-by: Peter Jones --- - Makefile.util.def | 6 ++ - grub-core/Makefile.core.def | 15 ++-- - grub-core/{lib => commands}/backtrace.c | 2 +- - grub-core/gdb/cstub.c | 1 - - grub-core/kern/arm64/backtrace.c | 94 ++++++++++++++++++++++++ - grub-core/kern/backtrace.c | 97 +++++++++++++++++++++++++ - grub-core/kern/dl.c | 45 ++++++++++++ - grub-core/kern/i386/backtrace.c | 125 ++++++++++++++++++++++++++++++++ - grub-core/kern/i386/pc/init.c | 4 +- - grub-core/kern/ieee1275/init.c | 1 - - grub-core/kern/misc.c | 13 ++-- - grub-core/kern/mm.c | 6 +- - grub-core/lib/arm64/backtrace.c | 62 ---------------- - grub-core/lib/i386/backtrace.c | 78 -------------------- - include/grub/backtrace.h | 10 ++- - include/grub/dl.h | 2 + - include/grub/kernel.h | 3 + - grub-core/kern/arm/efi/startup.S | 2 + - grub-core/kern/arm/startup.S | 2 + - grub-core/kern/arm64/efi/startup.S | 2 + - grub-core/kern/i386/qemu/startup.S | 3 +- - grub-core/kern/ia64/efi/startup.S | 3 +- - grub-core/kern/sparc64/ieee1275/crt0.S | 3 +- - grub-core/Makefile.am | 1 + - 24 files changed, 414 insertions(+), 166 deletions(-) - rename grub-core/{lib => commands}/backtrace.c (98%) + Makefile.util.def | 6 ++ + grub-core/Makefile.am | 1 + + grub-core/Makefile.core.def | 16 ++--- + grub-core/commands/backtrace.c | 72 +++++++++++++++++++ + grub-core/gdb/cstub.c | 1 - + grub-core/kern/arm/efi/startup.S | 2 + + grub-core/kern/arm/startup.S | 2 + + grub-core/kern/arm64/backtrace.c | 94 +++++++++++++++++++++++++ + grub-core/kern/arm64/efi/startup.S | 2 + + grub-core/kern/backtrace.c | 97 +++++++++++++++++++++++++ + grub-core/kern/dl.c | 45 ++++++++++++ + grub-core/kern/i386/backtrace.c | 125 +++++++++++++++++++++++++++++++++ + grub-core/kern/i386/pc/init.c | 4 +- + grub-core/kern/i386/qemu/startup.S | 3 +- + grub-core/kern/ia64/efi/startup.S | 3 +- + grub-core/kern/ieee1275/init.c | 1 - + grub-core/kern/misc.c | 13 ++-- + grub-core/kern/mm.c | 6 +- + grub-core/kern/sparc64/ieee1275/crt0.S | 3 +- + grub-core/lib/arm64/backtrace.c | 62 ---------------- + grub-core/lib/backtrace.c | 72 ------------------- + grub-core/lib/i386/backtrace.c | 78 -------------------- + include/grub/backtrace.h | 10 ++- + include/grub/dl.h | 2 + + include/grub/kernel.h | 3 + + 25 files changed, 485 insertions(+), 238 deletions(-) + create mode 100644 grub-core/commands/backtrace.c create mode 100644 grub-core/kern/arm64/backtrace.c create mode 100644 grub-core/kern/backtrace.c create mode 100644 grub-core/kern/i386/backtrace.c delete mode 100644 grub-core/lib/arm64/backtrace.c + delete mode 100644 grub-core/lib/backtrace.c delete mode 100644 grub-core/lib/i386/backtrace.c diff --git a/Makefile.util.def b/Makefile.util.def -index f4fbd250630..cbd661d6348 100644 +index f55473c..c13ca68 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -49,6 +49,12 @@ library = { @@ -54,14 +56,26 @@ index f4fbd250630..cbd661d6348 100644 }; library = { +diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am +index 5ff3afd..d9ad300 100644 +--- a/grub-core/Makefile.am ++++ b/grub-core/Makefile.am +@@ -66,6 +66,7 @@ CLEANFILES += grub_script.yy.c grub_script.yy.h + + include $(srcdir)/Makefile.core.am + ++KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/backtrace.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cache.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/device.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 067b97a4221..cb24f92a431 100644 +index 528f76a..49c5dc4 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -130,6 +130,12 @@ kernel = { +@@ -140,6 +140,12 @@ kernel = { + common = kern/rescue_parser.c; common = kern/rescue_reader.c; common = kern/term.c; - common = kern/qsort.c; + common = kern/backtrace.c; + + x86 = kern/i386/backtrace.c; @@ -71,7 +85,7 @@ index 067b97a4221..cb24f92a431 100644 noemu = kern/compiler-rt.c; noemu = kern/mm.c; -@@ -176,9 +182,6 @@ kernel = { +@@ -186,9 +192,6 @@ kernel = { softdiv = lib/division.c; @@ -80,41 +94,105 @@ index 067b97a4221..cb24f92a431 100644 - i386 = kern/i386/dl.c; i386_xen = kern/i386/dl.c; - -@@ -2277,13 +2280,11 @@ module = { + i386_xen_pvh = kern/i386/dl.c; +@@ -2376,15 +2379,12 @@ module = { module = { name = backtrace; - x86 = lib/i386/backtrace.c; +- i386_xen_pvh = lib/i386/backtrace.c; - i386_xen = lib/i386/backtrace.c; - x86_64_xen = lib/i386/backtrace.c; - common = lib/backtrace.c; + common = commands/backtrace.c; enable = x86; + enable = i386_xen_pvh; enable = i386_xen; enable = x86_64_xen; + enable = arm64; }; module = { -diff --git a/grub-core/lib/backtrace.c b/grub-core/commands/backtrace.c -similarity index 98% -rename from grub-core/lib/backtrace.c -rename to grub-core/commands/backtrace.c -index c0ad6ab8be1..8b5ec3913b5 100644 ---- a/grub-core/lib/backtrace.c +diff --git a/grub-core/commands/backtrace.c b/grub-core/commands/backtrace.c +new file mode 100644 +index 0000000..8b5ec39 +--- /dev/null +++ b/grub-core/commands/backtrace.c -@@ -54,7 +54,7 @@ grub_cmd_backtrace (grub_command_t cmd __attribute__ ((unused)), - int argc __attribute__ ((unused)), - char **args __attribute__ ((unused))) - { -- grub_backtrace (); +@@ -0,0 +1,72 @@ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 2009 Free Software Foundation, Inc. ++ * ++ * GRUB is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * GRUB is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with GRUB. If not, see . ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++GRUB_MOD_LICENSE ("GPLv3+"); ++ ++void ++grub_backtrace_print_address (void *addr) ++{ ++#ifndef GRUB_UTIL ++ grub_dl_t mod; ++ ++ FOR_DL_MODULES (mod) ++ { ++ grub_dl_segment_t segment; ++ for (segment = mod->segment; segment; segment = segment->next) ++ if (segment->addr <= addr && (grub_uint8_t *) segment->addr ++ + segment->size > (grub_uint8_t *) addr) ++ { ++ grub_printf ("%s.%x+%" PRIxGRUB_SIZE, mod->name, segment->section, ++ (grub_size_t) ((grub_uint8_t *) addr - (grub_uint8_t *) segment->addr)); ++ return; ++ } ++ } ++ ++#endif ++ grub_printf ("%p", addr); ++} ++ ++static grub_err_t ++grub_cmd_backtrace (grub_command_t cmd __attribute__ ((unused)), ++ int argc __attribute__ ((unused)), ++ char **args __attribute__ ((unused))) ++{ + grub_backtrace (1); - return 0; - } - ++ return 0; ++} ++ ++static grub_command_t cmd; ++ ++GRUB_MOD_INIT(backtrace) ++{ ++ cmd = grub_register_command ("backtrace", grub_cmd_backtrace, ++ 0, N_("Print backtrace.")); ++} ++ ++GRUB_MOD_FINI(backtrace) ++{ ++ grub_unregister_command (cmd); ++} diff --git a/grub-core/gdb/cstub.c b/grub-core/gdb/cstub.c -index b64acd70fee..99281472d36 100644 +index b64acd7..9928147 100644 --- a/grub-core/gdb/cstub.c +++ b/grub-core/gdb/cstub.c @@ -215,7 +215,6 @@ grub_gdb_trap (int trap_no) @@ -125,9 +203,35 @@ index b64acd70fee..99281472d36 100644 grub_fatal ("Unhandled exception"); } +diff --git a/grub-core/kern/arm/efi/startup.S b/grub-core/kern/arm/efi/startup.S +index 9f82653..f3bc41f 100644 +--- a/grub-core/kern/arm/efi/startup.S ++++ b/grub-core/kern/arm/efi/startup.S +@@ -23,6 +23,8 @@ + .file "startup.S" + .text + .arm ++ .globl start, _start ++FUNCTION(start) + FUNCTION(_start) + /* + * EFI_SYSTEM_TABLE and EFI_HANDLE are passed in r1/r0. +diff --git a/grub-core/kern/arm/startup.S b/grub-core/kern/arm/startup.S +index 3946fe8..5679a1d 100644 +--- a/grub-core/kern/arm/startup.S ++++ b/grub-core/kern/arm/startup.S +@@ -48,6 +48,8 @@ + + .text + .arm ++ .globl start, _start ++FUNCTION(start) + FUNCTION(_start) + b codestart + diff --git a/grub-core/kern/arm64/backtrace.c b/grub-core/kern/arm64/backtrace.c new file mode 100644 -index 00000000000..019c6fdfef2 +index 0000000..019c6fd --- /dev/null +++ b/grub-core/kern/arm64/backtrace.c @@ -0,0 +1,94 @@ @@ -225,9 +329,23 @@ index 00000000000..019c6fdfef2 + skip += 1; + grub_backtrace_pointer(__builtin_frame_address(0), skip); +} +diff --git a/grub-core/kern/arm64/efi/startup.S b/grub-core/kern/arm64/efi/startup.S +index 666a7ee..41676bd 100644 +--- a/grub-core/kern/arm64/efi/startup.S ++++ b/grub-core/kern/arm64/efi/startup.S +@@ -19,7 +19,9 @@ + #include + + .file "startup.S" ++ .globl start, _start + .text ++FUNCTION(start) + FUNCTION(_start) + /* + * EFI_SYSTEM_TABLE and EFI_HANDLE are passed in x1/x0. diff --git a/grub-core/kern/backtrace.c b/grub-core/kern/backtrace.c new file mode 100644 -index 00000000000..4a82e865cc6 +index 0000000..4a82e86 --- /dev/null +++ b/grub-core/kern/backtrace.c @@ -0,0 +1,97 @@ @@ -329,7 +447,7 @@ index 00000000000..4a82e865cc6 + grub_backtrace (skip + 1); +} diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 621070918d4..5028d157c46 100644 +index d7718d2..2e57e5e 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -124,6 +124,50 @@ grub_dl_resolve_symbol (const char *name) @@ -393,7 +511,7 @@ index 621070918d4..5028d157c46 100644 i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) diff --git a/grub-core/kern/i386/backtrace.c b/grub-core/kern/i386/backtrace.c new file mode 100644 -index 00000000000..2413f9a57db +index 0000000..2413f9a --- /dev/null +++ b/grub-core/kern/i386/backtrace.c @@ -0,0 +1,125 @@ @@ -523,7 +641,7 @@ index 00000000000..2413f9a57db +#endif +} diff --git a/grub-core/kern/i386/pc/init.c b/grub-core/kern/i386/pc/init.c -index 27bc68b8a53..b51d0abfa6e 100644 +index 27bc68b..b51d0ab 100644 --- a/grub-core/kern/i386/pc/init.c +++ b/grub-core/kern/i386/pc/init.c @@ -153,7 +153,7 @@ compact_mem_regions (void) @@ -544,11 +662,40 @@ index 27bc68b8a53..b51d0abfa6e 100644 /* Initialize the console as early as possible. */ grub_console_init (); +diff --git a/grub-core/kern/i386/qemu/startup.S b/grub-core/kern/i386/qemu/startup.S +index 0d89858..939f182 100644 +--- a/grub-core/kern/i386/qemu/startup.S ++++ b/grub-core/kern/i386/qemu/startup.S +@@ -24,7 +24,8 @@ + + .text + .code32 +- .globl _start ++ .globl start, _start ++start: + _start: + jmp codestart + +diff --git a/grub-core/kern/ia64/efi/startup.S b/grub-core/kern/ia64/efi/startup.S +index d75c6d7..8f2a593 100644 +--- a/grub-core/kern/ia64/efi/startup.S ++++ b/grub-core/kern/ia64/efi/startup.S +@@ -24,8 +24,9 @@ + .psr lsb + .lsb + +- .global _start ++ .global start, _start + .proc _start ++start: + _start: + alloc loc0=ar.pfs,2,4,0,0 + mov loc1=rp diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index e01bc6eab19..e731a57a47b 100644 +index 0cd2a62..937c1bc 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c -@@ -60,7 +60,6 @@ +@@ -63,7 +63,6 @@ #define HEAP_MAX_ADDR (unsigned long) (32 * 1024 * 1024) #endif @@ -557,7 +704,7 @@ index e01bc6eab19..e731a57a47b 100644 #ifdef __sparc__ diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index e758ab3416d..5c2d2039d0b 100644 +index e758ab3..5c2d203 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -1110,15 +1110,15 @@ grub_xasprintf (const char *fmt, ...) @@ -571,12 +718,12 @@ index e758ab3416d..5c2d2039d0b 100644 -#ifndef GRUB_UTIL -#if (defined(__i386__) || defined(__x86_64__)) && !defined(GRUB_MACHINE_EMU) - grub_backtrace(); +-#endif +#if !defined(GRUB_MACHINE_EMU) && !defined(GRUB_UTIL) + grub_backtrace (1); +#else + grub_printf ("\n"); #endif --#endif - grub_printf ("\nAborted."); + grub_printf ("Aborted."); @@ -591,7 +738,7 @@ index e758ab3416d..5c2d2039d0b 100644 grub_vprintf (_(fmt), ap); va_end (ap); diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index ee88ff61187..002cbfa4f3d 100644 +index ee88ff6..002cbfa 100644 --- a/grub-core/kern/mm.c +++ b/grub-core/kern/mm.c @@ -95,13 +95,13 @@ get_header_from_pointer (void *ptr, grub_mm_header_t *p, grub_mm_region_t *r) @@ -611,9 +758,23 @@ index ee88ff61187..002cbfa4f3d 100644 (unsigned long) (*p)->magic); } +diff --git a/grub-core/kern/sparc64/ieee1275/crt0.S b/grub-core/kern/sparc64/ieee1275/crt0.S +index 03b916f..701bf63 100644 +--- a/grub-core/kern/sparc64/ieee1275/crt0.S ++++ b/grub-core/kern/sparc64/ieee1275/crt0.S +@@ -22,7 +22,8 @@ + + .text + .align 4 +- .globl _start ++ .globl start, _start ++start: + _start: + ba codestart + mov %o4, %o0 diff --git a/grub-core/lib/arm64/backtrace.c b/grub-core/lib/arm64/backtrace.c deleted file mode 100644 -index 1079b5380e1..00000000000 +index 1079b53..0000000 --- a/grub-core/lib/arm64/backtrace.c +++ /dev/null @@ -1,62 +0,0 @@ @@ -679,9 +840,87 @@ index 1079b5380e1..00000000000 - grub_backtrace_pointer (1); -} - +diff --git a/grub-core/lib/backtrace.c b/grub-core/lib/backtrace.c +deleted file mode 100644 +index c0ad6ab..0000000 +--- a/grub-core/lib/backtrace.c ++++ /dev/null +@@ -1,72 +0,0 @@ +-/* +- * GRUB -- GRand Unified Bootloader +- * Copyright (C) 2009 Free Software Foundation, Inc. +- * +- * GRUB is free software: you can redistribute it and/or modify +- * it under the terms of the GNU General Public License as published by +- * the Free Software Foundation, either version 3 of the License, or +- * (at your option) any later version. +- * +- * GRUB is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +- * GNU General Public License for more details. +- * +- * You should have received a copy of the GNU General Public License +- * along with GRUB. If not, see . +- */ +- +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-GRUB_MOD_LICENSE ("GPLv3+"); +- +-void +-grub_backtrace_print_address (void *addr) +-{ +-#ifndef GRUB_UTIL +- grub_dl_t mod; +- +- FOR_DL_MODULES (mod) +- { +- grub_dl_segment_t segment; +- for (segment = mod->segment; segment; segment = segment->next) +- if (segment->addr <= addr && (grub_uint8_t *) segment->addr +- + segment->size > (grub_uint8_t *) addr) +- { +- grub_printf ("%s.%x+%" PRIxGRUB_SIZE, mod->name, segment->section, +- (grub_size_t) ((grub_uint8_t *) addr - (grub_uint8_t *) segment->addr)); +- return; +- } +- } +- +-#endif +- grub_printf ("%p", addr); +-} +- +-static grub_err_t +-grub_cmd_backtrace (grub_command_t cmd __attribute__ ((unused)), +- int argc __attribute__ ((unused)), +- char **args __attribute__ ((unused))) +-{ +- grub_backtrace (); +- return 0; +-} +- +-static grub_command_t cmd; +- +-GRUB_MOD_INIT(backtrace) +-{ +- cmd = grub_register_command ("backtrace", grub_cmd_backtrace, +- 0, N_("Print backtrace.")); +-} +- +-GRUB_MOD_FINI(backtrace) +-{ +- grub_unregister_command (cmd); +-} diff --git a/grub-core/lib/i386/backtrace.c b/grub-core/lib/i386/backtrace.c deleted file mode 100644 -index c67273db3ae..00000000000 +index c67273d..0000000 --- a/grub-core/lib/i386/backtrace.c +++ /dev/null @@ -1,78 +0,0 @@ @@ -764,7 +1003,7 @@ index c67273db3ae..00000000000 -} - diff --git a/include/grub/backtrace.h b/include/grub/backtrace.h -index 395519762f0..275cf85e2d3 100644 +index 3955197..275cf85 100644 --- a/include/grub/backtrace.h +++ b/include/grub/backtrace.h @@ -19,8 +19,14 @@ @@ -785,10 +1024,10 @@ index 395519762f0..275cf85e2d3 100644 #endif diff --git a/include/grub/dl.h b/include/grub/dl.h -index b1ed3c33317..7b5bfb07ce6 100644 +index 90dc9bb..4fe2b52 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h -@@ -244,6 +244,8 @@ grub_dl_get (const char *name) +@@ -257,6 +257,8 @@ grub_dl_is_persistent (grub_dl_t mod) #endif @@ -798,10 +1037,10 @@ index b1ed3c33317..7b5bfb07ce6 100644 int isfunc, grub_dl_t mod); diff --git a/include/grub/kernel.h b/include/grub/kernel.h -index ecd88ca72c6..ae69218af20 100644 +index 133a37c..e5a5f43 100644 --- a/include/grub/kernel.h +++ b/include/grub/kernel.h -@@ -108,6 +108,9 @@ grub_addr_t grub_modules_get_end (void); +@@ -110,6 +110,9 @@ grub_addr_t grub_modules_get_end (void); #endif @@ -811,98 +1050,6 @@ index ecd88ca72c6..ae69218af20 100644 /* The start point of the C code. */ void grub_main (void) __attribute__ ((noreturn)); -diff --git a/grub-core/kern/arm/efi/startup.S b/grub-core/kern/arm/efi/startup.S -index 9f8265315a9..f3bc41f9d0f 100644 ---- a/grub-core/kern/arm/efi/startup.S -+++ b/grub-core/kern/arm/efi/startup.S -@@ -23,6 +23,8 @@ - .file "startup.S" - .text - .arm -+ .globl start, _start -+FUNCTION(start) - FUNCTION(_start) - /* - * EFI_SYSTEM_TABLE and EFI_HANDLE are passed in r1/r0. -diff --git a/grub-core/kern/arm/startup.S b/grub-core/kern/arm/startup.S -index 3946fe8e183..5679a1d00ad 100644 ---- a/grub-core/kern/arm/startup.S -+++ b/grub-core/kern/arm/startup.S -@@ -48,6 +48,8 @@ - - .text - .arm -+ .globl start, _start -+FUNCTION(start) - FUNCTION(_start) - b codestart - -diff --git a/grub-core/kern/arm64/efi/startup.S b/grub-core/kern/arm64/efi/startup.S -index 666a7ee3c92..41676bdb2b8 100644 ---- a/grub-core/kern/arm64/efi/startup.S -+++ b/grub-core/kern/arm64/efi/startup.S -@@ -19,7 +19,9 @@ - #include - - .file "startup.S" -+ .globl start, _start - .text -+FUNCTION(start) - FUNCTION(_start) - /* - * EFI_SYSTEM_TABLE and EFI_HANDLE are passed in x1/x0. -diff --git a/grub-core/kern/i386/qemu/startup.S b/grub-core/kern/i386/qemu/startup.S -index 0d89858d9b3..939f182fc74 100644 ---- a/grub-core/kern/i386/qemu/startup.S -+++ b/grub-core/kern/i386/qemu/startup.S -@@ -24,7 +24,8 @@ - - .text - .code32 -- .globl _start -+ .globl start, _start -+start: - _start: - jmp codestart - -diff --git a/grub-core/kern/ia64/efi/startup.S b/grub-core/kern/ia64/efi/startup.S -index d75c6d7cc74..8f2a593e529 100644 ---- a/grub-core/kern/ia64/efi/startup.S -+++ b/grub-core/kern/ia64/efi/startup.S -@@ -24,8 +24,9 @@ - .psr lsb - .lsb - -- .global _start -+ .global start, _start - .proc _start -+start: - _start: - alloc loc0=ar.pfs,2,4,0,0 - mov loc1=rp -diff --git a/grub-core/kern/sparc64/ieee1275/crt0.S b/grub-core/kern/sparc64/ieee1275/crt0.S -index 03b916f0534..701bf63abcf 100644 ---- a/grub-core/kern/sparc64/ieee1275/crt0.S -+++ b/grub-core/kern/sparc64/ieee1275/crt0.S -@@ -22,7 +22,8 @@ - - .text - .align 4 -- .globl _start -+ .globl start, _start -+start: - _start: - ba codestart - mov %o4, %o0 -diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am -index 0108c0d4233..f36200bd688 100644 ---- a/grub-core/Makefile.am -+++ b/grub-core/Makefile.am -@@ -66,6 +66,7 @@ CLEANFILES += grub_script.yy.c grub_script.yy.h - - include $(srcdir)/Makefile.core.am - -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/backtrace.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cache.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/device.h +-- +1.8.3.1 + diff --git a/0123-normal-don-t-draw-our-startup-message-if-debug-is-se.patch b/0101-normal-don-t-draw-our-startup-message-if-debug-is-se.patch similarity index 72% rename from 0123-normal-don-t-draw-our-startup-message-if-debug-is-se.patch rename to 0101-normal-don-t-draw-our-startup-message-if-debug-is-se.patch index d2a8fd079adb985664baf4dad1aae947a2d60806..555227baf975e7445f0abf57d484af56bcc17342 100644 --- a/0123-normal-don-t-draw-our-startup-message-if-debug-is-se.patch +++ b/0101-normal-don-t-draw-our-startup-message-if-debug-is-se.patch @@ -1,17 +1,18 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From e215e2c09bc7d7e970f4b644c30a1a3818829bfb Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 9 Nov 2017 15:58:52 -0500 -Subject: [PATCH] normal: don't draw our startup message if debug is set +Subject: [PATCH 101/220] normal: don't draw our startup message if debug is + set --- grub-core/normal/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index b69f9e738fa..04ae9ed02f6 100644 +index 2fe6743..f7ee912 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -419,6 +419,9 @@ grub_normal_reader_init (int nested) +@@ -425,6 +425,9 @@ grub_normal_reader_init (int nested) const char *msg_esc = _("ESC at any time exits."); char *msg_formatted; @@ -21,3 +22,6 @@ index b69f9e738fa..04ae9ed02f6 100644 msg_formatted = grub_xasprintf (_("Minimal BASH-like line editing is supported. For " "the first word, TAB lists possible command completions. Anywhere " "else TAB lists possible device or file completions. %s"), +-- +1.8.3.1 + diff --git a/0124-Work-around-some-minor-include-path-weirdnesses.patch b/0102-Work-around-some-minor-include-path-weirdnesses.patch similarity index 95% rename from 0124-Work-around-some-minor-include-path-weirdnesses.patch rename to 0102-Work-around-some-minor-include-path-weirdnesses.patch index 460d792707723c4de647d169db2f2316a995b5ce..7a999873beab15a735c3ae8fa1e16822460e709f 100644 --- a/0124-Work-around-some-minor-include-path-weirdnesses.patch +++ b/0102-Work-around-some-minor-include-path-weirdnesses.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 5327dd96cf5e2323a3aaac3f191ed72ad3d7294b Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Fri, 16 Mar 2018 13:28:57 -0400 -Subject: [PATCH] Work around some minor include path weirdnesses +Subject: [PATCH 102/220] Work around some minor include path weirdnesses Signed-off-by: Peter Jones --- @@ -17,7 +17,7 @@ Signed-off-by: Peter Jones diff --git a/include/grub/arm/efi/console.h b/include/grub/arm/efi/console.h new file mode 100644 -index 00000000000..1592f6f76b5 +index 0000000..1592f6f --- /dev/null +++ b/include/grub/arm/efi/console.h @@ -0,0 +1,24 @@ @@ -47,7 +47,7 @@ index 00000000000..1592f6f76b5 +#endif /* ! GRUB_ARM_EFI_CONSOLE_H */ diff --git a/include/grub/arm64/efi/console.h b/include/grub/arm64/efi/console.h new file mode 100644 -index 00000000000..95689339384 +index 0000000..9568933 --- /dev/null +++ b/include/grub/arm64/efi/console.h @@ -0,0 +1,24 @@ @@ -77,7 +77,7 @@ index 00000000000..95689339384 +#endif /* ! GRUB_ARM64_EFI_CONSOLE_H */ diff --git a/include/grub/i386/efi/console.h b/include/grub/i386/efi/console.h new file mode 100644 -index 00000000000..9231375cb07 +index 0000000..9231375 --- /dev/null +++ b/include/grub/i386/efi/console.h @@ -0,0 +1,24 @@ @@ -107,7 +107,7 @@ index 00000000000..9231375cb07 +#endif /* ! GRUB_I386_EFI_CONSOLE_H */ diff --git a/include/grub/x86_64/efi/console.h b/include/grub/x86_64/efi/console.h new file mode 100644 -index 00000000000..dba9d8678d0 +index 0000000..dba9d86 --- /dev/null +++ b/include/grub/x86_64/efi/console.h @@ -0,0 +1,24 @@ @@ -135,3 +135,6 @@ index 00000000000..dba9d8678d0 +#include + +#endif /* ! GRUB_X86_64_EFI_CONSOLE_H */ +-- +1.8.3.1 + diff --git a/0125-Make-it-possible-to-enabled-build-id-sha1.patch b/0103-Make-it-possible-to-enabled-build-id-sha1.patch similarity index 87% rename from 0125-Make-it-possible-to-enabled-build-id-sha1.patch rename to 0103-Make-it-possible-to-enabled-build-id-sha1.patch index 2ed085c19a316695e0a0f80b1e3ad3ca488d6110..9873991baacf5b565b24518883d95d656b64bd2d 100644 --- a/0125-Make-it-possible-to-enabled-build-id-sha1.patch +++ b/0103-Make-it-possible-to-enabled-build-id-sha1.patch @@ -1,36 +1,16 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From cc30961c213539793d723cd1ce0c61b8a5553c12 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 25 Jun 2015 15:41:06 -0400 -Subject: [PATCH] Make it possible to enabled --build-id=sha1 +Subject: [PATCH 103/220] Make it possible to enabled --build-id=sha1 Signed-off-by: Peter Jones --- - configure.ac | 8 ++++++++ acinclude.m4 | 19 +++++++++++++++++++ + configure.ac | 8 ++++++++ 2 files changed, 27 insertions(+) -diff --git a/configure.ac b/configure.ac -index f69f8986791..359cac3c26b 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1386,7 +1386,15 @@ grub_PROG_TARGET_CC - if test "x$TARGET_APPLE_LINKER" != x1 ; then - grub_PROG_OBJCOPY_ABSOLUTE - fi -+ -+AC_ARG_ENABLE([build-id], -+ [AS_HELP_STRING([--enable-build-id], -+ [ask the linker to supply build-id notes (default=no)])]) -+if test x$enable_build_id = xyes; then -+grub_PROG_LD_BUILD_ID_SHA1 -+else - grub_PROG_LD_BUILD_ID_NONE -+fi - if test "x$target_cpu" = xi386; then - if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then - if test ! -z "$TARGET_IMG_LDSCRIPT"; then diff --git a/acinclude.m4 b/acinclude.m4 -index 78cdf6e1d01..242e829ff23 100644 +index 78cdf6e..242e829 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -136,6 +136,25 @@ if test "x$grub_cv_prog_ld_build_id_none" = xyes; then @@ -59,3 +39,26 @@ index 78cdf6e1d01..242e829ff23 100644 dnl Check nm AC_DEFUN([grub_PROG_NM_WORKS], [AC_MSG_CHECKING([whether nm works]) +diff --git a/configure.ac b/configure.ac +index eb851b8..8ee18ba 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1414,7 +1414,15 @@ grub_PROG_TARGET_CC + if test "x$TARGET_APPLE_LINKER" != x1 ; then + grub_PROG_OBJCOPY_ABSOLUTE + fi ++ ++AC_ARG_ENABLE([build-id], ++ [AS_HELP_STRING([--enable-build-id], ++ [ask the linker to supply build-id notes (default=no)])]) ++if test x$enable_build_id = xyes; then ++grub_PROG_LD_BUILD_ID_SHA1 ++else + grub_PROG_LD_BUILD_ID_NONE ++fi + if test "x$target_cpu" = xi386; then + if test "$platform" != emu && test "x$TARGET_APPLE_LINKER" != x1 ; then + if test ! -z "$TARGET_IMG_LDSCRIPT"; then +-- +1.8.3.1 + diff --git a/0126-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch b/0104-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch similarity index 87% rename from 0126-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch rename to 0104-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch index 8bd55480441f9f5007f47f51ca8e9af3b5bc21e4..d609304781ab6cefc45c9348d8dbf92251a2ec83 100644 --- a/0126-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch +++ b/0104-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 550772dbfbe9a0bc144d3d90ed0c2e87663a318b Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Sun, 28 Jun 2015 13:09:58 -0400 -Subject: [PATCH] Add grub_qdprintf() - grub_dprintf() without the file+line - number. +Subject: [PATCH 104/220] Add grub_qdprintf() - grub_dprintf() without the + file+line number. This just makes copy+paste of our debug loading info easier. @@ -13,7 +13,7 @@ Signed-off-by: Peter Jones 2 files changed, 20 insertions(+) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 5c2d2039d0b..0e89c483d5e 100644 +index 5c2d203..0e89c48 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -190,6 +190,24 @@ grub_real_dprintf (const char *file, const int line, const char *condition, @@ -42,7 +42,7 @@ index 5c2d2039d0b..0e89c483d5e 100644 int diff --git a/include/grub/misc.h b/include/grub/misc.h -index f7473c154f0..5f1c1c1be4e 100644 +index 4a4f485..960097f 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -372,6 +372,8 @@ void EXPORT_FUNC(grub_real_dprintf) (const char *file, @@ -54,3 +54,6 @@ index f7473c154f0..5f1c1c1be4e 100644 int EXPORT_FUNC(grub_vprintf) (const char *fmt, va_list args); int EXPORT_FUNC(grub_snprintf) (char *str, grub_size_t n, const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 3, 4))); +-- +1.8.3.1 + diff --git a/0127-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch b/0105-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch similarity index 91% rename from 0127-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch rename to 0105-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch index f3e24d5a827a0ed8acfdd631c372ca80264eb0cc..5f44b93e12f252f7df53e10ae2dfffc17dfb67d9 100644 --- a/0127-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch +++ b/0105-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 0439dd373f4c7fe346fd3e2b4680e21135f5a00b Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 25 Jun 2015 15:11:36 -0400 -Subject: [PATCH] Make a "gdb" dprintf that tells us load addresses. +Subject: [PATCH 105/220] Make a "gdb" dprintf that tells us load addresses. This makes a grub_dprintf() call during platform init and during module loading that tells us the virtual addresses of the .text and .data @@ -20,7 +20,7 @@ Signed-off-by: Peter Jones 4 files changed, 78 insertions(+), 4 deletions(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 5028d157c46..eb8b969cded 100644 +index 2e57e5e..6a5e770 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -501,6 +501,23 @@ grub_dl_find_section (Elf_Ehdr *e, const char *name) @@ -95,7 +95,7 @@ index 5028d157c46..eb8b969cded 100644 { grub_dl_unload (mod); diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index bcae7f4699d..a2a732ffc0d 100644 +index 2cf6a5a..19054b1 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -283,7 +283,7 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, @@ -117,7 +117,7 @@ index bcae7f4699d..a2a732ffc0d 100644 } diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c -index 71d2279a0c1..e6183a4c44d 100644 +index 71d2279..e6183a4 100644 --- a/grub-core/kern/efi/init.c +++ b/grub-core/kern/efi/init.c @@ -59,10 +59,33 @@ grub_efi_env_init (void) @@ -164,11 +164,11 @@ index 71d2279a0c1..e6183a4c44d 100644 } diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 09a18e56302..570a69361a5 100644 +index 5e2b479..8ca3981 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h -@@ -132,7 +132,7 @@ grub_err_t grub_armxx_efi_linux_check_image(struct linux_armxx_kernel_header *lh - grub_err_t grub_armxx_efi_linux_boot_image(grub_addr_t addr, char *args); +@@ -132,7 +132,7 @@ grub_err_t grub_arch_efi_linux_check_image(struct linux_arch_kernel_header *lh); + grub_err_t grub_arch_efi_linux_boot_image(grub_addr_t addr, char *args); #endif -grub_addr_t grub_efi_modules_addr (void); @@ -176,3 +176,6 @@ index 09a18e56302..570a69361a5 100644 void grub_efi_mm_init (void); void grub_efi_mm_fini (void); +-- +1.8.3.1 + diff --git a/0152-Fixup-for-newer-compiler.patch b/0106-Fixup-for-newer-compiler.patch similarity index 79% rename from 0152-Fixup-for-newer-compiler.patch rename to 0106-Fixup-for-newer-compiler.patch index a63ca6bd686eb94d67abc178f5991cdc55f92c47..cc830c752d2502fa181f915504774fb22c6b824b 100644 --- a/0152-Fixup-for-newer-compiler.patch +++ b/0106-Fixup-for-newer-compiler.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From d274cc00ea92dc4aa9c7b4b63e230e37186d31c6 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 10 May 2018 13:40:19 -0400 -Subject: [PATCH] Fixup for newer compiler +Subject: [PATCH 106/220] Fixup for newer compiler --- grub-core/fs/btrfs.c | 2 +- @@ -9,10 +9,10 @@ Subject: [PATCH] Fixup for newer compiler 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 7002ad81b7e..dac73b2fa8b 100644 +index ba99d04..9cd7f4b 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -198,7 +198,7 @@ struct grub_btrfs_inode +@@ -215,7 +215,7 @@ struct grub_btrfs_inode grub_uint64_t size; grub_uint8_t dummy2[0x70]; struct grub_btrfs_time mtime; @@ -22,7 +22,7 @@ index 7002ad81b7e..dac73b2fa8b 100644 struct grub_btrfs_extent_data { diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h -index 7a93f43291c..8212697bf6b 100644 +index 7a93f43..8212697 100644 --- a/include/grub/gpt_partition.h +++ b/include/grub/gpt_partition.h @@ -76,7 +76,7 @@ struct grub_gpt_partentry @@ -34,3 +34,6 @@ index 7a93f43291c..8212697bf6b 100644 grub_err_t grub_gpt_partition_map_iterate (grub_disk_t disk, +-- +1.8.3.1 + diff --git a/0153-Don-t-attempt-to-export-the-start-and-_start-symbols.patch b/0107-Don-t-attempt-to-export-the-start-and-_start-symbols.patch similarity index 84% rename from 0153-Don-t-attempt-to-export-the-start-and-_start-symbols.patch rename to 0107-Don-t-attempt-to-export-the-start-and-_start-symbols.patch index 33ceb3d40ab0fafbdc32fb3004c9cf979bb8bf17..db380c1e5fa4e400c2de986eb0c3e8cd0d1dce5a 100644 --- a/0153-Don-t-attempt-to-export-the-start-and-_start-symbols.patch +++ b/0107-Don-t-attempt-to-export-the-start-and-_start-symbols.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From c6522389c9a795007a54aedeb10f8c3afd9dab24 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sat, 12 May 2018 11:29:07 +0200 -Subject: [PATCH] Don't attempt to export the start and _start symbols for - grub-emu +Subject: [PATCH 107/220] Don't attempt to export the start and _start symbols + for grub-emu Commit 318ee04aadc ("make better backtraces") reworked the backtrace logic but the changes lead to the following build error on the grub-emu platform: @@ -26,10 +26,10 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 2 insertions(+) diff --git a/include/grub/kernel.h b/include/grub/kernel.h -index ae69218af20..9548d552aad 100644 +index e5a5f43..de48cd4 100644 --- a/include/grub/kernel.h +++ b/include/grub/kernel.h -@@ -108,8 +108,10 @@ grub_addr_t grub_modules_get_end (void); +@@ -110,8 +110,10 @@ grub_addr_t grub_modules_get_end (void); #endif @@ -40,3 +40,6 @@ index ae69218af20..9548d552aad 100644 /* The start point of the C code. */ void grub_main (void) __attribute__ ((noreturn)); +-- +1.8.3.1 + diff --git a/0157-Fixup-for-newer-compiler.patch b/0108-Fixup-for-newer-compiler.patch similarity index 86% rename from 0157-Fixup-for-newer-compiler.patch rename to 0108-Fixup-for-newer-compiler.patch index e518af8feaf2dbb7f95624fc958003d27f23ec5e..f6b78d256c8b30db3e98f817152d3cf0121173ba 100644 --- a/0157-Fixup-for-newer-compiler.patch +++ b/0108-Fixup-for-newer-compiler.patch @@ -1,14 +1,14 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 433752e769b2a31d94b7e70fba2a73be509e8510 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 10 May 2018 13:40:19 -0400 -Subject: [PATCH] Fixup for newer compiler +Subject: [PATCH 108/220] Fixup for newer compiler --- conf/Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/Makefile.common b/conf/Makefile.common -index 044ab3abe88..c75848f5c06 100644 +index 4ba729e..5e8ba2a 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -38,7 +38,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding @@ -20,3 +20,6 @@ index 044ab3abe88..c75848f5c06 100644 CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d +-- +1.8.3.1 + diff --git a/0167-Add-support-for-non-Ethernet-network-cards.patch b/0109-Add-support-for-non-Ethernet-network-cards.patch similarity index 90% rename from 0167-Add-support-for-non-Ethernet-network-cards.patch rename to 0109-Add-support-for-non-Ethernet-network-cards.patch index e61bcc110fbe40cb09976738255309225de49d75..c66ef7d8bd3c5bfcb797aad6b183cc01f32c6093 100644 --- a/0167-Add-support-for-non-Ethernet-network-cards.patch +++ b/0109-Add-support-for-non-Ethernet-network-cards.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From e8e2d019246798865075a3577619ac89ac34eee6 Mon Sep 17 00:00:00 2001 From: Andrzej Kacprowski -Date: Fri, 21 Apr 2017 10:06:20 +0200 -Subject: [PATCH] Add support for non-Ethernet network cards +Date: Wed, 10 Jul 2019 15:22:29 +0200 +Subject: [PATCH 109/220] Add support for non-Ethernet network cards This patch replaces fixed 6-byte link layer address with up to 32-byte variable sized address. @@ -20,26 +20,25 @@ then chaddr field in BOOTP it will be set to 0 as per rfc4390. Resolves: rhbz#1370642 Signed-off-by: Andrzej Kacprowski - -Conflicts: - grub-core/net/ip.c +[msalter: Fix max string calculation in grub_net_hwaddr_to_str] +Signed-off-by: Mark Salter --- - grub-core/net/arp.c | 155 ++++++++++++++++++++++----------- - grub-core/net/bootp.c | 14 ++- + grub-core/net/arp.c | 157 +++++++++++++++++++++------------ + grub-core/net/bootp.c | 15 ++-- grub-core/net/drivers/efi/efinet.c | 8 +- grub-core/net/drivers/emu/emunet.c | 1 + grub-core/net/drivers/i386/pc/pxe.c | 13 +-- grub-core/net/drivers/ieee1275/ofnet.c | 2 + grub-core/net/drivers/uboot/ubootnet.c | 1 + - grub-core/net/ethernet.c | 88 +++++++++---------- + grub-core/net/ethernet.c | 88 +++++++++--------- grub-core/net/icmp6.c | 15 ++-- grub-core/net/ip.c | 4 +- - grub-core/net/net.c | 48 +++++----- + grub-core/net/net.c | 50 ++++++----- include/grub/net.h | 19 ++-- - 12 files changed, 216 insertions(+), 152 deletions(-) + 12 files changed, 220 insertions(+), 153 deletions(-) diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c -index 54306e3b16d..67b409a8acc 100644 +index 54306e3..67b409a 100644 --- a/grub-core/net/arp.c +++ b/grub-core/net/arp.c @@ -31,22 +31,12 @@ enum @@ -147,15 +146,16 @@ index 54306e3b16d..67b409a8acc 100644 grub_net_network_level_address_t sender_addr, target_addr; grub_net_link_level_address_t sender_mac_addr; struct grub_net_network_level_interface *inf; +- +- if (arp_packet->pro != grub_cpu_to_be16_compile_time (GRUB_NET_ETHERTYPE_IP) +- || arp_packet->pln != 4 || arp_packet->hln != 6 +- || nb->tail - nb->data < (int) sizeof (*arp_packet)) + grub_uint16_t hw_type; + grub_uint8_t hln; + grub_uint8_t pln; + grub_uint8_t arp_packet_len; + grub_uint8_t *tmp_ptr; - -- if (arp_packet->pro != grub_cpu_to_be16_compile_time (GRUB_NET_ETHERTYPE_IP) -- || arp_packet->pln != 4 || arp_packet->hln != 6 -- || nb->tail - nb->data < (int) sizeof (*arp_packet)) ++ + hw_type = card->default_address.type; + hln = card->default_address.len; + pln = sizeof(sender_addr.ipv4); @@ -178,29 +178,29 @@ index 54306e3b16d..67b409a8acc 100644 + + /* The source protocol address. */ sender_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; +- target_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; +- sender_addr.ipv4 = arp_packet->sender_ip; +- target_addr.ipv4 = arp_packet->recv_ip; +- if (arp_packet->sender_ip == pending_req) +- have_pending = 1; + grub_memcpy(&sender_addr.ipv4, tmp_ptr, pln); + tmp_ptr += pln; -+ -+ grub_net_link_layer_add_address (card, &sender_addr, &sender_mac_addr, 1); -+ + +- sender_mac_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; +- grub_memcpy (sender_mac_addr.mac, arp_packet->sender_mac, +- sizeof (sender_mac_addr.mac)); + grub_net_link_layer_add_address (card, &sender_addr, &sender_mac_addr, 1); + + /* The target hardware address. */ + tmp_ptr += hln; + + /* The target protocol address. */ - target_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; -- sender_addr.ipv4 = arp_packet->sender_ip; -- target_addr.ipv4 = arp_packet->recv_ip; -- if (arp_packet->sender_ip == pending_req) ++ target_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; + grub_memcpy(&target_addr.ipv4, tmp_ptr, pln); + + if (sender_addr.ipv4 == pending_req) - have_pending = 1; - -- sender_mac_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; -- grub_memcpy (sender_mac_addr.mac, arp_packet->sender_mac, -- sizeof (sender_mac_addr.mac)); -- grub_net_link_layer_add_address (card, &sender_addr, &sender_mac_addr, 1); -- ++ have_pending = 1; ++ FOR_NET_NETWORK_LEVEL_INTERFACES (inf) { /* Verify vlantag id */ @@ -272,10 +272,10 @@ index 54306e3b16d..67b409a8acc 100644 /* Change operation to REPLY and send packet */ send_ethernet_packet (inf, &nb_reply, target, GRUB_NET_ETHERTYPE_ARP); diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 2869482fe06..4e55adc557b 100644 +index 8c96959..3cf6dbf 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c -@@ -219,7 +219,6 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -269,7 +269,6 @@ grub_net_configure_by_dhcp_ack (const char *name, int is_def, char **device, char **path) { grub_net_network_level_address_t addr; @@ -283,7 +283,7 @@ index 2869482fe06..4e55adc557b 100644 struct grub_net_network_level_interface *inter; int mask = -1; char server_ip[sizeof ("xxx.xxx.xxx.xxx")]; -@@ -232,12 +231,8 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -286,12 +285,8 @@ grub_net_configure_by_dhcp_ack (const char *name, if (path) *path = 0; @@ -298,30 +298,31 @@ index 2869482fe06..4e55adc557b 100644 if (!inter) return 0; -@@ -770,7 +765,8 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), - grub_memset (pack, 0, sizeof (*pack) + 64); - pack->opcode = 1; - pack->hw_type = 1; -- pack->hw_len = 6; -+ pack->hw_len = ifaces[j].hwaddress.len > 16 ? 0 -+ : ifaces[j].hwaddress.len; - err = grub_get_datetime (&date); - if (err || !grub_datetime2unixtime (&date, &t)) - { -@@ -781,7 +777,7 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), - ifaces[j].dhcp_xid = pack->xid; - pack->seconds = grub_cpu_to_be16 (t); +@@ -601,7 +596,9 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface) + grub_memset (pack, 0, sizeof (*pack)); + pack->opcode = 1; + pack->hw_type = 1; +- pack->hw_len = 6; ++ pack->hw_len = iface->hwaddress.len > 16 ? 0 ++ : iface->hwaddress.len; ++ + err = grub_get_datetime (&date); + if (err || !grub_datetime2unixtime (&date, &t)) + { +@@ -614,7 +611,7 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface) + else + pack->ident = iface->xid; -- grub_memcpy (&pack->mac_addr, &ifaces[j].hwaddress.mac, 6); -+ grub_memcpy (&pack->mac_addr, &ifaces[j].hwaddress.mac, pack->hw_len); +- grub_memcpy (&pack->mac_addr, &iface->hwaddress.mac, 6); ++ grub_memcpy (&pack->mac_addr, &iface->hwaddress.mac, pack->hw_len); - grub_netbuff_push (nb, sizeof (*udph)); + grub_netbuff_push (nb, sizeof (*udph)); diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 329024b6f2c..bf36b446dc4 100644 +index a57189e..4444e8e 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c -@@ -329,6 +329,9 @@ grub_efinet_find_snp_cards (int preferred_only, grub_efi_handle_t preferred, +@@ -280,6 +280,9 @@ grub_efinet_findcards (void) /* This should not happen... Why? */ continue; @@ -331,8 +332,8 @@ index 329024b6f2c..bf36b446dc4 100644 if (net->mode->state == GRUB_EFI_NETWORK_STOPPED && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) continue; -@@ -366,10 +369,11 @@ grub_efinet_find_snp_cards (int preferred_only, grub_efi_handle_t preferred, - *i = (*i)+1; +@@ -316,10 +319,11 @@ grub_efinet_findcards (void) + card->name = grub_xasprintf ("efinet%d", i++); card->driver = &efidriver; card->flags = 0; - card->default_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; @@ -346,7 +347,7 @@ index 329024b6f2c..bf36b446dc4 100644 card->efi_handle = *handle; diff --git a/grub-core/net/drivers/emu/emunet.c b/grub-core/net/drivers/emu/emunet.c -index b194920861f..5b6c5e16a6d 100644 +index b194920..5b6c5e1 100644 --- a/grub-core/net/drivers/emu/emunet.c +++ b/grub-core/net/drivers/emu/emunet.c @@ -46,6 +46,7 @@ static struct grub_net_card emucard = @@ -358,7 +359,7 @@ index b194920861f..5b6c5e16a6d 100644 }, .flags = 0 diff --git a/grub-core/net/drivers/i386/pc/pxe.c b/grub-core/net/drivers/i386/pc/pxe.c -index 3f4152d036c..9f8fb4b6d2b 100644 +index 3f4152d..9f8fb4b 100644 --- a/grub-core/net/drivers/i386/pc/pxe.c +++ b/grub-core/net/drivers/i386/pc/pxe.c @@ -386,20 +386,21 @@ GRUB_MOD_INIT(pxe) @@ -390,7 +391,7 @@ index 3f4152d036c..9f8fb4b6d2b 100644 grub_pxe_card.default_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c -index 3df75357a70..ba50415f5f6 100644 +index 3860b6f..bcb3f9e 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -160,6 +160,7 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, @@ -410,7 +411,7 @@ index 3df75357a70..ba50415f5f6 100644 card->txbufsize = ALIGN_UP (card->mtu, 64) + 256; diff --git a/grub-core/net/drivers/uboot/ubootnet.c b/grub-core/net/drivers/uboot/ubootnet.c -index 056052e40d5..22ebcbf211e 100644 +index 056052e..22ebcbf 100644 --- a/grub-core/net/drivers/uboot/ubootnet.c +++ b/grub-core/net/drivers/uboot/ubootnet.c @@ -131,6 +131,7 @@ GRUB_MOD_INIT (ubootnet) @@ -422,7 +423,7 @@ index 056052e40d5..22ebcbf211e 100644 card->txbufsize = ALIGN_UP (card->mtu, 64) + 256; card->txbuf = grub_zalloc (card->txbufsize); diff --git a/grub-core/net/ethernet.c b/grub-core/net/ethernet.c -index 4d7ceed6f93..9aae83a5eb4 100644 +index 4d7ceed..9aae83a 100644 --- a/grub-core/net/ethernet.c +++ b/grub-core/net/ethernet.c @@ -29,13 +29,6 @@ @@ -572,7 +573,7 @@ index 4d7ceed6f93..9aae83a5eb4 100644 { /* ARP packet. */ diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c -index 2cbd95dce25..56a3ec5c8e8 100644 +index 2cbd95d..56a3ec5 100644 --- a/grub-core/net/icmp6.c +++ b/grub-core/net/icmp6.c @@ -231,8 +231,9 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb, @@ -612,22 +613,22 @@ index 2cbd95dce25..56a3ec5c8e8 100644 } if (ohdr->type == OPTION_PREFIX && ohdr->len == 4) diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c -index 8411e0ecca3..b2ca74b6eb1 100644 +index ea5edf8..a5896f6 100644 --- a/grub-core/net/ip.c +++ b/grub-core/net/ip.c -@@ -277,8 +277,8 @@ handle_dgram (struct grub_net_buff *nb, +@@ -276,8 +276,8 @@ handle_dgram (struct grub_net_buff *nb, + if (inf->card == card && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV - && inf->dhcp_xid == bootp->xid && inf->hwaddress.type == GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET - && grub_memcmp (inf->hwaddress.mac, &bootp->mac_addr, - sizeof (inf->hwaddress.mac)) == 0) + && (grub_memcmp (inf->hwaddress.mac, &bootp->mac_addr, + bootp->hw_len) == 0 || bootp->hw_len == 0)) { - grub_net_process_dhcp (nb, inf->card); + grub_net_process_dhcp (nb, inf); grub_netbuff_free (nb); diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index fa3e2912643..9b8944292c7 100644 +index 5366e44..6468eb2 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -128,8 +128,9 @@ grub_net_link_layer_resolve (struct grub_net_network_level_interface *inf, @@ -650,7 +651,7 @@ index fa3e2912643..9b8944292c7 100644 hw_addr->mac[0] = 0x33; hw_addr->mac[1] = 0x33; hw_addr->mac[2] = ((grub_be_to_cpu64 (proto_addr->ipv6[1]) >> 24) & 0xff); -@@ -757,23 +759,21 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target, char *buf) +@@ -757,23 +759,23 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target, char *buf) void grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str) { @@ -658,6 +659,7 @@ index fa3e2912643..9b8944292c7 100644 - switch (addr->type) + char *ptr; + unsigned i; ++ int maxstr; + + if (addr->len > GRUB_NET_MAX_LINK_ADDRESS_SIZE) { @@ -678,16 +680,17 @@ index fa3e2912643..9b8944292c7 100644 + addr->type, addr->len); + return; + } ++ maxstr = addr->len * grub_strlen ("XX:"); + for (ptr = str, i = 0; i < addr->len; i++) + { -+ ptr += grub_snprintf (ptr, GRUB_NET_MAX_STR_HWADDR_LEN - (ptr - str), ++ ptr += grub_snprintf (ptr, maxstr - (ptr - str), + "%02x:", addr->mac[i] & 0xff); } - grub_printf (_("Unsupported hw address type %d\n"), addr->type); } int -@@ -784,13 +784,17 @@ grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a, +@@ -784,13 +786,17 @@ grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a, return -1; if (a->type > b->type) return +1; @@ -711,7 +714,7 @@ index fa3e2912643..9b8944292c7 100644 int diff --git a/include/grub/net.h b/include/grub/net.h -index de51894cbbf..e9ebc6a1b4f 100644 +index 3647012..fc1fc44 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -29,7 +29,8 @@ @@ -744,7 +747,7 @@ index de51894cbbf..e9ebc6a1b4f 100644 }; } grub_net_link_level_address_t; -@@ -555,11 +558,13 @@ grub_net_addr_cmp (const grub_net_network_level_address_t *a, +@@ -566,11 +569,13 @@ grub_net_addr_cmp (const grub_net_network_level_address_t *a, #define GRUB_NET_MAX_STR_ADDR_LEN sizeof ("XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX") /* @@ -762,3 +765,6 @@ index de51894cbbf..e9ebc6a1b4f 100644 void grub_net_addr_to_str (const grub_net_network_level_address_t *target, +-- +1.8.3.1 + diff --git a/0168-misc-fix-invalid-character-recongition-in-strto-l.patch b/0110-misc-fix-invalid-character-recongition-in-strto-l.patch similarity index 85% rename from 0168-misc-fix-invalid-character-recongition-in-strto-l.patch rename to 0110-misc-fix-invalid-character-recongition-in-strto-l.patch index 40060286f7400770417597640b0d993656d4d30b..110cfc9745e725a09f6c46d5fcea8cebf99960bd 100644 --- a/0168-misc-fix-invalid-character-recongition-in-strto-l.patch +++ b/0110-misc-fix-invalid-character-recongition-in-strto-l.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From d2f8885f7d9ea9581d93541c321dd1ce564c8446 Mon Sep 17 00:00:00 2001 From: Aaron Miller Date: Fri, 29 Jul 2016 17:41:27 +0800 -Subject: [PATCH] misc: fix invalid character recongition in strto*l +Subject: [PATCH 110/220] misc: fix invalid character recongition in strto*l Would previously allow digits larger than the base and didn't check that subtracting the difference from 0-9 to lowercase letters for characters @@ -12,7 +12,7 @@ parses: ` = 9, _ = 8, ^ = 7, ] = 6, \ = 5, and [ = 4 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 0e89c483d5e..5c3899f0e5b 100644 +index 0e89c48..5c3899f 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -434,11 +434,14 @@ grub_strtoull (const char *str, char **end, int base) @@ -35,3 +35,6 @@ index 0e89c483d5e..5c3899f0e5b 100644 if (digit >= (unsigned long) base) break; +-- +1.8.3.1 + diff --git a/0169-net-read-bracketed-ipv6-addrs-and-port-numbers.patch b/0111-net-read-bracketed-ipv6-addrs-and-port-numbers.patch similarity index 71% rename from 0169-net-read-bracketed-ipv6-addrs-and-port-numbers.patch rename to 0111-net-read-bracketed-ipv6-addrs-and-port-numbers.patch index 4f6818783abb9926cef37825f65c90efb551b822..fef7bf81ceecf3dea92b65ee29fa62ea9f67bec7 100644 --- a/0169-net-read-bracketed-ipv6-addrs-and-port-numbers.patch +++ b/0111-net-read-bracketed-ipv6-addrs-and-port-numbers.patch @@ -1,23 +1,38 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 4a61dd01be61bb37b64866659e357558535b8b56 Mon Sep 17 00:00:00 2001 From: Aaron Miller Date: Fri, 29 Jul 2016 17:41:38 +0800 -Subject: [PATCH] net: read bracketed ipv6 addrs and port numbers +Subject: [PATCH 111/220] net: read bracketed ipv6 addrs and port numbers Allow specifying port numbers for http and tftp paths, and allow ipv6 addresses to be recognized with brackets around them, which is required to specify a port number + +Signed-off-by: Aaron Miller +[pjones: various bug fixes] +Signed-off-by: Peter Jones --- - grub-core/net/http.c | 21 +++++++++++--- - grub-core/net/net.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ - grub-core/net/tftp.c | 8 ++++-- + grub-core/net/http.c | 27 ++++++++++++---- + grub-core/net/net.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++--- + grub-core/net/tftp.c | 8 +++-- include/grub/net.h | 1 + - 4 files changed, 101 insertions(+), 6 deletions(-) + 4 files changed, 110 insertions(+), 13 deletions(-) diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index 5aa4ad3befc..f182d7b871d 100644 +index 5aa4ad3..00737c5 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c -@@ -312,12 +312,14 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) +@@ -289,7 +289,9 @@ http_receive (grub_net_tcp_socket_t sock __attribute__ ((unused)), + nb2 = grub_netbuff_alloc (data->chunk_rem); + if (!nb2) + return grub_errno; +- grub_netbuff_put (nb2, data->chunk_rem); ++ err = grub_netbuff_put (nb2, data->chunk_rem); ++ if (err) ++ return grub_errno; + grub_memcpy (nb2->data, nb->data, data->chunk_rem); + if (file->device->net->packs.count >= 20) + { +@@ -312,12 +314,14 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) int i; struct grub_net_buff *nb; grub_err_t err; @@ -33,7 +48,7 @@ index 5aa4ad3befc..f182d7b871d 100644 + sizeof ("\r\nUser-Agent: " PACKAGE_STRING "\r\n") - 1 + sizeof ("Range: bytes=XXXXXXXXXXXXXXXXXXXX" -@@ -356,7 +358,7 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) +@@ -356,7 +360,7 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) sizeof (" HTTP/1.1\r\nHost: ") - 1); ptr = nb->tail; @@ -42,7 +57,7 @@ index 5aa4ad3befc..f182d7b871d 100644 if (err) { grub_netbuff_free (nb); -@@ -365,6 +367,15 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) +@@ -365,6 +369,15 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) grub_memcpy (ptr, file->device->net->server, grub_strlen (file->device->net->server)); @@ -58,47 +73,49 @@ index 5aa4ad3befc..f182d7b871d 100644 ptr = nb->tail; err = grub_netbuff_put (nb, sizeof ("\r\nUser-Agent: " PACKAGE_STRING "\r\n") -@@ -390,8 +401,10 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) +@@ -390,9 +403,11 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) grub_netbuff_put (nb, 2); grub_memcpy (ptr, "\r\n", 2); - data->sock = grub_net_tcp_open (file->device->net->server, - HTTP_PORT, http_receive, +- http_err, http_err, + grub_dprintf ("http", "opening path %s on host %s TCP port %d\n", + data->filename, server, port ? port : HTTP_PORT); + data->sock = grub_net_tcp_open (server, + port ? port : HTTP_PORT, http_receive, - http_err, http_err, ++ http_err, NULL, file); if (!data->sock) + { diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 9b8944292c7..1f887d44b32 100644 +index 6468eb2..2734f70 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c -@@ -439,6 +439,12 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) +@@ -439,6 +439,13 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) grub_uint16_t newip[8]; const char *ptr = val; int word, quaddot = -1; + int bracketed = 0; + -+ if (ptr[0] == '[') { -+ bracketed = 1; -+ ptr++; -+ } ++ if (ptr[0] == '[') ++ { ++ bracketed = 1; ++ ptr++; ++ } if (ptr[0] == ':' && ptr[1] != ':') return 0; -@@ -477,6 +483,9 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) +@@ -477,6 +484,8 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) grub_memset (&newip[quaddot], 0, (7 - word) * sizeof (newip[0])); } grub_memcpy (ip, newip, 16); -+ if (bracketed && *ptr == ']') { ++ if (bracketed && *ptr == ']') + ptr++; -+ } if (rest) *rest = ptr; return 1; -@@ -1336,8 +1345,10 @@ grub_net_open_real (const char *name) +@@ -1338,8 +1347,10 @@ grub_net_open_real (const char *name) { grub_net_app_level_t proto; const char *protname, *server; @@ -109,14 +126,14 @@ index 9b8944292c7..1f887d44b32 100644 if (grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) == 0) { -@@ -1375,6 +1386,72 @@ grub_net_open_real (const char *name) +@@ -1377,6 +1388,72 @@ grub_net_open_real (const char *name) return NULL; } + char* port_start; + /* ipv6 or port specified? */ + if ((port_start = grub_strchr (server, ':'))) -+ { ++ { + char* ipv6_begin; + if((ipv6_begin = grub_strchr (server, '['))) + { @@ -182,8 +199,35 @@ index 9b8944292c7..1f887d44b32 100644 for (try = 0; try < 2; try++) { FOR_NET_APP_LEVEL (proto) +@@ -1386,14 +1463,13 @@ grub_net_open_real (const char *name) + { + grub_net_t ret = grub_zalloc (sizeof (*ret)); + if (!ret) +- return NULL; +- ret->protocol = proto; +- ret->server = grub_strdup (server); +- if (!ret->server) + { +- grub_free (ret); ++ grub_free (host); + return NULL; + } ++ ret->protocol = proto; ++ ret->port = port; ++ ret->server = host; + ret->fs = &grub_net_fs; + return ret; + } +@@ -1468,6 +1544,7 @@ grub_net_open_real (const char *name) + grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' not found"), + name); + ++ grub_free (host); + return NULL; + } + diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index f90071353ad..e267af354f4 100644 +index f900713..e267af3 100644 --- a/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c @@ -333,6 +333,7 @@ tftp_open (struct grub_file *file, const char *filename) @@ -216,7 +260,7 @@ index f90071353ad..e267af354f4 100644 if (!data->sock) { diff --git a/include/grub/net.h b/include/grub/net.h -index e9ebc6a1b4f..f4cd86e582f 100644 +index fc1fc44..fa7a8c3 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -273,6 +273,7 @@ typedef struct grub_net @@ -227,3 +271,6 @@ index e9ebc6a1b4f..f4cd86e582f 100644 grub_net_app_level_t protocol; grub_net_packets_t packs; grub_off_t offset; +-- +1.8.3.1 + diff --git a/0112-Add-quicksort-implementation.patch b/0112-Add-quicksort-implementation.patch deleted file mode 100644 index 06fe563605afb4f0fb3da96407a3da4d8f8d96a5..0000000000000000000000000000000000000000 --- a/0112-Add-quicksort-implementation.patch +++ /dev/null @@ -1,322 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 9 Dec 2016 15:39:47 -0500 -Subject: [PATCH] Add quicksort implementation - -This will be used to sort the boot menu entries that are read from -the BootLoaderSpec config files. ---- - grub-core/kern/qsort.c | 279 +++++++++++++++++++++++++++++++++++++++++++++++++ - include/grub/misc.h | 15 +++ - 2 files changed, 294 insertions(+) - create mode 100644 grub-core/kern/qsort.c - -diff --git a/grub-core/kern/qsort.c b/grub-core/kern/qsort.c -new file mode 100644 -index 00000000000..7f3fc9ffdae ---- /dev/null -+++ b/grub-core/kern/qsort.c -@@ -0,0 +1,279 @@ -+/* quicksort -+ * This file from the GNU C Library. -+ * Copyright (C) 1991-2016 Free Software Foundation, Inc. -+ * Written by Douglas C. Schmidt (schmidt@ics.uci.edu). -+ * -+ * GRUB -- GRand Unified Bootloader -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+/* If you consider tuning this algorithm, you should consult first: -+ Engineering a sort function; Jon Bentley and M. Douglas McIlroy; -+ Software - Practice and Experience; Vol. 23 (11), 1249-1265, 1993. */ -+ -+#include -+#include -+#include -+ -+#define CHAR_BIT 8 -+ -+/* Byte-wise swap two items of size SIZE. */ -+#define SWAP(a, b, size) \ -+ do \ -+ { \ -+ grub_size_t __size = (size); \ -+ char *__a = (a), *__b = (b); \ -+ do \ -+ { \ -+ char __tmp = *__a; \ -+ *__a++ = *__b; \ -+ *__b++ = __tmp; \ -+ } while (--__size > 0); \ -+ } while (0) -+ -+/* Discontinue quicksort algorithm when partition gets below this size. -+ This particular magic number was chosen to work best on a Sun 4/260. */ -+#define MAX_THRESH 4 -+ -+/* Stack node declarations used to store unfulfilled partition obligations. */ -+typedef struct -+ { -+ char *lo; -+ char *hi; -+ } stack_node; -+ -+/* The next 4 #defines implement a very fast in-line stack abstraction. */ -+/* The stack needs log (total_elements) entries (we could even subtract -+ log(MAX_THRESH)). Since total_elements has type grub_size_t, we get as -+ upper bound for log (total_elements): -+ bits per byte (CHAR_BIT) * sizeof(grub_size_t). */ -+#define STACK_SIZE (CHAR_BIT * sizeof(grub_size_t)) -+#define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) -+#define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) -+#define STACK_NOT_EMPTY (stack < top) -+ -+ -+/* Order size using quicksort. This implementation incorporates -+ four optimizations discussed in Sedgewick: -+ -+ 1. Non-recursive, using an explicit stack of pointer that store the -+ next array partition to sort. To save time, this maximum amount -+ of space required to store an array of SIZE_MAX is allocated on the -+ stack. Assuming a 32-bit (64 bit) integer for grub_size_t, this needs -+ only 32 * sizeof(stack_node) == 256 bytes (for 64 bit: 1024 bytes). -+ Pretty cheap, actually. -+ -+ 2. Chose the pivot element using a median-of-three decision tree. -+ This reduces the probability of selecting a bad pivot value and -+ eliminates certain extraneous comparisons. -+ -+ 3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving -+ insertion sort to order the MAX_THRESH items within each partition. -+ This is a big win, since insertion sort is faster for small, mostly -+ sorted array segments. -+ -+ 4. The larger of the two sub-partitions is always pushed onto the -+ stack first, with the algorithm then concentrating on the -+ smaller partition. This *guarantees* no more than log (total_elems) -+ stack size is needed (actually O(1) in this case)! */ -+ -+void -+grub_qsort (void *const pbase, grub_size_t total_elems, grub_size_t size, -+ grub_compar_d_fn_t cmp, void *arg) -+{ -+ char *base_ptr = (char *) pbase; -+ -+ const grub_size_t max_thresh = MAX_THRESH * size; -+ -+ if (total_elems == 0) -+ /* Avoid lossage with unsigned arithmetic below. */ -+ return; -+ -+ if (total_elems > MAX_THRESH) -+ { -+ char *lo = base_ptr; -+ char *hi = &lo[size * (total_elems - 1)]; -+ stack_node stack[STACK_SIZE]; -+ stack_node *top = stack; -+ -+ PUSH (NULL, NULL); -+ -+ while (STACK_NOT_EMPTY) -+ { -+ char *left_ptr; -+ char *right_ptr; -+ -+ /* Select median value from among LO, MID, and HI. Rearrange -+ LO and HI so the three values are sorted. This lowers the -+ probability of picking a pathological pivot value and -+ skips a comparison for both the LEFT_PTR and RIGHT_PTR in -+ the while loops. */ -+ -+ char *mid = lo + size * ((hi - lo) / size >> 1); -+ -+ if ((*cmp) ((void *) mid, (void *) lo, arg) < 0) -+ SWAP (mid, lo, size); -+ if ((*cmp) ((void *) hi, (void *) mid, arg) < 0) -+ SWAP (mid, hi, size); -+ else -+ goto jump_over; -+ if ((*cmp) ((void *) mid, (void *) lo, arg) < 0) -+ SWAP (mid, lo, size); -+ jump_over:; -+ -+ left_ptr = lo + size; -+ right_ptr = hi - size; -+ -+ /* Here's the famous ``collapse the walls'' section of quicksort. -+ Gotta like those tight inner loops! They are the main reason -+ that this algorithm runs much faster than others. */ -+ do -+ { -+ while ((*cmp) ((void *) left_ptr, (void *) mid, arg) < 0) -+ left_ptr += size; -+ -+ while ((*cmp) ((void *) mid, (void *) right_ptr, arg) < 0) -+ right_ptr -= size; -+ -+ if (left_ptr < right_ptr) -+ { -+ SWAP (left_ptr, right_ptr, size); -+ if (mid == left_ptr) -+ mid = right_ptr; -+ else if (mid == right_ptr) -+ mid = left_ptr; -+ left_ptr += size; -+ right_ptr -= size; -+ } -+ else if (left_ptr == right_ptr) -+ { -+ left_ptr += size; -+ right_ptr -= size; -+ break; -+ } -+ } -+ while (left_ptr <= right_ptr); -+ -+ /* Set up pointers for next iteration. First determine whether -+ left and right partitions are below the threshold size. If so, -+ ignore one or both. Otherwise, push the larger partition's -+ bounds on the stack and continue sorting the smaller one. */ -+ -+ if ((grub_size_t) (right_ptr - lo) <= max_thresh) -+ { -+ if ((grub_size_t) (hi - left_ptr) <= max_thresh) -+ /* Ignore both small partitions. */ -+ POP (lo, hi); -+ else -+ /* Ignore small left partition. */ -+ lo = left_ptr; -+ } -+ else if ((grub_size_t) (hi - left_ptr) <= max_thresh) -+ /* Ignore small right partition. */ -+ hi = right_ptr; -+ else if ((right_ptr - lo) > (hi - left_ptr)) -+ { -+ /* Push larger left partition indices. */ -+ PUSH (lo, right_ptr); -+ lo = left_ptr; -+ } -+ else -+ { -+ /* Push larger right partition indices. */ -+ PUSH (left_ptr, hi); -+ hi = right_ptr; -+ } -+ } -+ } -+ -+ /* Once the BASE_PTR array is partially sorted by quicksort the rest -+ is completely sorted using insertion sort, since this is efficient -+ for partitions below MAX_THRESH size. BASE_PTR points to the beginning -+ of the array to sort, and END_PTR points at the very last element in -+ the array (*not* one beyond it!). */ -+ -+#define min(x, y) ((x) < (y) ? (x) : (y)) -+ -+ { -+ char *const end_ptr = &base_ptr[size * (total_elems - 1)]; -+ char *tmp_ptr = base_ptr; -+ char *thresh = min(end_ptr, base_ptr + max_thresh); -+ char *run_ptr; -+ -+ /* Find smallest element in first threshold and place it at the -+ array's beginning. This is the smallest array element, -+ and the operation speeds up insertion sort's inner loop. */ -+ -+ for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) -+ if ((*cmp) ((void *) run_ptr, (void *) tmp_ptr, arg) < 0) -+ tmp_ptr = run_ptr; -+ -+ if (tmp_ptr != base_ptr) -+ SWAP (tmp_ptr, base_ptr, size); -+ -+ /* Insertion sort, running from left-hand-side up to right-hand-side. */ -+ -+ run_ptr = base_ptr + size; -+ while ((run_ptr += size) <= end_ptr) -+ { -+ tmp_ptr = run_ptr - size; -+ while ((*cmp) ((void *) run_ptr, (void *) tmp_ptr, arg) < 0) -+ tmp_ptr -= size; -+ -+ tmp_ptr += size; -+ if (tmp_ptr != run_ptr) -+ { -+ char *trav; -+ -+ trav = run_ptr + size; -+ while (--trav >= run_ptr) -+ { -+ char c = *trav; -+ char *hi, *lo; -+ -+ for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) -+ *hi = *lo; -+ *hi = c; -+ } -+ } -+ } -+ } -+} -+ -+void * -+grub_bsearch (const void *key, const void *base, grub_size_t nmemb, grub_size_t size, -+ grub_compar_d_fn_t compar, void *state) -+{ -+ grub_size_t l, u, idx; -+ const void *p; -+ int comparison; -+ -+ l = 0; -+ u = nmemb; -+ while (l < u) -+ { -+ idx = (l + u) / 2; -+ p = (void *) (((const char *) base) + (idx * size)); -+ comparison = (*compar) (key, p, state); -+ if (comparison < 0) -+ u = idx; -+ else if (comparison > 0) -+ l = idx + 1; -+ else -+ return (void *) p; -+ } -+ -+ return NULL; -+} -diff --git a/include/grub/misc.h b/include/grub/misc.h -index fcaf1201e39..cbfae75a1b4 100644 ---- a/include/grub/misc.h -+++ b/include/grub/misc.h -@@ -507,4 +507,19 @@ void EXPORT_FUNC(grub_real_boot_time) (const char *file, - #define grub_max(a, b) (((a) > (b)) ? (a) : (b)) - #define grub_min(a, b) (((a) < (b)) ? (a) : (b)) - -+typedef int (*grub_compar_d_fn_t) (const void *p0, const void *p1, void *state); -+ -+void *EXPORT_FUNC(grub_bsearch) (const void *key, -+ const void *base, -+ grub_size_t nmemb, -+ grub_size_t size, -+ grub_compar_d_fn_t compar, -+ void *state); -+ -+void EXPORT_FUNC(grub_qsort) (void *const pbase, -+ grub_size_t total_elems, -+ grub_size_t size, -+ grub_compar_d_fn_t cmp, -+ void *state); -+ - #endif /* ! GRUB_MISC_HEADER */ diff --git a/0171-bootp-New-net_bootp6-command.patch b/0112-bootp-New-net_bootp6-command.patch similarity index 82% rename from 0171-bootp-New-net_bootp6-command.patch rename to 0112-bootp-New-net_bootp6-command.patch index 684f540f02f0ea89e4de63f8ac5f245a1550ffab..1f8d22939f907ef480c967ec5b49422c3dd4065c 100644 --- a/0171-bootp-New-net_bootp6-command.patch +++ b/0112-bootp-New-net_bootp6-command.patch @@ -1,23 +1,25 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From c8eb4df74d416a4d94c364f2d361c7cc3f9b2cac Mon Sep 17 00:00:00 2001 From: Michael Chang -Date: Sun, 10 Jul 2016 23:46:06 +0800 -Subject: [PATCH] bootp: New net_bootp6 command +Date: Wed, 10 Jul 2019 15:42:36 +0200 +Subject: [PATCH 112/220] bootp: New net_bootp6 command Implement new net_bootp6 command for IPv6 network auto configuration via the DHCPv6 protocol (RFC3315). Signed-off-by: Michael Chang Signed-off-by: Ken Lin +[pjones: Put back our code to add a local route] +Signed-off-by: Peter Jones --- - grub-core/net/bootp.c | 1048 ++++++++++++++++++++++++++++++------ + grub-core/net/bootp.c | 1059 ++++++++++++++++++++++++++++++------ grub-core/net/drivers/efi/efinet.c | 20 +- grub-core/net/ip.c | 39 ++ include/grub/efi/api.h | 2 +- include/grub/net.h | 91 ++-- - 5 files changed, 994 insertions(+), 206 deletions(-) + 5 files changed, 1002 insertions(+), 209 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 4e55adc557b..ff1d7776e7f 100644 +index 3cf6dbf..85adc9c 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -25,6 +25,98 @@ @@ -117,26 +119,12 @@ index 4e55adc557b..ff1d7776e7f 100644 + return 1; +} - static char * - grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)), -@@ -345,178 +437,578 @@ grub_net_configure_by_dhcp_ack (const char *name, - return inter; + struct grub_dhcp_discover_options + { +@@ -638,6 +730,584 @@ out: + return err; } --struct grub_net_network_level_interface * --grub_net_configure_by_dhcpv6_ack (const char *name, -- struct grub_net_card *card, -- grub_net_interface_flags_t flags -- __attribute__((__unused__)), -- const grub_net_link_level_address_t *hwaddr, -- const struct grub_net_dhcpv6_packet *packet, -- int is_def, char **device, char **path) --{ -- struct grub_net_network_level_interface *inter = NULL; -- struct grub_net_network_level_address addr; -- int mask = -1; -- -- if (!device || !path) +/* The default netbuff size for sending DHCPv6 packets which should be + large enough to hold the information */ +#define GRUB_DHCP6_DEFAULT_NETBUFF_ALLOC_SIZE 512 @@ -354,19 +342,8 @@ index 4e55adc557b..ff1d7776e7f 100644 + + options = grub_zalloc (sizeof(*options)); + if (!options) - return NULL; - -- *device = 0; -- *path = 0; -- -- grub_dprintf ("net", "mac address is %02x:%02x:%02x:%02x:%02x:%02x\n", -- hwaddr->mac[0], hwaddr->mac[1], hwaddr->mac[2], -- hwaddr->mac[3], hwaddr->mac[4], hwaddr->mac[5]); -- -- if (is_def) -- grub_net_default_server = 0; -- -- if (is_def && !grub_net_default_server && packet) ++ return NULL; ++ + foreach_dhcp6_option ((const struct grub_net_dhcp6_option *)v6h->dhcp_options, + size - sizeof (*v6h), parse_dhcp6_option, options); + @@ -410,165 +387,37 @@ index 4e55adc557b..ff1d7776e7f 100644 + struct grub_net_network_level_interface *inf; + + if (dhcp6->ia_addr) - { -- const grub_uint8_t *options = packet->dhcp_options; -- unsigned int option_max = 1024 - OFFSET_OF (dhcp_options, packet); -- unsigned int i; -- -- for (i = 0; i < option_max - sizeof (grub_net_dhcpv6_option_t); ) -- { -- grub_uint16_t num, len; -- grub_net_dhcpv6_option_t *opt = -- (grub_net_dhcpv6_option_t *)(options + i); -- -- num = grub_be_to_cpu16(opt->option_num); -- len = grub_be_to_cpu16(opt->option_len); -- -- grub_dprintf ("net", "got dhcpv6 option %d len %d\n", num, len); -- -- if (len == 0) -- break; -- -- if (len + i > 1024) -- break; -- -- if (num == GRUB_NET_DHCP6_BOOTFILE_URL) -- { -- char *scheme, *userinfo, *host, *file; -- char *tmp; -- int hostlen; -- int port; -- int rc = extract_url_info ((const char *)opt->option_data, -- (grub_size_t)len, -- &scheme, &userinfo, &host, &port, -- &file); -- if (rc < 0) -- continue; -- -- /* right now this only handles tftp. */ -- if (grub_strcmp("tftp", scheme)) -- { -- grub_free (scheme); -- grub_free (userinfo); -- grub_free (host); -- grub_free (file); -- continue; -- } -- grub_free (userinfo); -- -- hostlen = grub_strlen (host); -- if (hostlen > 2 && host[0] == '[' && host[hostlen-1] == ']') -- { -- tmp = host+1; -- host[hostlen-1] = '\0'; -- } -- else -- tmp = host; ++ { + inf = grub_net_add_addr (name, card, dhcp6->ia_addr, &card->default_address, flags); - -- *device = grub_xasprintf ("%s,%s", scheme, tmp); -- grub_free (scheme); -- grub_free (host); ++ + netaddr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; + netaddr.ipv6.base[0] = dhcp6->ia_addr->ipv6[0]; + netaddr.ipv6.base[1] = 0; + netaddr.ipv6.masksize = 64; + grub_net_add_route (name, netaddr, inf); - -- if (file && *file) -- { -- tmp = grub_strrchr (file, '/'); -- if (tmp) -- *(tmp+1) = '\0'; -- else -- file[0] = '\0'; -- } -- else if (!file) -- file = grub_strdup (""); -- -- if (file[0] == '/') -- { -- *path = grub_strdup (file+1); -- grub_free (file); -- } -- else -- *path = file; -- } -- else if (num == GRUB_NET_DHCP6_IA_NA) -- { -- const grub_net_dhcpv6_option_t *ia_na_opt; -- const grub_net_dhcpv6_opt_ia_na_t *ia_na = -- (const grub_net_dhcpv6_opt_ia_na_t *)opt; -- unsigned int left = len - OFFSET_OF (options, ia_na); -- unsigned int j; -- -- if ((grub_uint8_t *)ia_na + left > -- (grub_uint8_t *)options + option_max) -- left -= ((grub_uint8_t *)ia_na + left) -- - ((grub_uint8_t *)options + option_max); -- -- if (len < OFFSET_OF (option_data, opt) -- + sizeof (grub_net_dhcpv6_option_t)) -- { -- grub_dprintf ("net", -- "found dhcpv6 ia_na option with no address\n"); -- continue; -- } -- -- for (j = 0; left > sizeof (grub_net_dhcpv6_option_t); ) -- { -- ia_na_opt = (const grub_net_dhcpv6_option_t *) -- (ia_na->options + j); -- grub_uint16_t ia_na_opt_num, ia_na_opt_len; -- -- ia_na_opt_num = grub_be_to_cpu16 (ia_na_opt->option_num); -- ia_na_opt_len = grub_be_to_cpu16 (ia_na_opt->option_len); -- if (ia_na_opt_len == 0) -- break; -- if (j + ia_na_opt_len > left) -- break; -- if (ia_na_opt_num == GRUB_NET_DHCP6_IA_ADDRESS) -- { -- const grub_net_dhcpv6_opt_ia_address_t *ia_addr; -- -- ia_addr = (const grub_net_dhcpv6_opt_ia_address_t *) -- ia_na_opt; -- addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; -- grub_memcpy(addr.ipv6, ia_addr->ipv6_address, -- sizeof (ia_addr->ipv6_address)); -- inter = grub_net_add_addr (name, card, &addr, hwaddr, 0); -- } -- -- j += ia_na_opt_len; -- left -= ia_na_opt_len; -- } -- } ++ + if (ret_inf) + *ret_inf = inf; + } - -- i += len + 4; -- } ++ + if (dhcp6->dns_server_addrs) + { + grub_uint16_t i; - -- grub_print_error (); ++ + for (i = 0; i < dhcp6->num_dns_server; ++i) + grub_net_add_dns_server (dhcp6->dns_server_addrs + i); - } - -- if (is_def) ++ } ++ + if (dhcp6->boot_file_path) + grub_env_set_net_property (name, "boot_file", dhcp6->boot_file_path, + grub_strlen (dhcp6->boot_file_path)); + + if (is_def && dhcp6->boot_file_server_ip) - { ++ { + grub_net_default_server = grub_strdup (dhcp6->boot_file_server_ip); - grub_env_set ("net_default_interface", name); - grub_env_export ("net_default_interface"); - } ++ grub_env_set ("net_default_interface", name); ++ grub_env_export ("net_default_interface"); ++ } +} + +static void @@ -628,10 +477,7 @@ index 4e55adc557b..ff1d7776e7f 100644 +grub_dhcp6_session_configure_network (grub_dhcp6_session_t se) +{ + char *name; - -- if (inter) -- grub_net_add_ipv6_local (inter, mask); -- return inter; ++ + name = grub_xasprintf ("%s:dhcp6", se->iface->card->name); + if (!name) + return grub_errno; @@ -640,8 +486,8 @@ index 4e55adc557b..ff1d7776e7f 100644 + grub_free (name); + + return GRUB_ERR_NONE; - } - ++} ++ +static grub_err_t +grub_dhcp6_session_send_request (grub_dhcp6_session_t se) +{ @@ -818,6 +664,7 @@ index 4e55adc557b..ff1d7776e7f 100644 +{ + struct grub_net_network_level_interface *inf; + grub_dhcp6_options_t dhcp6; ++ int mask = -1; + + dhcp6 = grub_dhcp6_options_get (v6h, size); + if (!dhcp6) @@ -849,18 +696,23 @@ index 4e55adc557b..ff1d7776e7f 100644 + } + + grub_dhcp6_options_free (dhcp6); ++ ++ if (inf) ++ grub_net_add_ipv6_local (inf, mask); ++ + return inf; +} - - void - grub_net_process_dhcp (struct grub_net_buff *nb, -@@ -550,6 +1042,77 @@ grub_net_process_dhcp (struct grub_net_buff *nb, ++ + /* + * This is called directly from net/ip.c:handle_dgram(), because those + * BOOTP/DHCP packets are a bit special due to their improper +@@ -706,6 +1376,77 @@ grub_net_process_dhcp (struct grub_net_buff *nb, } } +grub_err_t +grub_net_process_dhcp6 (struct grub_net_buff *nb, -+ struct grub_net_card *card __attribute__ ((unused))) ++ struct grub_net_card *card __attribute__ ((unused))) +{ + const struct grub_net_dhcp6_packet *v6h; + grub_dhcp6_session_t se; @@ -883,9 +735,9 @@ index 4e55adc557b..ff1d7776e7f 100644 + FOR_DHCP6_SESSIONS (se) + { + if (se->transaction_id == v6h->transaction_id && -+ grub_memcmp (options->client_duid, &se->duid, sizeof (se->duid)) == 0 && -+ se->iaid == options->iaid) -+ break; ++ grub_memcmp (options->client_duid, &se->duid, sizeof (se->duid)) == 0 && ++ se->iaid == options->iaid) ++ break; + } + + if (!se) @@ -898,11 +750,11 @@ index 4e55adc557b..ff1d7776e7f 100644 + if (v6h->message_type == GRUB_NET_DHCP6_ADVERTISE) + { + if (se->adv) -+ { -+ grub_dprintf ("bootp", "Skipped DHCPv6 Advertised .. \n"); -+ grub_dhcp6_options_free (options); -+ return GRUB_ERR_NONE; -+ } ++ { ++ grub_dprintf ("bootp", "Skipped DHCPv6 Advertised .. \n"); ++ grub_dhcp6_options_free (options); ++ return GRUB_ERR_NONE; ++ } + + se->adv = options; + return grub_dhcp6_session_send_request (se); @@ -910,11 +762,11 @@ index 4e55adc557b..ff1d7776e7f 100644 + else if (v6h->message_type == GRUB_NET_DHCP6_REPLY) + { + if (!se->adv) -+ { -+ grub_dprintf ("bootp", "Skipped DHCPv6 Reply .. \n"); -+ grub_dhcp6_options_free (options); -+ return GRUB_ERR_NONE; -+ } ++ { ++ grub_dprintf ("bootp", "Skipped DHCPv6 Reply .. \n"); ++ grub_dhcp6_options_free (options); ++ return GRUB_ERR_NONE; ++ } + + se->reply = options; + grub_dhcp6_session_configure_network (se); @@ -932,183 +784,342 @@ index 4e55adc557b..ff1d7776e7f 100644 static grub_err_t grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), int argc, char **args) -@@ -824,7 +1387,174 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), +@@ -931,180 +1672,174 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), return err; } --static grub_command_t cmd_getdhcp, cmd_bootp; +-static grub_command_t cmd_getdhcp, cmd_bootp, cmd_dhcp; +- +-struct grub_net_network_level_interface * +-grub_net_configure_by_dhcpv6_ack (const char *name, +- struct grub_net_card *card, +- grub_net_interface_flags_t flags +- __attribute__((__unused__)), +- const grub_net_link_level_address_t *hwaddr, +- const struct grub_net_dhcpv6_packet *packet, +- int is_def, char **device, char **path) +static grub_err_t +grub_cmd_bootp6 (struct grub_command *cmd __attribute__ ((unused)), -+ int argc, char **args) -+{ ++ int argc, char **args) + { +- struct grub_net_network_level_interface *inter = NULL; +- struct grub_net_network_level_address addr; +- int mask = -1; +- +- if (!device || !path) +- return NULL; +- +- *device = 0; +- *path = 0; +- +- grub_dprintf ("net", "mac address is %02x:%02x:%02x:%02x:%02x:%02x\n", +- hwaddr->mac[0], hwaddr->mac[1], hwaddr->mac[2], +- hwaddr->mac[3], hwaddr->mac[4], hwaddr->mac[5]); +- +- if (is_def) +- grub_net_default_server = 0; +- +- if (is_def && !grub_net_default_server && packet) +- { +- const grub_uint8_t *options = packet->dhcp_options; +- unsigned int option_max = 1024 - OFFSET_OF (dhcp_options, packet); +- unsigned int i; +- +- for (i = 0; i < option_max - sizeof (grub_net_dhcpv6_option_t); ) +- { +- grub_uint16_t num, len; +- grub_net_dhcpv6_option_t *opt = +- (grub_net_dhcpv6_option_t *)(options + i); +- +- num = grub_be_to_cpu16(opt->option_num); +- len = grub_be_to_cpu16(opt->option_len); + struct grub_net_card *card; + grub_uint32_t iaid = 0; + int interval; + grub_err_t err; + grub_dhcp6_session_t se; -+ + +- grub_dprintf ("net", "got dhcpv6 option %d len %d\n", num, len); + err = GRUB_ERR_NONE; -+ + +- if (len == 0) +- break; + FOR_NET_CARDS (card) + { + struct grub_net_network_level_interface *iface; -+ + +- if (len + i > 1024) +- break; + if (argc > 0 && grub_strcmp (card->name, args[0]) != 0) + continue; -+ + +- if (num == GRUB_NET_DHCP6_BOOTFILE_URL) +- { +- char *scheme, *userinfo, *host, *file; +- char *tmp; +- int hostlen; +- int port; +- int rc = extract_url_info ((const char *)opt->option_data, +- (grub_size_t)len, +- &scheme, &userinfo, &host, &port, +- &file); +- if (rc < 0) +- continue; +- +- /* right now this only handles tftp. */ +- if (grub_strcmp("tftp", scheme)) +- { +- grub_free (scheme); +- grub_free (userinfo); +- grub_free (host); +- grub_free (file); +- continue; +- } +- grub_free (userinfo); +- +- hostlen = grub_strlen (host); +- if (hostlen > 2 && host[0] == '[' && host[hostlen-1] == ']') +- { +- tmp = host+1; +- host[hostlen-1] = '\0'; +- } +- else +- tmp = host; +- +- *device = grub_xasprintf ("%s,%s", scheme, tmp); +- grub_free (scheme); +- grub_free (host); +- +- if (file && *file) +- { +- tmp = grub_strrchr (file, '/'); +- if (tmp) +- *(tmp+1) = '\0'; +- else +- file[0] = '\0'; +- } +- else if (!file) +- file = grub_strdup (""); +- +- if (file[0] == '/') +- { +- *path = grub_strdup (file+1); +- grub_free (file); +- } +- else +- *path = file; +- } +- else if (num == GRUB_NET_DHCP6_IA_NA) +- { +- const grub_net_dhcpv6_option_t *ia_na_opt; +- const grub_net_dhcpv6_opt_ia_na_t *ia_na = +- (const grub_net_dhcpv6_opt_ia_na_t *)opt; +- unsigned int left = len - OFFSET_OF (options, ia_na); +- unsigned int j; +- +- if ((grub_uint8_t *)ia_na + left > +- (grub_uint8_t *)options + option_max) +- left -= ((grub_uint8_t *)ia_na + left) +- - ((grub_uint8_t *)options + option_max); +- +- if (len < OFFSET_OF (option_data, opt) +- + sizeof (grub_net_dhcpv6_option_t)) +- { +- grub_dprintf ("net", +- "found dhcpv6 ia_na option with no address\n"); +- continue; +- } +- +- for (j = 0; left > sizeof (grub_net_dhcpv6_option_t); ) +- { +- ia_na_opt = (const grub_net_dhcpv6_option_t *) +- (ia_na->options + j); +- grub_uint16_t ia_na_opt_num, ia_na_opt_len; +- +- ia_na_opt_num = grub_be_to_cpu16 (ia_na_opt->option_num); +- ia_na_opt_len = grub_be_to_cpu16 (ia_na_opt->option_len); +- if (ia_na_opt_len == 0) +- break; +- if (j + ia_na_opt_len > left) +- break; +- if (ia_na_opt_num == GRUB_NET_DHCP6_IA_ADDRESS) +- { +- const grub_net_dhcpv6_opt_ia_address_t *ia_addr; +- +- ia_addr = (const grub_net_dhcpv6_opt_ia_address_t *) +- ia_na_opt; +- addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; +- grub_memcpy(addr.ipv6, ia_addr->ipv6_address, +- sizeof (ia_addr->ipv6_address)); +- inter = grub_net_add_addr (name, card, &addr, hwaddr, 0); +- } +- +- j += ia_na_opt_len; +- left -= ia_na_opt_len; +- } +- } + iface = grub_net_ipv6_get_link_local (card, &card->default_address); + if (!iface) + { -+ grub_dhcp6_session_remove_all (); -+ return grub_errno; ++ grub_dhcp6_session_remove_all (); ++ return grub_errno; + } -+ + +- i += len + 4; +- } + grub_dhcp6_session_add (iface, iaid++); + } -+ + +- grub_print_error (); + for (interval = 200; interval < 10000; interval *= 2) + { + int done = 1; + + FOR_DHCP6_SESSIONS (se) -+ { -+ struct grub_net_buff *nb; -+ struct grub_net_dhcp6_option *opt; -+ struct grub_net_dhcp6_packet *v6h; -+ struct grub_net_dhcp6_option_duid_ll *duid; -+ struct grub_net_dhcp6_option_iana *ia_na; -+ grub_net_network_level_address_t multicast; -+ grub_net_link_level_address_t ll_multicast; -+ struct udphdr *udph; -+ -+ multicast.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; -+ multicast.ipv6[0] = grub_cpu_to_be64_compile_time (0xff02ULL << 48); -+ multicast.ipv6[1] = grub_cpu_to_be64_compile_time (0x10002ULL); -+ -+ err = grub_net_link_layer_resolve (se->iface, -+ &multicast, &ll_multicast); -+ if (err) -+ { -+ grub_dhcp6_session_remove_all (); -+ return err; -+ } -+ -+ nb = grub_netbuff_alloc (GRUB_DHCP6_DEFAULT_NETBUFF_ALLOC_SIZE); -+ -+ if (!nb) -+ { -+ grub_dhcp6_session_remove_all (); -+ return grub_errno; -+ } -+ -+ err = grub_netbuff_reserve (nb, GRUB_DHCP6_DEFAULT_NETBUFF_ALLOC_SIZE); -+ if (err) -+ { -+ grub_dhcp6_session_remove_all (); -+ grub_netbuff_free (nb); -+ return err; -+ } -+ -+ err = grub_netbuff_push (nb, sizeof (*opt) + sizeof (grub_uint16_t)); -+ if (err) -+ { -+ grub_dhcp6_session_remove_all (); -+ grub_netbuff_free (nb); -+ return err; -+ } -+ -+ opt = (struct grub_net_dhcp6_option *)nb->data; -+ opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_ELAPSED_TIME); -+ opt->len = grub_cpu_to_be16_compile_time (sizeof (grub_uint16_t)); -+ grub_set_unaligned16 (opt->data, 0); -+ -+ err = grub_netbuff_push (nb, sizeof (*opt) + sizeof (*duid)); -+ if (err) -+ { -+ grub_dhcp6_session_remove_all (); -+ grub_netbuff_free (nb); -+ return err; -+ } -+ -+ opt = (struct grub_net_dhcp6_option *)nb->data; -+ opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_CLIENTID); -+ opt->len = grub_cpu_to_be16 (sizeof (*duid)); -+ -+ duid = (struct grub_net_dhcp6_option_duid_ll *) opt->data; -+ grub_memcpy (duid, &se->duid, sizeof (*duid)); -+ -+ err = grub_netbuff_push (nb, sizeof (*opt) + sizeof (*ia_na)); -+ if (err) -+ { -+ grub_dhcp6_session_remove_all (); -+ grub_netbuff_free (nb); -+ return err; -+ } -+ -+ opt = (struct grub_net_dhcp6_option *)nb->data; -+ opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_IA_NA); -+ opt->len = grub_cpu_to_be16 (sizeof (*ia_na)); -+ ia_na = (struct grub_net_dhcp6_option_iana *)opt->data; -+ ia_na->iaid = grub_cpu_to_be32 (se->iaid); -+ ia_na->t1 = 0; -+ ia_na->t2 = 0; -+ -+ err = grub_netbuff_push (nb, sizeof (*v6h)); -+ if (err) -+ { -+ grub_dhcp6_session_remove_all (); -+ grub_netbuff_free (nb); -+ return err; -+ } -+ -+ v6h = (struct grub_net_dhcp6_packet *)nb->data; -+ v6h->message_type = GRUB_NET_DHCP6_SOLICIT; -+ v6h->transaction_id = se->transaction_id; -+ -+ grub_netbuff_push (nb, sizeof (*udph)); -+ -+ udph = (struct udphdr *) nb->data; -+ udph->src = grub_cpu_to_be16_compile_time (DHCP6_CLIENT_PORT); -+ udph->dst = grub_cpu_to_be16_compile_time (DHCP6_SERVER_PORT); -+ udph->chksum = 0; -+ udph->len = grub_cpu_to_be16 (nb->tail - nb->data); -+ -+ udph->chksum = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_UDP, -+ &se->iface->address, &multicast); -+ -+ err = grub_net_send_ip_packet (se->iface, &multicast, -+ &ll_multicast, nb, GRUB_NET_IP_UDP); -+ done = 0; -+ grub_netbuff_free (nb); -+ -+ if (err) -+ { -+ grub_dhcp6_session_remove_all (); -+ return err; -+ } -+ } ++ { ++ struct grub_net_buff *nb; ++ struct grub_net_dhcp6_option *opt; ++ struct grub_net_dhcp6_packet *v6h; ++ struct grub_net_dhcp6_option_duid_ll *duid; ++ struct grub_net_dhcp6_option_iana *ia_na; ++ grub_net_network_level_address_t multicast; ++ grub_net_link_level_address_t ll_multicast; ++ struct udphdr *udph; ++ ++ multicast.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; ++ multicast.ipv6[0] = grub_cpu_to_be64_compile_time (0xff02ULL << 48); ++ multicast.ipv6[1] = grub_cpu_to_be64_compile_time (0x10002ULL); ++ ++ err = grub_net_link_layer_resolve (se->iface, ++ &multicast, &ll_multicast); ++ if (err) ++ { ++ grub_dhcp6_session_remove_all (); ++ return err; ++ } ++ ++ nb = grub_netbuff_alloc (GRUB_DHCP6_DEFAULT_NETBUFF_ALLOC_SIZE); ++ ++ if (!nb) ++ { ++ grub_dhcp6_session_remove_all (); ++ return grub_errno; ++ } ++ ++ err = grub_netbuff_reserve (nb, GRUB_DHCP6_DEFAULT_NETBUFF_ALLOC_SIZE); ++ if (err) ++ { ++ grub_dhcp6_session_remove_all (); ++ grub_netbuff_free (nb); ++ return err; ++ } ++ ++ err = grub_netbuff_push (nb, sizeof (*opt) + sizeof (grub_uint16_t)); ++ if (err) ++ { ++ grub_dhcp6_session_remove_all (); ++ grub_netbuff_free (nb); ++ return err; ++ } ++ ++ opt = (struct grub_net_dhcp6_option *)nb->data; ++ opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_ELAPSED_TIME); ++ opt->len = grub_cpu_to_be16_compile_time (sizeof (grub_uint16_t)); ++ grub_set_unaligned16 (opt->data, 0); ++ ++ err = grub_netbuff_push (nb, sizeof (*opt) + sizeof (*duid)); ++ if (err) ++ { ++ grub_dhcp6_session_remove_all (); ++ grub_netbuff_free (nb); ++ return err; ++ } ++ ++ opt = (struct grub_net_dhcp6_option *)nb->data; ++ opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_CLIENTID); ++ opt->len = grub_cpu_to_be16 (sizeof (*duid)); ++ ++ duid = (struct grub_net_dhcp6_option_duid_ll *) opt->data; ++ grub_memcpy (duid, &se->duid, sizeof (*duid)); ++ ++ err = grub_netbuff_push (nb, sizeof (*opt) + sizeof (*ia_na)); ++ if (err) ++ { ++ grub_dhcp6_session_remove_all (); ++ grub_netbuff_free (nb); ++ return err; ++ } ++ ++ opt = (struct grub_net_dhcp6_option *)nb->data; ++ opt->code = grub_cpu_to_be16_compile_time (GRUB_NET_DHCP6_OPTION_IA_NA); ++ opt->len = grub_cpu_to_be16 (sizeof (*ia_na)); ++ ia_na = (struct grub_net_dhcp6_option_iana *)opt->data; ++ ia_na->iaid = grub_cpu_to_be32 (se->iaid); ++ ia_na->t1 = 0; ++ ia_na->t2 = 0; ++ ++ err = grub_netbuff_push (nb, sizeof (*v6h)); ++ if (err) ++ { ++ grub_dhcp6_session_remove_all (); ++ grub_netbuff_free (nb); ++ return err; ++ } ++ ++ v6h = (struct grub_net_dhcp6_packet *)nb->data; ++ v6h->message_type = GRUB_NET_DHCP6_SOLICIT; ++ v6h->transaction_id = se->transaction_id; ++ ++ grub_netbuff_push (nb, sizeof (*udph)); ++ ++ udph = (struct udphdr *) nb->data; ++ udph->src = grub_cpu_to_be16_compile_time (DHCP6_CLIENT_PORT); ++ udph->dst = grub_cpu_to_be16_compile_time (DHCP6_SERVER_PORT); ++ udph->chksum = 0; ++ udph->len = grub_cpu_to_be16 (nb->tail - nb->data); ++ ++ udph->chksum = grub_net_ip_transport_checksum (nb, GRUB_NET_IP_UDP, ++ &se->iface->address, &multicast); ++ ++ err = grub_net_send_ip_packet (se->iface, &multicast, ++ &ll_multicast, nb, GRUB_NET_IP_UDP); ++ done = 0; ++ grub_netbuff_free (nb); ++ ++ if (err) ++ { ++ grub_dhcp6_session_remove_all (); ++ return err; ++ } ++ } + if (!done) -+ grub_net_poll_cards (interval, 0); -+ } -+ ++ grub_net_poll_cards (interval, 0); + } + +- if (is_def) + FOR_DHCP6_SESSIONS (se) -+ { + { +- grub_env_set ("net_default_interface", name); +- grub_env_export ("net_default_interface"); + grub_error_push (); + err = grub_error (GRUB_ERR_FILE_NOT_FOUND, -+ N_("couldn't autoconfigure %s"), -+ se->iface->card->name); -+ } -+ ++ N_("couldn't autoconfigure %s"), ++ se->iface->card->name); + } + +- if (inter) +- grub_net_add_ipv6_local (inter, mask); +- return inter; + grub_dhcp6_session_remove_all (); + + return err; -+} -+ -+static grub_command_t cmd_getdhcp, cmd_bootp, cmd_bootp6; + } + ++static grub_command_t cmd_getdhcp, cmd_bootp, cmd_dhcp, cmd_bootp6; void grub_bootp_init (void) -@@ -835,6 +1565,9 @@ grub_bootp_init (void) +@@ -1118,11 +1853,15 @@ grub_bootp_init (void) cmd_getdhcp = grub_register_command ("net_get_dhcp_option", grub_cmd_dhcpopt, N_("VAR INTERFACE NUMBER DESCRIPTION"), N_("retrieve DHCP option and save it into VAR. If VAR is - then print the value.")); @@ -1118,17 +1129,17 @@ index 4e55adc557b..ff1d7776e7f 100644 } void -@@ -842,4 +1575,5 @@ grub_bootp_fini (void) + grub_bootp_fini (void) { ++ grub_unregister_command (cmd_bootp6); grub_unregister_command (cmd_getdhcp); grub_unregister_command (cmd_bootp); -+ grub_unregister_command (cmd_bootp6); - } + grub_unregister_command (cmd_dhcp); diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index bf36b446dc4..da90f0f40ce 100644 +index 4444e8e..00d7d37 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c -@@ -477,9 +477,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -394,9 +394,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, pxe_mode = pxe->mode; if (pxe_mode->using_ipv6) { @@ -1138,7 +1149,7 @@ index bf36b446dc4..da90f0f40ce 100644 grub_dprintf ("efinet", "using ipv6 and dhcpv6\n"); grub_dprintf ("efinet", "dhcp_ack_received: %s%s\n", pxe_mode->dhcp_ack_received ? "yes" : "no", -@@ -487,15 +484,14 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -404,15 +401,14 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, if (!pxe_mode->dhcp_ack_received) continue; @@ -1163,7 +1174,7 @@ index bf36b446dc4..da90f0f40ce 100644 } else diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c -index b2ca74b6eb1..9a4e589aa39 100644 +index a5896f6..ce6bdc7 100644 --- a/grub-core/net/ip.c +++ b/grub-core/net/ip.c @@ -239,6 +239,45 @@ handle_dgram (struct grub_net_buff *nb, @@ -1213,10 +1224,10 @@ index b2ca74b6eb1..9a4e589aa39 100644 { const struct grub_net_bootp_packet *bootp; diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index ddc5ecfb03d..6a545cc6d5d 100644 +index 955973e..71d972a 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -1511,7 +1511,7 @@ typedef struct grub_efi_pxe_ip_filter +@@ -1507,7 +1507,7 @@ typedef struct grub_efi_pxe_ip_filter { grub_efi_uint8_t filters; grub_efi_uint8_t ip_count; @@ -1226,10 +1237,10 @@ index ddc5ecfb03d..6a545cc6d5d 100644 } grub_efi_pxe_ip_filter_t; diff --git a/include/grub/net.h b/include/grub/net.h -index f4cd86e582f..5f78b22e109 100644 +index fa7a8c3..aedf4b5 100644 --- a/include/grub/net.h +++ b/include/grub/net.h -@@ -447,50 +447,65 @@ struct grub_net_bootp_packet +@@ -451,50 +451,65 @@ struct grub_net_bootp_packet grub_uint8_t vendor[0]; } GRUB_PACKED; @@ -1325,7 +1336,7 @@ index f4cd86e582f..5f78b22e109 100644 #define GRUB_NET_BOOTP_RFC1048_MAGIC_0 0x63 #define GRUB_NET_BOOTP_RFC1048_MAGIC_1 0x82 -@@ -521,12 +536,12 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -532,12 +547,12 @@ grub_net_configure_by_dhcp_ack (const char *name, int is_def, char **device, char **path); struct grub_net_network_level_interface * @@ -1344,9 +1355,9 @@ index f4cd86e582f..5f78b22e109 100644 int grub_ipv6_get_masksize(grub_uint16_t *mask); -@@ -543,6 +558,10 @@ void +@@ -554,6 +569,10 @@ void grub_net_process_dhcp (struct grub_net_buff *nb, - struct grub_net_card *card); + struct grub_net_network_level_interface *iface); +grub_err_t +grub_net_process_dhcp6 (struct grub_net_buff *nb, @@ -1355,3 +1366,6 @@ index f4cd86e582f..5f78b22e109 100644 int grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a, const grub_net_link_level_address_t *b); +-- +1.8.3.1 + diff --git a/0173-efinet-UEFI-IPv6-PXE-support.patch b/0113-efinet-UEFI-IPv6-PXE-support.patch similarity index 89% rename from 0173-efinet-UEFI-IPv6-PXE-support.patch rename to 0113-efinet-UEFI-IPv6-PXE-support.patch index 98995530b19b4abd982e6012af8d85f9cd576b41..daf647609cddf2cf0257e168c8fe936c1325edab 100644 --- a/0173-efinet-UEFI-IPv6-PXE-support.patch +++ b/0113-efinet-UEFI-IPv6-PXE-support.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 31d0e54b21a9dde2cfe4eefcab5371fc1454e373 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Wed, 15 Apr 2015 14:48:30 +0800 -Subject: [PATCH] efinet: UEFI IPv6 PXE support +Subject: [PATCH 113/220] efinet: UEFI IPv6 PXE support When grub2 image is booted from UEFI IPv6 PXE, the DHCPv6 Reply packet is cached in firmware buffer which can be obtained by PXE Base Code protocol. The @@ -15,10 +15,10 @@ Signed-off-by: Ken Lin 2 files changed, 46 insertions(+), 27 deletions(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index da90f0f40ce..ac58e3e82cf 100644 +index 00d7d37..c3db328 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c -@@ -493,6 +493,8 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -410,6 +410,8 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, grub_print_error (); if (device && path) grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path); @@ -28,10 +28,10 @@ index da90f0f40ce..ac58e3e82cf 100644 else { diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 6a545cc6d5d..7dbd8807b80 100644 +index 71d972a..186cf39 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -1503,31 +1503,6 @@ typedef union +@@ -1499,31 +1499,6 @@ typedef union grub_efi_pxe_dhcpv6_packet_t dhcpv6; } grub_efi_pxe_packet_t; @@ -63,7 +63,7 @@ index 6a545cc6d5d..7dbd8807b80 100644 typedef struct grub_efi_pxe_icmp_error { grub_efi_uint8_t type; -@@ -1553,6 +1528,48 @@ typedef struct grub_efi_pxe_tftp_error +@@ -1549,6 +1524,48 @@ typedef struct grub_efi_pxe_tftp_error grub_efi_char8_t error_string[127]; } grub_efi_pxe_tftp_error_t; @@ -112,7 +112,7 @@ index 6a545cc6d5d..7dbd8807b80 100644 typedef struct grub_efi_pxe_mode { grub_efi_boolean_t started; -@@ -1584,9 +1601,9 @@ typedef struct grub_efi_pxe_mode +@@ -1580,9 +1597,9 @@ typedef struct grub_efi_pxe_mode grub_efi_pxe_packet_t pxe_bis_reply; grub_efi_pxe_ip_filter_t ip_filter; grub_efi_uint32_t arp_cache_entries; @@ -124,3 +124,6 @@ index 6a545cc6d5d..7dbd8807b80 100644 grub_efi_pxe_icmp_error_t icmp_error; grub_efi_pxe_tftp_error_t tftp_error; } grub_efi_pxe_mode_t; +-- +1.8.3.1 + diff --git a/0114-Add-BLS-support-to-grub-mkconfig.patch b/0114-Add-BLS-support-to-grub-mkconfig.patch deleted file mode 100644 index 75698fdfa07aa742046230599464ad48a45adb10..0000000000000000000000000000000000000000 --- a/0114-Add-BLS-support-to-grub-mkconfig.patch +++ /dev/null @@ -1,167 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 9 Dec 2016 15:40:29 -0500 -Subject: [PATCH] Add BLS support to grub-mkconfig - -GRUB now has BootLoaderSpec support, the user can choose to use this by -setting GRUB_ENABLE_BLSCFG to true in /etc/default/grub. On this setup, -the boot menu entries are not added to the grub.cfg, instead BLS config -files are parsed by blscfg command and the entries created dynamically. ---- - util/grub-mkconfig.in | 3 ++- - util/grub-mkconfig_lib.in | 29 +++++++++++++++++++---------- - util/grub.d/10_linux.in | 37 +++++++++++++++++++++++++++++++++++-- - 3 files changed, 56 insertions(+), 13 deletions(-) - -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 4248b9341ab..c20171919d9 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -259,7 +259,8 @@ export GRUB_DEFAULT \ - GRUB_OS_PROBER_SKIP_LIST \ - GRUB_DISABLE_SUBMENU \ - GRUB_DEFAULT_DTB \ -- SUSE_BTRFS_SNAPSHOT_BOOTING -+ SUSE_BTRFS_SNAPSHOT_BOOTING \ -+ GRUB_ENABLE_BLSCFG - - if test "x${grub_cfg}" != "x"; then - rm -f "${grub_cfg}.new" -diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index b3aae534ddc..1acc1d01c39 100644 ---- a/util/grub-mkconfig_lib.in -+++ b/util/grub-mkconfig_lib.in -@@ -30,6 +30,9 @@ fi - if test "x$grub_file" = x; then - grub_file="${bindir}/@grub_file@" - fi -+if test "x$grub_editenv" = x; then -+ grub_editenv="${bindir}/@grub_editenv@" -+fi - if test "x$grub_mkrelpath" = x; then - grub_mkrelpath="${bindir}/@grub_mkrelpath@" - fi -@@ -127,10 +130,16 @@ EOF - - prepare_grub_to_access_device () - { -+ local device=$1 && shift -+ if [ "$#" -gt 0 ]; then -+ local variable=$1 && shift -+ else -+ local variable=root -+ fi - old_ifs="$IFS" - IFS=' - ' -- partmap="`"${grub_probe}" --device $@ --target=partmap`" -+ partmap="`"${grub_probe}" --device ${device} --target=partmap`" - for module in ${partmap} ; do - case "${module}" in - netbsd | openbsd) -@@ -141,34 +150,34 @@ prepare_grub_to_access_device () - done - - # Abstraction modules aren't auto-loaded. -- abstraction="`"${grub_probe}" --device $@ --target=abstraction`" -+ abstraction="`"${grub_probe}" --device ${device} --target=abstraction`" - for module in ${abstraction} ; do - echo "insmod ${module}" - done - -- fs="`"${grub_probe}" --device $@ --target=fs`" -+ fs="`"${grub_probe}" --device ${device} --target=fs`" - for module in ${fs} ; do - echo "insmod ${module}" - done - - if [ x$GRUB_ENABLE_CRYPTODISK = xy ]; then -- for uuid in `"${grub_probe}" --device $@ --target=cryptodisk_uuid`; do -+ for uuid in `"${grub_probe}" --device ${device} --target=cryptodisk_uuid`; do - echo "cryptomount -u $uuid" - done - fi - - # If there's a filesystem UUID that GRUB is capable of identifying, use it; - # otherwise set root as per value in device.map. -- fs_hint="`"${grub_probe}" --device $@ --target=compatibility_hint`" -+ fs_hint="`"${grub_probe}" --device ${device} --target=compatibility_hint`" - if [ "x$fs_hint" != x ]; then -- echo "set root='$fs_hint'" -+ echo "set ${variable}='$fs_hint'" - fi -- if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device $@ --target=fs_uuid 2> /dev/null`" ; then -- hints="`"${grub_probe}" --device $@ --target=hints_string 2> /dev/null`" || hints= -+ if [ "x$GRUB_DISABLE_UUID" != "xtrue" ] && fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`" ; then -+ hints="`"${grub_probe}" --device ${device} --target=hints_string 2> /dev/null`" || hints= - echo "if [ x\$feature_platform_search_hint = xy ]; then" -- echo " search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}" -+ echo " search --no-floppy --fs-uuid --set=${variable} ${hints} ${fs_uuid}" - echo "else" -- echo " search --no-floppy --fs-uuid --set=root ${fs_uuid}" -+ echo " search --no-floppy --fs-uuid --set=${variable} ${fs_uuid}" - echo "fi" - fi - IFS="$old_ifs" -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index d9a05937e46..839f1fdb655 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -121,6 +121,34 @@ linux_entry () - if [ -z "$boot_device_id" ]; then - boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" - fi -+ -+ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then -+ if [ x$dirname = x/ ]; then -+ if [ -z "${prepare_root_cache}" ]; then -+ prepare_grub_to_access_device ${GRUB_DEVICE} -+ fi -+ else -+ if [ -z "${prepare_boot_cache}" ]; then -+ prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} -+ fi -+ fi -+ -+ bootefi_device="`${grub_probe} --target=device /boot/efi/`" -+ prepare_grub_to_access_device ${bootefi_device} boot -+ -+ cat << EOF -+insmod blscfg -+blscfg -+if [ -s \$prefix/grubenv ]; then -+ load_env -+fi -+EOF -+ -+ ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" -+ -+ exit 0 -+ fi -+ - if [ x$type != xsimple ] ; then - title=$(mktitle "$type" "$version") - if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then -@@ -223,7 +251,10 @@ submenu_indentation="" - is_top_level=true - while [ "x$list" != "x" ] ; do - linux=`version_find_latest $list` -- gettext_printf "Found linux image: %s\n" "$linux" >&2 -+ if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then -+ gettext_printf "Found linux image: %s\n" "$linux" >&2 -+ fi -+ - basename=`basename $linux` - dirname=`dirname $linux` - rel_dirname=`make_system_path_relative_to_its_root $dirname` -@@ -262,7 +293,9 @@ while [ "x$list" != "x" ] ; do - for i in ${initrd}; do - initrd_display="${initrd_display} ${dirname}/${i}" - done -- gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 -+ if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then -+ gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 -+ fi - fi - - fdt= diff --git a/0174-grub.texi-Add-net_bootp6-doument.patch b/0114-grub.texi-Add-net_bootp6-doument.patch similarity index 82% rename from 0174-grub.texi-Add-net_bootp6-doument.patch rename to 0114-grub.texi-Add-net_bootp6-doument.patch index b66a80c05f257e87e9cc373e9bc6f7757bbcc623..acd465c82e41f18c304b066359a3864bac24e76a 100644 --- a/0174-grub.texi-Add-net_bootp6-doument.patch +++ b/0114-grub.texi-Add-net_bootp6-doument.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 5d9e28b3bf21eebf915b4519d6bac521f87815d3 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Tue, 5 May 2015 14:19:24 +0800 -Subject: [PATCH] grub.texi: Add net_bootp6 doument +Subject: [PATCH 114/220] grub.texi: Add net_bootp6 doument Update grub documentation for net_bootp6 command. @@ -12,10 +12,10 @@ Signed-off-by: Ken Lin 1 file changed, 17 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi -index 2b7b7faf847..c54bee31679 100644 +index 960e5f3..495462b 100644 --- a/docs/grub.texi +++ b/docs/grub.texi -@@ -5303,6 +5303,7 @@ This command is only available on AArch64 systems. +@@ -5338,6 +5338,7 @@ This command is only available on AArch64 systems. * net_add_dns:: Add a DNS server * net_add_route:: Add routing entry * net_bootp:: Perform a bootp autoconfiguration @@ -23,7 +23,7 @@ index 2b7b7faf847..c54bee31679 100644 * net_del_addr:: Remove IP address from interface * net_del_dns:: Remove a DNS server * net_del_route:: Remove a route entry -@@ -5384,6 +5385,22 @@ Sets environment variable @samp{net_}@var{}@samp{_dhcp_extensionspath} +@@ -5419,6 +5420,22 @@ Sets environment variable @samp{net_}@var{}@samp{_dhcp_extensionspath} @end deffn @@ -46,3 +46,6 @@ index 2b7b7faf847..c54bee31679 100644 @node net_del_addr @subsection net_del_addr +-- +1.8.3.1 + diff --git a/0115-Remove-duplicated-grub_exit-definition-for-grub-emu-.patch b/0115-Remove-duplicated-grub_exit-definition-for-grub-emu-.patch deleted file mode 100644 index 53bf22eb024d32597de41fc46322371db988c3e1..0000000000000000000000000000000000000000 --- a/0115-Remove-duplicated-grub_exit-definition-for-grub-emu-.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 6 Feb 2018 11:02:09 +0100 -Subject: [PATCH] Remove duplicated grub_exit() definition for grub-emu - platform - -The grub_exit() function signature was changed on all platforms to take a -return code, but latter on a following commit the grub_exit() for the emu -platform was duplicated. It causes a build error so remove the duplicated -function definition. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/kern/emu/main.c | 6 ------ - 1 file changed, 6 deletions(-) - -diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c -index 7e47ec81263..55ea5a11ccd 100644 ---- a/grub-core/kern/emu/main.c -+++ b/grub-core/kern/emu/main.c -@@ -72,12 +72,6 @@ grub_exit (int retval __attribute__((unused))) - grub_reboot (); - } - --void --grub_exit (int retval __attribute__((unused))) --{ -- grub_reboot (); --} -- - void - grub_machine_init (void) - { diff --git a/0175-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch b/0115-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch similarity index 33% rename from 0175-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch rename to 0115-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch index 1874107d7c5a33b6ed8e04ff32613639ebbe9d95..a28b33b69baa2e86bc23473accb59d207d6927d4 100644 --- a/0175-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch +++ b/0115-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 03bca00dc93a92f9f5ae5194b2c86a40b6281766 Mon Sep 17 00:00:00 2001 From: Michael Chang -Date: Thu, 14 Jul 2016 18:45:14 +0800 -Subject: [PATCH] bootp: Add processing DHCPACK packet from HTTP Boot +Date: Wed, 10 Jul 2019 23:58:28 +0200 +Subject: [PATCH 115/220] bootp: Add processing DHCPACK packet from HTTP Boot The vendor class identifier with the string "HTTPClient" is used to denote the packet as responding to HTTP boot request. In DHCP4 config, the filename for @@ -17,12 +17,12 @@ packet by treating it as HTTP format, not as the PXE format. Signed-off-by: Michael Chang Signed-off-by: Ken Lin --- - grub-core/net/bootp.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++-- + grub-core/net/bootp.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/grub/net.h | 1 + - 2 files changed, 67 insertions(+), 2 deletions(-) + 2 files changed, 56 insertions(+) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 242cd1f4cbd..8b6fc9f2411 100644 +index 85adc9c..2e46842 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -20,6 +20,7 @@ @@ -33,103 +33,79 @@ index 242cd1f4cbd..8b6fc9f2411 100644 #include #include #include -@@ -254,6 +255,11 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) - taglength); - break; +@@ -567,6 +568,60 @@ grub_net_configure_by_dhcp_ack (const char *name, + if (opt && opt_len) + grub_env_set_net_property (name, "rootpath", (const char *) opt, opt_len); -+ case GRUB_NET_BOOTP_VENDOR_CLASS_IDENTIFIER: -+ grub_env_set_net_property (name, "vendor_class_identifier", (const char *) ptr, -+ taglength); -+ break; -+ - case GRUB_NET_BOOTP_EXTENSIONS_PATH: - grub_env_set_net_property (name, "extensionspath", (const char *) ptr, - taglength); -@@ -357,6 +363,66 @@ grub_net_configure_by_dhcp_ack (const char *name, - } - #endif - -+ if (size > OFFSET_OF (vendor, bp)) ++ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_VENDOR_CLASS_IDENTIFIER, &opt_len); ++ if (opt && opt_len) + { -+ char *cidvar; -+ const char *cid; -+ -+ parse_dhcp_vendor (name, &bp->vendor, size - OFFSET_OF (vendor, bp), &mask); -+ cidvar = grub_xasprintf ("net_%s_%s", name, "vendor_class_identifier"); -+ cid = grub_env_get (cidvar); -+ grub_free (cidvar); ++ grub_env_set_net_property (name, "vendor_class_identifier", (const char *) opt, opt_len); ++ if (opt && grub_strcmp (opt, "HTTPClient") == 0) ++ { ++ char *proto, *ip, *pa; + -+ if (cid && grub_strcmp (cid, "HTTPClient") == 0) -+ { -+ char *proto, *ip, *pa; ++ if (!dissect_url (bp->boot_file, &proto, &ip, &pa)) ++ return inter; + -+ if (!dissect_url (bp->boot_file, &proto, &ip, &pa)) -+ return inter; ++ grub_env_set_net_property (name, "boot_file", pa, grub_strlen (pa)); ++ if (is_def) ++ { ++ grub_net_default_server = grub_strdup (ip); ++ grub_env_set ("net_default_interface", name); ++ grub_env_export ("net_default_interface"); ++ } ++ if (device && !*device) ++ { ++ *device = grub_xasprintf ("%s,%s", proto, ip); ++ grub_print_error (); ++ } ++ if (path) ++ { ++ *path = grub_strdup (pa); ++ grub_print_error (); ++ if (*path) ++ { ++ char *slash; ++ slash = grub_strrchr (*path, '/'); ++ if (slash) ++ *slash = 0; ++ else ++ **path = 0; ++ } ++ } ++ grub_net_add_ipv4_local (inter, mask); ++ inter->dhcp_ack = grub_malloc (size); ++ if (inter->dhcp_ack) ++ { ++ grub_memcpy (inter->dhcp_ack, bp, size); ++ inter->dhcp_acklen = size; ++ } ++ else ++ grub_errno = GRUB_ERR_NONE; + -+ grub_env_set_net_property (name, "boot_file", pa, grub_strlen (pa)); -+ if (is_def) -+ { -+ grub_net_default_server = grub_strdup (ip); -+ grub_env_set ("net_default_interface", name); -+ grub_env_export ("net_default_interface"); -+ } -+ if (device && !*device) -+ { -+ *device = grub_xasprintf ("%s,%s", proto, ip); -+ grub_print_error (); -+ } -+ if (path) -+ { -+ *path = grub_strdup (pa); -+ grub_print_error (); -+ if (*path) -+ { -+ char *slash; -+ slash = grub_strrchr (*path, '/'); -+ if (slash) -+ *slash = 0; -+ else -+ **path = 0; -+ } -+ } -+ grub_net_add_ipv4_local (inter, mask); -+ inter->dhcp_ack = grub_malloc (size); -+ if (inter->dhcp_ack) -+ { -+ grub_memcpy (inter->dhcp_ack, bp, size); -+ inter->dhcp_acklen = size; -+ } -+ else -+ grub_errno = GRUB_ERR_NONE; -+ -+ grub_free (proto); -+ grub_free (ip); -+ grub_free (pa); -+ return inter; -+ } ++ grub_free (proto); ++ grub_free (ip); ++ grub_free (pa); ++ return inter; ++ } + } + - if (size > OFFSET_OF (boot_file, bp)) - grub_env_set_net_property (name, "boot_file", bp->boot_file, - sizeof (bp->boot_file)); -@@ -421,8 +487,6 @@ grub_net_configure_by_dhcp_ack (const char *name, - **path = 0; - } - } -- if (size > OFFSET_OF (vendor, bp)) -- parse_dhcp_vendor (name, &bp->vendor, size - OFFSET_OF (vendor, bp), &mask); - grub_net_add_ipv4_local (inter, mask); - - inter->dhcp_ack = grub_malloc (size); + opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_EXTENSIONS_PATH, &opt_len); + if (opt && opt_len) + grub_env_set_net_property (name, "extensionspath", (const char *) opt, opt_len); diff --git a/include/grub/net.h b/include/grub/net.h -index 5f78b22e109..9cf6da68973 100644 +index aedf4b5..ebb569b 100644 --- a/include/grub/net.h +++ b/include/grub/net.h -@@ -522,6 +522,7 @@ enum +@@ -526,6 +526,7 @@ enum GRUB_NET_BOOTP_DOMAIN = 0x0f, GRUB_NET_BOOTP_ROOT_PATH = 0x11, GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12, + GRUB_NET_BOOTP_VENDOR_CLASS_IDENTIFIER = 0x3C, GRUB_NET_BOOTP_CLIENT_ID = 0x3d, GRUB_NET_BOOTP_CLIENT_UUID = 0x61, - GRUB_NET_BOOTP_END = 0xff + GRUB_NET_DHCP_REQUESTED_IP_ADDRESS = 50, +-- +1.8.3.1 + diff --git a/0176-efinet-Setting-network-from-UEFI-device-path.patch b/0116-efinet-Setting-network-from-UEFI-device-path.patch similarity index 94% rename from 0176-efinet-Setting-network-from-UEFI-device-path.patch rename to 0116-efinet-Setting-network-from-UEFI-device-path.patch index 6f978865478e9824f99250470b0a3c1de652a0aa..6a766bc9de182dc200483cc62929408400e080f0 100644 --- a/0176-efinet-Setting-network-from-UEFI-device-path.patch +++ b/0116-efinet-Setting-network-from-UEFI-device-path.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From b412d2074f75951680962af0f64b1467cd485821 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Sun, 10 Jul 2016 23:46:31 +0800 -Subject: [PATCH] efinet: Setting network from UEFI device path +Subject: [PATCH 116/220] efinet: Setting network from UEFI device path The PXE Base Code protocol used to obtain cached PXE DHCPACK packet is no longer provided for HTTP Boot. Instead, we have to get the HTTP boot @@ -32,7 +32,7 @@ Signed-off-by: Ken Lin 2 files changed, 280 insertions(+), 15 deletions(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index ac58e3e82cf..431b72916b6 100644 +index c3db328..2817b6f 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -27,6 +27,7 @@ @@ -43,8 +43,8 @@ index ac58e3e82cf..431b72916b6 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -412,6 +413,227 @@ grub_efinet_findcards (void) - } +@@ -332,6 +333,227 @@ grub_efinet_findcards (void) + grub_free (handles); } +static struct grub_net_buff * @@ -271,7 +271,7 @@ index ac58e3e82cf..431b72916b6 100644 static void grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, char **path) -@@ -427,7 +649,11 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -347,7 +569,11 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, { grub_efi_device_path_t *cdp; struct grub_efi_pxe *pxe; @@ -284,7 +284,7 @@ index ac58e3e82cf..431b72916b6 100644 if (card->driver != &efidriver) continue; -@@ -454,11 +680,21 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -371,11 +597,21 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, */ if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE @@ -307,7 +307,7 @@ index ac58e3e82cf..431b72916b6 100644 dup_ldp = grub_efi_find_last_device_path (dup_dp); dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; -@@ -471,23 +707,37 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -388,23 +624,37 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, pxe = grub_efi_open_protocol (hnd, &pxe_io_guid, GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); @@ -356,7 +356,7 @@ index ac58e3e82cf..431b72916b6 100644 1, device, path); if (grub_errno) grub_print_error (); -@@ -501,11 +751,15 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -418,11 +668,15 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, grub_dprintf ("efinet", "using ipv4 and dhcp\n"); grub_net_configure_by_dhcp_ack (card->name, card, 0, (struct grub_net_bootp_packet *) @@ -375,10 +375,10 @@ index ac58e3e82cf..431b72916b6 100644 } } diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 7dbd8807b80..0b61f791850 100644 +index 186cf39..0d4839a 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -843,6 +843,8 @@ struct grub_efi_ipv4_device_path +@@ -839,6 +839,8 @@ struct grub_efi_ipv4_device_path grub_efi_uint16_t remote_port; grub_efi_uint16_t protocol; grub_efi_uint8_t static_ip_address; @@ -387,7 +387,7 @@ index 7dbd8807b80..0b61f791850 100644 } GRUB_PACKED; typedef struct grub_efi_ipv4_device_path grub_efi_ipv4_device_path_t; -@@ -897,6 +899,15 @@ struct grub_efi_sata_device_path +@@ -893,6 +895,15 @@ struct grub_efi_sata_device_path } GRUB_PACKED; typedef struct grub_efi_sata_device_path grub_efi_sata_device_path_t; @@ -403,3 +403,6 @@ index 7dbd8807b80..0b61f791850 100644 #define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10 /* Media Device Path. */ +-- +1.8.3.1 + diff --git a/0117-Enable-blscfg-command-for-the-emu-platform.patch b/0117-Enable-blscfg-command-for-the-emu-platform.patch deleted file mode 100644 index 5a2f7b74bcb47ff5ef20aba393fc10ec8a69f7f4..0000000000000000000000000000000000000000 --- a/0117-Enable-blscfg-command-for-the-emu-platform.patch +++ /dev/null @@ -1,164 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 2 Feb 2018 11:36:29 +0100 -Subject: [PATCH] Enable blscfg command for the emu platform - -Allow grub-emu to call a blscfg command. This may be useful for platforms -that don't support GRUB, so grub-emu can be used to parse the BLS configs -and kexec a new kernel using that information. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/Makefile.core.def | 1 + - grub-core/commands/blscfg.c | 46 +++++++++++++++++++++++++++++++++++---------- - 2 files changed, 37 insertions(+), 10 deletions(-) - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 96ccb402125..e52d776887a 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -777,6 +777,7 @@ module = { - common = commands/blscfg.c; - enable = efi; - enable = i386_pc; -+ enable = emu; - }; - - module = { -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 86796c8cd83..e0b65534af4 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -37,7 +37,12 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #include "loadenv.h" - - #define GRUB_BLS_CONFIG_PATH "/loader/entries/" -+#ifdef GRUB_MACHINE_EMU -+#define GRUB_BOOT_DEVICE "/boot" -+#else - #define GRUB_BOOT_DEVICE "($root)" -+#endif -+ - #ifdef GRUB_MACHINE_EFI - #define GRUB_LINUX_CMD "linuxefi" - #define GRUB_INITRD_CMD "initrdefi" -@@ -46,6 +51,13 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #define GRUB_INITRD_CMD "initrd" - #endif - -+enum -+ { -+ PLATFORM_EFI, -+ PLATFORM_EMU, -+ PLATFORM_BIOS, -+ }; -+ - #define grub_free(x) ({grub_dprintf("blscfg", "%s freeing %p\n", __func__, x); grub_free(x); }) - - struct keyval -@@ -641,7 +653,7 @@ finish: - struct find_entry_info { - grub_device_t dev; - grub_fs_t fs; -- int efi; -+ int platform; - }; - - /* -@@ -668,13 +680,16 @@ static int find_entry (const char *filename, - !grub_strcmp (filename, "..")) - return 0; - -- if (info->efi && !grub_strcasecmp (filename, "boot")) -+ if (info->platform == PLATFORM_EFI && !grub_strcasecmp (filename, "boot")) - return 0; - - saved_env_buf = grub_malloc (512); - - // set a default blsdir -- if (info->efi) -+ if (info->platform == PLATFORM_EMU) -+ default_blsdir = grub_xasprintf ("%s%s", GRUB_BOOT_DEVICE, -+ GRUB_BLS_CONFIG_PATH); -+ else if (info->platform == PLATFORM_EFI) - default_blsdir = grub_xasprintf ("/EFI/%s%s", filename, - GRUB_BLS_CONFIG_PATH); - else -@@ -686,7 +701,7 @@ static int find_entry (const char *filename, - /* - * try to load a grubenv from /EFI/wherever/grubenv - */ -- if (info->efi) -+ if (info->platform == PLATFORM_EFI) - grubenv_path = grub_xasprintf ("(%s)/EFI/%s/grubenv", devid, filename); - else - grubenv_path = grub_xasprintf ("(%s)/grub2/grubenv", devid); -@@ -740,7 +755,7 @@ static int find_entry (const char *filename, - goto finish; - - grub_dprintf ("blscfg", "blsdir: \"%s\"\n", blsdir); -- if (blsdir[0] != '/' && info->efi) -+ if (blsdir[0] != '/' && info->platform == PLATFORM_EFI) - blsdir = grub_xasprintf ("/EFI/%s/%s/", filename, blsdir); - else - blsdir = grub_strdup (blsdir); -@@ -818,15 +833,21 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - { - .dev = NULL, - .fs = NULL, -- .efi = 0, -+ .platform = PLATFORM_BIOS, - }; - - - grub_dprintf ("blscfg", "finding boot\n"); -+ -+#ifdef GRUB_MACHINE_EMU -+ devid = "host"; -+ grub_env_set ("boot", devid); -+#else - devid = grub_env_get ("boot"); - if (!devid) - return grub_error (GRUB_ERR_FILE_NOT_FOUND, - N_("variable `%s' isn't set"), "boot"); -+#endif - - grub_dprintf ("blscfg", "opening %s\n", devid); - dev = grub_device_open (devid); -@@ -844,11 +865,16 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - info.dev = dev; - info.fs = fs; - #ifdef GRUB_MACHINE_EFI -- info.efi = 1; -+ info.platform = PLATFORM_EFI; - grub_dprintf ("blscfg", "scanning /EFI/\n"); - r = fs->dir (dev, "/EFI/", find_entry, &info); -+#elif GRUB_MACHINE_EMU -+ info.platform = PLATFORM_EMU; -+ grub_dprintf ("blscfg", "scanning %s%s\n", GRUB_BOOT_DEVICE, -+ GRUB_BLS_CONFIG_PATH); -+ r = fs->dir (dev, "/boot/loader/", -+ find_entry, &info); - #else -- info.efi = 0; - grub_dprintf ("blscfg", "scanning %s\n", GRUB_BLS_CONFIG_PATH); - r = fs->dir (dev, "/", find_entry, &info); - #endif -@@ -863,7 +889,7 @@ finish: - static grub_extcmd_t cmd; - static grub_extcmd_t oldcmd; - --GRUB_MOD_INIT(bls) -+GRUB_MOD_INIT(blscfg) - { - grub_dprintf("blscfg", "%s got here\n", __func__); - cmd = grub_register_extcmd ("blscfg", -@@ -880,7 +906,7 @@ GRUB_MOD_INIT(bls) - NULL); - } - --GRUB_MOD_FINI(bls) -+GRUB_MOD_FINI(blscfg) - { - grub_unregister_extcmd (cmd); - grub_unregister_extcmd (oldcmd); diff --git a/0177-efinet-Setting-DNS-server-from-UEFI-protocol.patch b/0117-efinet-Setting-DNS-server-from-UEFI-protocol.patch similarity index 94% rename from 0177-efinet-Setting-DNS-server-from-UEFI-protocol.patch rename to 0117-efinet-Setting-DNS-server-from-UEFI-protocol.patch index 11f9f6886b41f3397e5fd0923e492fd244126885..75d786b87552ec4092635af76be53afbc9a7af0d 100644 --- a/0177-efinet-Setting-DNS-server-from-UEFI-protocol.patch +++ b/0117-efinet-Setting-DNS-server-from-UEFI-protocol.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 8bccd41162bf0172c30934330b71983706d796f4 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 14 Jul 2016 17:48:45 +0800 -Subject: [PATCH] efinet: Setting DNS server from UEFI protocol +Subject: [PATCH 117/220] efinet: Setting DNS server from UEFI protocol In the URI device path node, any name rahter than address can be used for looking up the resources so that DNS service become needed to get answer of the @@ -33,7 +33,7 @@ Signed-off-by: Ken Lin 2 files changed, 239 insertions(+) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 431b72916b6..c25a68161b8 100644 +index 2817b6f..c843654 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -34,6 +34,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); @@ -45,8 +45,8 @@ index 431b72916b6..c25a68161b8 100644 static grub_err_t send_card_buffer (struct grub_net_card *dev, -@@ -413,6 +415,125 @@ grub_efinet_findcards (void) - } +@@ -333,6 +335,125 @@ grub_efinet_findcards (void) + grub_free (handles); } +static grub_efi_handle_t @@ -171,7 +171,7 @@ index 431b72916b6..c25a68161b8 100644 static struct grub_net_buff * grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *use_ipv6) { -@@ -471,6 +592,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -391,6 +512,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u grub_efi_ipv4_device_path_t *ipv4 = (grub_efi_ipv4_device_path_t *) ldp; struct grub_net_bootp_packet *bp; grub_uint8_t *ptr; @@ -180,7 +180,7 @@ index 431b72916b6..c25a68161b8 100644 bp = (struct grub_net_bootp_packet *) nb->tail; err = grub_netbuff_put (nb, sizeof (*bp) + 4); -@@ -532,6 +655,25 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -452,6 +575,25 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u *ptr++ = sizeof ("HTTPClient") - 1; grub_memcpy (ptr, "HTTPClient", sizeof ("HTTPClient") - 1); @@ -206,7 +206,7 @@ index 431b72916b6..c25a68161b8 100644 ptr = nb->tail; err = grub_netbuff_put (nb, 1); if (err) -@@ -564,6 +706,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -484,6 +626,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u struct grub_net_dhcp6_option *opt; struct grub_net_dhcp6_option_iana *iana; struct grub_net_dhcp6_option_iaaddr *iaaddr; @@ -215,7 +215,7 @@ index 431b72916b6..c25a68161b8 100644 d6p = (struct grub_net_dhcp6_packet *)nb->tail; err = grub_netbuff_put (nb, sizeof(*d6p)); -@@ -627,6 +771,25 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -547,6 +691,25 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u opt->len = grub_cpu_to_be16 (uri_len); grub_memcpy (opt->data, uri_dp->uri, uri_len); @@ -242,7 +242,7 @@ index 431b72916b6..c25a68161b8 100644 } diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 0b61f791850..80f6d79cfaf 100644 +index 0d4839a..716f121 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -334,6 +334,16 @@ @@ -262,7 +262,7 @@ index 0b61f791850..80f6d79cfaf 100644 struct grub_efi_sal_system_table { grub_uint32_t signature; -@@ -1842,6 +1852,72 @@ struct grub_efi_block_io +@@ -1838,6 +1848,72 @@ struct grub_efi_block_io }; typedef struct grub_efi_block_io grub_efi_block_io_t; @@ -333,5 +333,8 @@ index 0b61f791850..80f6d79cfaf 100644 +typedef struct grub_efi_ip6_config_protocol grub_efi_ip6_config_protocol_t; + #if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \ - || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) - + || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) \ + || defined(__riscv) +-- +1.8.3.1 + diff --git a/0178-Fix-one-more-coverity-complaint.patch b/0118-Fix-one-more-coverity-complaint.patch similarity index 76% rename from 0178-Fix-one-more-coverity-complaint.patch rename to 0118-Fix-one-more-coverity-complaint.patch index ba00fbd1fc15ba86d9672760969b1999985f407d..f8a130dc513a2dc8b4028939165d67c021295606 100644 --- a/0178-Fix-one-more-coverity-complaint.patch +++ b/0118-Fix-one-more-coverity-complaint.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From c160c16be2002a3f61b7c0432ff2759c9a5219a0 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 25 May 2017 11:27:40 -0400 -Subject: [PATCH] Fix one more coverity complaint +Subject: [PATCH 118/220] Fix one more coverity complaint No idea why covscan thinks this is an "added" bug, since the file hasn't changed in 3 years, but... yeah. @@ -12,7 +12,7 @@ Signed-off-by: Peter Jones 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/normal/completion.c b/grub-core/normal/completion.c -index 2c9b9e9312a..93aa0d8eda8 100644 +index 5961028..c07100a 100644 --- a/grub-core/normal/completion.c +++ b/grub-core/normal/completion.c @@ -284,7 +284,8 @@ complete_file (void) @@ -24,4 +24,7 @@ index 2c9b9e9312a..93aa0d8eda8 100644 + dirfile[1] = '\0'; /* Iterate the directory. */ - (fs->dir) (dev, dir, iterate_dir, NULL); + (fs->fs_dir) (dev, dir, iterate_dir, NULL); +-- +1.8.3.1 + diff --git a/0119-Fix-the-efidir-in-grub-setpassword.patch b/0119-Fix-the-efidir-in-grub-setpassword.patch deleted file mode 100644 index 2d815e2a50d359fb6374e21fe2eaf673c4d1b704..0000000000000000000000000000000000000000 --- a/0119-Fix-the-efidir-in-grub-setpassword.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 15 Mar 2018 14:12:54 -0400 -Subject: [PATCH] Fix the efidir in grub-setpassword - -Signed-off-by: Peter Jones ---- - util/grub-setpassword.in | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in -index d7924af5192..cf70257eed6 100644 ---- a/util/grub-setpassword.in -+++ b/util/grub-setpassword.in -@@ -1,7 +1,8 @@ - #!/bin/sh -e - -+EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') - if [ -d /sys/firmware/efi/efivars/ ]; then -- grubdir=`echo "/@bootdirname@/efi/EFI/redhat/" | sed 's,//*,/,g'` -+ grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'` - else - grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'` - fi diff --git a/0180-Support-UEFI-networking-protocols.patch b/0119-Support-UEFI-networking-protocols.patch similarity index 98% rename from 0180-Support-UEFI-networking-protocols.patch rename to 0119-Support-UEFI-networking-protocols.patch index 20728f9fb7640a8eb706c66364dd278f27c337d6..38414496768f8188c3c806c369d301292b571180 100644 --- a/0180-Support-UEFI-networking-protocols.patch +++ b/0119-Support-UEFI-networking-protocols.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 52cf36ce649fc8a5f915b143ccc680cf4a2ebbda Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Wed, 22 Feb 2017 14:27:50 +0800 -Subject: [PATCH] Support UEFI networking protocols +Subject: [PATCH 119/220] Support UEFI networking protocols References: fate#320130, bsc#1015589, bsc#1076132 Patch-Mainline: no @@ -22,8 +22,12 @@ V3: * Use HEAD request method to test before GET * Finish HTTP transaction in one go * Fix bsc#1076132 + +Signed-off-by: Michael Chang +[pjones: make efi_netfs not duplicate symbols from efinet] +Signed-off-by: Peter Jones --- - grub-core/Makefile.core.def | 18 + + grub-core/Makefile.core.def | 12 + grub-core/io/bufio.c | 2 +- grub-core/kern/efi/efi.c | 96 ++- grub-core/net/drivers/efi/efinet.c | 27 + @@ -35,12 +39,12 @@ V3: grub-core/net/efi/net.c | 1428 ++++++++++++++++++++++++++++++++++++ grub-core/net/efi/pxe.c | 424 +++++++++++ grub-core/net/net.c | 74 ++ - util/grub-mknetdir.c | 23 +- include/grub/efi/api.h | 180 ++++- include/grub/efi/dhcp.h | 343 +++++++++ include/grub/efi/http.h | 215 ++++++ include/grub/net/efi.h | 144 ++++ - 17 files changed, 4626 insertions(+), 41 deletions(-) + util/grub-mknetdir.c | 23 +- + 17 files changed, 4620 insertions(+), 41 deletions(-) create mode 100644 grub-core/net/efi/dhcp.c create mode 100644 grub-core/net/efi/efi_netfs.c create mode 100644 grub-core/net/efi/http.c @@ -53,29 +57,23 @@ V3: create mode 100644 include/grub/net/efi.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 420831bc89e..2851437e098 100644 +index 49c5dc4..48491b5 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -2181,6 +2181,18 @@ module = { - common = hook/datehook.c; +@@ -2277,6 +2277,12 @@ module = { }; -+module = { + module = { + name = efi_netfs; + common = net/efi/efi_netfs.c; -+ common = net/efi/net.c; -+ common = net/efi/http.c; -+ common = net/efi/pxe.c; -+ common = net/efi/ip4_config.c; -+ common = net/efi/ip6_config.c; -+ common = net/efi/dhcp.c; + enable = efi; +}; + - module = { ++module = { name = net; common = net/net.c; -@@ -2195,6 +2207,12 @@ module = { + common = net/dns.c; +@@ -2290,6 +2296,12 @@ module = { common = net/arp.c; common = net/netbuff.c; common = net/url.c; @@ -89,7 +87,7 @@ index 420831bc89e..2851437e098 100644 module = { diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c -index dbed6474431..6118bade50d 100644 +index a458c3a..1637731 100644 --- a/grub-core/io/bufio.c +++ b/grub-core/io/bufio.c @@ -139,7 +139,7 @@ grub_bufio_read (grub_file_t file, char *buf, grub_size_t len) @@ -102,10 +100,10 @@ index dbed6474431..6118bade50d 100644 if (file->offset + res < next_buf) { diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index a2a732ffc0d..4d36fe31177 100644 +index 19054b1..ada3004 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -696,7 +696,7 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) +@@ -709,7 +709,7 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) { grub_efi_ipv4_device_path_t *ipv4 = (grub_efi_ipv4_device_path_t *) dp; @@ -114,7 +112,7 @@ index a2a732ffc0d..4d36fe31177 100644 (unsigned) ipv4->local_ip_address[0], (unsigned) ipv4->local_ip_address[1], (unsigned) ipv4->local_ip_address[2], -@@ -709,33 +709,60 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) +@@ -722,33 +722,60 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) (unsigned) ipv4->remote_port, (unsigned) ipv4->protocol, (unsigned) ipv4->static_ip_address); @@ -192,7 +190,7 @@ index a2a732ffc0d..4d36fe31177 100644 } break; case GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE: -@@ -775,6 +802,39 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) +@@ -788,6 +815,39 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) dump_vendor_path ("Messaging", (grub_efi_vendor_device_path_t *) dp); break; @@ -233,7 +231,7 @@ index a2a732ffc0d..4d36fe31177 100644 grub_printf ("/UnknownMessaging(%x)", (unsigned) subtype); break; diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index c25a68161b8..56305f46a3d 100644 +index c843654..ca8bd3c 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -28,6 +28,7 @@ @@ -244,7 +242,7 @@ index c25a68161b8..56305f46a3d 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -572,6 +573,17 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -492,6 +493,17 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u ldp = grub_efi_find_last_device_path (ddp); @@ -262,7 +260,7 @@ index c25a68161b8..56305f46a3d 100644 if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE)) -@@ -844,6 +856,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -761,6 +773,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE @@ -270,11 +268,10 @@ index c25a68161b8..56305f46a3d 100644 && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_URI_DEVICE_PATH_SUBTYPE)) continue; dup_dp = grub_efi_duplicate_device_path (dp); -@@ -858,6 +871,15 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - dup_ldp->length = sizeof (*dup_ldp); +@@ -776,6 +789,15 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, } -+ dup_ldp = grub_efi_find_last_device_path (dup_dp); + dup_ldp = grub_efi_find_last_device_path (dup_dp); + if (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_DNS_DEVICE_PATH_SUBTYPE) + { + dup_ldp = grub_efi_find_last_device_path (dup_dp); @@ -283,10 +280,11 @@ index c25a68161b8..56305f46a3d 100644 + dup_ldp->length = sizeof (*dup_ldp); + } + - dup_ldp = grub_efi_find_last_device_path (dup_dp); ++ dup_ldp = grub_efi_find_last_device_path (dup_dp); dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; -@@ -929,6 +951,9 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, + dup_ldp->length = sizeof (*dup_ldp); +@@ -846,6 +868,9 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, GRUB_MOD_INIT(efinet) { @@ -296,7 +294,7 @@ index c25a68161b8..56305f46a3d 100644 grub_efinet_findcards (); grub_efi_net_config = grub_efi_net_config_real; } -@@ -940,5 +965,7 @@ GRUB_MOD_FINI(efinet) +@@ -857,5 +882,7 @@ GRUB_MOD_FINI(efinet) FOR_NET_CARDS_SAFE (card, next) if (card->driver == &efidriver) grub_net_card_unregister (card); @@ -306,7 +304,7 @@ index c25a68161b8..56305f46a3d 100644 diff --git a/grub-core/net/efi/dhcp.c b/grub-core/net/efi/dhcp.c new file mode 100644 -index 00000000000..dbef63d8c08 +index 0000000..dbef63d --- /dev/null +++ b/grub-core/net/efi/dhcp.c @@ -0,0 +1,397 @@ @@ -709,7 +707,7 @@ index 00000000000..dbef63d8c08 +grub_command_func_t grub_efi_net_bootp6 = grub_cmd_efi_bootp6; diff --git a/grub-core/net/efi/efi_netfs.c b/grub-core/net/efi/efi_netfs.c new file mode 100644 -index 00000000000..ef371d885ea +index 0000000..ef371d8 --- /dev/null +++ b/grub-core/net/efi/efi_netfs.c @@ -0,0 +1,57 @@ @@ -772,7 +770,7 @@ index 00000000000..ef371d885ea +} diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c new file mode 100644 -index 00000000000..3f61fd2fa5b +index 0000000..3f61fd2 --- /dev/null +++ b/grub-core/net/efi/http.c @@ -0,0 +1,419 @@ @@ -1197,7 +1195,7 @@ index 00000000000..3f61fd2fa5b + }; diff --git a/grub-core/net/efi/ip4_config.c b/grub-core/net/efi/ip4_config.c new file mode 100644 -index 00000000000..b711a5d9457 +index 0000000..b711a5d --- /dev/null +++ b/grub-core/net/efi/ip4_config.c @@ -0,0 +1,398 @@ @@ -1601,7 +1599,7 @@ index 00000000000..b711a5d9457 + }; diff --git a/grub-core/net/efi/ip6_config.c b/grub-core/net/efi/ip6_config.c new file mode 100644 -index 00000000000..017c4d05bc7 +index 0000000..017c4d0 --- /dev/null +++ b/grub-core/net/efi/ip6_config.c @@ -0,0 +1,422 @@ @@ -2029,7 +2027,7 @@ index 00000000000..017c4d05bc7 + }; diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c new file mode 100644 -index 00000000000..9e0078ac1c6 +index 0000000..86bce65 --- /dev/null +++ b/grub-core/net/efi/net.c @@ -0,0 +1,1428 @@ @@ -3326,13 +3324,13 @@ index 00000000000..9e0078ac1c6 +static struct grub_fs grub_efi_netfs = + { + .name = "efi netfs", -+ .dir = grub_efi_netfs_dir, -+ .open = grub_efi_netfs_open, -+ .read = grub_efi_netfs_read, -+ .close = grub_efi_netfs_close, -+ .label = NULL, -+ .uuid = NULL, -+ .mtime = NULL, ++ .fs_dir = grub_efi_netfs_dir, ++ .fs_open = grub_efi_netfs_open, ++ .fs_read = grub_efi_netfs_read, ++ .fs_close = grub_efi_netfs_close, ++ .fs_label = NULL, ++ .fs_uuid = NULL, ++ .fs_mtime = NULL, + }; + +int @@ -3463,7 +3461,7 @@ index 00000000000..9e0078ac1c6 +} diff --git a/grub-core/net/efi/pxe.c b/grub-core/net/efi/pxe.c new file mode 100644 -index 00000000000..531949cba5c +index 0000000..531949c --- /dev/null +++ b/grub-core/net/efi/pxe.c @@ -0,0 +1,424 @@ @@ -3892,7 +3890,7 @@ index 00000000000..531949cba5c + }; + diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 191e8e41bd6..a571ee92efa 100644 +index 2734f70..27a0a1d 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -32,6 +32,9 @@ @@ -4001,90 +3999,8 @@ index 191e8e41bd6..a571ee92efa 100644 + init_mode = INIT_MODE_NONE; +#endif } -diff --git a/util/grub-mknetdir.c b/util/grub-mknetdir.c -index 82073d5cc94..ae31271bbc0 100644 ---- a/util/grub-mknetdir.c -+++ b/util/grub-mknetdir.c -@@ -32,13 +32,15 @@ - - static char *rootdir = NULL, *subdir = NULL; - static char *debug_image = NULL; -+static char efi_netfs = 0; - - enum - { - OPTION_NET_DIRECTORY = 0x301, - OPTION_SUBDIR, - OPTION_DEBUG, -- OPTION_DEBUG_IMAGE -+ OPTION_DEBUG_IMAGE, -+ OPTION_DEBUG_EFI_NETFS - }; - - static struct argp_option options[] = { -@@ -49,6 +51,7 @@ static struct argp_option options[] = { - 0, N_("relative subdirectory on network server"), 2}, - {"debug", OPTION_DEBUG, 0, OPTION_HIDDEN, 0, 2}, - {"debug-image", OPTION_DEBUG_IMAGE, N_("STRING"), OPTION_HIDDEN, 0, 2}, -+ {"debug-efi-netfs", OPTION_DEBUG_EFI_NETFS, 0, OPTION_HIDDEN, 0, 2}, - {0, 0, 0, 0, 0, 0} - }; - -@@ -67,6 +70,9 @@ argp_parser (int key, char *arg, struct argp_state *state) - free (subdir); - subdir = xstrdup (arg); - return 0; -+ case OPTION_DEBUG_EFI_NETFS: -+ efi_netfs = 1; -+ return 0; - /* This is an undocumented feature... */ - case OPTION_DEBUG: - verbosity++; -@@ -82,7 +88,6 @@ argp_parser (int key, char *arg, struct argp_state *state) - } - } - -- - struct argp argp = { - options, argp_parser, NULL, - "\v"N_("Prepares GRUB network boot images at net_directory/subdir " -@@ -92,7 +97,7 @@ struct argp argp = { - - static char *base; - --static const struct -+static struct - { - const char *mkimage_target; - const char *netmodule; -@@ -154,6 +159,7 @@ process_input_dir (const char *input_dir, enum grub_install_plat platform) - grub_install_push_module (targets[platform].netmodule); - - output = grub_util_path_concat_ext (2, grubdir, "core", targets[platform].ext); -+ - grub_install_make_image_wrap (input_dir, prefix, output, - 0, load_cfg, - targets[platform].mkimage_target, 0); -@@ -190,7 +196,16 @@ main (int argc, char *argv[]) - - grub_install_mkdir_p (base); - -- grub_install_push_module ("tftp"); -+ if (!efi_netfs) -+ { -+ grub_install_push_module ("tftp"); -+ grub_install_push_module ("http"); -+ } -+ else -+ { -+ targets[GRUB_INSTALL_PLATFORM_I386_EFI].netmodule = "efi_netfs"; -+ targets[GRUB_INSTALL_PLATFORM_X86_64_EFI].netmodule = "efi_netfs"; -+ } - - if (!grub_install_source_directory) - { diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 80f6d79cfaf..5f62a2d4292 100644 +index 716f121..2ed9c26 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -602,6 +602,23 @@ typedef union @@ -4111,7 +4027,7 @@ index 80f6d79cfaf..5f62a2d4292 100644 struct grub_efi_guid { -@@ -869,6 +886,8 @@ struct grub_efi_ipv6_device_path +@@ -865,6 +882,8 @@ struct grub_efi_ipv6_device_path grub_efi_uint16_t remote_port; grub_efi_uint16_t protocol; grub_efi_uint8_t static_ip_address; @@ -4120,7 +4036,7 @@ index 80f6d79cfaf..5f62a2d4292 100644 } GRUB_PACKED; typedef struct grub_efi_ipv6_device_path grub_efi_ipv6_device_path_t; -@@ -918,6 +937,15 @@ struct grub_efi_uri_device_path +@@ -914,6 +933,15 @@ struct grub_efi_uri_device_path } GRUB_PACKED; typedef struct grub_efi_uri_device_path grub_efi_uri_device_path_t; @@ -4136,7 +4052,7 @@ index 80f6d79cfaf..5f62a2d4292 100644 #define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10 /* Media Device Path. */ -@@ -1000,6 +1028,23 @@ struct grub_efi_bios_device_path +@@ -996,6 +1024,23 @@ struct grub_efi_bios_device_path } GRUB_PACKED; typedef struct grub_efi_bios_device_path grub_efi_bios_device_path_t; @@ -4160,7 +4076,7 @@ index 80f6d79cfaf..5f62a2d4292 100644 struct grub_efi_open_protocol_information_entry { grub_efi_handle_t agent_handle; -@@ -1549,23 +1594,27 @@ typedef struct grub_efi_pxe_tftp_error +@@ -1545,23 +1590,27 @@ typedef struct grub_efi_pxe_tftp_error grub_efi_char8_t error_string[127]; } grub_efi_pxe_tftp_error_t; @@ -4202,7 +4118,7 @@ index 80f6d79cfaf..5f62a2d4292 100644 #define GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT 8 typedef struct grub_efi_pxe_ip_filter -@@ -1632,17 +1681,31 @@ typedef struct grub_efi_pxe_mode +@@ -1628,17 +1677,31 @@ typedef struct grub_efi_pxe_mode typedef struct grub_efi_pxe { grub_uint64_t rev; @@ -4238,7 +4154,7 @@ index 80f6d79cfaf..5f62a2d4292 100644 void (*setpackets) (void); struct grub_efi_pxe_mode *mode; } grub_efi_pxe_t; -@@ -1884,6 +1947,44 @@ struct grub_efi_ip4_config2_protocol +@@ -1880,6 +1943,44 @@ struct grub_efi_ip4_config2_protocol }; typedef struct grub_efi_ip4_config2_protocol grub_efi_ip4_config2_protocol_t; @@ -4283,7 +4199,7 @@ index 80f6d79cfaf..5f62a2d4292 100644 enum grub_efi_ip6_config_data_type { GRUB_EFI_IP6_CONFIG_DATA_TYPE_INTERFACEINFO, GRUB_EFI_IP6_CONFIG_DATA_TYPE_ALT_INTERFACEID, -@@ -1918,6 +2019,49 @@ struct grub_efi_ip6_config_protocol +@@ -1914,6 +2015,49 @@ struct grub_efi_ip6_config_protocol }; typedef struct grub_efi_ip6_config_protocol grub_efi_ip6_config_protocol_t; @@ -4331,11 +4247,11 @@ index 80f6d79cfaf..5f62a2d4292 100644 +typedef struct grub_efi_ip6_config_manual_address grub_efi_ip6_config_manual_address_t; + #if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \ - || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) - + || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) \ + || defined(__riscv) diff --git a/include/grub/efi/dhcp.h b/include/grub/efi/dhcp.h new file mode 100644 -index 00000000000..fdb88eb810e +index 0000000..fdb88eb --- /dev/null +++ b/include/grub/efi/dhcp.h @@ -0,0 +1,343 @@ @@ -4684,7 +4600,7 @@ index 00000000000..fdb88eb810e +#endif /* ! GRUB_EFI_DHCP_HEADER */ diff --git a/include/grub/efi/http.h b/include/grub/efi/http.h new file mode 100644 -index 00000000000..c5e9a89f505 +index 0000000..c5e9a89 --- /dev/null +++ b/include/grub/efi/http.h @@ -0,0 +1,215 @@ @@ -4905,7 +4821,7 @@ index 00000000000..c5e9a89f505 +#endif /* !GRUB_EFI_HTTP_HEADER */ diff --git a/include/grub/net/efi.h b/include/grub/net/efi.h new file mode 100644 -index 00000000000..de90d223e8e +index 0000000..de90d22 --- /dev/null +++ b/include/grub/net/efi.h @@ -0,0 +1,144 @@ @@ -5053,3 +4969,88 @@ index 00000000000..de90d223e8e +extern grub_command_func_t grub_efi_net_bootp6; + +#endif /* ! GRUB_NET_EFI_HEADER */ +diff --git a/util/grub-mknetdir.c b/util/grub-mknetdir.c +index 602574d..1a61e05 100644 +--- a/util/grub-mknetdir.c ++++ b/util/grub-mknetdir.c +@@ -32,13 +32,15 @@ + + static char *rootdir = NULL, *subdir = NULL; + static char *debug_image = NULL; ++static char efi_netfs = 0; + + enum + { + OPTION_NET_DIRECTORY = 0x301, + OPTION_SUBDIR, + OPTION_DEBUG, +- OPTION_DEBUG_IMAGE ++ OPTION_DEBUG_IMAGE, ++ OPTION_DEBUG_EFI_NETFS + }; + + static struct argp_option options[] = { +@@ -49,6 +51,7 @@ static struct argp_option options[] = { + 0, N_("relative subdirectory on network server"), 2}, + {"debug", OPTION_DEBUG, 0, OPTION_HIDDEN, 0, 2}, + {"debug-image", OPTION_DEBUG_IMAGE, N_("STRING"), OPTION_HIDDEN, 0, 2}, ++ {"debug-efi-netfs", OPTION_DEBUG_EFI_NETFS, 0, OPTION_HIDDEN, 0, 2}, + {0, 0, 0, 0, 0, 0} + }; + +@@ -67,6 +70,9 @@ argp_parser (int key, char *arg, struct argp_state *state) + free (subdir); + subdir = xstrdup (arg); + return 0; ++ case OPTION_DEBUG_EFI_NETFS: ++ efi_netfs = 1; ++ return 0; + /* This is an undocumented feature... */ + case OPTION_DEBUG: + verbosity++; +@@ -82,7 +88,6 @@ argp_parser (int key, char *arg, struct argp_state *state) + } + } + +- + struct argp argp = { + options, argp_parser, NULL, + "\v"N_("Prepares GRUB network boot images at net_directory/subdir " +@@ -92,7 +97,7 @@ struct argp argp = { + + static char *base; + +-static const struct ++static struct + { + const char *mkimage_target; + const char *netmodule; +@@ -156,6 +161,7 @@ process_input_dir (const char *input_dir, enum grub_install_plat platform) + grub_install_push_module (targets[platform].netmodule); + + output = grub_util_path_concat_ext (2, grubdir, "core", targets[platform].ext); ++ + grub_install_make_image_wrap (input_dir, prefix, output, + 0, load_cfg, + targets[platform].mkimage_target, 0); +@@ -192,7 +198,16 @@ main (int argc, char *argv[]) + + grub_install_mkdir_p (base); + +- grub_install_push_module ("tftp"); ++ if (!efi_netfs) ++ { ++ grub_install_push_module ("tftp"); ++ grub_install_push_module ("http"); ++ } ++ else ++ { ++ targets[GRUB_INSTALL_PLATFORM_I386_EFI].netmodule = "efi_netfs"; ++ targets[GRUB_INSTALL_PLATFORM_X86_64_EFI].netmodule = "efi_netfs"; ++ } + + if (!grub_install_source_directory) + { +-- +1.8.3.1 + diff --git a/0181-AUDIT-0-http-boot-tracker-bug.patch b/0120-AUDIT-0-http-boot-tracker-bug.patch similarity index 90% rename from 0181-AUDIT-0-http-boot-tracker-bug.patch rename to 0120-AUDIT-0-http-boot-tracker-bug.patch index 3d8d96b3e779670dae95ce19408e82ce10360c62..1bc19bcca6b1287dd69079e70cd4598151373deb 100644 --- a/0181-AUDIT-0-http-boot-tracker-bug.patch +++ b/0120-AUDIT-0-http-boot-tracker-bug.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From c5fa5fa521644d4f41ba0f436826d0b0345645b2 Mon Sep 17 00:00:00 2001 From: Sebastian Krahmer Date: Tue, 28 Nov 2017 17:24:38 +0800 -Subject: [PATCH] AUDIT-0: http boot tracker bug +Subject: [PATCH 120/220] AUDIT-0: http boot tracker bug Fixing a memory leak in case of error, and a integer overflow, leading to a heap overflow due to overly large chunk sizes. @@ -22,7 +22,7 @@ Signed-off-by: Michael Chang 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c -index 9e0078ac1c6..2bf15447fd5 100644 +index 86bce65..4bb3080 100644 --- a/grub-core/net/efi/net.c +++ b/grub-core/net/efi/net.c @@ -645,8 +645,10 @@ grub_efihttp_chunk_read (grub_file_t file, char *buf, @@ -38,7 +38,7 @@ index 9e0078ac1c6..2bf15447fd5 100644 if (buf) { diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index 00737c52750..c9c59690a98 100644 +index 00737c5..c9c5969 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c @@ -31,7 +31,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); @@ -60,3 +60,6 @@ index 00737c52750..c9c59690a98 100644 grub_errno = GRUB_ERR_NONE; if (data->chunk_rem == 0) { +-- +1.8.3.1 + diff --git a/0182-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch b/0121-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch similarity index 88% rename from 0182-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch rename to 0121-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch index 33cde3ba1074c72cc8d1222201faacd0eb147cb2..f12a3f7f517ed2841b6457f8bddb9fb93a55cf2e 100644 --- a/0182-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch +++ b/0121-grub-core-video-efi_gop.c-Add-support-for-BLT_ONLY-a.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From dc1adda5b575712665a1e5a4d2a86232e34748a8 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Wed, 1 Feb 2017 23:10:45 +0100 -Subject: [PATCH] grub-core/video/efi_gop.c: Add support for BLT_ONLY adapters +Subject: [PATCH 121/220] grub-core/video/efi_gop.c: Add support for BLT_ONLY + adapters EFI GOP has support for multiple different bitness types of frame buffers and for a special "BLT only" type which is always defined to be RGBx. @@ -21,7 +22,7 @@ Signed-off-by: Alexander Graf 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/video/efi_gop.c b/grub-core/video/efi_gop.c -index 7f9d1c2dfa1..c9e40e8d4e9 100644 +index 7f9d1c2..c9e40e8 100644 --- a/grub-core/video/efi_gop.c +++ b/grub-core/video/efi_gop.c @@ -121,6 +121,7 @@ grub_video_gop_get_bpp (struct grub_efi_gop_mode_info *in) @@ -41,7 +42,7 @@ index 7f9d1c2dfa1..c9e40e8d4e9 100644 out->red_field_pos = 0; out->green_mask_size = 8; diff --git a/include/grub/efi/graphics_output.h b/include/grub/efi/graphics_output.h -index 12977741192..e4388127c66 100644 +index 1297774..e438812 100644 --- a/include/grub/efi/graphics_output.h +++ b/include/grub/efi/graphics_output.h @@ -28,7 +28,8 @@ typedef enum @@ -54,3 +55,6 @@ index 12977741192..e4388127c66 100644 } grub_efi_gop_pixel_format_t; +-- +1.8.3.1 + diff --git a/0183-efi-uga-use-64-bit-for-fb_base.patch b/0122-efi-uga-use-64-bit-for-fb_base.patch similarity index 94% rename from 0183-efi-uga-use-64-bit-for-fb_base.patch rename to 0122-efi-uga-use-64-bit-for-fb_base.patch index bafcb648a7c922a050e6f1b2b2ba993654249d89..a08c153f176183e6ad211c3427e8f4adea1d7a0d 100644 --- a/0183-efi-uga-use-64-bit-for-fb_base.patch +++ b/0122-efi-uga-use-64-bit-for-fb_base.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 0cb697c89b068b6a130150fb5f980fd7e17da387 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 16 May 2018 13:06:04 -0400 -Subject: [PATCH] efi/uga: use 64 bit for fb_base +Subject: [PATCH 122/220] efi/uga: use 64 bit for fb_base We get 64 bit from PCI BAR but then truncate by assigning to 32 bit. Make sure to check that pointer does not overflow on 32 bit platform. @@ -12,7 +12,7 @@ Closes: 50931 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/grub-core/video/efi_uga.c b/grub-core/video/efi_uga.c -index 044af1d20d3..97a607c01a5 100644 +index 044af1d..97a607c 100644 --- a/grub-core/video/efi_uga.c +++ b/grub-core/video/efi_uga.c @@ -34,7 +34,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); @@ -103,3 +103,6 @@ index 044af1d20d3..97a607c01a5 100644 { struct find_framebuf_ctx ctx = { .fb_base = fb_base, +-- +1.8.3.1 + diff --git a/0184-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch b/0123-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch similarity index 96% rename from 0184-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch rename to 0123-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch index 20aadf6630c811c035917e6e37966240b3f69008..8040da5b4e40802c9217925f56dbd35a3c132c13 100644 --- a/0184-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch +++ b/0123-EFI-console-Do-not-set-text-mode-until-we-actually-n.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From de237e1a95e9526f500d7de8264a481a1cc0201a Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 6 Mar 2018 17:11:15 +0100 -Subject: [PATCH] EFI: console: Do not set text-mode until we actually need it +Subject: [PATCH 123/220] EFI: console: Do not set text-mode until we actually + need it If we're running with a hidden menu we may never need text mode, so do not change the video-mode to text until we actually need it. @@ -12,7 +13,7 @@ Signed-off-by: Hans de Goede 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c -index 4840cc59d3f..051633d71e9 100644 +index 4840cc5..051633d 100644 --- a/grub-core/term/efi/console.c +++ b/grub-core/term/efi/console.c @@ -24,6 +24,11 @@ @@ -182,3 +183,6 @@ index 4840cc59d3f..051633d71e9 100644 grub_term_register_output ("console", &grub_console_term_output); grub_term_register_input ("console", &grub_console_term_input); } +-- +1.8.3.1 + diff --git a/0185-EFI-console-Add-grub_console_read_key_stroke-helper-.patch b/0124-EFI-console-Add-grub_console_read_key_stroke-helper-.patch similarity index 83% rename from 0185-EFI-console-Add-grub_console_read_key_stroke-helper-.patch rename to 0124-EFI-console-Add-grub_console_read_key_stroke-helper-.patch index 6da36b26c6f9eed886ceb5fbd0dae795ae2a49dc..bbcb6c3fa7c8b01a0a6cb5cd619beb66a1a0084c 100644 --- a/0185-EFI-console-Add-grub_console_read_key_stroke-helper-.patch +++ b/0124-EFI-console-Add-grub_console_read_key_stroke-helper-.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 6662c908c594e9b6bd6d3b7102c56310002cc5af Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 6 Jun 2018 15:54:44 +0200 -Subject: [PATCH] EFI: console: Add grub_console_read_key_stroke() helper - function +Subject: [PATCH 124/220] EFI: console: Add grub_console_read_key_stroke() + helper function This is a preparation patch for adding getkeystatus() support to the EFI console terminal input driver. @@ -29,7 +29,7 @@ Signed-off-by: Hans de Goede 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c -index 051633d71e9..3d36c5c701b 100644 +index 051633d..3d36c5c 100644 --- a/grub-core/term/efi/console.c +++ b/grub-core/term/efi/console.c @@ -157,27 +157,56 @@ grub_console_getkey_con (struct grub_term_input *term __attribute__ ((unused))) @@ -41,28 +41,38 @@ index 051633d71e9..3d36c5c701b 100644 + * press from the queue, this function buffers the press for the regular + * getkey() so that it does not get lost. + */ -+static int + static int +-grub_console_getkey_ex(struct grub_term_input *term) +grub_console_read_key_stroke ( + grub_efi_simple_text_input_ex_interface_t *text_input, + grub_efi_key_data_t *key_data_ret, int *key_ret, + int consume) -+{ + { +- grub_efi_key_data_t key_data; + static grub_efi_key_data_t key_data; -+ grub_efi_status_t status; + grub_efi_status_t status; +- grub_efi_uint32_t kss; +- int key = -1; + int key; -+ + +- grub_efi_simple_text_input_ex_interface_t *text_input = term->data; + if (!text_input) + return GRUB_ERR_EOF; -+ + +- status = efi_call_2 (text_input->read_key_stroke, text_input, &key_data); + key = grub_efi_translate_key (key_data.key); + if (key == GRUB_TERM_NO_KEY) { + status = efi_call_2 (text_input->read_key_stroke, text_input, &key_data); + if (status != GRUB_EFI_SUCCESS) + return GRUB_ERR_EOF; -+ + +- if (status != GRUB_EFI_SUCCESS) +- return GRUB_TERM_NO_KEY; + key = grub_efi_translate_key (key_data.key); + } -+ + +- kss = key_data.key_state.key_shift_state; +- key = grub_efi_translate_key(key_data.key); + *key_data_ret = key_data; + *key_ret = key; + @@ -74,29 +84,22 @@ index 051633d71e9..3d36c5c701b 100644 + return 0; +} + - static int - grub_console_getkey_ex(struct grub_term_input *term) - { - grub_efi_key_data_t key_data; -- grub_efi_status_t status; - grub_efi_uint32_t kss; - int key = -1; ++static int ++grub_console_getkey_ex(struct grub_term_input *term) ++{ ++ grub_efi_key_data_t key_data; ++ grub_efi_uint32_t kss; ++ int key = -1; -- grub_efi_simple_text_input_ex_interface_t *text_input = term->data; -- -- status = efi_call_2 (text_input->read_key_stroke, text_input, &key_data); -- -- if (status != GRUB_EFI_SUCCESS) +- if (key == GRUB_TERM_NO_KEY) + if (grub_console_read_key_stroke (term->data, &key_data, &key, 1) || + key == GRUB_TERM_NO_KEY) return GRUB_TERM_NO_KEY; - kss = key_data.key_state.key_shift_state; -- key = grub_efi_translate_key(key_data.key); -- -- if (key == GRUB_TERM_NO_KEY) -- return GRUB_TERM_NO_KEY; -- ++ kss = key_data.key_state.key_shift_state; if (kss & GRUB_EFI_SHIFT_STATE_VALID) { if ((kss & GRUB_EFI_LEFT_SHIFT_PRESSED +-- +1.8.3.1 + diff --git a/0186-EFI-console-Implement-getkeystatus-support.patch b/0125-EFI-console-Implement-getkeystatus-support.patch similarity index 92% rename from 0186-EFI-console-Implement-getkeystatus-support.patch rename to 0125-EFI-console-Implement-getkeystatus-support.patch index 74fa2536745b8e6ad3e27bb95f9f66f31384f69a..3410681b0cbefee3a39babf63240def43c667dcd 100644 --- a/0186-EFI-console-Implement-getkeystatus-support.patch +++ b/0125-EFI-console-Implement-getkeystatus-support.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 05bea373a5f88292528ed2b2fef16448f0265771 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 6 Jun 2018 16:16:47 +0200 -Subject: [PATCH] EFI: console: Implement getkeystatus() support +Subject: [PATCH 125/220] EFI: console: Implement getkeystatus() support Implement getkeystatus() support. @@ -19,7 +19,7 @@ Signed-off-by: Hans de Goede 1 file changed, 34 insertions(+) diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c -index 3d36c5c701b..92dd4996bb7 100644 +index 3d36c5c..92dd499 100644 --- a/grub-core/term/efi/console.c +++ b/grub-core/term/efi/console.c @@ -223,6 +223,39 @@ grub_console_getkey_ex(struct grub_term_input *term) @@ -70,3 +70,6 @@ index 3d36c5c701b..92dd4996bb7 100644 .init = grub_efi_console_input_init, }; +-- +1.8.3.1 + diff --git a/0187-Make-grub_getkeystatus-helper-funtion-available-ever.patch b/0126-Make-grub_getkeystatus-helper-funtion-available-ever.patch similarity index 90% rename from 0187-Make-grub_getkeystatus-helper-funtion-available-ever.patch rename to 0126-Make-grub_getkeystatus-helper-funtion-available-ever.patch index 9840a5588401965dedfc18cd9707b9550dd6ed38..c49a7878c79c6268526f4bc8a3a89e9b62334695 100644 --- a/0187-Make-grub_getkeystatus-helper-funtion-available-ever.patch +++ b/0126-Make-grub_getkeystatus-helper-funtion-available-ever.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 493de1bf8d04c9129efd66e7134eef12f436aba4 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 6 Jun 2018 16:47:11 +0200 -Subject: [PATCH] Make grub_getkeystatus helper funtion available everywhere +Subject: [PATCH 126/220] Make grub_getkeystatus helper funtion available + everywhere Move the grub_getkeystatus helper function from grub-core/commands/keystatus.c to grub-core/kern/term.c @@ -16,7 +17,7 @@ Signed-off-by: Hans de Goede 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/grub-core/commands/keystatus.c b/grub-core/commands/keystatus.c -index 460cf4e7e50..ff3f5878163 100644 +index 460cf4e..ff3f587 100644 --- a/grub-core/commands/keystatus.c +++ b/grub-core/commands/keystatus.c @@ -35,24 +35,6 @@ static const struct grub_arg_option options[] = @@ -45,7 +46,7 @@ index 460cf4e7e50..ff3f5878163 100644 grub_cmd_keystatus (grub_extcmd_context_t ctxt, int argc __attribute__ ((unused)), diff --git a/grub-core/kern/term.c b/grub-core/kern/term.c -index 07720ee6746..93bd3378d18 100644 +index 07720ee..93bd337 100644 --- a/grub-core/kern/term.c +++ b/grub-core/kern/term.c @@ -120,6 +120,24 @@ grub_getkey (void) @@ -74,7 +75,7 @@ index 07720ee6746..93bd3378d18 100644 grub_refresh (void) { diff --git a/include/grub/term.h b/include/grub/term.h -index 8117e2a24da..c215133383f 100644 +index 8117e2a..c215133 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -327,6 +327,7 @@ grub_term_unregister_output (grub_term_output_t term) @@ -85,3 +86,6 @@ index 8117e2a24da..c215133383f 100644 void grub_cls (void); void EXPORT_FUNC(grub_refresh) (void); void grub_puts_terminal (const char *str, struct grub_term_output *term); +-- +1.8.3.1 + diff --git a/0188-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch b/0127-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch similarity index 91% rename from 0188-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch rename to 0127-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch index 2945fd62d9a14c646981d4a5e3bf9182dd7d01cf..d7516f914c8e4d9e291d144ed801f6a927095206 100644 --- a/0188-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch +++ b/0127-Accept-ESC-F8-and-holding-SHIFT-as-user-interrupt-ke.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From a4df3e0fa8fa0e188889883195e5b7830def4cd7 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 26 Mar 2018 16:15:53 +0200 -Subject: [PATCH] Accept ESC, F8 and holding SHIFT as user interrupt keys +Subject: [PATCH 127/220] Accept ESC, F8 and holding SHIFT as user interrupt + keys On some devices the ESC key is the hotkey to enter the BIOS/EFI setup screen, making it really hard to time pressing it right. Besides that @@ -28,7 +29,7 @@ Signed-off-by: Hans de Goede 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/sleep.c b/grub-core/commands/sleep.c -index e77e7900fac..a1370b710c9 100644 +index e77e790..a1370b7 100644 --- a/grub-core/commands/sleep.c +++ b/grub-core/commands/sleep.c @@ -55,7 +55,7 @@ grub_interruptible_millisleep (grub_uint32_t ms) @@ -41,7 +42,7 @@ index e77e7900fac..a1370b710c9 100644 return 0; diff --git a/grub-core/kern/term.c b/grub-core/kern/term.c -index 93bd3378d18..6cae4c23e7a 100644 +index 93bd337..6cae4c2 100644 --- a/grub-core/kern/term.c +++ b/grub-core/kern/term.c @@ -138,6 +138,22 @@ grub_getkeystatus (void) @@ -68,7 +69,7 @@ index 93bd3378d18..6cae4c23e7a 100644 grub_refresh (void) { diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index 5e2f5283d3d..6cb2a071490 100644 +index 783bde5..046a1fb 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -655,7 +655,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) @@ -81,7 +82,7 @@ index 5e2f5283d3d..6cb2a071490 100644 timeout = -1; break; diff --git a/include/grub/term.h b/include/grub/term.h -index c215133383f..2b079c29b80 100644 +index c215133..2b079c2 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -328,6 +328,7 @@ void grub_putcode (grub_uint32_t code, struct grub_term_output *term); @@ -92,3 +93,6 @@ index c215133383f..2b079c29b80 100644 void grub_cls (void); void EXPORT_FUNC(grub_refresh) (void); void grub_puts_terminal (const char *str, struct grub_term_output *term); +-- +1.8.3.1 + diff --git a/0128-Only-attempt-to-scan-different-BLS-directories-on-EF.patch b/0128-Only-attempt-to-scan-different-BLS-directories-on-EF.patch deleted file mode 100644 index 52a108532bf80a5d389543f091a2a334fe4d7726..0000000000000000000000000000000000000000 --- a/0128-Only-attempt-to-scan-different-BLS-directories-on-EF.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 3 Apr 2018 15:42:47 +0200 -Subject: [PATCH] Only attempt to scan different BLS directories on EFI - machines - -Current BLS support attempted to scan for BLS directories, but this only -makes sense on EFI, where BLS fragments are in /loader/$vendor/entries. - -For BIOS, only either the default /loader/entries path should be scanned -or the BLS directory defined in the blsdir GRUB 2 environment variable. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index e0b65534af4..e775c6b8794 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -676,8 +676,8 @@ static int find_entry (const char *filename, - const char *devid = grub_env_get ("boot"); - - grub_dprintf("blscfg", "%s got here\n", __func__); -- if (!grub_strcmp (filename, ".") || -- !grub_strcmp (filename, "..")) -+ if (filename && (!grub_strcmp (filename, ".") || -+ !grub_strcmp (filename, ".."))) - return 0; - - if (info->platform == PLATFORM_EFI && !grub_strcasecmp (filename, "boot")) -@@ -872,11 +872,10 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - info.platform = PLATFORM_EMU; - grub_dprintf ("blscfg", "scanning %s%s\n", GRUB_BOOT_DEVICE, - GRUB_BLS_CONFIG_PATH); -- r = fs->dir (dev, "/boot/loader/", -- find_entry, &info); -+ find_entry(NULL, NULL, &info); - #else - grub_dprintf ("blscfg", "scanning %s\n", GRUB_BLS_CONFIG_PATH); -- r = fs->dir (dev, "/", find_entry, &info); -+ find_entry(NULL, NULL, &info); - #endif - - finish: diff --git a/0189-grub-editenv-Add-incr-command-to-increment-integer-v.patch b/0128-grub-editenv-Add-incr-command-to-increment-integer-v.patch similarity index 89% rename from 0189-grub-editenv-Add-incr-command-to-increment-integer-v.patch rename to 0128-grub-editenv-Add-incr-command-to-increment-integer-v.patch index d83627400309694752d4391d5e203de9b27e17fa..7d1d531488add286b2d5db212761915410203611 100644 --- a/0189-grub-editenv-Add-incr-command-to-increment-integer-v.patch +++ b/0128-grub-editenv-Add-incr-command-to-increment-integer-v.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 379558c0a9affaef66eea173f58952e2848b654c Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 4 Jun 2018 19:49:47 +0200 -Subject: [PATCH] grub-editenv: Add "incr" command to increment integer value - env. variables +Subject: [PATCH 128/220] grub-editenv: Add "incr" command to increment integer + value env. variables To be able to automatically detect if the last boot was successful, We want to keep count of succesful / failed boots in some integer @@ -17,7 +17,7 @@ Signed-off-by: Hans de Goede 1 file changed, 50 insertions(+) diff --git a/util/grub-editenv.c b/util/grub-editenv.c -index 118e89fe57f..2918bb71cfe 100644 +index f3662c9..d848038 100644 --- a/util/grub-editenv.c +++ b/util/grub-editenv.c @@ -53,6 +53,9 @@ static struct argp_option options[] = { @@ -30,7 +30,7 @@ index 118e89fe57f..2918bb71cfe 100644 {0, 0, 0, OPTION_DOC, N_("Options:"), -1}, {"verbose", 'v', 0, 0, N_("print verbose messages."), 0}, -@@ -246,6 +249,51 @@ unset_variables (const char *name, int argc, char *argv[]) +@@ -247,6 +250,51 @@ unset_variables (const char *name, int argc, char *argv[]) grub_envblk_close (envblk); } @@ -82,7 +82,7 @@ index 118e89fe57f..2918bb71cfe 100644 int main (int argc, char *argv[]) { -@@ -285,6 +333,8 @@ main (int argc, char *argv[]) +@@ -286,6 +334,8 @@ main (int argc, char *argv[]) set_variables (filename, argc - curindex, argv + curindex); else if (strcmp (command, "unset") == 0) unset_variables (filename, argc - curindex, argv + curindex); @@ -91,3 +91,6 @@ index 118e89fe57f..2918bb71cfe 100644 else { char *program = xstrdup(program_name); +-- +1.8.3.1 + diff --git a/0190-Add-auto-hide-menu-support.patch b/0129-Add-auto-hide-menu-support.patch similarity index 84% rename from 0190-Add-auto-hide-menu-support.patch rename to 0129-Add-auto-hide-menu-support.patch index efbc9ebf204c7dec174a0996dce6178bccad6212..83ea2232963a109d7d8c7c2b421922932134659f 100644 --- a/0190-Add-auto-hide-menu-support.patch +++ b/0129-Add-auto-hide-menu-support.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 07f39734261c2c98ed3e0486558de362e7294d1f Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 6 Jun 2018 08:44:11 +0200 -Subject: [PATCH] Add auto-hide menu support +Subject: [PATCH 129/220] Add auto-hide menu support On single-os systems we do not want to show the menu, unless something went wrong with the previous boot, in which case the user may need the @@ -35,42 +35,36 @@ fastboot If set to "1" and the conditions for auto-hiding the menu https://git.launchpad.net/~ubuntu-core-dev/grub/+git/ubuntu/tree/debian/patches/quick_boot.patch Signed-off-by: Hans de Goede ---- -Changes in v2: --Drop shutdown_success tests, there is no meaningful way for systemd to set - this flag (by the time it knows all filesystems are unmounted or read-only --Drop fwsetup_once support, systemd already supports booting directly into - the fwsetup by doing "systemctl reboot --firmware" --- Makefile.util.def | 6 +++++ - util/grub.d/00_menu_auto_hide.in | 50 ++++++++++++++++++++++++++++++++++++++++ + util/grub.d/01_menu_auto_hide.in | 48 ++++++++++++++++++++++++++++++++++++++++ util/grub.d/30_os-prober.in | 18 +++++++++++++++ - 3 files changed, 74 insertions(+) - create mode 100644 util/grub.d/00_menu_auto_hide.in + 3 files changed, 72 insertions(+) + create mode 100644 util/grub.d/01_menu_auto_hide.in diff --git a/Makefile.util.def b/Makefile.util.def -index cbd661d6348..0fdfdd91fb0 100644 +index c13ca68..026b458 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -448,6 +448,12 @@ script = { - installdir = grubconf; +@@ -458,6 +458,12 @@ script = { }; -+script = { -+ name = '00_menu_auto_hide'; -+ common = util/grub.d/00_menu_auto_hide.in; + script = { ++ name = '01_menu_auto_hide'; ++ common = util/grub.d/01_menu_auto_hide.in; + installdir = grubconf; +}; + - script = { ++script = { name = '01_users'; common = util/grub.d/01_users.in; -diff --git a/util/grub.d/00_menu_auto_hide.in b/util/grub.d/00_menu_auto_hide.in + installdir = grubconf; +diff --git a/util/grub.d/01_menu_auto_hide.in b/util/grub.d/01_menu_auto_hide.in new file mode 100644 -index 00000000000..a10fe45bb2c +index 0000000..ad17587 --- /dev/null -+++ b/util/grub.d/00_menu_auto_hide.in -@@ -0,0 +1,50 @@ ++++ b/util/grub.d/01_menu_auto_hide.in +@@ -0,0 +1,48 @@ +#! /bin/sh + +# Disable / skip generating menu-auto-hide config parts on serial terminals @@ -92,21 +86,19 @@ index 00000000000..a10fe45bb2c +# Reset boot_indeterminate after a successful boot +if [ "\${boot_success}" = "1" ] ; then + set boot_indeterminate=0 -+ save_env boot_indeterminate +# Avoid boot_indeterminate causing the menu to be hidden more then once +elif [ "\${boot_indeterminate}" = "1" ]; then + set boot_indeterminate=2 -+ save_env boot_indeterminate +fi +set boot_success=0 -+save_env boot_success ++save_env boot_success boot_indeterminate + +if [ x\$feature_timeout_style = xy ] ; then + if [ "\${menu_show_once}" ]; then + unset menu_show_once + save_env menu_show_once + set timeout_style=menu -+ unset timeout ++ set timeout=60 + elif [ "\${menu_auto_hide}" -a "\${last_boot_ok}" = "1" ]; then + set orig_timeout_style=\${timeout_style} + set orig_timeout=\${timeout} @@ -122,7 +114,7 @@ index 00000000000..a10fe45bb2c +fi +EOF diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in -index 13a3a6bc752..ab634393a31 100644 +index 13a3a6b..ab63439 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -42,6 +42,7 @@ if [ -z "${OSPROBED}" ] ; then @@ -189,3 +181,6 @@ index 13a3a6bc752..ab634393a31 100644 +fi +EOF +fi +-- +1.8.3.1 + diff --git a/0129-Core-TPM-support.patch b/0129-Core-TPM-support.patch deleted file mode 100644 index 43ab68938ea4666b53e2a5b08c25dcbb68f97d8c..0000000000000000000000000000000000000000 --- a/0129-Core-TPM-support.patch +++ /dev/null @@ -1,786 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Tue, 14 Jul 2015 17:06:35 -0700 -Subject: [PATCH] Core TPM support - -Add support for performing basic TPM measurements. Right now this only -supports extending PCRs statically and only on UEFI and BIOS systems, but -will measure all modules as they're loaded. ---- - grub-core/Makefile.core.def | 3 + - grub-core/kern/dl.c | 3 + - grub-core/kern/efi/tpm.c | 282 +++++++++++++++++++++++++++++++++++++++++++ - grub-core/kern/i386/pc/tpm.c | 132 ++++++++++++++++++++ - grub-core/kern/tpm.c | 13 ++ - include/grub/efi/tpm.h | 153 +++++++++++++++++++++++ - include/grub/tpm.h | 91 ++++++++++++++ - grub-core/Makefile.am | 1 + - 8 files changed, 678 insertions(+) - create mode 100644 grub-core/kern/efi/tpm.c - create mode 100644 grub-core/kern/i386/pc/tpm.c - create mode 100644 grub-core/kern/tpm.c - create mode 100644 include/grub/efi/tpm.h - create mode 100644 include/grub/tpm.h - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index cb24f92a431..420831bc89e 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -131,6 +131,7 @@ kernel = { - common = kern/term.c; - common = kern/qsort.c; - common = kern/backtrace.c; -+ common = kern/tpm.c; - - x86 = kern/i386/backtrace.c; - i386_xen = kern/i386/backtrace.c; -@@ -199,6 +200,7 @@ kernel = { - efi = kern/acpi.c; - efi = kern/efi/acpi.c; - efi = lib/envblk.c; -+ efi = kern/efi/tpm.c; - i386_coreboot = kern/i386/pc/acpi.c; - i386_multiboot = kern/i386/pc/acpi.c; - i386_coreboot = kern/acpi.c; -@@ -245,6 +247,7 @@ kernel = { - - i386_pc = kern/i386/pc/init.c; - i386_pc = kern/i386/pc/mmap.c; -+ i386_pc = kern/i386/pc/tpm.c; - i386_pc = term/i386/pc/console.c; - - i386_qemu = bus/pci.c; -diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index eb8b969cded..387d1e6446d 100644 ---- a/grub-core/kern/dl.c -+++ b/grub-core/kern/dl.c -@@ -33,6 +33,7 @@ - #include - #include - #include -+#include - - /* Platforms where modules are in a readonly area of memory. */ - #if defined(GRUB_MACHINE_QEMU) -@@ -829,6 +830,8 @@ grub_dl_load_file (const char *filename) - opens of the same device. */ - grub_file_close (file); - -+ grub_tpm_measure(core, size, GRUB_TPM_PCR, filename); -+ - mod = grub_dl_load_core (core, size); - grub_free (core); - if (! mod) -diff --git a/grub-core/kern/efi/tpm.c b/grub-core/kern/efi/tpm.c -new file mode 100644 -index 00000000000..c9fb3c133f3 ---- /dev/null -+++ b/grub-core/kern/efi/tpm.c -@@ -0,0 +1,282 @@ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+static grub_efi_guid_t tpm_guid = EFI_TPM_GUID; -+static grub_efi_guid_t tpm2_guid = EFI_TPM2_GUID; -+ -+static grub_efi_boolean_t grub_tpm_present(grub_efi_tpm_protocol_t *tpm) -+{ -+ grub_efi_status_t status; -+ TCG_EFI_BOOT_SERVICE_CAPABILITY caps; -+ grub_uint32_t flags; -+ grub_efi_physical_address_t eventlog, lastevent; -+ -+ caps.Size = (grub_uint8_t)sizeof(caps); -+ -+ status = efi_call_5(tpm->status_check, tpm, &caps, &flags, &eventlog, -+ &lastevent); -+ -+ if (status != GRUB_EFI_SUCCESS || caps.TPMDeactivatedFlag -+ || !caps.TPMPresentFlag) -+ return 0; -+ -+ return 1; -+} -+ -+static grub_efi_boolean_t grub_tpm2_present(grub_efi_tpm2_protocol_t *tpm) -+{ -+ grub_efi_status_t status; -+ EFI_TCG2_BOOT_SERVICE_CAPABILITY caps; -+ -+ caps.Size = (grub_uint8_t)sizeof(caps); -+ -+ status = efi_call_2(tpm->get_capability, tpm, &caps); -+ -+ if (status != GRUB_EFI_SUCCESS || !caps.TPMPresentFlag) -+ return 0; -+ -+ return 1; -+} -+ -+static grub_efi_boolean_t grub_tpm_handle_find(grub_efi_handle_t *tpm_handle, -+ grub_efi_uint8_t *protocol_version) -+{ -+ grub_efi_handle_t *handles; -+ grub_efi_uintn_t num_handles; -+ -+ handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &tpm_guid, NULL, -+ &num_handles); -+ if (handles && num_handles > 0) { -+ *tpm_handle = handles[0]; -+ *protocol_version = 1; -+ return 1; -+ } -+ -+ handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &tpm2_guid, NULL, -+ &num_handles); -+ if (handles && num_handles > 0) { -+ *tpm_handle = handles[0]; -+ *protocol_version = 2; -+ return 1; -+ } -+ -+ return 0; -+} -+ -+static grub_err_t -+grub_tpm1_execute(grub_efi_handle_t tpm_handle, -+ PassThroughToTPM_InputParamBlock *inbuf, -+ PassThroughToTPM_OutputParamBlock *outbuf) -+{ -+ grub_efi_status_t status; -+ grub_efi_tpm_protocol_t *tpm; -+ grub_uint32_t inhdrsize = sizeof(*inbuf) - sizeof(inbuf->TPMOperandIn); -+ grub_uint32_t outhdrsize = sizeof(*outbuf) - sizeof(outbuf->TPMOperandOut); -+ -+ tpm = grub_efi_open_protocol (tpm_handle, &tpm_guid, -+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); -+ -+ if (!grub_tpm_present(tpm)) -+ return 0; -+ -+ /* UEFI TPM protocol takes the raw operand block, no param block header */ -+ status = efi_call_5 (tpm->pass_through_to_tpm, tpm, -+ inbuf->IPBLength - inhdrsize, inbuf->TPMOperandIn, -+ outbuf->OPBLength - outhdrsize, outbuf->TPMOperandOut); -+ -+ switch (status) { -+ case GRUB_EFI_SUCCESS: -+ return 0; -+ case GRUB_EFI_DEVICE_ERROR: -+ return grub_error (GRUB_ERR_IO, N_("Command failed")); -+ case GRUB_EFI_INVALID_PARAMETER: -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter")); -+ case GRUB_EFI_BUFFER_TOO_SMALL: -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Output buffer too small")); -+ case GRUB_EFI_NOT_FOUND: -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable")); -+ default: -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error")); -+ } -+} -+ -+static grub_err_t -+grub_tpm2_execute(grub_efi_handle_t tpm_handle, -+ PassThroughToTPM_InputParamBlock *inbuf, -+ PassThroughToTPM_OutputParamBlock *outbuf) -+{ -+ grub_efi_status_t status; -+ grub_efi_tpm2_protocol_t *tpm; -+ grub_uint32_t inhdrsize = sizeof(*inbuf) - sizeof(inbuf->TPMOperandIn); -+ grub_uint32_t outhdrsize = sizeof(*outbuf) - sizeof(outbuf->TPMOperandOut); -+ -+ tpm = grub_efi_open_protocol (tpm_handle, &tpm2_guid, -+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); -+ -+ if (!grub_tpm2_present(tpm)) -+ return 0; -+ -+ /* UEFI TPM protocol takes the raw operand block, no param block header */ -+ status = efi_call_5 (tpm->submit_command, tpm, -+ inbuf->IPBLength - inhdrsize, inbuf->TPMOperandIn, -+ outbuf->OPBLength - outhdrsize, outbuf->TPMOperandOut); -+ -+ switch (status) { -+ case GRUB_EFI_SUCCESS: -+ return 0; -+ case GRUB_EFI_DEVICE_ERROR: -+ return grub_error (GRUB_ERR_IO, N_("Command failed")); -+ case GRUB_EFI_INVALID_PARAMETER: -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter")); -+ case GRUB_EFI_BUFFER_TOO_SMALL: -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Output buffer too small")); -+ case GRUB_EFI_NOT_FOUND: -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable")); -+ default: -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error")); -+ } -+} -+ -+grub_err_t -+grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, -+ PassThroughToTPM_OutputParamBlock *outbuf) -+{ -+ grub_efi_handle_t tpm_handle; -+ grub_uint8_t protocol_version; -+ -+ /* It's not a hard failure for there to be no TPM */ -+ if (!grub_tpm_handle_find(&tpm_handle, &protocol_version)) -+ return 0; -+ -+ if (protocol_version == 1) { -+ return grub_tpm1_execute(tpm_handle, inbuf, outbuf); -+ } else { -+ return grub_tpm2_execute(tpm_handle, inbuf, outbuf); -+ } -+} -+ -+typedef struct { -+ grub_uint32_t pcrindex; -+ grub_uint32_t eventtype; -+ grub_uint8_t digest[20]; -+ grub_uint32_t eventsize; -+ grub_uint8_t event[1]; -+} Event; -+ -+ -+static grub_err_t -+grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf, -+ grub_size_t size, grub_uint8_t pcr, -+ const char *description) -+{ -+ Event *event; -+ grub_efi_status_t status; -+ grub_efi_tpm_protocol_t *tpm; -+ grub_efi_physical_address_t lastevent; -+ grub_uint32_t algorithm; -+ grub_uint32_t eventnum = 0; -+ -+ tpm = grub_efi_open_protocol (tpm_handle, &tpm_guid, -+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); -+ -+ if (!grub_tpm_present(tpm)) -+ return 0; -+ -+ event = grub_zalloc(sizeof (Event) + grub_strlen(description) + 1); -+ if (!event) -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ N_("cannot allocate TPM event buffer")); -+ -+ event->pcrindex = pcr; -+ event->eventtype = EV_IPL; -+ event->eventsize = grub_strlen(description) + 1; -+ grub_memcpy(event->event, description, event->eventsize); -+ -+ algorithm = TCG_ALG_SHA; -+ status = efi_call_7 (tpm->log_extend_event, tpm, buf, (grub_uint64_t) size, -+ algorithm, event, &eventnum, &lastevent); -+ -+ switch (status) { -+ case GRUB_EFI_SUCCESS: -+ return 0; -+ case GRUB_EFI_DEVICE_ERROR: -+ return grub_error (GRUB_ERR_IO, N_("Command failed")); -+ case GRUB_EFI_INVALID_PARAMETER: -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter")); -+ case GRUB_EFI_BUFFER_TOO_SMALL: -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Output buffer too small")); -+ case GRUB_EFI_NOT_FOUND: -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable")); -+ default: -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error")); -+ } -+} -+ -+static grub_err_t -+grub_tpm2_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf, -+ grub_size_t size, grub_uint8_t pcr, -+ const char *description) -+{ -+ EFI_TCG2_EVENT *event; -+ grub_efi_status_t status; -+ grub_efi_tpm2_protocol_t *tpm; -+ -+ tpm = grub_efi_open_protocol (tpm_handle, &tpm2_guid, -+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); -+ -+ if (!grub_tpm2_present(tpm)) -+ return 0; -+ -+ event = grub_zalloc(sizeof (EFI_TCG2_EVENT) + grub_strlen(description) + 1); -+ if (!event) -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ N_("cannot allocate TPM event buffer")); -+ -+ event->Header.HeaderSize = sizeof(EFI_TCG2_EVENT_HEADER); -+ event->Header.HeaderVersion = 1; -+ event->Header.PCRIndex = pcr; -+ event->Header.EventType = EV_IPL; -+ event->Size = sizeof(*event) - sizeof(event->Event) + grub_strlen(description) + 1; -+ grub_memcpy(event->Event, description, grub_strlen(description) + 1); -+ -+ status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, buf, -+ (grub_uint64_t) size, event); -+ -+ switch (status) { -+ case GRUB_EFI_SUCCESS: -+ return 0; -+ case GRUB_EFI_DEVICE_ERROR: -+ return grub_error (GRUB_ERR_IO, N_("Command failed")); -+ case GRUB_EFI_INVALID_PARAMETER: -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter")); -+ case GRUB_EFI_BUFFER_TOO_SMALL: -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Output buffer too small")); -+ case GRUB_EFI_NOT_FOUND: -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable")); -+ default: -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error")); -+ } -+} -+ -+grub_err_t -+grub_tpm_log_event(unsigned char *buf, grub_size_t size, grub_uint8_t pcr, -+ const char *description) -+{ -+ grub_efi_handle_t tpm_handle; -+ grub_efi_uint8_t protocol_version; -+ -+ if (!grub_tpm_handle_find(&tpm_handle, &protocol_version)) -+ return 0; -+ -+ if (protocol_version == 1) { -+ return grub_tpm1_log_event(tpm_handle, buf, size, pcr, description); -+ } else { -+ return grub_tpm2_log_event(tpm_handle, buf, size, pcr, description); -+ } -+} -diff --git a/grub-core/kern/i386/pc/tpm.c b/grub-core/kern/i386/pc/tpm.c -new file mode 100644 -index 00000000000..8c6c1e6ece2 ---- /dev/null -+++ b/grub-core/kern/i386/pc/tpm.c -@@ -0,0 +1,132 @@ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define TCPA_MAGIC 0x41504354 -+ -+int tpm_present(void); -+ -+int tpm_present(void) -+{ -+ struct grub_bios_int_registers regs; -+ -+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; -+ regs.eax = 0xbb00; -+ regs.ebx = TCPA_MAGIC; -+ grub_bios_interrupt (0x1a, ®s); -+ -+ if (regs.eax == 0) -+ return 1; -+ -+ return 0; -+} -+ -+grub_err_t -+grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, -+ PassThroughToTPM_OutputParamBlock *outbuf) -+{ -+ struct grub_bios_int_registers regs; -+ grub_addr_t inaddr, outaddr; -+ -+ if (!tpm_present()) -+ return 0; -+ -+ inaddr = (grub_addr_t) inbuf; -+ outaddr = (grub_addr_t) outbuf; -+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; -+ regs.eax = 0xbb02; -+ regs.ebx = TCPA_MAGIC; -+ regs.ecx = 0; -+ regs.edx = 0; -+ regs.es = (inaddr & 0xffff0000) >> 4; -+ regs.edi = inaddr & 0xffff; -+ regs.ds = outaddr >> 4; -+ regs.esi = outaddr & 0xf; -+ -+ grub_bios_interrupt (0x1a, ®s); -+ -+ if (regs.eax) -+ return grub_error (GRUB_ERR_IO, N_("TPM error %x\n"), regs.eax); -+ -+ return 0; -+} -+ -+typedef struct { -+ grub_uint32_t pcrindex; -+ grub_uint32_t eventtype; -+ grub_uint8_t digest[20]; -+ grub_uint32_t eventdatasize; -+ grub_uint8_t event[0]; -+} GRUB_PACKED Event; -+ -+typedef struct { -+ grub_uint16_t ipblength; -+ grub_uint16_t reserved; -+ grub_uint32_t hashdataptr; -+ grub_uint32_t hashdatalen; -+ grub_uint32_t pcr; -+ grub_uint32_t reserved2; -+ grub_uint32_t logdataptr; -+ grub_uint32_t logdatalen; -+} GRUB_PACKED EventIncoming; -+ -+typedef struct { -+ grub_uint16_t opblength; -+ grub_uint16_t reserved; -+ grub_uint32_t eventnum; -+ grub_uint8_t hashvalue[20]; -+} GRUB_PACKED EventOutgoing; -+ -+grub_err_t -+grub_tpm_log_event(unsigned char *buf, grub_size_t size, grub_uint8_t pcr, -+ const char *description) -+{ -+ struct grub_bios_int_registers regs; -+ EventIncoming incoming; -+ EventOutgoing outgoing; -+ Event *event; -+ grub_uint32_t datalength; -+ -+ if (!tpm_present()) -+ return 0; -+ -+ datalength = grub_strlen(description); -+ event = grub_zalloc(datalength + sizeof(Event)); -+ if (!event) -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ N_("cannot allocate TPM event buffer")); -+ -+ event->pcrindex = pcr; -+ event->eventtype = 0x0d; -+ event->eventdatasize = grub_strlen(description); -+ grub_memcpy(event->event, description, datalength); -+ -+ incoming.ipblength = sizeof(incoming); -+ incoming.hashdataptr = (grub_uint32_t)buf; -+ incoming.hashdatalen = size; -+ incoming.pcr = pcr; -+ incoming.logdataptr = (grub_uint32_t)event; -+ incoming.logdatalen = datalength + sizeof(Event); -+ -+ regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; -+ regs.eax = 0xbb01; -+ regs.ebx = TCPA_MAGIC; -+ regs.ecx = 0; -+ regs.edx = 0; -+ regs.es = (((grub_addr_t) &incoming) & 0xffff0000) >> 4; -+ regs.edi = ((grub_addr_t) &incoming) & 0xffff; -+ regs.ds = (((grub_addr_t) &outgoing) & 0xffff0000) >> 4; -+ regs.esi = ((grub_addr_t) &outgoing) & 0xffff; -+ -+ grub_bios_interrupt (0x1a, ®s); -+ -+ grub_free(event); -+ -+ if (regs.eax) -+ return grub_error (GRUB_ERR_IO, N_("TPM error %x\n"), regs.eax); -+ -+ return 0; -+} -diff --git a/grub-core/kern/tpm.c b/grub-core/kern/tpm.c -new file mode 100644 -index 00000000000..1a991876c83 ---- /dev/null -+++ b/grub-core/kern/tpm.c -@@ -0,0 +1,13 @@ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+grub_err_t -+grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, -+ const char *description) -+{ -+ return grub_tpm_log_event(buf, size, pcr, description); -+} -diff --git a/include/grub/efi/tpm.h b/include/grub/efi/tpm.h -new file mode 100644 -index 00000000000..e2aff4a3c22 ---- /dev/null -+++ b/include/grub/efi/tpm.h -@@ -0,0 +1,153 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2015 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#ifndef GRUB_EFI_TPM_HEADER -+#define GRUB_EFI_TPM_HEADER 1 -+ -+#define EFI_TPM_GUID {0xf541796d, 0xa62e, 0x4954, {0xa7, 0x75, 0x95, 0x84, 0xf6, 0x1b, 0x9c, 0xdd }}; -+#define EFI_TPM2_GUID {0x607f766c, 0x7455, 0x42be, {0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f }}; -+ -+typedef struct { -+ grub_efi_uint8_t Major; -+ grub_efi_uint8_t Minor; -+ grub_efi_uint8_t RevMajor; -+ grub_efi_uint8_t RevMinor; -+} TCG_VERSION; -+ -+typedef struct _TCG_EFI_BOOT_SERVICE_CAPABILITY { -+ grub_efi_uint8_t Size; /// Size of this structure. -+ TCG_VERSION StructureVersion; -+ TCG_VERSION ProtocolSpecVersion; -+ grub_efi_uint8_t HashAlgorithmBitmap; /// Hash algorithms . -+ char TPMPresentFlag; /// 00h = TPM not present. -+ char TPMDeactivatedFlag; /// 01h = TPM currently deactivated. -+} TCG_EFI_BOOT_SERVICE_CAPABILITY; -+ -+typedef struct { -+ grub_efi_uint32_t PCRIndex; -+ grub_efi_uint32_t EventType; -+ grub_efi_uint8_t digest[20]; -+ grub_efi_uint32_t EventSize; -+ grub_efi_uint8_t Event[1]; -+} TCG_PCR_EVENT; -+ -+struct grub_efi_tpm_protocol -+{ -+ grub_efi_status_t (*status_check) (struct grub_efi_tpm_protocol *this, -+ TCG_EFI_BOOT_SERVICE_CAPABILITY *ProtocolCapability, -+ grub_efi_uint32_t *TCGFeatureFlags, -+ grub_efi_physical_address_t *EventLogLocation, -+ grub_efi_physical_address_t *EventLogLastEntry); -+ grub_efi_status_t (*hash_all) (struct grub_efi_tpm_protocol *this, -+ grub_efi_uint8_t *HashData, -+ grub_efi_uint64_t HashLen, -+ grub_efi_uint32_t AlgorithmId, -+ grub_efi_uint64_t *HashedDataLen, -+ grub_efi_uint8_t **HashedDataResult); -+ grub_efi_status_t (*log_event) (struct grub_efi_tpm_protocol *this, -+ TCG_PCR_EVENT *TCGLogData, -+ grub_efi_uint32_t *EventNumber, -+ grub_efi_uint32_t Flags); -+ grub_efi_status_t (*pass_through_to_tpm) (struct grub_efi_tpm_protocol *this, -+ grub_efi_uint32_t TpmInputParameterBlockSize, -+ grub_efi_uint8_t *TpmInputParameterBlock, -+ grub_efi_uint32_t TpmOutputParameterBlockSize, -+ grub_efi_uint8_t *TpmOutputParameterBlock); -+ grub_efi_status_t (*log_extend_event) (struct grub_efi_tpm_protocol *this, -+ grub_efi_physical_address_t HashData, -+ grub_efi_uint64_t HashDataLen, -+ grub_efi_uint32_t AlgorithmId, -+ TCG_PCR_EVENT *TCGLogData, -+ grub_efi_uint32_t *EventNumber, -+ grub_efi_physical_address_t *EventLogLastEntry); -+}; -+ -+typedef struct grub_efi_tpm_protocol grub_efi_tpm_protocol_t; -+ -+typedef grub_efi_uint32_t EFI_TCG2_EVENT_LOG_BITMAP; -+typedef grub_efi_uint32_t EFI_TCG2_EVENT_LOG_FORMAT; -+typedef grub_efi_uint32_t EFI_TCG2_EVENT_ALGORITHM_BITMAP; -+ -+typedef struct tdEFI_TCG2_VERSION { -+ grub_efi_uint8_t Major; -+ grub_efi_uint8_t Minor; -+} GRUB_PACKED EFI_TCG2_VERSION; -+ -+typedef struct tdEFI_TCG2_BOOT_SERVICE_CAPABILITY { -+ grub_efi_uint8_t Size; -+ EFI_TCG2_VERSION StructureVersion; -+ EFI_TCG2_VERSION ProtocolVersion; -+ EFI_TCG2_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap; -+ EFI_TCG2_EVENT_LOG_BITMAP SupportedEventLogs; -+ grub_efi_boolean_t TPMPresentFlag; -+ grub_efi_uint16_t MaxCommandSize; -+ grub_efi_uint16_t MaxResponseSize; -+ grub_efi_uint32_t ManufacturerID; -+ grub_efi_uint32_t NumberOfPcrBanks; -+ EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks; -+} EFI_TCG2_BOOT_SERVICE_CAPABILITY; -+ -+typedef grub_efi_uint32_t TCG_PCRINDEX; -+typedef grub_efi_uint32_t TCG_EVENTTYPE; -+ -+typedef struct tdEFI_TCG2_EVENT_HEADER { -+ grub_efi_uint32_t HeaderSize; -+ grub_efi_uint16_t HeaderVersion; -+ TCG_PCRINDEX PCRIndex; -+ TCG_EVENTTYPE EventType; -+} GRUB_PACKED EFI_TCG2_EVENT_HEADER; -+ -+typedef struct tdEFI_TCG2_EVENT { -+ grub_efi_uint32_t Size; -+ EFI_TCG2_EVENT_HEADER Header; -+ grub_efi_uint8_t Event[1]; -+} GRUB_PACKED EFI_TCG2_EVENT; -+ -+struct grub_efi_tpm2_protocol -+{ -+ grub_efi_status_t (*get_capability) (struct grub_efi_tpm2_protocol *this, -+ EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability); -+ grub_efi_status_t (*get_event_log) (struct grub_efi_tpm2_protocol *this, -+ EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat, -+ grub_efi_physical_address_t *EventLogLocation, -+ grub_efi_physical_address_t *EventLogLastEntry, -+ grub_efi_boolean_t *EventLogTruncated); -+ grub_efi_status_t (*hash_log_extend_event) (struct grub_efi_tpm2_protocol *this, -+ grub_efi_uint64_t Flags, -+ grub_efi_physical_address_t *DataToHash, -+ grub_efi_uint64_t DataToHashLen, -+ EFI_TCG2_EVENT *EfiTcgEvent); -+ grub_efi_status_t (*submit_command) (struct grub_efi_tpm2_protocol *this, -+ grub_efi_uint32_t InputParameterBlockSize, -+ grub_efi_uint8_t *InputParameterBlock, -+ grub_efi_uint32_t OutputParameterBlockSize, -+ grub_efi_uint8_t *OutputParameterBlock); -+ grub_efi_status_t (*get_active_pcr_blanks) (struct grub_efi_tpm2_protocol *this, -+ grub_efi_uint32_t *ActivePcrBanks); -+ grub_efi_status_t (*set_active_pcr_banks) (struct grub_efi_tpm2_protocol *this, -+ grub_efi_uint32_t ActivePcrBanks); -+ grub_efi_status_t (*get_result_of_set_active_pcr_banks) (struct grub_efi_tpm2_protocol *this, -+ grub_efi_uint32_t *OperationPresent, -+ grub_efi_uint32_t *Response); -+}; -+ -+typedef struct grub_efi_tpm2_protocol grub_efi_tpm2_protocol_t; -+ -+#define TCG_ALG_SHA 0x00000004 -+ -+#endif -diff --git a/include/grub/tpm.h b/include/grub/tpm.h -new file mode 100644 -index 00000000000..40d3cf65ba6 ---- /dev/null -+++ b/include/grub/tpm.h -@@ -0,0 +1,91 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2015 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#ifndef GRUB_TPM_HEADER -+#define GRUB_TPM_HEADER 1 -+ -+#define SHA1_DIGEST_SIZE 20 -+ -+#define TPM_BASE 0x0 -+#define TPM_SUCCESS TPM_BASE -+#define TPM_AUTHFAIL (TPM_BASE + 0x1) -+#define TPM_BADINDEX (TPM_BASE + 0x2) -+ -+#define GRUB_TPM_PCR 9 -+#define GRUB_KERNEL_PCR 10 -+#define GRUB_INITRD_PCR 11 -+#define GRUB_CMDLINE_PCR 12 -+ -+#define TPM_TAG_RQU_COMMAND 0x00C1 -+#define TPM_ORD_Extend 0x14 -+ -+#define EV_IPL 0x0d -+ -+/* TCG_PassThroughToTPM Input Parameter Block */ -+typedef struct { -+ grub_uint16_t IPBLength; -+ grub_uint16_t Reserved1; -+ grub_uint16_t OPBLength; -+ grub_uint16_t Reserved2; -+ grub_uint8_t TPMOperandIn[1]; -+} GRUB_PACKED PassThroughToTPM_InputParamBlock; -+ -+/* TCG_PassThroughToTPM Output Parameter Block */ -+typedef struct { -+ grub_uint16_t OPBLength; -+ grub_uint16_t Reserved; -+ grub_uint8_t TPMOperandOut[1]; -+} GRUB_PACKED PassThroughToTPM_OutputParamBlock; -+ -+typedef struct { -+ grub_uint16_t tag; -+ grub_uint32_t paramSize; -+ grub_uint32_t ordinal; -+ grub_uint32_t pcrNum; -+ grub_uint8_t inDigest[SHA1_DIGEST_SIZE]; /* The 160 bit value representing the event to be recorded. */ -+} GRUB_PACKED ExtendIncoming; -+ -+/* TPM_Extend Outgoing Operand */ -+typedef struct { -+ grub_uint16_t tag; -+ grub_uint32_t paramSize; -+ grub_uint32_t returnCode; -+ grub_uint8_t outDigest[SHA1_DIGEST_SIZE]; /* The PCR value after execution of the command. */ -+} GRUB_PACKED ExtendOutgoing; -+ -+grub_err_t EXPORT_FUNC(grub_tpm_measure) (unsigned char *buf, grub_size_t size, -+ grub_uint8_t pcr, -+ const char *description); -+#if defined (GRUB_MACHINE_EFI) || defined (GRUB_MACHINE_PCBIOS) -+grub_err_t grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, -+ PassThroughToTPM_OutputParamBlock *outbuf); -+grub_err_t grub_tpm_log_event(unsigned char *buf, grub_size_t size, -+ grub_uint8_t pcr, const char *description); -+#else -+static inline grub_err_t grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, -+ PassThroughToTPM_OutputParamBlock *outbuf) { return 0; }; -+static inline grub_err_t grub_tpm_log_event(unsigned char *buf, -+ grub_size_t size, -+ grub_uint8_t pcr, -+ const char *description) -+{ -+ return 0; -+}; -+#endif -+ -+#endif -diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am -index f36200bd688..3781bb9cbb9 100644 ---- a/grub-core/Makefile.am -+++ b/grub-core/Makefile.am -@@ -94,6 +94,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/tpm.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h - - if COND_i386_pc diff --git a/0130-Measure-kernel-initrd.patch b/0130-Measure-kernel-initrd.patch deleted file mode 100644 index ff1f10b50fc606757ace64b6968c82bffc5414a3..0000000000000000000000000000000000000000 --- a/0130-Measure-kernel-initrd.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Thu, 16 Jul 2015 15:22:34 -0700 -Subject: [PATCH] Measure kernel + initrd - -Measure the kernel and initrd when loaded on UEFI systems ---- - grub-core/loader/i386/efi/linux.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 800c3e54022..d837249b4a1 100644 ---- a/grub-core/loader/i386/efi/linux.c -+++ b/grub-core/loader/i386/efi/linux.c -@@ -27,6 +27,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -131,6 +132,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - argv[i]); - goto fail; - } -+ grub_tpm_measure (ptr, cursize, GRUB_INITRD_PCR, "UEFI Linux initrd"); - ptr += cursize; - grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); - ptr += ALIGN_UP_OVERHEAD (cursize, 4); -@@ -195,6 +197,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -+ grub_tpm_measure (kernel, filelen, GRUB_KERNEL_PCR, "UEFI Linux kernel"); -+ - rc = grub_linuxefi_secure_validate (kernel, filelen); - if (rc < 0) - { diff --git a/0191-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch b/0130-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch similarity index 86% rename from 0191-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch rename to 0130-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch index 4daefdbf681190c78e87c3e34218d8956297e678..2b3fb8190e7f4c5550a1aab3230180e6cb43d27e 100644 --- a/0191-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch +++ b/0130-Output-a-menu-entry-for-firmware-setup-on-UEFI-FastB.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From ebd3c8a460e55ac9507f1c690d49b6919cf908ad Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Mon, 13 Jan 2014 12:13:12 +0000 -Subject: [PATCH] Output a menu entry for firmware setup on UEFI FastBoot - systems +Subject: [PATCH 130/220] Output a menu entry for firmware setup on UEFI + FastBoot systems If fastboot is enabled in the BIOS then often it is not possible to enter the firmware setup menu, add a menu entry for this. @@ -15,6 +15,7 @@ According to: https://git.launchpad.net/~ubuntu-core-dev/grub/+git/ubuntu/tree/debian/copyright The patch is licensed under GPL-3+ +[hdegoede: fix use with /sys/firmware/efi/efivars] Signed-off-by: Hans de Goede --- Makefile.util.def | 6 ++++++ @@ -23,25 +24,25 @@ Signed-off-by: Hans de Goede create mode 100644 util/grub.d/30_uefi-firmware.in diff --git a/Makefile.util.def b/Makefile.util.def -index 0fdfdd91fb0..5a8c390a1da 100644 +index 026b458..89a9da1 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -529,6 +529,12 @@ script = { - installdir = grubconf; +@@ -546,6 +546,12 @@ script = { }; -+script = { + script = { + name = '30_uefi-firmware'; + common = util/grub.d/30_uefi-firmware.in; + installdir = grubconf; +}; + - script = { ++script = { name = '40_custom'; common = util/grub.d/40_custom.in; + installdir = grubconf; diff --git a/util/grub.d/30_uefi-firmware.in b/util/grub.d/30_uefi-firmware.in new file mode 100644 -index 00000000000..3c9f533d8c6 +index 0000000..93ececf --- /dev/null +++ b/util/grub.d/30_uefi-firmware.in @@ -0,0 +1,46 @@ @@ -73,12 +74,12 @@ index 00000000000..3c9f533d8c6 + +. "@datadir@/@PACKAGE@/grub-mkconfig_lib" + -+efi_vars_dir=/sys/firmware/efi/vars ++efi_vars_dir=/sys/firmware/efi/efivars +EFI_GLOBAL_VARIABLE=8be4df61-93ca-11d2-aa0d-00e098032b8c -+OsIndications="$efi_vars_dir/OsIndicationsSupported-$EFI_GLOBAL_VARIABLE/data" ++OsIndications="$efi_vars_dir/OsIndicationsSupported-$EFI_GLOBAL_VARIABLE" + +if [ -e "$OsIndications" ] && \ -+ [ "$(( $(printf 0x%x \'"$(cat $OsIndications | cut -b1)") & 1 ))" = 1 ]; then ++ [ "$(( $(printf 0x%x \'"$(cat $OsIndications | cut -b5)") & 1 ))" = 1 ]; then + LABEL="System setup" + + gettext_printf "Adding boot menu entry for EFI firmware configuration\n" >&2 @@ -91,3 +92,6 @@ index 00000000000..3c9f533d8c6 +} +EOF +fi +-- +1.8.3.1 + diff --git a/0131-Add-BIOS-boot-measurement.patch b/0131-Add-BIOS-boot-measurement.patch deleted file mode 100644 index a428d327ed53301b6f235646c897174c02017cde..0000000000000000000000000000000000000000 --- a/0131-Add-BIOS-boot-measurement.patch +++ /dev/null @@ -1,176 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Sun, 9 Aug 2015 15:48:51 -0700 -Subject: [PATCH] Add BIOS boot measurement - -Measure the on-disk grub core on BIOS systems - unlike UEFI, the firmware -can't do this stage for us. ---- - grub-core/boot/i386/pc/boot.S | 30 +++++++++++++++++++++++++- - grub-core/boot/i386/pc/diskboot.S | 44 +++++++++++++++++++++++++++++++++++++++ - 2 files changed, 73 insertions(+), 1 deletion(-) - -diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S -index ea167fe1206..c1df86dec0b 100644 ---- a/grub-core/boot/i386/pc/boot.S -+++ b/grub-core/boot/i386/pc/boot.S -@@ -24,11 +24,14 @@ - * defines for the code go here - */ - -+#define TPM 1 -+ - /* Print message string */ - #define MSG(x) movw $x, %si; call LOCAL(message) - #define ERR(x) movw $x, %si; jmp LOCAL(error_message) - - .macro floppy -+#ifndef TPM - part_start: - - LOCAL(probe_values): -@@ -85,6 +88,7 @@ fd_probe_error_string: .asciz "Floppy" - movb MACRO_DOLLAR(79), %ch - - jmp LOCAL(final_init) -+#endif - .endm - - .macro scratch -@@ -252,6 +256,7 @@ real_start: - /* set %si to the disk address packet */ - movw $disk_address_packet, %si - -+#ifndef TPM - /* check if LBA is supported */ - movb $0x41, %ah - movw $0x55aa, %bx -@@ -271,6 +276,7 @@ real_start: - - andw $1, %cx - jz LOCAL(chs_mode) -+#endif - - LOCAL(lba_mode): - xorw %ax, %ax -@@ -314,6 +320,9 @@ LOCAL(lba_mode): - jmp LOCAL(copy_buffer) - - LOCAL(chs_mode): -+#ifdef TPM -+ jmp LOCAL(general_error) -+#else - /* - * Determine the hard disk geometry from the BIOS! - * We do this first, so that LS-120 IDE floppies work correctly. -@@ -425,7 +434,7 @@ setup_sectors: - jc LOCAL(read_error) - - movw %es, %bx -- -+#endif /* TPM */ - LOCAL(copy_buffer): - /* - * We need to save %cx and %si because the startup code in -@@ -448,6 +457,25 @@ LOCAL(copy_buffer): - popw %ds - popa - -+#ifdef TPM -+ pusha -+ -+ movw $0xBB00, %ax /* TCG_StatusCheck */ -+ int $0x1A -+ test %eax, %eax -+ jnz boot /* No TPM or TPM deactivated */ -+ -+ movw $0xBB07, %ax /* TCG_CompactHashLogExtendEvent */ -+ movw $GRUB_BOOT_MACHINE_KERNEL_ADDR, %di -+ xorl %esi, %esi -+ movl $0x41504354, %ebx /* TCPA */ -+ movl $0x200, %ecx /* Measure 512 bytes */ -+ movl $0x8, %edx /* PCR 8 */ -+ int $0x1A -+ -+ popa -+#endif -+boot: - /* boot kernel */ - jmp *(LOCAL(kernel_address)) - -diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S -index 68d31de0c4c..f4744ec6fcb 100644 ---- a/grub-core/boot/i386/pc/diskboot.S -+++ b/grub-core/boot/i386/pc/diskboot.S -@@ -19,6 +19,8 @@ - #include - #include - -+#define TPM 1 -+ - /* - * defines for the code go here - */ -@@ -53,6 +55,21 @@ _start: - /* this sets up for the first run through "bootloop" */ - movw $LOCAL(firstlist), %di - -+#ifdef TPM -+ /* clear EAX to remove potential garbage */ -+ xorl %eax, %eax -+ /* 8(%di) = number of sectors to read */ -+ movw 8(%di), %ax -+ -+ /* Multiply number of sectors to read with 512 bytes. EAX is 32bit -+ * which is large enough to hold values of up to 4GB. I doubt there -+ * will ever be a core.img larger than that. ;-) */ -+ shll $9, %eax -+ -+ /* write result to bytes_to_measure var */ -+ movl %eax, bytes_to_measure -+#endif -+ - /* save the sector number of the second sector in %ebp */ - movl (%di), %ebp - -@@ -290,6 +307,29 @@ LOCAL(copy_buffer): - /* END OF MAIN LOOP */ - - LOCAL(bootit): -+#ifdef TPM -+ pusha -+ movw $0xBB07, %ax /* TCG_CompactHashLogExtendEvent */ -+ -+ movw $0x0, %bx -+ movw %bx, %es -+ -+ /* We've already measured the first 512 bytes, now measure the rest */ -+ xorl %edi, %edi -+ movw $(GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200), %di -+ -+ movl $0x41504354, %ebx /* EBX = "TCPA" */ -+ -+ /* %ecx = The length, in bytes, of the buffer to measure */ -+ movl $bytes_to_measure, %esi -+ movl (%esi), %ecx -+ xorl %esi, %esi -+ movl $0x9, %edx /* PCR 9 */ -+ -+ int $0x1A -+ -+ popa -+#endif - /* print a newline */ - MSG(notification_done) - popw %dx /* this makes sure %dl is our "boot" drive */ -@@ -324,6 +364,10 @@ geometry_error_string: .asciz "Geom" - read_error_string: .asciz "Read" - general_error_string: .asciz " Error" - -+#ifdef TPM -+bytes_to_measure: .long 0 -+#endif -+ - /* - * message: write the string pointed to by %si - * diff --git a/0192-Add-grub-set-bootflag-utility.patch b/0131-Add-grub-set-bootflag-utility.patch similarity index 73% rename from 0192-Add-grub-set-bootflag-utility.patch rename to 0131-Add-grub-set-bootflag-utility.patch index 9adc1c03536556cfd724209a4ef4eaf6d95409df..af4acd2dba2792e5af322a720412c088e2f4dbb3 100644 --- a/0192-Add-grub-set-bootflag-utility.patch +++ b/0131-Add-grub-set-bootflag-utility.patch @@ -1,58 +1,55 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 07c1dfb9df01d3be4bbb9219fbe8a25b5d7dc0d9 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 12 Jun 2018 13:25:16 +0200 -Subject: [PATCH] Add grub-set-bootflag utility +Subject: [PATCH 131/220] Add grub-set-bootflag utility This commit adds a new grub-set-bootflag utility, which can be used to set known bootflags in the grubenv: boot_success or menu_show_once. grub-set-bootflag is different from grub-editenv in 2 ways: -1) It is intended to be executed by regular users through pkexec, so -running as root if the polkit policy allows this. As such it is written -to not use any existing grubenv related code for easy auditing. +1) It is intended to be executed by regular users so must be installed +as suid root. As such it is written to not use any existing grubenv +related code for easy auditing. + +It can't be executed through pkexec because we want to call it under gdm +and pkexec does not work under gdm due the gdm user having /sbin/nologin +as shell. 2) Since it can be executed by regular users it only allows setting (assigning a value of 1 to) bootflags which it knows about. Currently those are just boot_success and menu_show_once. -This commit also adds a couple of example systemd and polkit files which -show how this can be used to set boot_success from a user-session: +This commit also adds a couple of example systemd and files which show +how this can be used to set boot_success from a user-session: docs/grub-boot-success.service docs/grub-boot-success.timer -docs/org.gnu.grub.policy The 2 grub-boot-success.systemd files should be placed in /lib/systemd/user and a symlink to grub-boot-success.timer should be added to /lib/systemd/user/timers.target.wants. -The org.gnu.grub.policy polkit file should be placed in -/usr/share/polkit-1/actions. - Signed-off-by: Hans de Goede --- Makefile.util.def | 7 ++ - util/grub-set-bootflag.c | 158 +++++++++++++++++++++++++++++++++++++++++ - .gitignore | 2 + conf/Makefile.extra-dist | 3 + docs/grub-boot-success.service | 6 ++ - docs/grub-boot-success.timer | 5 ++ - docs/org.gnu.grub.policy | 20 ++++++ + docs/grub-boot-success.timer | 6 ++ util/grub-set-bootflag.1 | 20 ++++++ - 8 files changed, 221 insertions(+) - create mode 100644 util/grub-set-bootflag.c + util/grub-set-bootflag.c | 160 +++++++++++++++++++++++++++++++++++++++++ + 6 files changed, 202 insertions(+) create mode 100644 docs/grub-boot-success.service create mode 100644 docs/grub-boot-success.timer - create mode 100644 docs/org.gnu.grub.policy create mode 100644 util/grub-set-bootflag.1 + create mode 100644 util/grub-set-bootflag.c diff --git a/Makefile.util.def b/Makefile.util.def -index 5a8c390a1da..5da55393291 100644 +index 89a9da1..125ad62 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -1435,3 +1435,10 @@ program = { - ldadd = grub-core/gnulib/libgnu.a; +@@ -1451,3 +1451,10 @@ program = { + ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; + @@ -62,12 +59,76 @@ index 5a8c390a1da..5da55393291 100644 + mansection = 1; + common = util/grub-set-bootflag.c; +}; +diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist +index 58d7d95..375b1bf 100644 +--- a/conf/Makefile.extra-dist ++++ b/conf/Makefile.extra-dist +@@ -14,6 +14,9 @@ EXTRA_DIST += util/import_unicode.py + EXTRA_DIST += docs/autoiso.cfg + EXTRA_DIST += docs/grub.cfg + EXTRA_DIST += docs/osdetect.cfg ++EXTRA_DIST += docs/org.gnu.grub.policy ++EXTRA_DIST += docs/grub-boot-success.service ++EXTRA_DIST += docs/grub-boot-success.timer + + EXTRA_DIST += conf/i386-cygwin-img-ld.sc + +diff --git a/docs/grub-boot-success.service b/docs/grub-boot-success.service +new file mode 100644 +index 0000000..80e7958 +--- /dev/null ++++ b/docs/grub-boot-success.service +@@ -0,0 +1,6 @@ ++[Unit] ++Description=Mark boot as successful ++ ++[Service] ++Type=oneshot ++ExecStart=/usr/sbin/grub2-set-bootflag boot_success +diff --git a/docs/grub-boot-success.timer b/docs/grub-boot-success.timer +new file mode 100644 +index 0000000..5d8fcba +--- /dev/null ++++ b/docs/grub-boot-success.timer +@@ -0,0 +1,6 @@ ++[Unit] ++Description=Mark boot as successful after the user session has run 2 minutes ++ConditionUser=!@system ++ ++[Timer] ++OnActiveSec=2min +diff --git a/util/grub-set-bootflag.1 b/util/grub-set-bootflag.1 +new file mode 100644 +index 0000000..57801da +--- /dev/null ++++ b/util/grub-set-bootflag.1 +@@ -0,0 +1,20 @@ ++.TH GRUB-SET-BOOTFLAG 1 "Tue Jun 12 2018" ++.SH NAME ++\fBgrub-set-bootflag\fR \(em Set a bootflag in the GRUB environment block. ++ ++.SH SYNOPSIS ++\fBgrub-set-bootflag\fR <\fIBOOTFLAG\fR> ++ ++.SH DESCRIPTION ++\fBgrub-set-bootflag\fR is a command line to set bootflags in GRUB's ++stored environment. ++ ++.SH COMMANDS ++.TP ++\fBBOOTFLAG\fR ++.RS 7 ++Bootflag to set, one of \fIboot_success\fR or \fIshow_menu_once\fR. ++.RE ++ ++.SH SEE ALSO ++.BR "info grub" diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c new file mode 100644 -index 00000000000..f8dc310909a +index 0000000..bb198f0 --- /dev/null +++ b/util/grub-set-bootflag.c -@@ -0,0 +1,158 @@ +@@ -0,0 +1,160 @@ +/* grub-set-bootflag.c - tool to set boot-flags in the grubenv. */ +/* + * GRUB -- GRand Unified Bootloader @@ -96,6 +157,7 @@ index 00000000000..f8dc310909a +#include /* For *_DIR_NAME defines */ +#include +#include /* For GRUB_ENVBLK_DEFCFG define */ ++#include +#include +#include +#include @@ -156,6 +218,7 @@ index 00000000000..f8dc310909a + fclose (f); + if (ret != GRUBENV_SIZE) + { ++ errno = EINVAL; + perror ("Error reading from " GRUBENV); + return 1; + } @@ -226,105 +289,6 @@ index 00000000000..f8dc310909a + + return 0; +} -diff --git a/.gitignore b/.gitignore -index 42475592123..6c4cfc53781 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -111,6 +111,8 @@ grub-*.tar.* - /grub*-rpm-sort.8 - /grub*-script-check - /grub*-script-check.1 -+/grub*-set-bootflag -+/grub*-set-bootflag.1 - /grub*-set-default - /grub*-set-default.8 - /grub*-setsetpassword -diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist -index 39eb94bded6..5946ec24a65 100644 ---- a/conf/Makefile.extra-dist -+++ b/conf/Makefile.extra-dist -@@ -14,6 +14,9 @@ EXTRA_DIST += util/import_unicode.py - EXTRA_DIST += docs/autoiso.cfg - EXTRA_DIST += docs/grub.cfg - EXTRA_DIST += docs/osdetect.cfg -+EXTRA_DIST += docs/org.gnu.grub.policy -+EXTRA_DIST += docs/grub-boot-success.service -+EXTRA_DIST += docs/grub-boot-success.timer - - EXTRA_DIST += conf/i386-cygwin-img-ld.sc - -diff --git a/docs/grub-boot-success.service b/docs/grub-boot-success.service -new file mode 100644 -index 00000000000..c8c91c34d49 ---- /dev/null -+++ b/docs/grub-boot-success.service -@@ -0,0 +1,6 @@ -+[Unit] -+Description=Mark boot as successful -+ -+[Service] -+Type=oneshot -+ExecStart=/usr/bin/pkexec /usr/sbin/grub2-set-bootflag boot_success -diff --git a/docs/grub-boot-success.timer b/docs/grub-boot-success.timer -new file mode 100644 -index 00000000000..221b532781b ---- /dev/null -+++ b/docs/grub-boot-success.timer -@@ -0,0 +1,5 @@ -+[Unit] -+Description=Mark boot as successful after the user session has run 2 minutes -+ -+[Timer] -+OnActiveSec=2min -diff --git a/docs/org.gnu.grub.policy b/docs/org.gnu.grub.policy -new file mode 100644 -index 00000000000..18391efc8e7 ---- /dev/null -+++ b/docs/org.gnu.grub.policy -@@ -0,0 +1,20 @@ -+ -+ -+ -+ GNU GRUB -+ https://www.gnu.org/software/grub/ -+ -+ -+ Set GRUB bootflags -+ Authentication is required to modify the bootloaders bootflags -+ -+ no -+ no -+ yes -+ -+ /usr/sbin/grub2-set-bootflag -+ -+ -diff --git a/util/grub-set-bootflag.1 b/util/grub-set-bootflag.1 -new file mode 100644 -index 00000000000..57801da22a0 ---- /dev/null -+++ b/util/grub-set-bootflag.1 -@@ -0,0 +1,20 @@ -+.TH GRUB-SET-BOOTFLAG 1 "Tue Jun 12 2018" -+.SH NAME -+\fBgrub-set-bootflag\fR \(em Set a bootflag in the GRUB environment block. -+ -+.SH SYNOPSIS -+\fBgrub-set-bootflag\fR <\fIBOOTFLAG\fR> -+ -+.SH DESCRIPTION -+\fBgrub-set-bootflag\fR is a command line to set bootflags in GRUB's -+stored environment. -+ -+.SH COMMANDS -+.TP -+\fBBOOTFLAG\fR -+.RS 7 -+Bootflag to set, one of \fIboot_success\fR or \fIshow_menu_once\fR. -+.RE -+ -+.SH SEE ALSO -+.BR "info grub" +-- +1.8.3.1 + diff --git a/0132-Measure-kernel-and-initrd-on-BIOS-systems.patch b/0132-Measure-kernel-and-initrd-on-BIOS-systems.patch deleted file mode 100644 index 69d58fb40d29c1af3c6c9f25e859713f9fbd956e..0000000000000000000000000000000000000000 --- a/0132-Measure-kernel-and-initrd-on-BIOS-systems.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Sun, 9 Aug 2015 16:28:29 -0700 -Subject: [PATCH] Measure kernel and initrd on BIOS systems - -Measure the kernel and initrd when loaded on BIOS systems ---- - grub-core/loader/i386/linux.c | 5 +++++ - grub-core/loader/i386/pc/linux.c | 3 +++ - grub-core/loader/linux.c | 2 ++ - 3 files changed, 10 insertions(+) - -diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index c84747ea857..94526966e8a 100644 ---- a/grub-core/loader/i386/linux.c -+++ b/grub-core/loader/i386/linux.c -@@ -36,6 +36,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -724,7 +725,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -+ grub_tpm_measure (kernel, len, GRUB_KERNEL_PCR, "Linux Kernel"); -+ - grub_memcpy (&lh, kernel, sizeof (lh)); -+ - kernel_offset = sizeof (lh); - - if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) -@@ -1038,6 +1042,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - len = prot_file_size; - grub_memcpy (prot_mode_mem, kernel + kernel_offset, len); -+ kernel_offset += len; - - if (grub_errno == GRUB_ERR_NONE) - { -diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index 783a3cd93bc..15544230763 100644 ---- a/grub-core/loader/i386/pc/linux.c -+++ b/grub-core/loader/i386/pc/linux.c -@@ -36,6 +36,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -161,6 +162,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -+ grub_tpm_measure (kernel, len, GRUB_KERNEL_PCR, "BIOS Linux Kernel"); -+ - grub_memcpy (&lh, kernel, sizeof (lh)); - kernel_offset = sizeof (lh); - -diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c -index be6fa0f4d45..3005c0d19c9 100644 ---- a/grub-core/loader/linux.c -+++ b/grub-core/loader/linux.c -@@ -4,6 +4,7 @@ - #include - #include - #include -+#include - - struct newc_head - { -@@ -288,6 +289,7 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, - grub_initrd_close (initrd_ctx); - return grub_errno; - } -+ grub_tpm_measure (ptr, cursize, GRUB_INITRD_PCR, "Linux Initrd"); - ptr += cursize; - } - if (newc) diff --git a/0195-docs-Add-grub-boot-indeterminate.service-example.patch b/0132-docs-Add-grub-boot-indeterminate.service-example.patch similarity index 83% rename from 0195-docs-Add-grub-boot-indeterminate.service-example.patch rename to 0132-docs-Add-grub-boot-indeterminate.service-example.patch index 44f6ad3984b8dd0c9ab108d395e1a68934a831a2..029366414996aa0d652386567e6b42c2b67cdcd7 100644 --- a/0195-docs-Add-grub-boot-indeterminate.service-example.patch +++ b/0132-docs-Add-grub-boot-indeterminate.service-example.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 600518039d5a46d1098d28da0e352a4f92dbc145 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 19 Jun 2018 15:20:54 +0200 -Subject: [PATCH] docs: Add grub-boot-indeterminate.service example +Subject: [PATCH 132/220] docs: Add grub-boot-indeterminate.service example This is an example service file, for use from /lib/systemd/system/system-update.target.wants @@ -16,7 +16,7 @@ Signed-off-by: Hans de Goede diff --git a/docs/grub-boot-indeterminate.service b/docs/grub-boot-indeterminate.service new file mode 100644 -index 00000000000..6c8dcb186b6 +index 0000000..6c8dcb1 --- /dev/null +++ b/docs/grub-boot-indeterminate.service @@ -0,0 +1,11 @@ @@ -31,3 +31,6 @@ index 00000000000..6c8dcb186b6 +[Service] +Type=oneshot +ExecStart=/usr/bin/grub2-editenv - incr boot_indeterminate +-- +1.8.3.1 + diff --git a/0133-Measure-the-kernel-commandline.patch b/0133-Measure-the-kernel-commandline.patch deleted file mode 100644 index 7fe2809a90a33758b48fe54847bd176611f32450..0000000000000000000000000000000000000000 --- a/0133-Measure-the-kernel-commandline.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Sun, 9 Aug 2015 16:32:29 -0700 -Subject: [PATCH] Measure the kernel commandline - -Measure the kernel commandline to ensure that it hasn't been modified ---- - grub-core/lib/cmdline.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c -index 970ea868c14..6b56304d4a7 100644 ---- a/grub-core/lib/cmdline.c -+++ b/grub-core/lib/cmdline.c -@@ -19,6 +19,7 @@ - - #include - #include -+#include - - static int - is_hex(char c) -@@ -79,7 +80,7 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, - { - int i, space; - unsigned int arg_size; -- char *c; -+ char *c, *orig = buf; - - for (i = 0; i < argc; i++) - { -@@ -125,5 +126,8 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, - - *buf = 0; - -+ grub_tpm_measure ((void *)orig, grub_strlen (orig), GRUB_CMDLINE_PCR, -+ "Kernel Commandline"); -+ - return i; - } diff --git a/0199-gentpl-add-disable-support.patch b/0133-gentpl-add-disable-support.patch similarity index 81% rename from 0199-gentpl-add-disable-support.patch rename to 0133-gentpl-add-disable-support.patch index d82d6331c8c2d9b7b3ecf43ce44aa25f57fe2d69..3f12f5fb0ba4e0c33363ab47f3ccb814b4532c3f 100644 --- a/0199-gentpl-add-disable-support.patch +++ b/0133-gentpl-add-disable-support.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 5b8e719389524825b88322555030188309d88ba6 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 11 Jul 2018 13:43:15 -0400 -Subject: [PATCH] gentpl: add 'disable = ' support +Subject: [PATCH 133/220] gentpl: add 'disable = ' support Signed-off-by: Peter Jones --- @@ -9,10 +9,10 @@ Signed-off-by: Peter Jones 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gentpl.py b/gentpl.py -index bf8439fa743..a8cd540550f 100644 +index f05812e..3a0c049 100644 --- a/gentpl.py +++ b/gentpl.py -@@ -589,11 +589,21 @@ def platform_conditional(platform, closure): +@@ -592,11 +592,21 @@ def platform_conditional(platform, closure): # }; # def foreach_enabled_platform(defn, closure): @@ -35,7 +35,7 @@ index bf8439fa743..a8cd540550f 100644 for platform in GRUB_PLATFORMS: platform_conditional(platform, closure) -@@ -652,6 +662,8 @@ def first_time(defn, snippet): +@@ -655,6 +665,8 @@ def first_time(defn, snippet): def is_platform_independent(defn): if 'enable' in defn: return False @@ -44,3 +44,6 @@ index bf8439fa743..a8cd540550f 100644 for suffix in [ "", "_nodist" ]: template = platform_values(defn, GRUB_PLATFORMS[0], suffix) for platform in GRUB_PLATFORMS[1:]: +-- +1.8.3.1 + diff --git a/0134-Measure-commands.patch b/0134-Measure-commands.patch deleted file mode 100644 index bac4c8dbc698c2aab82e9472d3c7e9f9cd92a7b9..0000000000000000000000000000000000000000 --- a/0134-Measure-commands.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Mon, 10 Aug 2015 15:27:12 -0700 -Subject: [PATCH] Measure commands - -Measure each command executed by grub, which includes script execution. ---- - grub-core/script/execute.c | 25 +++++++++++++++++++++++-- - include/grub/tpm.h | 1 + - 2 files changed, 24 insertions(+), 2 deletions(-) - -diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index cf6cd6601d6..9ae04a05160 100644 ---- a/grub-core/script/execute.c -+++ b/grub-core/script/execute.c -@@ -30,6 +30,7 @@ - #ifdef GRUB_MACHINE_IEEE1275 - #include - #endif -+#include - - /* Max digits for a char is 3 (0xFF is 255), similarly for an int it - is sizeof (int) * 3, and one extra for a possible -ve sign. */ -@@ -967,8 +968,9 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) - grub_err_t ret = 0; - grub_script_function_t func = 0; - char errnobuf[18]; -- char *cmdname; -- int argc; -+ char *cmdname, *cmdstring; -+ int argc, offset = 0, cmdlen = 0; -+ unsigned int i; - char **args; - int invert; - struct grub_script_argv argv = { 0, 0, 0 }; -@@ -977,6 +979,25 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) - if (grub_script_arglist_to_argv (cmdline->arglist, &argv) || ! argv.args[0]) - return grub_errno; - -+ for (i = 0; i < argv.argc; i++) { -+ cmdlen += grub_strlen (argv.args[i]) + 1; -+ } -+ -+ cmdstring = grub_malloc (cmdlen); -+ if (!cmdstring) -+ { -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ N_("cannot allocate command buffer")); -+ } -+ -+ for (i = 0; i < argv.argc; i++) { -+ offset += grub_snprintf (cmdstring + offset, cmdlen - offset, "%s ", -+ argv.args[i]); -+ } -+ cmdstring[cmdlen-1]= '\0'; -+ grub_tpm_measure ((unsigned char *)cmdstring, cmdlen, GRUB_COMMAND_PCR, -+ cmdstring); -+ grub_free(cmdstring); - invert = 0; - argc = argv.argc - 1; - args = argv.args + 1; -diff --git a/include/grub/tpm.h b/include/grub/tpm.h -index 40d3cf65ba6..7fc9d77d277 100644 ---- a/include/grub/tpm.h -+++ b/include/grub/tpm.h -@@ -30,6 +30,7 @@ - #define GRUB_KERNEL_PCR 10 - #define GRUB_INITRD_PCR 11 - #define GRUB_CMDLINE_PCR 12 -+#define GRUB_COMMAND_PCR 13 - - #define TPM_TAG_RQU_COMMAND 0x00C1 - #define TPM_ORD_Extend 0x14 diff --git a/0200-gentpl-add-pc-firmware-type.patch b/0134-gentpl-add-pc-firmware-type.patch similarity index 53% rename from 0200-gentpl-add-pc-firmware-type.patch rename to 0134-gentpl-add-pc-firmware-type.patch index 94737b3bdfe98848b98715624c06a19e1a50ec41..9b5a74256f9a868868f13fc7179ca301fc8ca865 100644 --- a/0200-gentpl-add-pc-firmware-type.patch +++ b/0134-gentpl-add-pc-firmware-type.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From f763ca059bb527b66e2b7194e7f0bb7b6d47ccb9 Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Wed, 11 Jul 2018 13:43:34 -0400 -Subject: [PATCH] gentpl: add 'pc' firmware type +Date: Thu, 11 Jul 2019 11:04:24 +0200 +Subject: [PATCH 134/220] gentpl: add 'pc' firmware type Signed-off-by: Peter Jones --- @@ -9,14 +9,17 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+) diff --git a/gentpl.py b/gentpl.py -index a8cd540550f..baac6a2af69 100644 +index 3a0c049..1d9dda4 100644 --- a/gentpl.py +++ b/gentpl.py -@@ -49,6 +49,7 @@ GROUPS["arm"] = [ "arm_uboot", "arm_efi", "arm_coreboot" ] - GROUPS["arm64"] = [ "arm64_efi" ] +@@ -51,6 +51,7 @@ GROUPS["riscv32"] = [ "riscv32_efi" ] + GROUPS["riscv64"] = [ "riscv64_efi" ] # Groups based on firmware +GROUPS["pc"] = [ "i386_pc" ] - GROUPS["efi"] = [ "i386_efi", "x86_64_efi", "ia64_efi", "arm_efi", "arm64_efi" ] + GROUPS["efi"] = [ "i386_efi", "x86_64_efi", "ia64_efi", "arm_efi", "arm64_efi", + "riscv32_efi", "riscv64_efi" ] GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ] - GROUPS["uboot"] = [ "arm_uboot" ] +-- +1.8.3.1 + diff --git a/0135-Measure-multiboot-images-and-modules.patch b/0135-Measure-multiboot-images-and-modules.patch deleted file mode 100644 index 0c19d8d6397ffb82d431fa7fa40f6608bc1f2a5c..0000000000000000000000000000000000000000 --- a/0135-Measure-multiboot-images-and-modules.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Tue, 1 Sep 2015 16:02:55 -0700 -Subject: [PATCH] Measure multiboot images and modules - ---- - grub-core/loader/i386/multiboot_mbi.c | 3 +++ - grub-core/loader/multiboot.c | 2 ++ - grub-core/loader/multiboot_mbi2.c | 4 +++- - 3 files changed, 8 insertions(+), 1 deletion(-) - -diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c -index dc98dbcae25..1c5b0ac25ce 100644 ---- a/grub-core/loader/i386/multiboot_mbi.c -+++ b/grub-core/loader/i386/multiboot_mbi.c -@@ -36,6 +36,7 @@ - #include - #include - #include -+#include - - #ifdef GRUB_MACHINE_EFI - #include -@@ -173,6 +174,8 @@ grub_multiboot_load (grub_file_t file, const char *filename) - return grub_errno; - } - -+ grub_tpm_measure((unsigned char*)buffer, len, GRUB_KERNEL_PCR, filename); -+ - header = find_header (buffer, len); - - if (header == 0) -diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c -index 26df46a4161..93e026c53db 100644 ---- a/grub-core/loader/multiboot.c -+++ b/grub-core/loader/multiboot.c -@@ -51,6 +51,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -440,6 +441,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), - } - - grub_file_close (file); -+ grub_tpm_measure (module, size, GRUB_KERNEL_PCR, argv[0]); - return GRUB_ERR_NONE; - } - -diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c -index 4df6595954d..d5ad02a33a1 100644 ---- a/grub-core/loader/multiboot_mbi2.c -+++ b/grub-core/loader/multiboot_mbi2.c -@@ -36,6 +36,7 @@ - #include - #include - #include -+#include - - #if defined (GRUB_MACHINE_EFI) - #include -@@ -131,8 +132,9 @@ grub_multiboot2_load (grub_file_t file, const char *filename) - - COMPILE_TIME_ASSERT (MULTIBOOT_HEADER_ALIGN % 4 == 0); - -+ grub_tpm_measure ((unsigned char *)buffer, len, GRUB_KERNEL_PCR, filename); -+ - header = find_header (mld.buffer, len); -- - if (header == 0) - { - grub_free (mld.buffer); diff --git a/0216-efinet-also-use-the-firmware-acceleration-for-http.patch b/0135-efinet-also-use-the-firmware-acceleration-for-http.patch similarity index 83% rename from 0216-efinet-also-use-the-firmware-acceleration-for-http.patch rename to 0135-efinet-also-use-the-firmware-acceleration-for-http.patch index 5771c8a5a89f178adecfb188c23dc5f47a950662..2132bd90ea553bcf642fe3c2ed97613d8f002b48 100644 --- a/0216-efinet-also-use-the-firmware-acceleration-for-http.patch +++ b/0135-efinet-also-use-the-firmware-acceleration-for-http.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 4b0d5c577825b4b9e4f0fc768ea57cfb941e6c45 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 30 Jul 2018 14:06:42 -0400 -Subject: [PATCH] efinet: also use the firmware acceleration for http +Subject: [PATCH 135/220] efinet: also use the firmware acceleration for http Signed-off-by: Peter Jones --- @@ -9,7 +9,7 @@ Signed-off-by: Peter Jones 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c -index 2bf15447fd5..f208d1b180c 100644 +index 4bb3080..6603cd8 100644 --- a/grub-core/net/efi/net.c +++ b/grub-core/net/efi/net.c @@ -1324,7 +1324,9 @@ grub_efi_net_boot_from_https (void) @@ -23,3 +23,6 @@ index 2bf15447fd5..f208d1b180c 100644 } if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp)) +-- +1.8.3.1 + diff --git a/0136-Fix-boot-when-there-s-no-TPM.patch b/0136-Fix-boot-when-there-s-no-TPM.patch deleted file mode 100644 index 60efb93883f16c34b7e4b3433a0a512879a5e99e..0000000000000000000000000000000000000000 --- a/0136-Fix-boot-when-there-s-no-TPM.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Wed, 23 Mar 2016 16:49:42 -0700 -Subject: [PATCH] Fix boot when there's no TPM - -If the firmware has TPM support but has no TPM, we're jumping to core.img -without popping the registers back onto the stack. Fix that. - -(cherry picked from commit c2eee36ec08f8ed0cd25b8030276347680be4843) ---- - grub-core/boot/i386/pc/boot.S | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S -index c1df86dec0b..acab37369ae 100644 ---- a/grub-core/boot/i386/pc/boot.S -+++ b/grub-core/boot/i386/pc/boot.S -@@ -473,9 +473,9 @@ LOCAL(copy_buffer): - movl $0x8, %edx /* PCR 8 */ - int $0x1A - -- popa --#endif - boot: -+ popa -+#endif - /* boot kernel */ - jmp *(LOCAL(kernel_address)) - diff --git a/0217-efi-http-Make-root_url-reflect-the-protocol-hostname.patch b/0136-efi-http-Make-root_url-reflect-the-protocol-hostname.patch similarity index 87% rename from 0217-efi-http-Make-root_url-reflect-the-protocol-hostname.patch rename to 0136-efi-http-Make-root_url-reflect-the-protocol-hostname.patch index 985a037828bde8390cc4d84d0b395a133fcc0338..43bfc60d84313f5254a59058d909703e52b4df2e 100644 --- a/0217-efi-http-Make-root_url-reflect-the-protocol-hostname.patch +++ b/0136-efi-http-Make-root_url-reflect-the-protocol-hostname.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From f1173dcc353427122e640347a35df802fabd020f Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 30 Jul 2018 16:39:57 -0400 -Subject: [PATCH] efi/http: Make root_url reflect the protocol+hostname of our - boot url. +Subject: [PATCH 136/220] efi/http: Make root_url reflect the protocol+hostname + of our boot url. This lets you write config files that don't know urls. @@ -12,7 +12,7 @@ Signed-off-by: Peter Jones 1 file changed, 19 insertions(+) diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c -index 3f61fd2fa5b..243acbaa35b 100644 +index 3f61fd2..243acba 100644 --- a/grub-core/net/efi/http.c +++ b/grub-core/net/efi/http.c @@ -4,6 +4,7 @@ @@ -48,3 +48,6 @@ index 3f61fd2fa5b..243acbaa35b 100644 err = efihttp_request (dev->http, file->device->net->server, file->device->net->name, type, 1, 0); if (err != GRUB_ERR_NONE) +-- +1.8.3.1 + diff --git a/0222-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch b/0137-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch similarity index 93% rename from 0222-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch rename to 0137-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch index 292e5658bc922c4e4f7135688b7fc09f06d2da0a..287dbe74ca280e9ff2f811cefb865926e6f33271 100644 --- a/0222-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch +++ b/0137-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 2ed3f5abf24ef7b6802aba64ecf2e3bf415f2f67 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 26 Jun 2018 17:16:06 -0400 -Subject: [PATCH] Make it so we can tell configure which cflags utils are built - with +Subject: [PATCH 137/220] Make it so we can tell configure which cflags utils + are built with This lets us have kernel.img be built with TARGET_CFLAGS but grub-mkimage and friends built with HOST_CFLAGS. That in turn lets us build with an ARM compiler @@ -11,16 +11,57 @@ float for grub.efi. Signed-off-by: Peter Jones --- - configure.ac | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- conf/Makefile.common | 23 ++++++++++++----------- + configure.ac | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- gentpl.py | 8 ++++---- 3 files changed, 64 insertions(+), 16 deletions(-) +diff --git a/conf/Makefile.common b/conf/Makefile.common +index 5e8ba2a..bbf33b0 100644 +--- a/conf/Makefile.common ++++ b/conf/Makefile.common +@@ -40,24 +40,25 @@ CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 + CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) + STRIPFLAGS_KERNEL = -R .eh_frame -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx -R .note.gnu.property -R .gnu.build.attributes + +-CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding +-LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d +-CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) +-CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) ++CFLAGS_MODULE = $(TARGET_CFLAGS) $(CFLAGS_PLATFORM) -ffreestanding ++LDFLAGS_MODULE = $(TARGET_LDFLAGS) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d ++CPPFLAGS_MODULE = $(TARGET_CPPFLAGS) $(CPPFLAGS_DEFAULT) $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) ++CCASFLAGS_MODULE = $(TARGET_CCASFLAGS) $(CCASFLAGS_DEFAULT) $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) + + CFLAGS_IMAGE = $(CFLAGS_PLATFORM) -fno-builtin + LDFLAGS_IMAGE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S + CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) + CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) + +-CFLAGS_PROGRAM = +-LDFLAGS_PROGRAM = +-CPPFLAGS_PROGRAM = +-CCASFLAGS_PROGRAM = ++CFLAGS_PROGRAM = $(UTILS_CFLAGS) ++LDFLAGS_PROGRAM = $(UTILS_LDFLAGS) ++CPPFLAGS_PROGRAM = $(UTILS_CPPFLAGS) ++CCASFLAGS_PROGRAM = $(UTILS_CCASFLAGS) + +-CFLAGS_LIBRARY = +-CPPFLAGS_LIBRARY = +-CCASFLAGS_LIBRARY = ++CFLAGS_LIBRARY = $(UTILS_CFLAGS) ++LDFLAGS_LIBRARY = $(UTILS_LDFLAGS) ++CPPFLAGS_LIBRARY = $(UTILS_CPPFLAGS) ++CCASFLAGS_LIBRARY = $(UTILS_CCASFLAGS) + + # Other variables + diff --git a/configure.ac b/configure.ac -index 9ab683fefac..819212095ff 100644 +index 8ee18ba..cf32748 100644 --- a/configure.ac +++ b/configure.ac -@@ -850,11 +850,23 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p +@@ -868,11 +868,23 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow" fi @@ -45,7 +86,7 @@ index 9ab683fefac..819212095ff 100644 AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [ grub_cv_target_cc_soft_float=no if test "x$target_cpu" = xarm64; then -@@ -1939,6 +1951,41 @@ HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include" +@@ -1951,6 +1963,41 @@ HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include" TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include" TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include" @@ -87,52 +128,11 @@ index 9ab683fefac..819212095ff 100644 GRUB_TARGET_CPU="${target_cpu}" GRUB_PLATFORM="${platform}" -diff --git a/conf/Makefile.common b/conf/Makefile.common -index 1ecb921db65..b93879804c0 100644 ---- a/conf/Makefile.common -+++ b/conf/Makefile.common -@@ -40,24 +40,25 @@ CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 - CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) - STRIPFLAGS_KERNEL = -R .eh_frame -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx -R .note.gnu.property -R .gnu.build.attributes - --CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding --LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d --CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) --CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) -+CFLAGS_MODULE = $(TARGET_CFLAGS) $(CFLAGS_PLATFORM) -ffreestanding -+LDFLAGS_MODULE = $(TARGET_LDFLAGS) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d -+CPPFLAGS_MODULE = $(TARGET_CPPFLAGS) $(CPPFLAGS_DEFAULT) $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -+CCASFLAGS_MODULE = $(TARGET_CCASFLAGS) $(CCASFLAGS_DEFAULT) $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) - - CFLAGS_IMAGE = $(CFLAGS_PLATFORM) -fno-builtin - LDFLAGS_IMAGE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S - CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) - CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) - --CFLAGS_PROGRAM = --LDFLAGS_PROGRAM = --CPPFLAGS_PROGRAM = --CCASFLAGS_PROGRAM = -+CFLAGS_PROGRAM = $(UTILS_CFLAGS) -+LDFLAGS_PROGRAM = $(UTILS_LDFLAGS) -+CPPFLAGS_PROGRAM = $(UTILS_CPPFLAGS) -+CCASFLAGS_PROGRAM = $(UTILS_CCASFLAGS) - --CFLAGS_LIBRARY = --CPPFLAGS_LIBRARY = --CCASFLAGS_LIBRARY = -+CFLAGS_LIBRARY = $(UTILS_CFLAGS) -+LDFLAGS_LIBRARY = $(UTILS_LDFLAGS) -+CPPFLAGS_LIBRARY = $(UTILS_CPPFLAGS) -+CCASFLAGS_LIBRARY = $(UTILS_CCASFLAGS) - - # Other variables - diff --git a/gentpl.py b/gentpl.py -index 6409736e81c..1e4635f4426 100644 +index 1d9dda4..95fe1a2 100644 --- a/gentpl.py +++ b/gentpl.py -@@ -694,10 +694,10 @@ def module(defn, platform): +@@ -697,10 +697,10 @@ def module(defn, platform): var_set(cname(defn) + "_SOURCES", platform_sources(defn, platform) + " ## platform sources") var_set("nodist_" + cname(defn) + "_SOURCES", platform_nodist_sources(defn, platform) + " ## platform nodist sources") var_set(cname(defn) + "_LDADD", platform_ldadd(defn, platform)) @@ -147,3 +147,6 @@ index 6409736e81c..1e4635f4426 100644 var_set(cname(defn) + "_DEPENDENCIES", "$(TARGET_OBJ2ELF) " + platform_dependencies(defn, platform)) gvar_add("dist_noinst_DATA", extra_dist(defn)) +-- +1.8.3.1 + diff --git a/0137-Rework-TPM-measurements.patch b/0137-Rework-TPM-measurements.patch deleted file mode 100644 index eb18094448612026dd664dfefa71dec329a69afd..0000000000000000000000000000000000000000 --- a/0137-Rework-TPM-measurements.patch +++ /dev/null @@ -1,216 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Wed, 23 Mar 2016 17:03:43 -0700 -Subject: [PATCH] Rework TPM measurements - -Rework TPM measurements to use fewer PCRs. After discussion with upstream, -it's preferable to avoid using so many PCRs. Instead, measure into PCRs 8 -and 9 but use a prefix in the event log to indicate which subsystem carried -out the measurements. - -(cherry picked from commit bb3473d7c8741ad5ef7cf8aafbbcf094df08bfc9) ---- - grub-core/kern/dl.c | 2 +- - grub-core/kern/tpm.c | 10 ++++++++-- - grub-core/lib/cmdline.c | 4 ++-- - grub-core/loader/i386/efi/linux.c | 4 ++-- - grub-core/loader/i386/linux.c | 2 +- - grub-core/loader/i386/multiboot_mbi.c | 2 +- - grub-core/loader/i386/pc/linux.c | 2 +- - grub-core/loader/linux.c | 2 +- - grub-core/loader/multiboot.c | 2 +- - grub-core/loader/multiboot_mbi2.c | 2 +- - grub-core/script/execute.c | 4 ++-- - include/grub/tpm.h | 9 +++------ - 12 files changed, 24 insertions(+), 21 deletions(-) - -diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 387d1e6446d..d0989573866 100644 ---- a/grub-core/kern/dl.c -+++ b/grub-core/kern/dl.c -@@ -830,7 +830,7 @@ grub_dl_load_file (const char *filename) - opens of the same device. */ - grub_file_close (file); - -- grub_tpm_measure(core, size, GRUB_TPM_PCR, filename); -+ grub_tpm_measure(core, size, GRUB_BINARY_PCR, "grub_module", filename); - - mod = grub_dl_load_core (core, size); - grub_free (core); -diff --git a/grub-core/kern/tpm.c b/grub-core/kern/tpm.c -index 1a991876c83..cb5a812035d 100644 ---- a/grub-core/kern/tpm.c -+++ b/grub-core/kern/tpm.c -@@ -7,7 +7,13 @@ - - grub_err_t - grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, -- const char *description) -+ const char *kind, const char *description) - { -- return grub_tpm_log_event(buf, size, pcr, description); -+ grub_err_t ret; -+ char *desc = grub_xasprintf("%s %s", kind, description); -+ if (!desc) -+ return GRUB_ERR_OUT_OF_MEMORY; -+ ret = grub_tpm_log_event(buf, size, pcr, description); -+ grub_free(desc); -+ return ret; - } -diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c -index 6b56304d4a7..178f7382f07 100644 ---- a/grub-core/lib/cmdline.c -+++ b/grub-core/lib/cmdline.c -@@ -126,8 +126,8 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, - - *buf = 0; - -- grub_tpm_measure ((void *)orig, grub_strlen (orig), GRUB_CMDLINE_PCR, -- "Kernel Commandline"); -+ grub_tpm_measure ((void *)orig, grub_strlen (orig), GRUB_ASCII_PCR, -+ "grub_kernel_cmdline", orig); - - return i; - } -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index d837249b4a1..074dbd6513e 100644 ---- a/grub-core/loader/i386/efi/linux.c -+++ b/grub-core/loader/i386/efi/linux.c -@@ -132,7 +132,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - argv[i]); - goto fail; - } -- grub_tpm_measure (ptr, cursize, GRUB_INITRD_PCR, "UEFI Linux initrd"); -+ grub_tpm_measure (ptr, cursize, GRUB_BINARY_PCR, "grub_linuxefi", "Initrd"); - ptr += cursize; - grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); - ptr += ALIGN_UP_OVERHEAD (cursize, 4); -@@ -197,7 +197,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- grub_tpm_measure (kernel, filelen, GRUB_KERNEL_PCR, "UEFI Linux kernel"); -+ grub_tpm_measure (kernel, filelen, GRUB_BINARY_PCR, "grub_linuxefi", "Kernel"); - - rc = grub_linuxefi_secure_validate (kernel, filelen); - if (rc < 0) -diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index 94526966e8a..273f48a6c88 100644 ---- a/grub-core/loader/i386/linux.c -+++ b/grub-core/loader/i386/linux.c -@@ -725,7 +725,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- grub_tpm_measure (kernel, len, GRUB_KERNEL_PCR, "Linux Kernel"); -+ grub_tpm_measure (kernel, len, GRUB_BINARY_PCR, "grub_linux", "Kernel"); - - grub_memcpy (&lh, kernel, sizeof (lh)); - -diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c -index 1c5b0ac25ce..2ce424a997b 100644 ---- a/grub-core/loader/i386/multiboot_mbi.c -+++ b/grub-core/loader/i386/multiboot_mbi.c -@@ -174,7 +174,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) - return grub_errno; - } - -- grub_tpm_measure((unsigned char*)buffer, len, GRUB_KERNEL_PCR, filename); -+ grub_tpm_measure((unsigned char*)buffer, len, GRUB_BINARY_PCR, "grub_multiboot", filename); - - header = find_header (buffer, len); - -diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index 15544230763..4f8c02288ec 100644 ---- a/grub-core/loader/i386/pc/linux.c -+++ b/grub-core/loader/i386/pc/linux.c -@@ -162,7 +162,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- grub_tpm_measure (kernel, len, GRUB_KERNEL_PCR, "BIOS Linux Kernel"); -+ grub_tpm_measure (kernel, len, GRUB_BINARY_PCR, "grub_linux16", "Kernel"); - - grub_memcpy (&lh, kernel, sizeof (lh)); - kernel_offset = sizeof (lh); -diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c -index 3005c0d19c9..78c41e33416 100644 ---- a/grub-core/loader/linux.c -+++ b/grub-core/loader/linux.c -@@ -289,7 +289,7 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, - grub_initrd_close (initrd_ctx); - return grub_errno; - } -- grub_tpm_measure (ptr, cursize, GRUB_INITRD_PCR, "Linux Initrd"); -+ grub_tpm_measure (ptr, cursize, GRUB_BINARY_PCR, "grub_initrd", "Initrd"); - ptr += cursize; - } - if (newc) -diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c -index 93e026c53db..3b87dc4fab3 100644 ---- a/grub-core/loader/multiboot.c -+++ b/grub-core/loader/multiboot.c -@@ -441,7 +441,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), - } - - grub_file_close (file); -- grub_tpm_measure (module, size, GRUB_KERNEL_PCR, argv[0]); -+ grub_tpm_measure (module, size, GRUB_BINARY_PCR, "grub_multiboot", argv[0]); - return GRUB_ERR_NONE; - } - -diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c -index d5ad02a33a1..60ae4606fda 100644 ---- a/grub-core/loader/multiboot_mbi2.c -+++ b/grub-core/loader/multiboot_mbi2.c -@@ -132,7 +132,7 @@ grub_multiboot2_load (grub_file_t file, const char *filename) - - COMPILE_TIME_ASSERT (MULTIBOOT_HEADER_ALIGN % 4 == 0); - -- grub_tpm_measure ((unsigned char *)buffer, len, GRUB_KERNEL_PCR, filename); -+ grub_tpm_measure ((unsigned char *)mld.buffer, len, GRUB_BINARY_PCR, "grub_multiboot", filename); - - header = find_header (mld.buffer, len); - if (header == 0) -diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index 9ae04a05160..976643c47b0 100644 ---- a/grub-core/script/execute.c -+++ b/grub-core/script/execute.c -@@ -995,8 +995,8 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) - argv.args[i]); - } - cmdstring[cmdlen-1]= '\0'; -- grub_tpm_measure ((unsigned char *)cmdstring, cmdlen, GRUB_COMMAND_PCR, -- cmdstring); -+ grub_tpm_measure ((unsigned char *)cmdstring, cmdlen, GRUB_ASCII_PCR, -+ "grub_cmd", cmdstring); - grub_free(cmdstring); - invert = 0; - argc = argv.argc - 1; -diff --git a/include/grub/tpm.h b/include/grub/tpm.h -index 7fc9d77d277..ecb2d09ff5d 100644 ---- a/include/grub/tpm.h -+++ b/include/grub/tpm.h -@@ -26,11 +26,8 @@ - #define TPM_AUTHFAIL (TPM_BASE + 0x1) - #define TPM_BADINDEX (TPM_BASE + 0x2) - --#define GRUB_TPM_PCR 9 --#define GRUB_KERNEL_PCR 10 --#define GRUB_INITRD_PCR 11 --#define GRUB_CMDLINE_PCR 12 --#define GRUB_COMMAND_PCR 13 -+#define GRUB_ASCII_PCR 8 -+#define GRUB_BINARY_PCR 9 - - #define TPM_TAG_RQU_COMMAND 0x00C1 - #define TPM_ORD_Extend 0x14 -@@ -70,7 +67,7 @@ typedef struct { - } GRUB_PACKED ExtendOutgoing; - - grub_err_t EXPORT_FUNC(grub_tpm_measure) (unsigned char *buf, grub_size_t size, -- grub_uint8_t pcr, -+ grub_uint8_t pcr, const char *kind, - const char *description); - #if defined (GRUB_MACHINE_EFI) || defined (GRUB_MACHINE_PCBIOS) - grub_err_t grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, diff --git a/0138-Fix-event-log-prefix.patch b/0138-Fix-event-log-prefix.patch deleted file mode 100644 index 7b98f9af88bb44869885baa37cb47912f8a90824..0000000000000000000000000000000000000000 --- a/0138-Fix-event-log-prefix.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Tue, 29 Mar 2016 15:36:49 -0700 -Subject: [PATCH] Fix event log prefix - -We're not passing the prefixed version of the description to the event log. -Fix that. - -(cherry picked from commit aab446306b8a78c741e229861c4988738cfc6426) ---- - grub-core/kern/tpm.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/kern/tpm.c b/grub-core/kern/tpm.c -index cb5a812035d..e5e8fced624 100644 ---- a/grub-core/kern/tpm.c -+++ b/grub-core/kern/tpm.c -@@ -13,7 +13,7 @@ grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, - char *desc = grub_xasprintf("%s %s", kind, description); - if (!desc) - return GRUB_ERR_OUT_OF_MEMORY; -- ret = grub_tpm_log_event(buf, size, pcr, description); -+ ret = grub_tpm_log_event(buf, size, pcr, desc); - grub_free(desc); - return ret; - } diff --git a/0223-module-verifier-make-it-possible-to-run-checkers-on-.patch b/0138-module-verifier-make-it-possible-to-run-checkers-on-.patch similarity index 87% rename from 0223-module-verifier-make-it-possible-to-run-checkers-on-.patch rename to 0138-module-verifier-make-it-possible-to-run-checkers-on-.patch index 0bdfca1ea98685a23d736b0d5fbf4fdfa9668c7a..0d6301e94f511393549b6a38c51c88f505a7476a 100644 --- a/0223-module-verifier-make-it-possible-to-run-checkers-on-.patch +++ b/0138-module-verifier-make-it-possible-to-run-checkers-on-.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From cf80fb1ad8e247a4d56a9740d489bb85c447a3ca Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 1 Aug 2018 10:24:52 -0400 -Subject: [PATCH] module-verifier: make it possible to run checkers on +Subject: [PATCH 138/220] module-verifier: make it possible to run checkers on grub-module-verifierxx.c This makes it so you can treat grub-module-verifierxx.c as a file you can @@ -22,7 +22,7 @@ Signed-off-by: Peter Jones 3 files changed, 13 insertions(+) diff --git a/util/grub-module-verifier32.c b/util/grub-module-verifier32.c -index 257229f8f08..ba7d41aafea 100644 +index 257229f..ba7d41a 100644 --- a/util/grub-module-verifier32.c +++ b/util/grub-module-verifier32.c @@ -1,2 +1,4 @@ @@ -31,7 +31,7 @@ index 257229f8f08..ba7d41aafea 100644 #include "grub-module-verifierXX.c" +#endif diff --git a/util/grub-module-verifier64.c b/util/grub-module-verifier64.c -index 4db6b4bedd1..fc23ef800b3 100644 +index 4db6b4b..fc23ef8 100644 --- a/util/grub-module-verifier64.c +++ b/util/grub-module-verifier64.c @@ -1,2 +1,4 @@ @@ -40,7 +40,7 @@ index 4db6b4bedd1..fc23ef800b3 100644 #include "grub-module-verifierXX.c" +#endif diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c -index 1feaafc9b9e..597ded14362 100644 +index ceb2430..a98e2f9 100644 --- a/util/grub-module-verifierXX.c +++ b/util/grub-module-verifierXX.c @@ -1,3 +1,12 @@ @@ -56,3 +56,6 @@ index 1feaafc9b9e..597ded14362 100644 #include #include +-- +1.8.3.1 + diff --git a/0226-Rework-how-the-fdt-command-builds.patch b/0139-Rework-how-the-fdt-command-builds.patch similarity index 82% rename from 0226-Rework-how-the-fdt-command-builds.patch rename to 0139-Rework-how-the-fdt-command-builds.patch index 5f66a7a9e6c379580ab67ff71b234f6b4da89cea..1c42474927e59677775082dd7c5e64facc2ecc9c 100644 --- a/0226-Rework-how-the-fdt-command-builds.patch +++ b/0139-Rework-how-the-fdt-command-builds.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 849085d266f998cdcf6191194b12fdf5b52a38bd Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Thu, 12 Jul 2018 11:00:45 -0400 -Subject: [PATCH] Rework how the fdt command builds. +Date: Thu, 11 Jul 2019 13:01:41 +0200 +Subject: [PATCH 139/220] Rework how the fdt command builds. Trying to avoid all variants of: cat syminfo.lst | sort | gawk -f ../../grub-core/genmoddep.awk > moddep.lst || (rm -f moddep.lst; exit 1) @@ -14,18 +14,30 @@ grub_fdt_unload in xen_boot is not defined Signed-off-by: Peter Jones --- + grub-core/Makefile.am | 1 + grub-core/Makefile.core.def | 5 ++--- grub-core/lib/fdt.c | 2 -- grub-core/loader/efi/fdt.c | 2 ++ include/grub/fdt.h | 4 ++++ - grub-core/Makefile.am | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) +diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am +index d9ad300..ee9c4e4 100644 +--- a/grub-core/Makefile.am ++++ b/grub-core/Makefile.am +@@ -76,6 +76,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/sb.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env_private.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/err.h ++KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdt.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/file.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fs.h + KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i18n.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 715d3a3ec02..203584fb00b 100644 +index 48491b5..556adca 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -166,7 +166,6 @@ kernel = { +@@ -175,7 +175,6 @@ kernel = { arm_coreboot = kern/arm/coreboot/init.c; arm_coreboot = kern/arm/coreboot/timer.c; arm_coreboot = kern/arm/coreboot/coreboot.S; @@ -33,24 +45,24 @@ index 715d3a3ec02..203584fb00b 100644 arm_coreboot = bus/fdt.c; arm_coreboot = term/ps2.c; arm_coreboot = term/arm/pl050.c; -@@ -317,6 +316,8 @@ kernel = { - arm64 = kern/arm64/dl.c; - arm64 = kern/arm64/dl_helper.c; +@@ -348,6 +347,8 @@ kernel = { + riscv64 = kern/riscv/cache_flush.S; + riscv64 = kern/riscv/dl.c; + fdt = lib/fdt.c; + emu = disk/host.c; emu = kern/emu/cache_s.S; emu = kern/emu/hostdisk.c; -@@ -1714,7 +1715,6 @@ module = { - arm_uboot = loader/arm/linux.c; - arm64 = loader/arm64/linux.c; +@@ -1801,7 +1802,6 @@ module = { + riscv32 = loader/riscv/linux.c; + riscv64 = loader/riscv/linux.c; emu = loader/emu/linux.c; - fdt = lib/fdt.c; common = loader/linux.c; common = lib/cmdline.c; -@@ -1725,7 +1725,6 @@ module = { +@@ -1812,7 +1812,6 @@ module = { module = { name = fdt; efi = loader/efi/fdt.c; @@ -59,7 +71,7 @@ index 715d3a3ec02..203584fb00b 100644 }; diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c -index 0d371c5633e..37e04bd69e7 100644 +index 0d371c5..37e04bd 100644 --- a/grub-core/lib/fdt.c +++ b/grub-core/lib/fdt.c @@ -21,8 +21,6 @@ @@ -72,7 +84,7 @@ index 0d371c5633e..37e04bd69e7 100644 #define FDT_BEGIN_NODE 0x00000001 diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c -index a4c6e803645..a9dbcfdfeaf 100644 +index ee9c559..37ca407 100644 --- a/grub-core/loader/efi/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -26,6 +26,8 @@ @@ -85,7 +97,7 @@ index a4c6e803645..a9dbcfdfeaf 100644 static void *fdt; diff --git a/include/grub/fdt.h b/include/grub/fdt.h -index 158b1bc4b3a..6ee57e11ab3 100644 +index e609c7e..22b7c54 100644 --- a/include/grub/fdt.h +++ b/include/grub/fdt.h @@ -19,6 +19,8 @@ @@ -97,22 +109,13 @@ index 158b1bc4b3a..6ee57e11ab3 100644 #include #include -@@ -141,4 +143,6 @@ int EXPORT_FUNC(grub_fdt_set_prop) (void *fdt, unsigned int nodeoffset, const ch +@@ -144,4 +146,6 @@ int EXPORT_FUNC(grub_fdt_set_prop) (void *fdt, unsigned int nodeoffset, const ch grub_fdt_set_prop ((fdt), (nodeoffset), "reg", reg_64, 16); \ }) +#endif /* defined(__arm__) || defined(__aarch64__) */ + #endif /* ! GRUB_FDT_HEADER */ -diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am -index 3781bb9cbb9..4062652506d 100644 ---- a/grub-core/Makefile.am -+++ b/grub-core/Makefile.am -@@ -76,6 +76,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/sb.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/env_private.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/err.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdt.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/file.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fs.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i18n.h +-- +1.8.3.1 + diff --git a/0139-Set-the-first-boot-menu-entry-as-default-when-using-.patch b/0139-Set-the-first-boot-menu-entry-as-default-when-using-.patch deleted file mode 100644 index 1e8e73fafa04ad329e3f98efb0f7eb46e6ef95fa..0000000000000000000000000000000000000000 --- a/0139-Set-the-first-boot-menu-entry-as-default-when-using-.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 6 Apr 2018 14:08:36 +0200 -Subject: [PATCH] Set the first boot menu entry as default when using BLS - fragments - -When BootLoaderSpec configuration files are used, the default boot menu -entry is always set to the first entry as sorted by the blscfg command. - -Suggested-by: Peter Jones -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 839f1fdb655..89cd71d852d 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -144,6 +144,7 @@ if [ -s \$prefix/grubenv ]; then - fi - EOF - -+ ${grub_editenv} - set saved_entry=0 - ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" - - exit 0 diff --git a/0227-Disable-non-wordsize-allocations-on-arm.patch b/0140-Disable-non-wordsize-allocations-on-arm.patch similarity index 84% rename from 0227-Disable-non-wordsize-allocations-on-arm.patch rename to 0140-Disable-non-wordsize-allocations-on-arm.patch index 5c627a3707101088f920f0be322861a0242596b2..6722d9c2a4310970c9375e91297d76c6a5d50279 100644 --- a/0227-Disable-non-wordsize-allocations-on-arm.patch +++ b/0140-Disable-non-wordsize-allocations-on-arm.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 454da6e71b93313ce7bc1067ea173ffb709a64bb Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 2 Aug 2018 10:56:38 -0400 -Subject: [PATCH] Disable non-wordsize allocations on arm +Subject: [PATCH 140/220] Disable non-wordsize allocations on arm Signed-off-by: Peter Jones --- @@ -9,10 +9,10 @@ Signed-off-by: Peter Jones 1 file changed, 20 insertions(+) diff --git a/configure.ac b/configure.ac -index 819212095ff..9323c125469 100644 +index cf32748..9b0946c 100644 --- a/configure.ac +++ b/configure.ac -@@ -1234,6 +1234,26 @@ if test "x$target_cpu" = xarm; then +@@ -1262,6 +1262,26 @@ if test "x$target_cpu" = xarm; then done ]) @@ -39,3 +39,6 @@ index 819212095ff..9323c125469 100644 if test x"$grub_cv_target_cc_mno_movt" != xno ; then # A trick so that clang doesn't see it on link stage TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_movt" +-- +1.8.3.1 + diff --git a/0140-tpm-fix-warnings-when-compiling-for-platforms-other-.patch b/0140-tpm-fix-warnings-when-compiling-for-platforms-other-.patch deleted file mode 100644 index 9f9373ff3be13504c32e7200641e3a7045908b73..0000000000000000000000000000000000000000 --- a/0140-tpm-fix-warnings-when-compiling-for-platforms-other-.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Michael Marineau -Date: Sun, 21 Aug 2016 18:24:58 -0700 -Subject: [PATCH] tpm: fix warnings when compiling for platforms other than pc - and efi - ---- - include/grub/tpm.h | 17 +++++++++++------ - 1 file changed, 11 insertions(+), 6 deletions(-) - -diff --git a/include/grub/tpm.h b/include/grub/tpm.h -index ecb2d09ff5d..972a5edc836 100644 ---- a/include/grub/tpm.h -+++ b/include/grub/tpm.h -@@ -75,12 +75,17 @@ grub_err_t grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, - grub_err_t grub_tpm_log_event(unsigned char *buf, grub_size_t size, - grub_uint8_t pcr, const char *description); - #else --static inline grub_err_t grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, -- PassThroughToTPM_OutputParamBlock *outbuf) { return 0; }; --static inline grub_err_t grub_tpm_log_event(unsigned char *buf, -- grub_size_t size, -- grub_uint8_t pcr, -- const char *description) -+static inline grub_err_t grub_tpm_execute( -+ PassThroughToTPM_InputParamBlock *inbuf __attribute__ ((unused)), -+ PassThroughToTPM_OutputParamBlock *outbuf __attribute__ ((unused))) -+{ -+ return 0; -+}; -+static inline grub_err_t grub_tpm_log_event( -+ unsigned char *buf __attribute__ ((unused)), -+ grub_size_t size __attribute__ ((unused)), -+ grub_uint8_t pcr __attribute__ ((unused)), -+ const char *description __attribute__ ((unused))) - { - return 0; - }; diff --git a/0141-Make-TPM-errors-less-fatal.patch b/0141-Make-TPM-errors-less-fatal.patch deleted file mode 100644 index bcee8a199c1ca41de494e120d8c10fe67c19839f..0000000000000000000000000000000000000000 --- a/0141-Make-TPM-errors-less-fatal.patch +++ /dev/null @@ -1,208 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Matthew Garrett -Date: Thu, 13 Oct 2016 13:55:26 -0700 -Subject: [PATCH] Make TPM errors less fatal - -Handle TPM errors, and stop trying to use the TPM once we hit one. ---- - grub-core/kern/dl.c | 1 + - grub-core/kern/i386/pc/tpm.c | 21 +++++++++++++++++---- - grub-core/lib/cmdline.c | 1 + - grub-core/loader/i386/efi/linux.c | 2 ++ - grub-core/loader/i386/linux.c | 1 + - grub-core/loader/i386/multiboot_mbi.c | 1 + - grub-core/loader/i386/pc/linux.c | 1 + - grub-core/loader/linux.c | 2 ++ - grub-core/loader/multiboot.c | 1 + - grub-core/loader/multiboot_mbi2.c | 1 + - grub-core/script/execute.c | 1 + - 11 files changed, 29 insertions(+), 4 deletions(-) - -diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index d0989573866..91105bc4677 100644 ---- a/grub-core/kern/dl.c -+++ b/grub-core/kern/dl.c -@@ -831,6 +831,7 @@ grub_dl_load_file (const char *filename) - grub_file_close (file); - - grub_tpm_measure(core, size, GRUB_BINARY_PCR, "grub_module", filename); -+ grub_print_error(); - - mod = grub_dl_load_core (core, size); - grub_free (core); -diff --git a/grub-core/kern/i386/pc/tpm.c b/grub-core/kern/i386/pc/tpm.c -index 8c6c1e6ece2..f6f264aff2e 100644 ---- a/grub-core/kern/i386/pc/tpm.c -+++ b/grub-core/kern/i386/pc/tpm.c -@@ -7,21 +7,28 @@ - - #define TCPA_MAGIC 0x41504354 - -+static int tpm_presence = -1; -+ - int tpm_present(void); - - int tpm_present(void) - { - struct grub_bios_int_registers regs; - -+ if (tpm_presence != -1) -+ return tpm_presence; -+ - regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; - regs.eax = 0xbb00; - regs.ebx = TCPA_MAGIC; - grub_bios_interrupt (0x1a, ®s); - - if (regs.eax == 0) -- return 1; -+ tpm_presence = 1; -+ else -+ tpm_presence = 0; - -- return 0; -+ return tpm_presence; - } - - grub_err_t -@@ -49,7 +56,10 @@ grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, - grub_bios_interrupt (0x1a, ®s); - - if (regs.eax) -- return grub_error (GRUB_ERR_IO, N_("TPM error %x\n"), regs.eax); -+ { -+ tpm_presence = 0; -+ return grub_error (GRUB_ERR_IO, N_("TPM error %x, disabling TPM"), regs.eax); -+ } - - return 0; - } -@@ -126,7 +136,10 @@ grub_tpm_log_event(unsigned char *buf, grub_size_t size, grub_uint8_t pcr, - grub_free(event); - - if (regs.eax) -- return grub_error (GRUB_ERR_IO, N_("TPM error %x\n"), regs.eax); -+ { -+ tpm_presence = 0; -+ return grub_error (GRUB_ERR_IO, N_("TPM error %x, disabling TPM"), regs.eax); -+ } - - return 0; - } -diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c -index 178f7382f07..d5c12957cad 100644 ---- a/grub-core/lib/cmdline.c -+++ b/grub-core/lib/cmdline.c -@@ -128,6 +128,7 @@ int grub_create_loader_cmdline (int argc, char *argv[], char *buf, - - grub_tpm_measure ((void *)orig, grub_strlen (orig), GRUB_ASCII_PCR, - "grub_kernel_cmdline", orig); -+ grub_print_error(); - - return i; - } -diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 074dbd6513e..ea9f5134e67 100644 ---- a/grub-core/loader/i386/efi/linux.c -+++ b/grub-core/loader/i386/efi/linux.c -@@ -133,6 +133,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - grub_tpm_measure (ptr, cursize, GRUB_BINARY_PCR, "grub_linuxefi", "Initrd"); -+ grub_print_error(); - ptr += cursize; - grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); - ptr += ALIGN_UP_OVERHEAD (cursize, 4); -@@ -198,6 +199,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - } - - grub_tpm_measure (kernel, filelen, GRUB_BINARY_PCR, "grub_linuxefi", "Kernel"); -+ grub_print_error(); - - rc = grub_linuxefi_secure_validate (kernel, filelen); - if (rc < 0) -diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index 273f48a6c88..76304f05700 100644 ---- a/grub-core/loader/i386/linux.c -+++ b/grub-core/loader/i386/linux.c -@@ -726,6 +726,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - } - - grub_tpm_measure (kernel, len, GRUB_BINARY_PCR, "grub_linux", "Kernel"); -+ grub_print_error(); - - grub_memcpy (&lh, kernel, sizeof (lh)); - -diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c -index 2ce424a997b..ca85358f771 100644 ---- a/grub-core/loader/i386/multiboot_mbi.c -+++ b/grub-core/loader/i386/multiboot_mbi.c -@@ -175,6 +175,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) - } - - grub_tpm_measure((unsigned char*)buffer, len, GRUB_BINARY_PCR, "grub_multiboot", filename); -+ grub_print_error(); - - header = find_header (buffer, len); - -diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index 4f8c02288ec..cfff25c21b5 100644 ---- a/grub-core/loader/i386/pc/linux.c -+++ b/grub-core/loader/i386/pc/linux.c -@@ -163,6 +163,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - } - - grub_tpm_measure (kernel, len, GRUB_BINARY_PCR, "grub_linux16", "Kernel"); -+ grub_print_error(); - - grub_memcpy (&lh, kernel, sizeof (lh)); - kernel_offset = sizeof (lh); -diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c -index 78c41e33416..c2c7cfcd0fd 100644 ---- a/grub-core/loader/linux.c -+++ b/grub-core/loader/linux.c -@@ -290,6 +290,8 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, - return grub_errno; - } - grub_tpm_measure (ptr, cursize, GRUB_BINARY_PCR, "grub_initrd", "Initrd"); -+ grub_print_error(); -+ - ptr += cursize; - } - if (newc) -diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c -index 3b87dc4fab3..9a8dae5565b 100644 ---- a/grub-core/loader/multiboot.c -+++ b/grub-core/loader/multiboot.c -@@ -442,6 +442,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), - - grub_file_close (file); - grub_tpm_measure (module, size, GRUB_BINARY_PCR, "grub_multiboot", argv[0]); -+ grub_print_error(); - return GRUB_ERR_NONE; - } - -diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c -index 60ae4606fda..54078455e2f 100644 ---- a/grub-core/loader/multiboot_mbi2.c -+++ b/grub-core/loader/multiboot_mbi2.c -@@ -133,6 +133,7 @@ grub_multiboot2_load (grub_file_t file, const char *filename) - COMPILE_TIME_ASSERT (MULTIBOOT_HEADER_ALIGN % 4 == 0); - - grub_tpm_measure ((unsigned char *)mld.buffer, len, GRUB_BINARY_PCR, "grub_multiboot", filename); -+ grub_print_error(); - - header = find_header (mld.buffer, len); - if (header == 0) -diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index 976643c47b0..93965777138 100644 ---- a/grub-core/script/execute.c -+++ b/grub-core/script/execute.c -@@ -997,6 +997,7 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) - cmdstring[cmdlen-1]= '\0'; - grub_tpm_measure ((unsigned char *)cmdstring, cmdlen, GRUB_ASCII_PCR, - "grub_cmd", cmdstring); -+ grub_print_error(); - grub_free(cmdstring); - invert = 0; - argc = argv.argc - 1; diff --git a/0228-strip-R-.note.gnu.property-at-more-places.patch b/0141-strip-R-.note.gnu.property-at-more-places.patch similarity index 93% rename from 0228-strip-R-.note.gnu.property-at-more-places.patch rename to 0141-strip-R-.note.gnu.property-at-more-places.patch index 0bd0be099555ea18e512afeda3d506b5aced70fb..aa8663e43ead73ada4868da4d2485281d67dfc36 100644 --- a/0228-strip-R-.note.gnu.property-at-more-places.patch +++ b/0141-strip-R-.note.gnu.property-at-more-places.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From bb28d337980306efaaac35cf5515cdfbaecc28e3 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Fri, 3 Aug 2018 15:07:23 -0400 -Subject: [PATCH] strip "-R .note.gnu.property" at more places. +Subject: [PATCH 141/220] strip "-R .note.gnu.property" at more places. For whatever reason, sometimes I see: @@ -55,7 +55,7 @@ Signed-off-by: Peter Jones 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am -index c7b0e6a9c46..287fff66b20 100644 +index bf9c1ba..0d4dd7c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -209,7 +209,7 @@ pc-chainloader.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S $(srcdir)/grub- @@ -68,10 +68,10 @@ index c7b0e6a9c46..287fff66b20 100644 ntldr.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S $(TARGET_CC) -o $@ $< -DTARGET_NTLDR=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -static -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0 -m32 diff --git a/gentpl.py b/gentpl.py -index 1e4635f4426..d662c305f66 100644 +index 95fe1a2..32cf745 100644 --- a/gentpl.py +++ b/gentpl.py -@@ -776,7 +776,7 @@ def image(defn, platform): +@@ -779,7 +779,7 @@ def image(defn, platform): if test x$(TARGET_APPLE_LINKER) = x1; then \ $(MACHO2IMG) $< $@; \ else \ @@ -80,3 +80,6 @@ index 1e4635f4426..d662c305f66 100644 fi """) +-- +1.8.3.1 + diff --git a/0229-Prepend-prefix-when-HTTP-path-is-relative.patch b/0142-Prepend-prefix-when-HTTP-path-is-relative.patch similarity index 83% rename from 0229-Prepend-prefix-when-HTTP-path-is-relative.patch rename to 0142-Prepend-prefix-when-HTTP-path-is-relative.patch index 9e9063643a150f8bed8494928ca869c88ae42fa6..3c086afd2602c0c92703a259901618a0bf0d83d7 100644 --- a/0229-Prepend-prefix-when-HTTP-path-is-relative.patch +++ b/0142-Prepend-prefix-when-HTTP-path-is-relative.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From d8321112ee226889aeeedff6c83a7c0f49151cc9 Mon Sep 17 00:00:00 2001 From: Stephen Benjamin Date: Thu, 16 Aug 2018 16:58:51 -0400 -Subject: [PATCH] Prepend prefix when HTTP path is relative +Subject: [PATCH 142/220] Prepend prefix when HTTP path is relative This sets a couple of variables. With the url http://www.example.com/foo/bar : http_path: /foo/bar @@ -10,11 +10,11 @@ http_url: http://www.example.com/foo/bar Signed-off-by: Peter Jones --- grub-core/kern/main.c | 10 +++++- - grub-core/net/efi/http.c | 82 ++++++++++++++++++++++++++++++++++++------------ - 2 files changed, 71 insertions(+), 21 deletions(-) + grub-core/net/efi/http.c | 84 ++++++++++++++++++++++++++++++++++++------------ + 2 files changed, 72 insertions(+), 22 deletions(-) diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index da47b18b50e..dcf48726d54 100644 +index da47b18..dcf4872 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c @@ -130,11 +130,19 @@ grub_set_prefix_and_root (void) @@ -39,7 +39,7 @@ index da47b18b50e..dcf48726d54 100644 } } diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c -index 243acbaa35b..2a9624dacc4 100644 +index 243acba..de351b2 100644 --- a/grub-core/net/efi/http.c +++ b/grub-core/net/efi/http.c @@ -9,10 +9,52 @@ @@ -56,7 +56,7 @@ index 243acbaa35b..2a9624dacc4 100644 + const char *rest, *http_server, *http_path = NULL; + + http_server = grub_env_get ("root"); -+ https = grub_strncmp (http_server, "https", 5) ? 1 : 0; ++ https = (grub_strncmp (http_server, "https", 5) == 0) ? 1 : 0; + + /* extract http server + port */ + if (http_server) @@ -102,16 +102,10 @@ index 243acbaa35b..2a9624dacc4 100644 - char *root_url; - grub_efi_ipv6_address_t address; - const char *rest; -+ char *file_name; -+ const char *http_path; - +- - if (grub_efi_string_to_ip6_address (file->device->net->server, &address, &rest) && *rest == 0) - root_url = grub_xasprintf ("%s://[%s]", type ? "https" : "http", file->device->net->server); -+ /* If path is relative, prepend http_path */ -+ http_path = grub_env_get ("http_path"); -+ if (http_path && file->device->net->name[0] != '/') -+ file_name = grub_xasprintf ("%s/%s", http_path, file->device->net->name); - else +- else - root_url = grub_xasprintf ("%s://%s", type ? "https" : "http", file->device->net->server); - if (root_url) - { @@ -121,15 +115,21 @@ index 243acbaa35b..2a9624dacc4 100644 - } - else - { -- return grub_errno; ++ char *file_name = NULL; ++ const char *http_path; ++ ++ /* If path is relative, prepend http_path */ ++ http_path = grub_env_get ("http_path"); ++ if (http_path && file->device->net->name[0] != '/') { ++ file_name = grub_xasprintf ("%s/%s", http_path, file->device->net->name); ++ if (!file_name) + return grub_errno; - } -+ file_name = grub_strdup (file->device->net->name); ++ } - err = efihttp_request (dev->http, file->device->net->server, file->device->net->name, type, 1, 0); -+ if (!file_name) -+ return grub_errno; -+ -+ err = efihttp_request (dev->http, file->device->net->server, file_name, type, 1, 0); ++ err = efihttp_request (dev->http, file->device->net->server, ++ file_name ? file_name : file->device->net->name, type, 1, 0); if (err != GRUB_ERR_NONE) - return err; + { @@ -138,7 +138,8 @@ index 243acbaa35b..2a9624dacc4 100644 + } - err = efihttp_request (dev->http, file->device->net->server, file->device->net->name, type, 0, &size); -+ err = efihttp_request (dev->http, file->device->net->server, file_name, type, 0, &size); ++ err = efihttp_request (dev->http, file->device->net->server, ++ file_name ? file_name : file->device->net->name, type, 0, &size); + grub_free (file_name); if (err != GRUB_ERR_NONE) - return err; @@ -148,3 +149,6 @@ index 243acbaa35b..2a9624dacc4 100644 buf = grub_malloc (size); efihttp_read (dev, buf, size); +-- +1.8.3.1 + diff --git a/0142-blscfg-handle-multiple-initramfs-images.patch b/0142-blscfg-handle-multiple-initramfs-images.patch deleted file mode 100644 index 2050ffa6ca922287929a7d7f878ab87cbb1a5c27..0000000000000000000000000000000000000000 --- a/0142-blscfg-handle-multiple-initramfs-images.patch +++ /dev/null @@ -1,104 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 11 Apr 2018 13:44:29 -0400 -Subject: [PATCH] blscfg: handle multiple initramfs images. - -Signed-off-by: Peter Jones ---- - grub-core/commands/blscfg.c | 54 ++++++++++++++++++++++++++++++++++++--------- - 1 file changed, 44 insertions(+), 10 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index e775c6b8794..6ab85df6b3a 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -587,6 +587,7 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - char *title = NULL; - char *clinux = NULL; - char *options = NULL; -+ char **initrds = NULL; - char *initrd = NULL; - char *id = NULL; - char *hotkey = NULL; -@@ -609,7 +610,7 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - - title = bls_get_val (entry, "title", NULL); - options = bls_get_val (entry, "options", NULL); -- initrd = bls_get_val (entry, "initrd", NULL); -+ initrds = bls_make_list (entry, "initrd", NULL); - id = bls_get_val (entry, "id", NULL); - - hotkey = bls_get_val (entry, "grub_hotkey", NULL); -@@ -624,30 +625,63 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - argv[i] = args[i-1]; - argv[argc] = NULL; - -- grub_dprintf("blscfg", "adding menu entry for \"%s\"\n", title); -+ grub_dprintf ("blscfg", "adding menu entry for \"%s\"\n", title); -+ if (initrds) -+ { -+ int initrd_size = sizeof (GRUB_INITRD_CMD); -+ char *tmp; -+ -+ for (i = 0; initrds != NULL && initrds[i] != NULL; i++) -+ initrd_size += sizeof (" " GRUB_BOOT_DEVICE) \ -+ + grub_strlen (initrds[i]) + 1; -+ initrd_size += 1; -+ -+ initrd = grub_malloc (initrd_size); -+ if (!initrd) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -+ goto finish; -+ } -+ -+ -+ tmp = grub_stpcpy(initrd, GRUB_INITRD_CMD); -+ for (i = 0; initrds != NULL && initrds[i] != NULL; i++) -+ { -+ grub_dprintf ("blscfg", "adding initrd %s\n", initrds[i]); -+ tmp = grub_stpcpy (tmp, " " GRUB_BOOT_DEVICE); -+ tmp = grub_stpcpy (tmp, initrds[i]); -+ } -+ tmp = grub_stpcpy (tmp, "\n"); -+ } -+ - src = grub_xasprintf ("load_video\n" - "set gfx_payload=keep\n" - "insmod gzio\n" - GRUB_LINUX_CMD " %s%s%s%s\n" -- "%s%s%s%s", -+ "%s", - GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", -- initrd ? GRUB_INITRD_CMD " " : "", initrd ? GRUB_BOOT_DEVICE : "", initrd ? initrd : "", initrd ? "\n" : ""); -+ initrd ? initrd : ""); - - grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0); - - finish: -+ if (initrd) -+ grub_free (initrd); -+ -+ if (initrds) -+ grub_free (initrds); -+ - if (classes) -- grub_free (classes); -- grub_dprintf("blscfg", "%s got here\n", __func__); -+ grub_free (classes); -+ - if (args) -- grub_free (args); -+ grub_free (args); - - if (argv) -- grub_free (argv); -+ grub_free (argv); - - if (src) -- grub_free (src); -- grub_dprintf("blscfg", "%s got here\n", __func__); -+ grub_free (src); - } - - struct find_entry_info { diff --git a/0143-BLS-Fix-grub2-switch-to-blscfg-on-non-EFI-machines.patch b/0143-BLS-Fix-grub2-switch-to-blscfg-on-non-EFI-machines.patch deleted file mode 100644 index a04564621a2fc9cae458be6f2e1bcb2522d00ebe..0000000000000000000000000000000000000000 --- a/0143-BLS-Fix-grub2-switch-to-blscfg-on-non-EFI-machines.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jan Hlavac -Date: Tue, 10 Apr 2018 16:07:36 +0200 -Subject: [PATCH] BLS: Fix grub2-switch-to-blscfg on non-EFI machines - -On the non-EFI machines the grub2-switch-to-blscfg script places the BLS -snippets into the /boot directory. But the right location is -/boot/loader/entries. ---- - util/grub-switch-to-blscfg.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 3ae5e4ea8d0..f740b8f4d03 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -44,7 +44,7 @@ if [ -d /sys/firmware/efi/efivars/ ]; then - else - startlink=/etc/grub2.cfg - grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'` -- blsdir=`echo "/@bootdirname@" | sed 's,//*,/,g'` -+ blsdir=`echo "/@bootdirname@/loader/entries" | sed 's,//*,/,g'` - fi - - backupsuffix=.bak diff --git a/0230-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch b/0143-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch similarity index 92% rename from 0230-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch rename to 0143-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch index e0becd6e351ce564d0397d2f3b68791232c537bb..73183f66e18b5199ef69da7af337220bd3a01ab3 100644 --- a/0230-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch +++ b/0143-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch @@ -1,7 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 1fc3dfd0a51daf61a4605217a89d35232d11959b Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 16 Aug 2018 11:08:11 -0400 -Subject: [PATCH] Make linux_arm_kernel_header.hdr_offset be at the right place +Subject: [PATCH 143/220] Make linux_arm_kernel_header.hdr_offset be at the + right place The kernel in front of me (slightly edited to make objdump work) looks like: @@ -42,7 +43,7 @@ Signed-off-by: Peter Jones 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index 0622dfa48d4..b56ea0bc041 100644 +index 0622dfa..b56ea0b 100644 --- a/grub-core/loader/efi/linux.c +++ b/grub-core/loader/efi/linux.c @@ -79,7 +79,10 @@ grub_efi_linux_boot (void *kernel_addr, grub_off_t handover_offset, @@ -57,7 +58,7 @@ index 0622dfa48d4..b56ea0bc041 100644 return GRUB_ERR_BUG; diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h -index 5900fc8a40c..bed308f22cb 100644 +index 775297d..b582f67 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -31,7 +31,7 @@ struct linux_arm_kernel_header { @@ -69,3 +70,6 @@ index 5900fc8a40c..bed308f22cb 100644 grub_uint32_t hdr_offset; }; +-- +1.8.3.1 + diff --git a/0144-BLS-Use-etcdefaultgrub-instead-of-etc.patch b/0144-BLS-Use-etcdefaultgrub-instead-of-etc.patch deleted file mode 100644 index db974101eab1372af09f6069a355dd40a90f9765..0000000000000000000000000000000000000000 --- a/0144-BLS-Use-etcdefaultgrub-instead-of-etc.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jan Hlavac -Date: Tue, 10 Apr 2018 16:56:28 +0200 -Subject: [PATCH] BLS: Use ${etcdefaultgrub} instead of /etc/... - -Inside the grub-switch-to-blscfg script the ${etcdefaultgrub} variable -is used. So replace the hardcoded /etc/default/grub with it. ---- - util/grub-switch-to-blscfg.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index f740b8f4d03..eae3c379e4a 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -252,7 +252,7 @@ if [[ "${GENERATE}" -eq 1 ]] ; then - cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}" - sed -i"${backupsuffix}" \ - -e 's,^GRUB_ENABLE_BLSCFG=.*,GRUB_ENABLE_BLSCFG=false,' \ -- /etc/default/grub -+ "${etcdefaultgrub}" - gettext_printf "Updating %s failed\n" "${GRUB_CONFIG_FILE}" - exit 1 - fi diff --git a/0232-Make-grub_error-more-verbose.patch b/0144-Make-grub_error-more-verbose.patch similarity index 91% rename from 0232-Make-grub_error-more-verbose.patch rename to 0144-Make-grub_error-more-verbose.patch index 6fffdeb7247c83964fb31283e7858dfb90e82035..f2ed9536bea94d2a81a6129f70bd1a11cbdf9ede 100644 --- a/0232-Make-grub_error-more-verbose.patch +++ b/0144-Make-grub_error-more-verbose.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From c1576dc60b66fc5219e99d8b6c817287c5f5ec4b Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 27 Aug 2018 13:14:06 -0400 -Subject: [PATCH] Make grub_error() more verbose +Subject: [PATCH 144/220] Make grub_error() more verbose Signed-off-by: Peter Jones --- @@ -11,7 +11,7 @@ Signed-off-by: Peter Jones 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index 5cdf6c943f2..7692e63ba24 100644 +index a9e3710..15595a4 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -157,12 +157,20 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, @@ -50,7 +50,7 @@ index 5cdf6c943f2..7692e63ba24 100644 grub_efi_store_alloc (address, pages); diff --git a/grub-core/kern/err.c b/grub-core/kern/err.c -index 53c734de70e..aebfe0cf839 100644 +index 53c734d..aebfe0c 100644 --- a/grub-core/kern/err.c +++ b/grub-core/kern/err.c @@ -33,15 +33,24 @@ static struct grub_error_saved grub_error_stack_items[GRUB_ERROR_STACK_SIZE]; @@ -81,10 +81,10 @@ index 53c734de70e..aebfe0cf839 100644 return n; diff --git a/include/grub/err.h b/include/grub/err.h -index 1590c688e1d..9b830757d35 100644 +index 24ba9f5..b68bbec 100644 --- a/include/grub/err.h +++ b/include/grub/err.h -@@ -84,7 +84,10 @@ struct grub_error_saved +@@ -85,7 +85,10 @@ struct grub_error_saved extern grub_err_t EXPORT_VAR(grub_errno); extern char EXPORT_VAR(grub_errmsg)[GRUB_MAX_ERRMSG]; @@ -96,3 +96,6 @@ index 1590c688e1d..9b830757d35 100644 void EXPORT_FUNC(grub_fatal) (const char *fmt, ...) __attribute__ ((noreturn)); void EXPORT_FUNC(grub_error_push) (void); int EXPORT_FUNC(grub_error_pop) (void); +-- +1.8.3.1 + diff --git a/0145-Add-missing-options-to-grub2-switch-to-blscfg-man-pa.patch b/0145-Add-missing-options-to-grub2-switch-to-blscfg-man-pa.patch deleted file mode 100644 index 16ab928c3b68d189b970e6941387d27ab96ace50..0000000000000000000000000000000000000000 --- a/0145-Add-missing-options-to-grub2-switch-to-blscfg-man-pa.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 11 Apr 2018 11:36:43 +0200 -Subject: [PATCH] Add missing options to grub2-switch-to-blscfg man page - -The script --bls-directory and --backup-suffix options were not documented -in the man page, add them as well so users can know what these are about. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.8 | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/util/grub-switch-to-blscfg.8 b/util/grub-switch-to-blscfg.8 -index 134dfc62a7b..7d99de2d2f9 100644 ---- a/util/grub-switch-to-blscfg.8 -+++ b/util/grub-switch-to-blscfg.8 -@@ -21,5 +21,13 @@ The grub config file to use. The default value is \fI/etc/grub2-efi.cfg\fR on U - --grub-defaults=\fIFILE\fR - The defaults file for grub-mkconfig. The default value is \fI/etc/default/grub\fR. - -+.TP -+--bls-directory=\fIDIR\fR -+Create BootLoaderSpec fragments in \fIDIR\fR. The default value is \fI/boot/loader/entries\fR on BIOS machines and \fI/boot/efi/EFI/\fBVENDOR\fI/loader/entries\fR on UEFI machines. -+ -+.TP -+--backup-suffix=\fSUFFIX\fR -+The suffix to use for saved backup files. The default value is \fI.bak\fR. -+ - .SH SEE ALSO - .BR "info grub" diff --git a/0233-Make-reset-an-alias-for-the-reboot-command.patch b/0145-Make-reset-an-alias-for-the-reboot-command.patch similarity index 86% rename from 0233-Make-reset-an-alias-for-the-reboot-command.patch rename to 0145-Make-reset-an-alias-for-the-reboot-command.patch index c86acf18a627bd3725b89d2a816648fa252dead9..6af5d06871aa017bc2cf7c9d2a23d45dd3b78aa5 100644 --- a/0233-Make-reset-an-alias-for-the-reboot-command.patch +++ b/0145-Make-reset-an-alias-for-the-reboot-command.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 0ad7fa987ac696ec412e3247e548a1e05e269537 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Fri, 31 Aug 2018 16:42:03 -0400 -Subject: [PATCH] Make "reset" an alias for the "reboot" command. +Subject: [PATCH 145/220] Make "reset" an alias for the "reboot" command. I'm really tired of half the tools I get to use having one and the other half having the other. @@ -12,7 +12,7 @@ Signed-off-by: Peter Jones 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/grub-core/commands/reboot.c b/grub-core/commands/reboot.c -index 46d364c99a9..f5cc2283636 100644 +index 46d364c..f5cc228 100644 --- a/grub-core/commands/reboot.c +++ b/grub-core/commands/reboot.c @@ -32,15 +32,18 @@ grub_cmd_reboot (grub_command_t cmd __attribute__ ((unused)), @@ -38,3 +38,6 @@ index 46d364c99a9..f5cc2283636 100644 + grub_unregister_command (reboot_cmd); + grub_unregister_command (reset_cmd); } +-- +1.8.3.1 + diff --git a/0234-EFI-more-debug-output-on-GOP-and-UGA-probing.patch b/0146-EFI-more-debug-output-on-GOP-and-UGA-probing.patch similarity index 90% rename from 0234-EFI-more-debug-output-on-GOP-and-UGA-probing.patch rename to 0146-EFI-more-debug-output-on-GOP-and-UGA-probing.patch index 37d6f4d3f3204e3e7e17b604797e88a643e73f1a..85de92f2705341162b98f0e9230802227aebca25 100644 --- a/0234-EFI-more-debug-output-on-GOP-and-UGA-probing.patch +++ b/0146-EFI-more-debug-output-on-GOP-and-UGA-probing.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 18dd72a5313ff33acaa0dd5e933ea7933439cedc Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Mon, 10 Sep 2018 13:01:24 -0400 -Subject: [PATCH] EFI: more debug output on GOP and UGA probing. +Subject: [PATCH 146/220] EFI: more debug output on GOP and UGA probing. Signed-off-by: Peter Jones --- @@ -10,7 +10,7 @@ Signed-off-by: Peter Jones 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/grub-core/video/efi_gop.c b/grub-core/video/efi_gop.c -index c9e40e8d4e9..be446f8d291 100644 +index c9e40e8..be446f8 100644 --- a/grub-core/video/efi_gop.c +++ b/grub-core/video/efi_gop.c @@ -71,7 +71,10 @@ check_protocol (void) @@ -43,7 +43,7 @@ index c9e40e8d4e9..be446f8d291 100644 } diff --git a/grub-core/video/efi_uga.c b/grub-core/video/efi_uga.c -index 97a607c01a5..e74d6c23500 100644 +index 97a607c..e74d6c2 100644 --- a/grub-core/video/efi_uga.c +++ b/grub-core/video/efi_uga.c @@ -110,7 +110,7 @@ find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data) @@ -64,3 +64,6 @@ index 97a607c01a5..e74d6c23500 100644 ((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) ? "VMEM" : "MMIO"), type == GRUB_PCI_ADDR_MEM_TYPE_64 ? i - 1 : i, base64); +-- +1.8.3.1 + diff --git a/0146-Make-grub2-switch-to-blscfg-to-generate-debug-BLS-wh.patch b/0146-Make-grub2-switch-to-blscfg-to-generate-debug-BLS-wh.patch deleted file mode 100644 index 5e47f2d848e6a95fd108095fba376901817f5433..0000000000000000000000000000000000000000 --- a/0146-Make-grub2-switch-to-blscfg-to-generate-debug-BLS-wh.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 11 Apr 2018 11:49:24 +0200 -Subject: [PATCH] Make grub2-switch-to-blscfg to generate debug BLS when - MAKEDEBUG is set - -If MAKEDEBUG=yes in /etc/sysconfig/kernel, then a debug menu entry should -be created. So for BLS, a debug configuration file has to be created that -contains additional debug kernel command line parameters. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 15 +++++++++++++++ - 1 file changed, 15 insertions(+) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index eae3c379e4a..c59299ffa6a 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -21,6 +21,7 @@ - # Initialize some variables. - prefix=@prefix@ - exec_prefix=@exec_prefix@ -+sbindir=@sbindir@ - bindir=@bindir@ - sysconfdir="@sysconfdir@" - PACKAGE_NAME=@PACKAGE_NAME@ -@@ -33,9 +34,12 @@ fi - - self=`basename $0` - -+grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@" - grub_editenv=${bindir}/@grub_editenv@ - etcdefaultgrub=/etc/default/grub - -+eval "$("${grub_get_kernel_settings}")" || true -+ - EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') - if [ -d /sys/firmware/efi/efivars/ ]; then - startlink=/etc/grub2-efi.cfg -@@ -226,6 +230,17 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \ - >"${bls_target}" - fi -+ -+ if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -+ arch="$(uname -m)" -+ bls_debug="$(echo ${bls_target} | sed -e "s/\.${arch}/-debug.${arch}/")" -+ cp -aT "${bls_target}" "${bls_debug}" -+ title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')" -+ blsid="$(grep '^id[ \t]' "${bls_debug}" | sed -e "s/\.${ARCH}/-debug.${arch}/")" -+ sed -i -e "s/^title.*/title ${title}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${bls_debug}" -+ sed -i -e "s/^id.*/${blsid}/" "${bls_debug}" -+ sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${bls_debug}" -+ fi - done - - GENERATE=0 diff --git a/0235-Add-a-version-command.patch b/0147-Add-a-version-command.patch similarity index 91% rename from 0235-Add-a-version-command.patch rename to 0147-Add-a-version-command.patch index f7398b943bd7c77debbf58c55a0c9cbc56ef407f..2b4ec61f88152089af9498833e6ddcd2fee11a2d 100644 --- a/0235-Add-a-version-command.patch +++ b/0147-Add-a-version-command.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 568f0094df7aeef7ec558142139c7e93a4d019f3 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 11 Sep 2018 14:20:37 -0400 -Subject: [PATCH] Add a "version" command. +Subject: [PATCH 147/220] Add a "version" command. This adds a command that shows you info about grub's version, the grub target platform, the compiler version, and if you built with @@ -9,18 +9,30 @@ platform, the compiler version, and if you built with Signed-off-by: Peter Jones --- + config.h.in | 1 + configure.ac | 13 ++++++++++ grub-core/Makefile.core.def | 5 ++++ grub-core/commands/version.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ - config.h.in | 1 + 4 files changed, 75 insertions(+) create mode 100644 grub-core/commands/version.c +diff --git a/config.h.in b/config.h.in +index 9e8f991..c7e316f 100644 +--- a/config.h.in ++++ b/config.h.in +@@ -59,6 +59,7 @@ + + #define GRUB_TARGET_CPU "@GRUB_TARGET_CPU@" + #define GRUB_PLATFORM "@GRUB_PLATFORM@" ++#define GRUB_RPM_VERSION "@GRUB_RPM_VERSION@" + + #define RE_ENABLE_I18N 1 + diff --git a/configure.ac b/configure.ac -index 9323c125469..61c4683cb76 100644 +index 9b0946c..bca7c28 100644 --- a/configure.ac +++ b/configure.ac -@@ -287,6 +287,19 @@ AC_SUBST(target_cpu) +@@ -303,6 +303,19 @@ AC_SUBST(target_cpu) AC_SUBST(platform) # Define default variables @@ -41,24 +53,24 @@ index 9323c125469..61c4683cb76 100644 have_with_bootdir=n AC_ARG_WITH([bootdir], diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 203584fb00b..701e5d32fa2 100644 +index 556adca..8bb1daf 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -537,6 +537,11 @@ image = { - enable = mips_loongson; +@@ -577,6 +577,11 @@ image = { }; -+module = { + module = { + name = version; + common = commands/version.c; +}; + - module = { ++module = { name = disk; common = lib/disk.c; + extra_dist = kern/disk_common.c; diff --git a/grub-core/commands/version.c b/grub-core/commands/version.c new file mode 100644 -index 00000000000..f0966a518f7 +index 0000000..f0966a5 --- /dev/null +++ b/grub-core/commands/version.c @@ -0,0 +1,56 @@ @@ -118,15 +130,6 @@ index 00000000000..f0966a518f7 +{ + grub_unregister_command (cmd); +} -diff --git a/config.h.in b/config.h.in -index 9e8f9911b18..c7e316f0f1f 100644 ---- a/config.h.in -+++ b/config.h.in -@@ -59,6 +59,7 @@ - - #define GRUB_TARGET_CPU "@GRUB_TARGET_CPU@" - #define GRUB_PLATFORM "@GRUB_PLATFORM@" -+#define GRUB_RPM_VERSION "@GRUB_RPM_VERSION@" - - #define RE_ENABLE_I18N 1 - +-- +1.8.3.1 + diff --git a/0147-Make-grub2-switch-to-blscfg-to-generate-BLS-fragment.patch b/0147-Make-grub2-switch-to-blscfg-to-generate-BLS-fragment.patch deleted file mode 100644 index eb1726be832082045807653d2f7d246a0ecfefb7..0000000000000000000000000000000000000000 --- a/0147-Make-grub2-switch-to-blscfg-to-generate-BLS-fragment.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 11 Apr 2018 12:39:59 +0200 -Subject: [PATCH] Make grub2-switch-to-blscfg to generate BLS fragment for - rescue kernel - -If a rescue image is available, it should have a BootLoaderSpec fragment. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index c59299ffa6a..bc28053cd30 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -243,6 +243,10 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - fi - done - -+if [[ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]]; then -+ mkbls "0-rescue-${MACHINE_ID}" "0" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" -+fi -+ - GENERATE=0 - if grep '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" \ - | grep -vq '^GRUB_ENABLE_BLSCFG="*true"*\s*$' ; then diff --git a/0236-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch b/0148-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch similarity index 86% rename from 0236-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch rename to 0148-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch index a86e6da70b45f00fec9f2dad11bc672d9a950bab..04d9b79e7a1870e6d0d47151342b4eebd2e394c9 100644 --- a/0236-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch +++ b/0148-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 088dae49c71c95b0c354afabad3263aca9a6d8bf Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Tue, 11 Sep 2018 15:58:29 -0400 -Subject: [PATCH] Add more dprintf, and nerf dprintf in script.c +Subject: [PATCH 148/220] Add more dprintf, and nerf dprintf in script.c Signed-off-by: Peter Jones --- @@ -12,7 +12,7 @@ Signed-off-by: Peter Jones 4 files changed, 10 insertions(+) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c -index 6f901c0adf7..66f6b992604 100644 +index c3b578a..1a3eb6b 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -188,6 +188,8 @@ scan_disk (const char *name, int accept_diskfilter) @@ -33,10 +33,10 @@ index 6f901c0adf7..66f6b992604 100644 if (!pv->disk) return grub_errno; diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c -index 5d2400f66f2..4bc51877f04 100644 +index 9e20af7..54c227b 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c -@@ -846,6 +846,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) +@@ -855,6 +855,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) return 0; } @@ -45,7 +45,7 @@ index 5d2400f66f2..4bc51877f04 100644 grub_free (dup_dp); diff --git a/grub-core/kern/device.c b/grub-core/kern/device.c -index 73b8ecc0c09..f58b58c89d5 100644 +index 73b8ecc..f58b58c 100644 --- a/grub-core/kern/device.c +++ b/grub-core/kern/device.c @@ -34,6 +34,7 @@ grub_device_open (const char *name) @@ -57,7 +57,7 @@ index 73b8ecc0c09..f58b58c89d5 100644 { name = grub_env_get ("root"); diff --git a/grub-core/script/script.c b/grub-core/script/script.c -index ec4d4337c66..844e8343ca7 100644 +index ec4d433..844e834 100644 --- a/grub-core/script/script.c +++ b/grub-core/script/script.c @@ -22,6 +22,11 @@ @@ -72,3 +72,6 @@ index ec4d4337c66..844e8343ca7 100644 /* It is not possible to deallocate the memory when a syntax error was found. Because of that it is required to keep track of all memory allocations. The memory is freed in case of an error, or assigned +-- +1.8.3.1 + diff --git a/0148-Only-attempt-to-query-dev-mounted-in-boot-efi-as-boo.patch b/0148-Only-attempt-to-query-dev-mounted-in-boot-efi-as-boo.patch deleted file mode 100644 index 84b01675348c11d2a4c274a1c00df22bf3393fff..0000000000000000000000000000000000000000 --- a/0148-Only-attempt-to-query-dev-mounted-in-boot-efi-as-boo.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 24 Apr 2018 02:16:38 +0200 -Subject: [PATCH] Only attempt to query dev mounted in /boot/efi as boot dev on - EFI machines - -The 10_linux script calls grub2-probe to probe the information for the dev -mounted in /boot/efi, but this directory may not exist on non-EFI machines -which leads to the following error when generating the grub2 config file: - -/usr/sbin/grub2-probe: error: failed to get canonical path of `/boot/efi/' - -Instead query for the device mounted in /boot and use that as the boot dev -for non-EFI machines. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 89cd71d852d..61d0664fb5c 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -133,8 +133,13 @@ linux_entry () - fi - fi - -- bootefi_device="`${grub_probe} --target=device /boot/efi/`" -- prepare_grub_to_access_device ${bootefi_device} boot -+ if [ -d /sys/firmware/efi ]; then -+ bootefi_device="`${grub_probe} --target=device /boot/efi/`" -+ prepare_grub_to_access_device ${bootefi_device} boot -+ else -+ boot_device="`${grub_probe} --target=device /boot/`" -+ prepare_grub_to_access_device ${boot_device} boot -+ fi - - cat << EOF - insmod blscfg diff --git a/0149-Include-OSTree-path-when-searching-kernels-images-if.patch b/0149-Include-OSTree-path-when-searching-kernels-images-if.patch deleted file mode 100644 index 70b33b3475b7b0d474261dfcdff7ce284c518d3f..0000000000000000000000000000000000000000 --- a/0149-Include-OSTree-path-when-searching-kernels-images-if.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 24 Apr 2018 02:28:04 +0200 -Subject: [PATCH] Include OSTree path when searching kernels images if BLS - config is enabled - -The OSTree based distros (i.e: Fedora Atomic) don't install kernel images -in the /boot directory, but in /boot/ostree. So the 10_linux script isn't -able to include these kernels in its list, so the linux_entry() function -is never called. - -This isn't a problem since the 10_linux script isn't used to populate the -menu entries anyways, but instead a custom 15_ostree script is used. But -for BLS we want the 10_linux script to generate the minimal grub.cfg that -calls the blscfg command, so add the OSTree kernel images to the list. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/10_linux.in | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 61d0664fb5c..9682e97b7f5 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -237,6 +237,12 @@ case "x$machine" in - done ;; - esac - -+if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then -+ for i in /boot/ostree/*/vmlinuz-* ; do -+ if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi -+ done -+fi -+ - case "$machine" in - i?86) GENKERNEL_ARCH="x86" ;; - mips|mips64) GENKERNEL_ARCH="mips" ;; diff --git a/0237-arm-arm64-loader-Better-memory-allocation-and-error-.patch b/0149-arm-arm64-loader-Better-memory-allocation-and-error-.patch similarity index 83% rename from 0237-arm-arm64-loader-Better-memory-allocation-and-error-.patch rename to 0149-arm-arm64-loader-Better-memory-allocation-and-error-.patch index a5cc064ab25625d8b428aa18a2401d793758b0e2..740ea2e80fa9d2fb57b604ec20f3efad52fdeed0 100644 --- a/0237-arm-arm64-loader-Better-memory-allocation-and-error-.patch +++ b/0149-arm-arm64-loader-Better-memory-allocation-and-error-.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 5df842469c4b53ecabeaad3edca5f31355507cee Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Tue, 14 Aug 2018 14:07:44 -0400 -Subject: [PATCH] arm/arm64 loader: Better memory allocation and error +Date: Thu, 11 Jul 2019 14:38:57 +0200 +Subject: [PATCH 149/220] arm/arm64 loader: Better memory allocation and error messages. On mustang, our memory map looks like: @@ -54,16 +54,8 @@ MMIO 0000000010548000-0000000010549fff 00000002 8KiB RT MMIO 0000000017000000-0000000017001fff 00000002 8KiB RT MMIO 000000001c025000-000000001c025fff 00000001 4KiB RT -When we're trying to find the base of ram, if we start with GRUB_UINT_MAX -(0xffffffff on all platforms) and always use min(), that means we eventually -decide that the base of ram is GRUB_UINT_MAX, which is lower than our first -memory address, and thus our allocation of the initramfs, which specifies this -value as the maximum possible address it can be at, fails. - -This patch changes it to start at GRUB_EFI_MAX_USABLE_ADDRESS, which is always -at least 0xffffffff on 32-bit platforms and at least 0x7ffffffffffffff on -64-bit platforms. Additionally, this adds a requirement that the memory we -choose is actually /allocatable/ conventional memory, not merely +This patch adds a requirement when we're trying to find the base of ram, that +the memory we choose is actually /allocatable/ conventional memory, not merely write-combining. On this machine that means we wind up with an allocation around 0x4392XXXXXX, which is a reasonable address. @@ -74,12 +66,12 @@ per-platform constraints on its given address are maintained. Signed-off-by: Peter Jones --- - grub-core/kern/efi/mm.c | 32 ++++++++++++----- + grub-core/kern/efi/mm.c | 33 +++++++++++++----- grub-core/loader/arm64/linux.c | 78 ++++++++++++++++++++++++++++++++---------- - 2 files changed, 82 insertions(+), 28 deletions(-) + 2 files changed, 84 insertions(+), 27 deletions(-) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index 7692e63ba24..306924f73a4 100644 +index 15595a4..1b14fa0 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -154,6 +154,7 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, @@ -90,7 +82,7 @@ index 7692e63ba24..306924f73a4 100644 /* Limit the memory access to less than 4GB for 32-bit platforms. */ if (address > GRUB_EFI_MAX_USABLE_ADDRESS) -@@ -165,19 +166,19 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, +@@ -165,19 +166,22 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, } b = grub_efi_system_table->boot_services; @@ -98,6 +90,9 @@ index 7692e63ba24..306924f73a4 100644 + status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &ret); if (status != GRUB_EFI_SUCCESS) { ++ grub_dprintf ("efi", ++ "allocate_pages(%d, %d, 0x%0lx, 0x%016lx) = 0x%016lx\n", ++ alloctype, memtype, pages, address, status); grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); return NULL; } @@ -114,7 +109,7 @@ index 7692e63ba24..306924f73a4 100644 grub_efi_free_pages (0, pages); if (status != GRUB_EFI_SUCCESS) { -@@ -186,9 +187,9 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, +@@ -186,9 +190,9 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, } } @@ -126,27 +121,23 @@ index 7692e63ba24..306924f73a4 100644 } void * -@@ -696,11 +697,24 @@ grub_efi_get_ram_base(grub_addr_t *base_addr) - if (ret < 1) - return GRUB_ERR_BUG; - -- for (desc = memory_map, *base_addr = GRUB_UINT_MAX; -+ for (desc = memory_map, *base_addr = GRUB_EFI_MAX_USABLE_ADDRESS; +@@ -699,8 +703,21 @@ grub_efi_get_ram_base(grub_addr_t *base_addr) + for (desc = memory_map, *base_addr = GRUB_EFI_MAX_USABLE_ADDRESS; (grub_addr_t) desc < ((grub_addr_t) memory_map + memory_map_size); desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) - if (desc->attribute & GRUB_EFI_MEMORY_WB) - *base_addr = grub_min (*base_addr, desc->physical_start); + { + if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY && -+ (desc->attribute & GRUB_EFI_MEMORY_WB)) -+ { -+ *base_addr = grub_min (*base_addr, desc->physical_start); -+ grub_dprintf ("efi", "setting base_addr=0x%016lx\n", *base_addr); -+ } ++ (desc->attribute & GRUB_EFI_MEMORY_WB)) ++ { ++ *base_addr = grub_min (*base_addr, desc->physical_start); ++ grub_dprintf ("efi", "setting base_addr=0x%016lx\n", *base_addr); ++ } + else -+ { -+ grub_dprintf ("efi", "ignoring address 0x%016lx\n", desc->physical_start); -+ } ++ { ++ grub_dprintf ("efi", "ignoring address 0x%016lx\n", desc->physical_start); ++ } + } + + if (*base_addr == GRUB_EFI_MAX_USABLE_ADDRESS) @@ -155,10 +146,10 @@ index 7692e63ba24..306924f73a4 100644 grub_free(memory_map); diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index 93b5cd306eb..e1110749eb9 100644 +index 4c0a09c..8791b35 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c -@@ -70,13 +70,15 @@ finalize_params_linux (void) +@@ -71,13 +71,15 @@ finalize_params_linux (void) { grub_efi_loaded_image_t *loaded_image = NULL; int node, retval, len; @@ -166,7 +157,7 @@ index 93b5cd306eb..e1110749eb9 100644 + grub_err_t err = GRUB_ERR_NONE; void *fdt; - fdt = grub_fdt_load (0x400); + fdt = grub_fdt_load (GRUB_EFI_LINUX_FDT_EXTRA_SPACE); - if (!fdt) - goto failure; @@ -177,7 +168,7 @@ index 93b5cd306eb..e1110749eb9 100644 node = grub_fdt_find_subnode (fdt, 0, "chosen"); if (node < 0) -@@ -87,17 +89,26 @@ finalize_params_linux (void) +@@ -88,17 +90,26 @@ finalize_params_linux (void) */ retval = grub_fdt_set_prop32(fdt, 0, "#address-cells", 2); if (retval) @@ -207,7 +198,7 @@ index 93b5cd306eb..e1110749eb9 100644 /* Set initrd info */ if (initrd_start && initrd_end > initrd_start) -@@ -108,15 +119,26 @@ finalize_params_linux (void) +@@ -109,15 +120,26 @@ finalize_params_linux (void) retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-start", initrd_start); if (retval) @@ -237,8 +228,8 @@ index 93b5cd306eb..e1110749eb9 100644 + } grub_dprintf ("linux", "Installed/updated FDT configuration table @ %p\n", - fdt); -@@ -124,14 +146,20 @@ finalize_params_linux (void) + fdt); +@@ -125,14 +147,20 @@ finalize_params_linux (void) /* Convert command line to UCS-2 */ loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); if (!loaded_image) @@ -261,7 +252,7 @@ index 93b5cd306eb..e1110749eb9 100644 loaded_image->load_options_size = 2 * grub_utf8_to_utf16 (loaded_image->load_options, len, -@@ -141,7 +169,7 @@ finalize_params_linux (void) +@@ -142,7 +170,7 @@ finalize_params_linux (void) failure: grub_fdt_unload(); @@ -270,7 +261,7 @@ index 93b5cd306eb..e1110749eb9 100644 } static void -@@ -225,16 +253,28 @@ grub_linux_unload (void) +@@ -226,16 +254,28 @@ grub_linux_unload (void) static void * allocate_initrd_mem (int initrd_pages) { @@ -278,16 +269,16 @@ index 93b5cd306eb..e1110749eb9 100644 + grub_addr_t max_addr = 0; + grub_err_t err; + void *ret; - -- if (grub_efi_get_ram_base (&max_addr) != GRUB_ERR_NONE) -- return NULL; ++ + err = grub_efi_get_ram_base (&max_addr); + if (err != GRUB_ERR_NONE) + { + grub_error (err, "grub_efi_get_ram_base() failed"); + return NULL; + } -+ + +- if (grub_efi_get_ram_base (&max_addr) != GRUB_ERR_NONE) +- return NULL; + grub_dprintf ("linux", "max_addr: 0x%016lx, INITRD_MAX_ADDRESS_OFFSET: 0x%016llx\n", + max_addr, INITRD_MAX_ADDRESS_OFFSET); @@ -305,3 +296,6 @@ index 93b5cd306eb..e1110749eb9 100644 } static grub_err_t +-- +1.8.3.1 + diff --git a/0238-Try-to-pick-better-locations-for-kernel-and-initrd.patch b/0150-Try-to-pick-better-locations-for-kernel-and-initrd.patch similarity index 88% rename from 0238-Try-to-pick-better-locations-for-kernel-and-initrd.patch rename to 0150-Try-to-pick-better-locations-for-kernel-and-initrd.patch index 2061a45333c1493f02838db67f3ecabc2b1be08c..138a525f3feaa7dcb78a4461977e49dcc4e86f59 100644 --- a/0238-Try-to-pick-better-locations-for-kernel-and-initrd.patch +++ b/0150-Try-to-pick-better-locations-for-kernel-and-initrd.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From f3626af8bf79ed7498b723f46c54312b69a429b8 Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Mon, 27 Aug 2018 14:31:37 -0400 -Subject: [PATCH] Try to pick better locations for kernel and initrd +Date: Thu, 11 Jul 2019 17:17:02 +0200 +Subject: [PATCH 150/220] Try to pick better locations for kernel and initrd - Don't limit allocations on 64-bit platforms to < 0x[37f]fffffff if we're using the "large" code model ; use __UINTPTR_MAX__. @@ -34,7 +34,7 @@ Signed-off-by: Peter Jones 7 files changed, 28 insertions(+), 12 deletions(-) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index 306924f73a4..a553f817edb 100644 +index 1b14fa0..d70e5b4 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -122,7 +122,7 @@ grub_efi_allocate_pages_max (grub_efi_physical_address_t max, @@ -46,7 +46,7 @@ index 306924f73a4..a553f817edb 100644 return 0; b = grub_efi_system_table->boot_services; -@@ -463,7 +463,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, +@@ -466,7 +466,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, { if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY #if 1 @@ -55,7 +55,7 @@ index 306924f73a4..a553f817edb 100644 #endif && desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000 && desc->num_pages != 0) -@@ -481,9 +481,9 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, +@@ -484,9 +484,9 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, #if 1 if (BYTES_TO_PAGES (filtered_desc->physical_start) + filtered_desc->num_pages @@ -68,18 +68,18 @@ index 306924f73a4..a553f817edb 100644 #endif diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index ea9f5134e67..851bce77f12 100644 +index 3017d0f..33e981e 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c -@@ -28,6 +28,7 @@ +@@ -27,6 +27,7 @@ + #include #include #include - #include +#include GRUB_MOD_LICENSE ("GPLv3+"); -@@ -108,7 +109,9 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), +@@ -106,7 +107,9 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), size += ALIGN_UP (grub_file_size (files[i]), 4); } @@ -90,7 +90,7 @@ index ea9f5134e67..851bce77f12 100644 if (!initrd_mem) { grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate initrd")); -@@ -209,8 +212,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -202,8 +205,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } @@ -103,7 +103,7 @@ index ea9f5134e67..851bce77f12 100644 if (! params) { grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate kernel parameters"); -@@ -280,8 +286,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -273,8 +279,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), #endif grub_dprintf ("linux", "setting up cmdline\n"); @@ -117,7 +117,7 @@ index ea9f5134e67..851bce77f12 100644 if (!linux_cmdline) { grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate cmdline")); -@@ -307,11 +316,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -301,11 +310,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), kernel_mem = grub_efi_allocate_pages_max(lh->pref_address, BYTES_TO_PAGES(lh->init_size)); @@ -134,7 +134,7 @@ index ea9f5134e67..851bce77f12 100644 { grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate kernel")); diff --git a/include/grub/arm/efi/memory.h b/include/grub/arm/efi/memory.h -index 2c64918e3f7..a4c2ec83502 100644 +index 2c64918..a4c2ec8 100644 --- a/include/grub/arm/efi/memory.h +++ b/include/grub/arm/efi/memory.h @@ -2,5 +2,6 @@ @@ -145,7 +145,7 @@ index 2c64918e3f7..a4c2ec83502 100644 #endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/arm64/efi/memory.h b/include/grub/arm64/efi/memory.h -index c6cb3241714..acb61dca44b 100644 +index c6cb324..acb61dc 100644 --- a/include/grub/arm64/efi/memory.h +++ b/include/grub/arm64/efi/memory.h @@ -2,5 +2,6 @@ @@ -156,7 +156,7 @@ index c6cb3241714..acb61dca44b 100644 #endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/i386/efi/memory.h b/include/grub/i386/efi/memory.h -index 2c64918e3f7..a4c2ec83502 100644 +index 2c64918..a4c2ec8 100644 --- a/include/grub/i386/efi/memory.h +++ b/include/grub/i386/efi/memory.h @@ -2,5 +2,6 @@ @@ -167,7 +167,7 @@ index 2c64918e3f7..a4c2ec83502 100644 #endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/ia64/efi/memory.h b/include/grub/ia64/efi/memory.h -index 2c64918e3f7..a4c2ec83502 100644 +index 2c64918..a4c2ec8 100644 --- a/include/grub/ia64/efi/memory.h +++ b/include/grub/ia64/efi/memory.h @@ -2,5 +2,6 @@ @@ -178,7 +178,7 @@ index 2c64918e3f7..a4c2ec83502 100644 #endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/x86_64/efi/memory.h b/include/grub/x86_64/efi/memory.h -index 46e9145a308..e81cfb32213 100644 +index 46e9145..e81cfb3 100644 --- a/include/grub/x86_64/efi/memory.h +++ b/include/grub/x86_64/efi/memory.h @@ -2,9 +2,11 @@ @@ -194,3 +194,6 @@ index 46e9145a308..e81cfb32213 100644 #endif #endif /* ! GRUB_MEMORY_CPU_HEADER */ +-- +1.8.3.1 + diff --git a/0150-Use-BLS-version-field-to-compare-entries-if-id-field.patch b/0150-Use-BLS-version-field-to-compare-entries-if-id-field.patch deleted file mode 100644 index 0d76ad81e9c18137ab014d7e0c73f4682cd65250..0000000000000000000000000000000000000000 --- a/0150-Use-BLS-version-field-to-compare-entries-if-id-field.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 27 Apr 2018 17:53:41 +0200 -Subject: [PATCH] Use BLS version field to compare entries if id field isn't - defined - -The BootLoaderSpec fragments generated by OSTree don't have the id field, -so grub2 will attempt to sort the entries by using the title field which -may not be correct. The entries do have a version field though so use it. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 6ab85df6b3a..c52d2b2e05a 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -418,6 +418,9 @@ static int bls_cmp(const void *p0, const void *p1, void *state UNUSED) - - rc = bls_keyval_cmp (e0, e1, "id"); - -+ if (rc == 0) -+ rc = bls_keyval_cmp (e0, e1, "version"); -+ - if (rc == 0) - rc = bls_keyval_cmp (e0, e1, "title"); - diff --git a/0151-Add-version-field-to-BLS-generated-by-grub2-switch-t.patch b/0151-Add-version-field-to-BLS-generated-by-grub2-switch-t.patch deleted file mode 100644 index 27e0a17c473237d6a7969203e8670c4703de268a..0000000000000000000000000000000000000000 --- a/0151-Add-version-field-to-BLS-generated-by-grub2-switch-t.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 10 May 2018 10:52:11 +0200 -Subject: [PATCH] Add version field to BLS generated by grub2-switch-to-blscfg - -The version field is present in the BLS fragments that are shipped in the -kernel packages, so add it to the BLS generated by grub2-switch-to-blscfg -for consistency. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index bc28053cd30..89487ad611c 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -190,12 +190,14 @@ mkbls() { - local datetime=$1 && shift - - local debugname="" -+ local debugid="" - local flavor="" - - if [[ "$kernelver" == *\+* ]] ; then - local flavor=-"${kernelver##*+}" - if [[ "${flavor}" == "-debug" ]]; then - local debugname=" with debugging" -+ local debugid="-debug" - fi - fi - ( -@@ -203,6 +205,7 @@ mkbls() { - - cat < +Date: Thu, 11 Jul 2019 18:03:25 +0200 +Subject: [PATCH 151/220] Attempt to fix up all the places -Wsign-compare=error + finds. + +Signed-off-by: Peter Jones +--- + grub-core/kern/emu/misc.c | 2 +- + .../gnulib-patches/fix-sign-compare-errors.patch | 161 +++++++++++++++++++++ + grub-core/lib/reed_solomon.c | 4 +- + grub-core/osdep/linux/blocklist.c | 2 +- + grub-core/osdep/linux/getroot.c | 2 +- + grub-core/osdep/linux/hostdisk.c | 2 +- + util/grub-fstest.c | 2 +- + util/grub-menulst2cfg.c | 2 +- + util/grub-mkfont.c | 13 +- + util/grub-probe.c | 2 +- + util/grub-rpm-sort.c | 2 +- + util/setup.c | 2 +- + 12 files changed, 179 insertions(+), 17 deletions(-) + create mode 100644 grub-core/lib/gnulib-patches/fix-sign-compare-errors.patch + +diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c +index 245b69c..7a8d9e6 100644 +--- a/grub-core/kern/emu/misc.c ++++ b/grub-core/kern/emu/misc.c +@@ -177,7 +177,7 @@ grub_util_get_image_size (const char *path) + sz = ftello (f); + if (sz < 0) + grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); +- if (sz != (size_t) sz) ++ if (sz > (off_t)(GRUB_SIZE_MAX >> 1)) + grub_util_error (_("file `%s' is too big"), path); + ret = (size_t) sz; + +diff --git a/grub-core/lib/gnulib-patches/fix-sign-compare-errors.patch b/grub-core/lib/gnulib-patches/fix-sign-compare-errors.patch +new file mode 100644 +index 0000000..479029c +--- /dev/null ++++ b/grub-core/lib/gnulib-patches/fix-sign-compare-errors.patch +@@ -0,0 +1,161 @@ ++diff --git a/lib/regcomp.c b/lib/regcomp.c ++index cc85f35ac58..361079d82d6 100644 ++--- a/lib/regcomp.c +++++ b/lib/regcomp.c ++@@ -322,7 +322,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state, ++ *p++ = dfa->nodes[node].opr.c; ++ memset (&state, '\0', sizeof (state)); ++ if (__mbrtowc (&wc, (const char *) buf, p - buf, ++- &state) == p - buf +++ &state) == (size_t)(p - buf) ++ && (__wcrtomb ((char *) buf, __towlower (wc), &state) ++ != (size_t) -1)) ++ re_set_fastmap (fastmap, false, buf[0]); ++@@ -3778,7 +3778,7 @@ fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax) ++ num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2) ++ ? -2 ++ : num == -1 ++- ? c - '0' +++ ? (Idx)(c - '0') ++ : MIN (RE_DUP_MAX + 1, num * 10 + c - '0')); ++ } ++ return num; ++diff --git a/lib/regex_internal.c b/lib/regex_internal.c ++index 9004ce809eb..193a1e3d332 100644 ++--- a/lib/regex_internal.c +++++ b/lib/regex_internal.c ++@@ -233,7 +233,7 @@ build_wcs_buffer (re_string_t *pstr) ++ /* Apply the translation if we need. */ ++ if (__glibc_unlikely (pstr->trans != NULL)) ++ { ++- int i, ch; +++ unsigned int i, ch; ++ ++ for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i) ++ { ++@@ -376,7 +376,7 @@ build_wcs_upper_buffer (re_string_t *pstr) ++ prev_st = pstr->cur_state; ++ if (__glibc_unlikely (pstr->trans != NULL)) ++ { ++- int i, ch; +++ unsigned int i, ch; ++ ++ for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i) ++ { ++@@ -754,7 +754,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) ++ memset (&cur_state, 0, sizeof (cur_state)); ++ mbclen = __mbrtowc (&wc2, (const char *) pp, mlen, ++ &cur_state); ++- if (raw + offset - p <= mbclen +++ if ((size_t)(raw + offset - p) <= mbclen ++ && mbclen < (size_t) -2) ++ { ++ memset (&pstr->cur_state, '\0', ++diff --git a/lib/regex_internal.h b/lib/regex_internal.h ++index 5462419b787..e0f8292395d 100644 ++--- a/lib/regex_internal.h +++++ b/lib/regex_internal.h ++@@ -425,7 +425,7 @@ struct re_string_t ++ unsigned char offsets_needed; ++ unsigned char newline_anchor; ++ unsigned char word_ops_used; ++- int mb_cur_max; +++ unsigned int mb_cur_max; ++ }; ++ typedef struct re_string_t re_string_t; ++ ++@@ -702,7 +702,7 @@ struct re_dfa_t ++ unsigned int is_utf8 : 1; ++ unsigned int map_notascii : 1; ++ unsigned int word_ops_used : 1; ++- int mb_cur_max; +++ unsigned int mb_cur_max; ++ bitset_t word_char; ++ reg_syntax_t syntax; ++ Idx *subexp_map; ++diff --git a/lib/regexec.c b/lib/regexec.c ++index 0a7a27b772e..b57d4f9141d 100644 ++--- a/lib/regexec.c +++++ b/lib/regexec.c ++@@ -443,7 +443,7 @@ re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length, ++ { ++ if (ret_len) ++ { ++- assert (pmatch[0].rm_so == start); +++ assert (pmatch[0].rm_so == (long)start); ++ rval = pmatch[0].rm_eo - start; ++ } ++ else ++@@ -877,11 +877,11 @@ re_search_internal (const regex_t *preg, const char *string, Idx length, ++ if (__glibc_unlikely (mctx.input.offsets_needed != 0)) ++ { ++ pmatch[reg_idx].rm_so = ++- (pmatch[reg_idx].rm_so == mctx.input.valid_len +++ (pmatch[reg_idx].rm_so == (long)mctx.input.valid_len ++ ? mctx.input.valid_raw_len ++ : mctx.input.offsets[pmatch[reg_idx].rm_so]); ++ pmatch[reg_idx].rm_eo = ++- (pmatch[reg_idx].rm_eo == mctx.input.valid_len +++ (pmatch[reg_idx].rm_eo == (long)mctx.input.valid_len ++ ? mctx.input.valid_raw_len ++ : mctx.input.offsets[pmatch[reg_idx].rm_eo]); ++ } ++@@ -1418,11 +1418,11 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch, ++ } ++ memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch); ++ ++- for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;) +++ for (idx = pmatch[0].rm_so; idx <= (long)pmatch[0].rm_eo ;) ++ { ++ update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch); ++ ++- if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node) +++ if (idx == (long)pmatch[0].rm_eo && cur_node == mctx->last_node) ++ { ++ Idx reg_idx; ++ if (fs) ++@@ -1519,7 +1519,7 @@ update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, ++ if (reg_num < nmatch) ++ { ++ /* We are at the last node of this sub expression. */ ++- if (pmatch[reg_num].rm_so < cur_idx) +++ if (pmatch[reg_num].rm_so < (long)cur_idx) ++ { ++ pmatch[reg_num].rm_eo = cur_idx; ++ /* This is a non-empty match or we are not inside an optional ++@@ -2938,7 +2938,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node, ++ mctx->state_log[str_idx] = cur_state; ++ } ++ ++- for (null_cnt = 0; str_idx < last_str && null_cnt <= mctx->max_mb_elem_len;) +++ for (null_cnt = 0; str_idx < last_str && null_cnt <= (long)mctx->max_mb_elem_len;) ++ { ++ re_node_set_empty (&next_nodes); ++ if (mctx->state_log[str_idx + 1]) ++@@ -3718,7 +3718,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, ++ const re_string_t *input, Idx str_idx) ++ { ++ const re_token_t *node = dfa->nodes + node_idx; ++- int char_len, elem_len; +++ unsigned int char_len, elem_len; ++ Idx i; ++ ++ if (__glibc_unlikely (node->type == OP_UTF8_PERIOD)) ++@@ -4066,7 +4066,7 @@ extend_buffers (re_match_context_t *mctx, int min_len) ++ /* Double the lengths of the buffers, but allocate at least MIN_LEN. */ ++ ret = re_string_realloc_buffers (pstr, ++ MAX (min_len, ++- MIN (pstr->len, pstr->bufs_len * 2))); +++ MIN ((long)pstr->len, pstr->bufs_len * 2))); ++ if (__glibc_unlikely (ret != REG_NOERROR)) ++ return ret; ++ ++@@ -4236,7 +4236,7 @@ match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from, ++ = (from == to ? -1 : 0); ++ ++ mctx->bkref_ents[mctx->nbkref_ents++].more = 0; ++- if (mctx->max_mb_elem_len < to - from) +++ if (mctx->max_mb_elem_len < (long)(to - from)) ++ mctx->max_mb_elem_len = to - from; ++ return REG_NOERROR; ++ } +diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c +index ee9fa7b..19c2008 100644 +--- a/grub-core/lib/reed_solomon.c ++++ b/grub-core/lib/reed_solomon.c +@@ -156,7 +156,7 @@ static void + rs_encode (gf_single_t *data, grub_size_t s, grub_size_t rs) + { + gf_single_t *rs_polynomial; +- int i, j; ++ unsigned int i, j; + gf_single_t *m; + m = xmalloc ((s + rs) * sizeof (gf_single_t)); + grub_memcpy (m, data, s * sizeof (gf_single_t)); +@@ -325,7 +325,7 @@ static void + encode_block (gf_single_t *ptr, grub_size_t s, + gf_single_t *rptr, grub_size_t rs) + { +- int i, j; ++ unsigned int i, j; + for (i = 0; i < SECTOR_SIZE; i++) + { + grub_size_t ds = (s + SECTOR_SIZE - 1 - i) / SECTOR_SIZE; +diff --git a/grub-core/osdep/linux/blocklist.c b/grub-core/osdep/linux/blocklist.c +index c77d608..42a3150 100644 +--- a/grub-core/osdep/linux/blocklist.c ++++ b/grub-core/osdep/linux/blocklist.c +@@ -109,7 +109,7 @@ grub_install_get_blocklist (grub_device_t root_dev, + else + { + struct fiemap *fie2; +- int i; ++ unsigned int i; + fie2 = xmalloc (sizeof (*fie2) + + fie1.fm_mapped_extents + * sizeof (fie1.fm_extents[1])); +diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c +index 4c5a130..2b7a626 100644 +--- a/grub-core/osdep/linux/getroot.c ++++ b/grub-core/osdep/linux/getroot.c +@@ -236,7 +236,7 @@ grub_find_root_devices_from_btrfs (const char *dir) + { + int fd; + struct btrfs_ioctl_fs_info_args fsi; +- int i, j = 0; ++ unsigned int i, j = 0; + char **ret; + + fd = open (dir, 0); +diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c +index 8b92f85..370d027 100644 +--- a/grub-core/osdep/linux/hostdisk.c ++++ b/grub-core/osdep/linux/hostdisk.c +@@ -83,7 +83,7 @@ grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_sec + if (sector_size & (sector_size - 1) || !sector_size) + return -1; + for (log_sector_size = 0; +- (1 << log_sector_size) < sector_size; ++ (1U << log_sector_size) < sector_size; + log_sector_size++); + + if (log_secsize) +diff --git a/util/grub-fstest.c b/util/grub-fstest.c +index f14e02d..88f9c5d 100644 +--- a/util/grub-fstest.c ++++ b/util/grub-fstest.c +@@ -323,7 +323,7 @@ cmd_cmp (char *src, char *dest) + read_file (src, cmp_hook, ff); + + { +- grub_uint64_t pre; ++ long long pre; + pre = ftell (ff); + fseek (ff, 0, SEEK_END); + if (pre != ftell (ff)) +diff --git a/util/grub-menulst2cfg.c b/util/grub-menulst2cfg.c +index a39f869..358d604 100644 +--- a/util/grub-menulst2cfg.c ++++ b/util/grub-menulst2cfg.c +@@ -34,7 +34,7 @@ main (int argc, char **argv) + char *buf = NULL; + size_t bufsize = 0; + char *suffix = xstrdup (""); +- int suffixlen = 0; ++ size_t suffixlen = 0; + const char *out_fname = 0; + + grub_util_host_init (&argc, &argv); +diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c +index 0fe45a6..3e09240 100644 +--- a/util/grub-mkfont.c ++++ b/util/grub-mkfont.c +@@ -138,7 +138,8 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face, + int width, height; + int cuttop, cutbottom, cutleft, cutright; + grub_uint8_t *data; +- int mask, i, j, bitmap_size; ++ int mask, i, bitmap_size; ++ unsigned int j; + FT_GlyphSlot glyph; + int flag = FT_LOAD_RENDER | FT_LOAD_MONOCHROME; + FT_Error err; +@@ -183,7 +184,7 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face, + cuttop = cutbottom = cutleft = cutright = 0; + else + { +- for (cuttop = 0; cuttop < glyph->bitmap.rows; cuttop++) ++ for (cuttop = 0; cuttop < (long)glyph->bitmap.rows; cuttop++) + { + for (j = 0; j < glyph->bitmap.width; j++) + if (glyph->bitmap.buffer[j / 8 + cuttop * glyph->bitmap.pitch] +@@ -203,10 +204,10 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face, + break; + } + cutbottom = glyph->bitmap.rows - 1 - cutbottom; +- if (cutbottom + cuttop >= glyph->bitmap.rows) ++ if (cutbottom + cuttop >= (long)glyph->bitmap.rows) + cutbottom = 0; + +- for (cutleft = 0; cutleft < glyph->bitmap.width; cutleft++) ++ for (cutleft = 0; cutleft < (long)glyph->bitmap.width; cutleft++) + { + for (j = 0; j < glyph->bitmap.rows; j++) + if (glyph->bitmap.buffer[cutleft / 8 + j * glyph->bitmap.pitch] +@@ -225,7 +226,7 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face, + break; + } + cutright = glyph->bitmap.width - 1 - cutright; +- if (cutright + cutleft >= glyph->bitmap.width) ++ if (cutright + cutleft >= (long)glyph->bitmap.width) + cutright = 0; + } + +@@ -262,7 +263,7 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face, + + mask = 0; + data = &glyph_info->bitmap[0] - 1; +- for (j = cuttop; j < height + cuttop; j++) ++ for (j = cuttop; j < (long)height + cuttop; j++) + for (i = cutleft; i < width + cutleft; i++) + add_pixel (&data, &mask, + glyph->bitmap.buffer[i / 8 + j * glyph->bitmap.pitch] & +diff --git a/util/grub-probe.c b/util/grub-probe.c +index 81d27ee..7481e48 100644 +--- a/util/grub-probe.c ++++ b/util/grub-probe.c +@@ -798,7 +798,7 @@ argp_parser (int key, char *arg, struct argp_state *state) + + case 't': + { +- int i; ++ unsigned int i; + + for (i = PRINT_FS; i < ARRAY_SIZE (targets); i++) + if (strcmp (arg, targets[i]) == 0) +diff --git a/util/grub-rpm-sort.c b/util/grub-rpm-sort.c +index f33bd1e..8345944 100644 +--- a/util/grub-rpm-sort.c ++++ b/util/grub-rpm-sort.c +@@ -232,7 +232,7 @@ main (int argc, char *argv[]) + struct arguments arguments; + char **package_names = NULL; + size_t n_package_names = 0; +- int i; ++ unsigned int i; + + grub_util_host_init (&argc, &argv); + +diff --git a/util/setup.c b/util/setup.c +index 6f88f3c..864094d 100644 +--- a/util/setup.c ++++ b/util/setup.c +@@ -402,7 +402,7 @@ SETUP (const char *dir, + int is_ldm; + grub_err_t err; + grub_disk_addr_t *sectors; +- int i; ++ unsigned int i; + grub_fs_t fs; + unsigned int nsec, maxsec; + +-- +1.8.3.1 + diff --git a/0152-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch b/0152-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch new file mode 100644 index 0000000000000000000000000000000000000000..145031da72fe29729eff1f7d1a876c04b814a505 --- /dev/null +++ b/0152-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch @@ -0,0 +1,62 @@ +From 7a86d5c7160b12f0608fa51cd5fa2fccd9b8f596 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 11 Jul 2019 18:20:37 +0200 +Subject: [PATCH 152/220] Don't use -Wno-sign-compare -Wno-conversion + -Wno-error, do use -Wextra. + +Signed-off-by: Peter Jones +--- + conf/Makefile.common | 2 +- + configure.ac | 14 +++++++++++--- + 2 files changed, 12 insertions(+), 4 deletions(-) + +diff --git a/conf/Makefile.common b/conf/Makefile.common +index bbf33b0..b867691 100644 +--- a/conf/Makefile.common ++++ b/conf/Makefile.common +@@ -66,7 +66,7 @@ grubconfdir = $(sysconfdir)/grub.d + platformdir = $(pkglibdir)/$(target_cpu)-$(platform) + starfielddir = $(pkgdatadir)/themes/starfield + +-CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion ++CFLAGS_GNULIB = -Wno-undef -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code + CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/lib/gnulib -I$(top_srcdir)/grub-core/lib/gnulib + + CFLAGS_POSIX = -fno-builtin +diff --git a/configure.ac b/configure.ac +index bca7c28..38d978b 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1424,11 +1424,11 @@ fi + # Set them to their new values for the tests below. + CC="$TARGET_CC" + if test x"$platform" = xemu ; then +-CFLAGS="$TARGET_CFLAGS -Wno-error" ++CFLAGS="$TARGET_CFLAGS" + elif test "x$TARGET_APPLE_LINKER" = x1 ; then +-CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error" ++CFLAGS="$TARGET_CFLAGS -nostdlib -static" + else +-CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error" ++CFLAGS="$TARGET_CFLAGS -nostdlib" + fi + CPPFLAGS="$TARGET_CPPFLAGS" + +@@ -1987,6 +1987,14 @@ if test x"$enable_werror" != xno ; then + HOST_CFLAGS="$HOST_CFLAGS -Werror" + fi + ++AC_ARG_ENABLE([wextra], ++ [AS_HELP_STRING([--disable-wextra], ++ [do not use -Wextra when building GRUB])]) ++if test x"$enable_wextra" != xno ; then ++ TARGET_CFLAGS="$TARGET_CFLAGS -Wextra" ++ HOST_CFLAGS="$HOST_CFLAGS -Wextra" ++fi ++ + TARGET_CPP="$TARGET_CC -E" + TARGET_CCAS=$TARGET_CC + +-- +1.8.3.1 + diff --git a/0153-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch b/0153-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch new file mode 100644 index 0000000000000000000000000000000000000000..6d5eaaed195100fb6f69ed7cb1e69bd4982890be --- /dev/null +++ b/0153-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch @@ -0,0 +1,105 @@ +From c776520796765685c405a72ecbf3ac6f5eeae1cb Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 12 Jul 2019 09:53:32 +0200 +Subject: [PATCH 153/220] x86-efi: Use bounce buffers for reading to addresses + > 4GB + +Lots of machines apparently can't DMA correctly above 4GB during UEFI, +so use bounce buffers for the initramfs read. + +Signed-off-by: Peter Jones +--- + grub-core/loader/i386/efi/linux.c | 52 +++++++++++++++++++++++++++++++++------ + 1 file changed, 45 insertions(+), 7 deletions(-) + +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index 33e981e..2f03368 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -35,11 +35,16 @@ static grub_dl_t my_mod; + static int loaded; + static void *kernel_mem; + static grub_uint64_t kernel_size; +-static grub_uint8_t *initrd_mem; ++static void *initrd_mem; + static grub_uint32_t handover_offset; + struct linux_kernel_params *params; + static char *linux_cmdline; + ++#define MIN(a, b) \ ++ ({ typeof (a) _a = (a); \ ++ typeof (b) _b = (b); \ ++ _a < _b ? _a : _b; }) ++ + #define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12) + + static grub_err_t +@@ -73,6 +78,44 @@ grub_linuxefi_unload (void) + return GRUB_ERR_NONE; + } + ++#define BOUNCE_BUFFER_MAX 0x10000000ull ++ ++static grub_ssize_t ++read(grub_file_t file, grub_uint8_t *bufp, grub_size_t len) ++{ ++ grub_ssize_t bufpos = 0; ++ static grub_size_t bbufsz = 0; ++ static char *bbuf = NULL; ++ ++ if (bbufsz == 0) ++ bbufsz = MIN(BOUNCE_BUFFER_MAX, len); ++ ++ while (!bbuf && bbufsz) ++ { ++ bbuf = grub_malloc(bbufsz); ++ if (!bbuf) ++ bbufsz >>= 1; ++ } ++ if (!bbuf) ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate bounce buffer")); ++ ++ while (bufpos < (long long)len) ++ { ++ grub_ssize_t sz; ++ ++ sz = grub_file_read (file, bbuf, MIN(bbufsz, len - bufpos)); ++ if (sz < 0) ++ return sz; ++ if (sz == 0) ++ break; ++ ++ grub_memcpy(bufp + bufpos, bbuf, sz); ++ bufpos += sz; ++ } ++ ++ return bufpos; ++} ++ + static grub_err_t + grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + int argc, char *argv[]) +@@ -126,7 +169,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + for (i = 0; i < nfiles; i++) + { + grub_ssize_t cursize = grub_file_size (files[i]); +- if (grub_file_read (files[i], ptr, cursize) != cursize) ++ if (read (files[i], ptr, cursize) != cursize) + { + if (!grub_errno) + grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"), +@@ -152,11 +195,6 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + return grub_errno; + } + +-#define MIN(a, b) \ +- ({ typeof (a) _a = (a); \ +- typeof (b) _b = (b); \ +- _a < _b ? _a : _b; }) +- + static grub_err_t + grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + int argc, char *argv[]) +-- +1.8.3.1 + diff --git a/0154-Simplify-BLS-entry-key-val-pairs-lookup.patch b/0154-Simplify-BLS-entry-key-val-pairs-lookup.patch deleted file mode 100644 index f3d2613adc4e2fb89eee638829bc2d8f5d4b0f52..0000000000000000000000000000000000000000 --- a/0154-Simplify-BLS-entry-key-val-pairs-lookup.patch +++ /dev/null @@ -1,170 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 11 May 2018 23:47:31 +0200 -Subject: [PATCH] Simplify BLS entry key val pairs lookup - -The pairs found in the BLS are being sorted but this isn't -really needed and it makes the implementation complex and error prone. - -For example, the current implementation has the following issues: - -1) Fields not present in the grub2 menu entry - - linux /linuz - initrd /foo - initrd /bar - - load_video - set gfx_payload=keep - insmod gzio - linux /boot/linuz - initrd /boot/bar - -2) Fields present but in the wrong order - - title Fedora (4.16.6-300.fc28.x86_64-tuned) 28 (Twenty Eight) - version 4.16.6-300.fc28.x86_64 - linux /vmlinuz-4.16.6-300.fc28.x86_64 - initrd /foo.img - initrd /bar.img - options $kernelopts - id fedora-20180430150025-4.16.6-300.fc28.x86_64 - - load_video - set gfx_payload=keep - insmod gzio - linux /boot/vmlinuz-4.16.6-300.fc28.x86_64 $kernelopts - initrd /boot/bar.img /boot/foo.img - -It's important to preserve the order in which fields have been defined -in the BLS fragment since for some of the fields the order has meaning. -For example, initramfs images have to be passed to the kernel in order -that were defined in the BLS fragment. - -This patch simplifies the pairs storage and lookup. Rather -than sorting and attempt to later figure out what's the expected order, -just store it in the same order as they were defined in the BLS config -file and return in that same order to callers when these look them up. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 88 ++++++++++----------------------------------- - 1 file changed, 18 insertions(+), 70 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index c52d2b2e05a..fb08d8e4c12 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -169,84 +169,35 @@ static void bls_free_entry(struct bls_entry *entry) - grub_free (entry); - } - --static int keyval_cmp (const void *p0, const void *p1, -- void *state UNUSED) --{ -- const struct keyval *kv0 = *(struct keyval * const *)p0; -- const struct keyval *kv1 = *(struct keyval * const *)p1; -- int rc; -- -- rc = grub_strcmp(kv0->key, kv1->key); -- -- return rc; --} -- - /* Find they value of the key named by keyname. If there are allowed to be - * more than one, pass a pointer to an int set to -1 the first time, and pass - * the same pointer through each time after, and it'll return them in sorted -- * order. */ -+ * order as defined in the BLS fragment file */ - static char *bls_get_val(struct bls_entry *entry, const char *keyname, int *last) - { -- char *foo = (char *)""; -- struct keyval *kv = NULL, **kvp, key = {keyname, foo}, *keyp = &key; -+ int idx, start = 0; -+ struct keyval *kv = NULL; - -- /* if we've already found an entry that matches, just iterate */ -- if (last && *last >= 0) -- { -- int next = ++last[0]; -+ if (last) -+ start = *last + 1; - -- if (next == entry->nkeyvals) -- { --done: -- *last = -1; -- return NULL; -- } -+ for (idx = start; idx < entry->nkeyvals; idx++) { -+ kv = entry->keyvals[idx]; - -- kv = entry->keyvals[next]; -- if (grub_strcmp (keyname, kv->key)) -- goto done; -+ if (!grub_strcmp (keyname, kv->key)) -+ break; -+ } - -- return kv->val; -- } -+ if (idx == entry->nkeyvals) { -+ if (last) -+ *last = -1; -+ return NULL; -+ } - -- kvp = grub_bsearch(&keyp, &entry->keyvals[0], entry->nkeyvals, -- sizeof (struct keyval *), keyval_cmp, NULL); -- if (kvp) -- kv = *kvp; -+ if (last) -+ *last = idx; - -- if (kv) -- { -- /* if we've got uninitialized but present state, track back until we find -- * the first match */ -- if (last) -- { -- grub_dprintf("blscfg", "%s trying to find another entry because last was set\n", __func__); -- /* figure out the position of this entry in the array */ -- int idx; -- for (idx = 0 ; idx < entry->nkeyvals; idx++) -- if (entry->keyvals[idx] == kv) -- break; -- *last = idx; -- -- while (idx > 0) -- { -- struct keyval *kvtmp = entry->keyvals[idx-1]; -- if (idx == 0 || grub_strcmp (keyname, kvtmp->key)) -- { -- /* if we're at the start, or if the previous entry doesn't -- * match, then we're done */ -- *last = idx; -- break; -- } -- else -- /* but if it does match, keep going backwards */ -- idx--; -- } -- } -- -- return kv->val; -- } -- return NULL; -+ return kv->val; - } - - #define goto_return(x) ({ ret = (x); goto finish; }) -@@ -503,9 +454,6 @@ static int read_entry ( - break; - } - -- grub_qsort(&entry->keyvals[0], entry->nkeyvals, sizeof (struct keyval *), -- keyval_cmp, NULL); -- - finish: - grub_free (p); - diff --git a/0154-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch b/0154-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch new file mode 100644 index 0000000000000000000000000000000000000000..056b4922d318375aa4af9290a7222eb93be87ef4 --- /dev/null +++ b/0154-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch @@ -0,0 +1,136 @@ +From da26129db9e007294b3b35dc75ef74c5e516afff Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 13 Sep 2018 14:42:34 -0400 +Subject: [PATCH 154/220] x86-efi: Re-arrange grub_cmd_linux() a little bit. + +This just helps the next patch be easier to read. + +Signed-off-by: Peter Jones +--- + grub-core/loader/i386/efi/linux.c | 75 +++++++++++++++++++++------------------ + 1 file changed, 41 insertions(+), 34 deletions(-) + +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index 2f03368..5f48fa5 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -243,32 +243,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + +- params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_ALLOCATION_ADDRESS, +- BYTES_TO_PAGES(sizeof(*params))); +- if (!params) +- params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_USABLE_ADDRESS, +- BYTES_TO_PAGES(sizeof(*params))); +- if (! params) +- { +- grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate kernel parameters"); +- goto fail; +- } +- +- grub_dprintf ("linux", "params = %p\n", params); +- +- grub_memset (params, 0, sizeof(*params)); ++ lh = (struct linux_i386_kernel_header *)kernel; ++ grub_dprintf ("linux", "original lh is at %p\n", kernel); + +- setup_header_end_offset = *((grub_uint8_t *)kernel + 0x201); +- grub_dprintf ("linux", "copying %lu bytes from %p to %p\n", +- MIN((grub_size_t)0x202+setup_header_end_offset, +- sizeof (*params)) - 0x1f1, +- (grub_uint8_t *)kernel + 0x1f1, +- (grub_uint8_t *)params + 0x1f1); +- grub_memcpy ((grub_uint8_t *)params + 0x1f1, +- (grub_uint8_t *)kernel + 0x1f1, +- MIN((grub_size_t)0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1); +- lh = (struct linux_i386_kernel_header *)params; +- grub_dprintf ("linux", "lh is at %p\n", lh); + grub_dprintf ("linux", "checking lh->boot_flag\n"); + if (lh->boot_flag != grub_cpu_to_le16 (0xaa55)) + { +@@ -316,6 +293,34 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + } + #endif + ++ params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_ALLOCATION_ADDRESS, ++ BYTES_TO_PAGES(sizeof(*params))); ++ if (!params) ++ params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_USABLE_ADDRESS, ++ BYTES_TO_PAGES(sizeof(*params))); ++ if (! params) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate kernel parameters"); ++ goto fail; ++ } ++ ++ grub_dprintf ("linux", "params = %p\n", params); ++ ++ grub_memset (params, 0, sizeof(*params)); ++ ++ setup_header_end_offset = *((grub_uint8_t *)kernel + 0x201); ++ grub_dprintf ("linux", "copying %lu bytes from %p to %p\n", ++ MIN((grub_size_t)0x202+setup_header_end_offset, ++ sizeof (*params)) - 0x1f1, ++ (grub_uint8_t *)kernel + 0x1f1, ++ (grub_uint8_t *)params + 0x1f1); ++ grub_memcpy ((grub_uint8_t *)params + 0x1f1, ++ (grub_uint8_t *)kernel + 0x1f1, ++ MIN((grub_size_t)0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1); ++ ++ lh = (struct linux_i386_kernel_header *)params; ++ grub_dprintf ("linux", "new lh is at %p\n", lh); ++ + grub_dprintf ("linux", "setting up cmdline\n"); + linux_cmdline = grub_efi_allocate_pages_max(GRUB_EFI_MAX_ALLOCATION_ADDRESS, + BYTES_TO_PAGES(lh->cmdline_size + 1)); +@@ -341,8 +346,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + grub_dprintf ("linux", "setting lh->cmd_line_ptr\n"); + lh->cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline; + +- grub_dprintf ("linux", "computing handover offset\n"); + handover_offset = lh->handover_offset; ++ grub_dprintf("linux", "handover_offset: %08x\n", handover_offset); + + start = (lh->setup_sects + 1) * 512; + +@@ -359,26 +364,28 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate kernel")); + goto fail; + } +- +- grub_dprintf ("linux", "kernel_mem = %lx\n", (unsigned long) kernel_mem); ++ grub_dprintf("linux", "kernel_mem = %p\n", kernel_mem); + + grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0); +- loaded=1; ++ ++ loaded = 1; ++ + grub_dprintf ("linux", "setting lh->code32_start to %p\n", kernel_mem); + lh->code32_start = (grub_uint32_t)(grub_addr_t) kernel_mem; + + grub_memcpy (kernel_mem, (char *)kernel + start, filelen - start); + +- grub_dprintf ("linux", "setting lh->type_of_loader\n"); + lh->type_of_loader = 0x6; ++ grub_dprintf ("linux", "setting lh->type_of_loader = 0x%02x\n", ++ lh->type_of_loader); + +- grub_dprintf ("linux", "setting lh->ext_loader_{type,ver}\n"); + params->ext_loader_type = 0; + params->ext_loader_ver = 2; +- grub_dprintf("linux", "kernel_mem: %p handover_offset: %08x\n", +- kernel_mem, handover_offset); ++ grub_dprintf ("linux", ++ "setting lh->ext_loader_{type,ver} = {0x%02x,0x%02x}\n", ++ params->ext_loader_type, params->ext_loader_ver); + +- fail: ++fail: + if (file) + grub_file_close (file); + +-- +1.8.3.1 + diff --git a/0155-Add-relative-path-to-the-kernel-and-initrds-BLS-fiel.patch b/0155-Add-relative-path-to-the-kernel-and-initrds-BLS-fiel.patch deleted file mode 100644 index 5a5a77d087945105daaaeef0e4fb410add098477..0000000000000000000000000000000000000000 --- a/0155-Add-relative-path-to-the-kernel-and-initrds-BLS-fiel.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 4 Jun 2018 16:10:22 +0200 -Subject: [PATCH] Add relative path to the kernel and initrds BLS fields if - needed - -The static BLS config file shipped with the kernel package assumes that -the /boot directory is a mount point, and that the kernel and initramfs -images relative path is to the root of a boot partition. - -But there are cases in which this isn't true, for example if a user has -its /boot in a btrfs subvolume or if /boot isn't a mount point at all. - -So instead of always using the BLS fragment file as distributed by the -package, check the relative path that GRUB 2 has to use for the images. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 20 +++++++++++++++++--- - 1 file changed, 17 insertions(+), 3 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 89487ad611c..2482483a437 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -188,6 +188,7 @@ fi - mkbls() { - local kernelver=$1 && shift - local datetime=$1 && shift -+ local bootprefix=$1 && shift - - local debugname="" - local debugid="" -@@ -206,8 +207,8 @@ mkbls() { - cat <"${bls_target}" - fi - -+ linux="$(grep '^linux[ \t]' "${bls_target}" | sed -e 's,^linux[ \t]*,,')" -+ initrd="$(grep '^initrd[ \t]' "${bls_target}" | sed -e 's,^initrd[ \t]*,,')" -+ linux_relpath="$("${grub_mkrelpath}" /boot/$linux)" -+ initrd_relpath="$("${grub_mkrelpath}" /boot/$initrd)" -+ -+ if [[ $linux != $linux_relpath ]]; then -+ sed -i -e "s,^linux.*,linux ${linux_relpath},g" "${bls_target}" -+ sed -i -e "s,^initrd.*,initrd ${initrd_relpath},g" "${bls_target}" -+ fi -+ - if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then - arch="$(uname -m)" - bls_debug="$(echo ${bls_target} | sed -e "s/\.${arch}/-debug.${arch}/")" -@@ -247,7 +258,10 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - done - - if [[ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]]; then -- mkbls "0-rescue-${MACHINE_ID}" "0" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" -+ if [[ $linux != $linux_relpath ]]; then -+ bootprefix="$(dirname ${linux_relpath})" -+ fi -+ mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" - fi - - GENERATE=0 diff --git a/0155-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch b/0155-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch new file mode 100644 index 0000000000000000000000000000000000000000..63d419fc72661938ecefe1445782a69ed7e47852 --- /dev/null +++ b/0155-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch @@ -0,0 +1,261 @@ +From 70dc54b23fb32c57a58540857c54ed3291215f28 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 12 Sep 2018 16:03:55 -0400 +Subject: [PATCH 155/220] x86-efi: Make our own allocator for kernel stuff + +This helps enable allocations above 4GB. + +Signed-off-by: Peter Jones +--- + grub-core/loader/i386/efi/linux.c | 167 +++++++++++++++++++++----------------- + 1 file changed, 94 insertions(+), 73 deletions(-) + +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index 5f48fa5..075b77e 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -47,6 +47,65 @@ static char *linux_cmdline; + + #define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12) + ++struct allocation_choice { ++ grub_efi_physical_address_t addr; ++ grub_efi_allocate_type_t alloc_type; ++}; ++ ++static struct allocation_choice max_addresses[] = ++ { ++ { GRUB_EFI_MAX_ALLOCATION_ADDRESS, GRUB_EFI_ALLOCATE_MAX_ADDRESS }, ++ { GRUB_EFI_MAX_ALLOCATION_ADDRESS, GRUB_EFI_ALLOCATE_MAX_ADDRESS }, ++ { GRUB_EFI_MAX_ALLOCATION_ADDRESS, GRUB_EFI_ALLOCATE_MAX_ADDRESS }, ++ { 0, 0 } ++ }; ++ ++static inline void ++kernel_free(void *addr, grub_efi_uintn_t size) ++{ ++ if (addr && size) ++ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)addr, ++ BYTES_TO_PAGES(size)); ++} ++ ++static void * ++kernel_alloc(grub_efi_uintn_t size, const char * const errmsg) ++{ ++ void *addr = 0; ++ unsigned int i; ++ grub_efi_physical_address_t prev_max = 0; ++ ++ for (i = 0; max_addresses[i].addr != 0 && addr == 0; i++) ++ { ++ grub_uint64_t max = max_addresses[i].addr; ++ grub_efi_uintn_t pages; ++ ++ if (max == prev_max) ++ continue; ++ ++ pages = BYTES_TO_PAGES(size); ++ grub_dprintf ("linux", "Trying to allocate %lu pages from %p\n", ++ pages, (void *)max); ++ ++ prev_max = max; ++ addr = grub_efi_allocate_pages_real (max, pages, ++ max_addresses[i].alloc_type, ++ GRUB_EFI_LOADER_DATA); ++ if (addr) ++ grub_dprintf ("linux", "Allocated at %p\n", addr); ++ } ++ ++ while (grub_error_pop ()) ++ { ++ ; ++ } ++ ++ if (addr == NULL) ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, errmsg); ++ ++ return addr; ++} ++ + static grub_err_t + grub_linuxefi_boot (void) + { +@@ -62,19 +121,12 @@ grub_linuxefi_unload (void) + { + grub_dl_unref (my_mod); + loaded = 0; +- if (initrd_mem) +- grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)initrd_mem, +- BYTES_TO_PAGES(params->ramdisk_size)); +- if (linux_cmdline) +- grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t) +- linux_cmdline, +- BYTES_TO_PAGES(params->cmdline_size + 1)); +- if (kernel_mem) +- grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, +- BYTES_TO_PAGES(kernel_size)); +- if (params) +- grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)params, +- BYTES_TO_PAGES(16384)); ++ ++ kernel_free(initrd_mem, params->ramdisk_size); ++ kernel_free(linux_cmdline, params->cmdline_size + 1); ++ kernel_free(kernel_mem, kernel_size); ++ kernel_free(params, sizeof(*params)); ++ + return GRUB_ERR_NONE; + } + +@@ -150,19 +202,13 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + size += ALIGN_UP (grub_file_size (files[i]), 4); + } + +- initrd_mem = grub_efi_allocate_pages_max (GRUB_EFI_MAX_ALLOCATION_ADDRESS, BYTES_TO_PAGES(size)); +- if (!initrd_mem) +- initrd_mem = grub_efi_allocate_pages_max (GRUB_EFI_MAX_USABLE_ADDRESS, BYTES_TO_PAGES(size)); +- if (!initrd_mem) +- { +- grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate initrd")); +- goto fail; +- } +- +- grub_dprintf ("linux", "initrd_mem = %lx\n", (unsigned long) initrd_mem); ++ initrd_mem = kernel_alloc(size, N_("can't allocate initrd")); ++ if (initrd_mem == NULL) ++ goto fail; ++ grub_dprintf ("linux", "initrd_mem = %p\n", initrd_mem); + + params->ramdisk_size = size; +- params->ramdisk_image = (grub_uint32_t)(grub_addr_t) initrd_mem; ++ params->ramdisk_image = initrd_mem; + + ptr = initrd_mem; + +@@ -221,7 +267,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + filelen = grub_file_size (file); + + kernel = grub_malloc(filelen); +- + if (!kernel) + { + grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate kernel buffer")); +@@ -274,7 +319,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + +-#if defined(__x86_64__) || defined(__aarch64__) ++#if defined(__x86_64__) + grub_dprintf ("linux", "checking lh->xloadflags\n"); + if (!(lh->xloadflags & LINUX_XLF_KERNEL_64)) + { +@@ -293,17 +338,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + } + #endif + +- params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_ALLOCATION_ADDRESS, +- BYTES_TO_PAGES(sizeof(*params))); ++ params = kernel_alloc (sizeof(*params), "cannot allocate kernel parameters"); + if (!params) +- params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_USABLE_ADDRESS, +- BYTES_TO_PAGES(sizeof(*params))); +- if (! params) +- { +- grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate kernel parameters"); +- goto fail; +- } +- ++ goto fail; + grub_dprintf ("linux", "params = %p\n", params); + + grub_memset (params, 0, sizeof(*params)); +@@ -322,19 +359,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + grub_dprintf ("linux", "new lh is at %p\n", lh); + + grub_dprintf ("linux", "setting up cmdline\n"); +- linux_cmdline = grub_efi_allocate_pages_max(GRUB_EFI_MAX_ALLOCATION_ADDRESS, +- BYTES_TO_PAGES(lh->cmdline_size + 1)); ++ linux_cmdline = kernel_alloc (lh->cmdline_size + 1, N_("can't allocate cmdline")); + if (!linux_cmdline) +- linux_cmdline = grub_efi_allocate_pages_max(GRUB_EFI_MAX_USABLE_ADDRESS, +- BYTES_TO_PAGES(lh->cmdline_size + 1)); +- if (!linux_cmdline) +- { +- grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate cmdline")); +- goto fail; +- } +- +- grub_dprintf ("linux", "linux_cmdline = %lx\n", +- (unsigned long)linux_cmdline); ++ goto fail; ++ grub_dprintf ("linux", "linux_cmdline = %p\n", linux_cmdline); + + grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE)); + grub_create_loader_cmdline (argc, argv, +@@ -343,27 +371,24 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + GRUB_VERIFY_KERNEL_CMDLINE); + + grub_dprintf ("linux", "cmdline:%s\n", linux_cmdline); +- grub_dprintf ("linux", "setting lh->cmd_line_ptr\n"); +- lh->cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline; ++ grub_dprintf ("linux", "setting lh->cmd_line_ptr to 0x%08x\n", ++ linux_cmdline); ++ lh->cmd_line_ptr = linux_cmdline; + + handover_offset = lh->handover_offset; +- grub_dprintf("linux", "handover_offset: %08x\n", handover_offset); ++ grub_dprintf("linux", "handover_offset: 0x%08x\n", handover_offset); + + start = (lh->setup_sects + 1) * 512; + +- kernel_mem = grub_efi_allocate_pages_max(lh->pref_address, +- BYTES_TO_PAGES(lh->init_size)); +- if (!kernel_mem) +- kernel_mem = grub_efi_allocate_pages_max(GRUB_EFI_MAX_ALLOCATION_ADDRESS, +- BYTES_TO_PAGES(lh->init_size)); +- if (!kernel_mem) +- kernel_mem = grub_efi_allocate_pages_max(GRUB_EFI_MAX_USABLE_ADDRESS, +- BYTES_TO_PAGES(lh->init_size)); +- if (!kernel_mem) ++ grub_dprintf ("linux", "lh->pref_address: %p\n", (void *)(grub_addr_t)lh->pref_address); ++ if (lh->pref_address < (grub_uint64_t)GRUB_EFI_MAX_ALLOCATION_ADDRESS) + { +- grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate kernel")); +- goto fail; ++ max_addresses[0].addr = lh->pref_address; ++ max_addresses[0].alloc_type = GRUB_EFI_ALLOCATE_ADDRESS; + } ++ kernel_mem = kernel_alloc (lh->init_size, N_("can't allocate kernel")); ++ if (!kernel_mem) ++ goto fail; + grub_dprintf("linux", "kernel_mem = %p\n", kernel_mem); + + grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0); +@@ -398,18 +423,14 @@ fail: + loaded = 0; + } + +- if (linux_cmdline && lh && !loaded) +- grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t) +- linux_cmdline, +- BYTES_TO_PAGES(lh->cmdline_size + 1)); +- +- if (kernel_mem && !loaded) +- grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, +- BYTES_TO_PAGES(kernel_size)); ++ if (!loaded) ++ { ++ if (lh) ++ kernel_free (linux_cmdline, lh->cmdline_size + 1); + +- if (params && !loaded) +- grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)params, +- BYTES_TO_PAGES(16384)); ++ kernel_free (kernel_mem, kernel_size); ++ kernel_free (params, sizeof(*params)); ++ } + + return grub_errno; + } +-- +1.8.3.1 + diff --git a/0156-Skip-leading-spaces-on-BLS-field-values.patch b/0156-Skip-leading-spaces-on-BLS-field-values.patch deleted file mode 100644 index df80edfd13e7ed2f75be9d8e3103457ef0431066..0000000000000000000000000000000000000000 --- a/0156-Skip-leading-spaces-on-BLS-field-values.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Thu, 7 Jun 2018 00:44:51 +0200 -Subject: [PATCH] Skip leading spaces on BLS field values - -The GRUB 2 blscfg command doesn't parse correctly the BLS fields if these -have extra spaces before the field values. For example, the following BLS -fragment generates a wrong menu entry due using spaces to tabulate values: - -title Fedora 28 (Twenty Eight) -version 4.16.13-300.fc28.x86_64 -machine-id e5c131dfee3249cbb9891c2641d8e350 -linux /vmlinuz-4.16.13-300.fc28.x86_64 -initrd /initramfs-4.16.13-300.fc28.x86_64.img -options root=/dev/mapper/fedora-root ro - -Wrong generated menu entry: - -load_video -set gfx_payload=keep -insmod gzio -linux ($root) /vmlinuz-4.16.13-300.fc28.x86_64 root=/dev/mapper/fedora-root ro -initrd ($root) /initramfs-4.16.13-300.fc28.x86_64.img - -Correct menu entry after the fix: - -load_video -set gfx_payload=keep -insmod gzio -linux ($root)/vmlinuz-4.16.13-300.fc28.x86_64 root=/dev/mapper/fedora-root ro -initrd ($root)/initramfs-4.16.13-300.fc28.x86_64.img - -Resolves: rhbz#1588184 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index fb08d8e4c12..831cdcaccdf 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -448,7 +448,11 @@ static int read_entry ( - - separator[0] = '\0'; - -- rc = bls_add_keyval (entry, buf, separator+1); -+ do { -+ separator++; -+ } while (*separator == ' ' || *separator == '\t'); -+ -+ rc = bls_add_keyval (entry, buf, separator); - grub_free (buf); - if (rc < 0) - break; diff --git a/0156-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch b/0156-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch new file mode 100644 index 0000000000000000000000000000000000000000..0b33b343f2b6f2bcfa874996c6dfce3e3ac61b43 --- /dev/null +++ b/0156-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch @@ -0,0 +1,175 @@ +From c2315ea6badfef590717c50b652c9d31a1156ca4 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 12 Sep 2018 16:12:27 -0400 +Subject: [PATCH 156/220] x86-efi: Allow initrd+params+cmdline allocations + above 4GB. + +This enables everything except the kernel itself to be above 4GB. +Putting the kernel up there still doesn't work, because of the way +params->code32_start is used. + +Signed-off-by: Peter Jones +--- + grub-core/loader/i386/efi/linux.c | 67 +++++++++++++++++++++++++++++++++++---- + include/grub/i386/linux.h | 6 +++- + 2 files changed, 65 insertions(+), 8 deletions(-) + +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index 075b77e..50b7798 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -52,13 +52,22 @@ struct allocation_choice { + grub_efi_allocate_type_t alloc_type; + }; + +-static struct allocation_choice max_addresses[] = ++static struct allocation_choice max_addresses[4] = + { ++ /* the kernel overrides this one with pref_address and ++ * GRUB_EFI_ALLOCATE_ADDRESS */ + { GRUB_EFI_MAX_ALLOCATION_ADDRESS, GRUB_EFI_ALLOCATE_MAX_ADDRESS }, ++ /* this one is always below 4GB, which we still *prefer* even if the flag ++ * is set. */ + { GRUB_EFI_MAX_ALLOCATION_ADDRESS, GRUB_EFI_ALLOCATE_MAX_ADDRESS }, ++ /* If the flag in params is set, this one gets changed to be above 4GB. */ + { GRUB_EFI_MAX_ALLOCATION_ADDRESS, GRUB_EFI_ALLOCATE_MAX_ADDRESS }, + { 0, 0 } + }; ++static struct allocation_choice saved_addresses[4]; ++ ++#define save_addresses() grub_memcpy(saved_addresses, max_addresses, sizeof(max_addresses)) ++#define restore_addresses() grub_memcpy(max_addresses, saved_addresses, sizeof(max_addresses)) + + static inline void + kernel_free(void *addr, grub_efi_uintn_t size) +@@ -80,6 +89,11 @@ kernel_alloc(grub_efi_uintn_t size, const char * const errmsg) + grub_uint64_t max = max_addresses[i].addr; + grub_efi_uintn_t pages; + ++ /* ++ * When we're *not* loading the kernel, or >4GB allocations aren't ++ * supported, these entries are basically all the same, so don't re-try ++ * the same parameters. ++ */ + if (max == prev_max) + continue; + +@@ -168,6 +182,9 @@ read(grub_file_t file, grub_uint8_t *bufp, grub_size_t len) + return bufpos; + } + ++#define LOW_U32(val) ((grub_uint32_t)(((grub_addr_t)(val)) & 0xffffffffull)) ++#define HIGH_U32(val) ((grub_uint32_t)(((grub_addr_t)(val) >> 32) & 0xffffffffull)) ++ + static grub_err_t + grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + int argc, char *argv[]) +@@ -207,8 +224,12 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + goto fail; + grub_dprintf ("linux", "initrd_mem = %p\n", initrd_mem); + +- params->ramdisk_size = size; +- params->ramdisk_image = initrd_mem; ++ params->ramdisk_size = LOW_U32(size); ++ params->ramdisk_image = LOW_U32(initrd_mem); ++#if defined(__x86_64__) ++ params->ext_ramdisk_size = HIGH_U32(size); ++ params->ext_ramdisk_image = HIGH_U32(initrd_mem); ++#endif + + ptr = initrd_mem; + +@@ -338,6 +359,18 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + } + #endif + ++#if defined(__x86_64__) ++ if (lh->xloadflags & LINUX_XLF_CAN_BE_LOADED_ABOVE_4G) ++ { ++ grub_dprintf ("linux", "Loading kernel above 4GB is supported; enabling.\n"); ++ max_addresses[2].addr = GRUB_EFI_MAX_USABLE_ADDRESS; ++ } ++ else ++ { ++ grub_dprintf ("linux", "Loading kernel above 4GB is not supported\n"); ++ } ++#endif ++ + params = kernel_alloc (sizeof(*params), "cannot allocate kernel parameters"); + if (!params) + goto fail; +@@ -372,21 +405,40 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + + grub_dprintf ("linux", "cmdline:%s\n", linux_cmdline); + grub_dprintf ("linux", "setting lh->cmd_line_ptr to 0x%08x\n", +- linux_cmdline); +- lh->cmd_line_ptr = linux_cmdline; ++ LOW_U32(linux_cmdline)); ++ lh->cmd_line_ptr = LOW_U32(linux_cmdline); ++#if defined(__x86_64__) ++ if ((grub_efi_uintn_t)linux_cmdline > 0xffffffffull) ++ { ++ grub_dprintf ("linux", "setting params->ext_cmd_line_ptr to 0x%08x\n", ++ HIGH_U32(linux_cmdline)); ++ params->ext_cmd_line_ptr = HIGH_U32(linux_cmdline); ++ } ++#endif + + handover_offset = lh->handover_offset; + grub_dprintf("linux", "handover_offset: 0x%08x\n", handover_offset); + + start = (lh->setup_sects + 1) * 512; + ++ /* ++ * AFAICS >4GB for kernel *cannot* work because of params->code32_start being ++ * 32-bit and getting called unconditionally in head_64.S from either entry ++ * point. ++ * ++ * so nerf that out here... ++ */ ++ save_addresses(); + grub_dprintf ("linux", "lh->pref_address: %p\n", (void *)(grub_addr_t)lh->pref_address); + if (lh->pref_address < (grub_uint64_t)GRUB_EFI_MAX_ALLOCATION_ADDRESS) + { + max_addresses[0].addr = lh->pref_address; + max_addresses[0].alloc_type = GRUB_EFI_ALLOCATE_ADDRESS; + } ++ max_addresses[1].addr = GRUB_EFI_MAX_ALLOCATION_ADDRESS; ++ max_addresses[2].addr = GRUB_EFI_MAX_ALLOCATION_ADDRESS; + kernel_mem = kernel_alloc (lh->init_size, N_("can't allocate kernel")); ++ restore_addresses(); + if (!kernel_mem) + goto fail; + grub_dprintf("linux", "kernel_mem = %p\n", kernel_mem); +@@ -395,8 +447,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + + loaded = 1; + +- grub_dprintf ("linux", "setting lh->code32_start to %p\n", kernel_mem); +- lh->code32_start = (grub_uint32_t)(grub_addr_t) kernel_mem; ++ grub_dprintf ("linux", "setting lh->code32_start to 0x%08x\n", ++ LOW_U32(kernel_mem)); ++ lh->code32_start = LOW_U32(kernel_mem); + + grub_memcpy (kernel_mem, (char *)kernel + start, filelen - start); + +diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h +index a093679..91123b1 100644 +--- a/include/grub/i386/linux.h ++++ b/include/grub/i386/linux.h +@@ -234,7 +234,11 @@ struct linux_kernel_params + grub_uint32_t ofw_cif_handler; /* b8 */ + grub_uint32_t ofw_idt; /* bc */ + +- grub_uint8_t padding7[0x1b8 - 0xc0]; ++ grub_uint32_t ext_ramdisk_image; /* 0xc0 */ ++ grub_uint32_t ext_ramdisk_size; /* 0xc4 */ ++ grub_uint32_t ext_cmd_line_ptr; /* 0xc8 */ ++ ++ grub_uint8_t padding7[0x1b8 - 0xcc]; + + union + { +-- +1.8.3.1 + diff --git a/0157-Fix-getroot.c-s-trampolines.patch b/0157-Fix-getroot.c-s-trampolines.patch new file mode 100644 index 0000000000000000000000000000000000000000..43b559febf462ead0069c1bae270a1849edf6474 --- /dev/null +++ b/0157-Fix-getroot.c-s-trampolines.patch @@ -0,0 +1,50 @@ +From 56c9e4636e9bfcdd16e8616c3b4084c12abe39d8 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 28 Sep 2018 15:42:19 -0400 +Subject: [PATCH 157/220] Fix getroot.c's trampolines. + +This makes the stack executable on most of the grub utilities, which is +bad, and rpmdiff complains about it. + +Signed-off-by: Peter Jones +--- + grub-core/osdep/linux/getroot.c | 16 +++++++--------- + 1 file changed, 7 insertions(+), 9 deletions(-) + +diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c +index 2b7a626..36429a7 100644 +--- a/grub-core/osdep/linux/getroot.c ++++ b/grub-core/osdep/linux/getroot.c +@@ -1264,22 +1264,20 @@ grub_util_get_grub_dev_os (const char *os_dev) + return grub_dev; + } + ++static void *mp = NULL; ++static void ++btrfs_mount_path_hook(const char *m) ++{ ++ mp = strdup (m); ++} + + char * + grub_util_get_btrfs_subvol (const char *path, char **mount_path) + { +- char *mp = NULL; +- + if (mount_path) + *mount_path = NULL; + +- auto void +- mount_path_hook (const char *m) +- { +- mp = strdup (m); +- } +- +- grub_find_root_btrfs_mount_path_hook = mount_path_hook; ++ grub_find_root_btrfs_mount_path_hook = btrfs_mount_path_hook; + grub_free (grub_find_root_devices_from_mountinfo (path, NULL)); + grub_find_root_btrfs_mount_path_hook = NULL; + +-- +1.8.3.1 + diff --git a/0158-Do-not-allow-stack-trampolines-anywhere.patch b/0158-Do-not-allow-stack-trampolines-anywhere.patch new file mode 100644 index 0000000000000000000000000000000000000000..f4a8b6e6f7b95fa6968c395b75ca460c6a1a008d --- /dev/null +++ b/0158-Do-not-allow-stack-trampolines-anywhere.patch @@ -0,0 +1,41 @@ +From 7840cc28efc1de9777fec4e9c85dd7d2887be628 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 12 Jul 2019 10:06:50 +0200 +Subject: [PATCH 158/220] Do not allow stack trampolines, anywhere. + +Signed-off-by: Peter Jones +--- + conf/Makefile.common | 2 +- + configure.ac | 3 +++ + 2 files changed, 4 insertions(+), 1 deletion(-) + +diff --git a/conf/Makefile.common b/conf/Makefile.common +index b867691..87c1f0e 100644 +--- a/conf/Makefile.common ++++ b/conf/Makefile.common +@@ -66,7 +66,7 @@ grubconfdir = $(sysconfdir)/grub.d + platformdir = $(pkglibdir)/$(target_cpu)-$(platform) + starfielddir = $(pkgdatadir)/themes/starfield + +-CFLAGS_GNULIB = -Wno-undef -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code ++CFLAGS_GNULIB = -Wno-undef -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Werror=trampolines -fno-trampolines + CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/lib/gnulib -I$(top_srcdir)/grub-core/lib/gnulib + + CFLAGS_POSIX = -fno-builtin +diff --git a/configure.ac b/configure.ac +index 38d978b..5076d63 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1995,6 +1995,9 @@ if test x"$enable_wextra" != xno ; then + HOST_CFLAGS="$HOST_CFLAGS -Wextra" + fi + ++TARGET_CFLAGS="$TARGET_CFLAGS -Werror=trampolines -fno-trampolines" ++HOST_CFLAGS="$HOST_CFLAGS -Werror=trampolines -fno-trampolines" ++ + TARGET_CPP="$TARGET_CC -E" + TARGET_CCAS=$TARGET_CC + +-- +1.8.3.1 + diff --git a/0158-TPM-Fix-hash_log_extend_event-function-prototype.patch b/0158-TPM-Fix-hash_log_extend_event-function-prototype.patch deleted file mode 100644 index 56cd1691f353f62cd41b6f79ac3e53181205fdef..0000000000000000000000000000000000000000 --- a/0158-TPM-Fix-hash_log_extend_event-function-prototype.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Fri, 15 Jun 2018 09:25:00 +0200 -Subject: [PATCH] TPM: Fix hash_log_extend_event function prototype - -The DataToHash argument is a efi_physical_address, not a *pointer* to -a efi_physical_address. - -This distinction is important for 32 bits builds, where the pointer is -only 32 bits where as an efi_physical_address is 64 bits. - -Fixing this fixes the tpm code not working with 32 bits build and grub -showing multiple: - -error: Invalid parameter - -Messages during boot, followed by a "press any key to continue" message. - -Signed-off-by: Hans de Goede ---- - grub-core/kern/efi/tpm.c | 2 +- - include/grub/efi/tpm.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/kern/efi/tpm.c b/grub-core/kern/efi/tpm.c -index c9fb3c133f3..36e1f69df16 100644 ---- a/grub-core/kern/efi/tpm.c -+++ b/grub-core/kern/efi/tpm.c -@@ -245,7 +245,7 @@ grub_tpm2_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf, - event->Size = sizeof(*event) - sizeof(event->Event) + grub_strlen(description) + 1; - grub_memcpy(event->Event, description, grub_strlen(description) + 1); - -- status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, buf, -+ status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (unsigned long) buf, - (grub_uint64_t) size, event); - - switch (status) { -diff --git a/include/grub/efi/tpm.h b/include/grub/efi/tpm.h -index e2aff4a3c22..63d8a0fe714 100644 ---- a/include/grub/efi/tpm.h -+++ b/include/grub/efi/tpm.h -@@ -129,7 +129,7 @@ struct grub_efi_tpm2_protocol - grub_efi_boolean_t *EventLogTruncated); - grub_efi_status_t (*hash_log_extend_event) (struct grub_efi_tpm2_protocol *this, - grub_efi_uint64_t Flags, -- grub_efi_physical_address_t *DataToHash, -+ grub_efi_physical_address_t DataToHash, - grub_efi_uint64_t DataToHashLen, - EFI_TCG2_EVENT *EfiTcgEvent); - grub_efi_status_t (*submit_command) (struct grub_efi_tpm2_protocol *this, diff --git a/0241-Reimplement-boot_counter.patch b/0159-Reimplement-boot_counter.patch similarity index 78% rename from 0241-Reimplement-boot_counter.patch rename to 0159-Reimplement-boot_counter.patch index 0dafac4aa2a493296b71da3d23bde485f6dacebc..88b642b7aa9987634e1230eebf14439767905dbd 100644 --- a/0241-Reimplement-boot_counter.patch +++ b/0159-Reimplement-boot_counter.patch @@ -1,7 +1,7 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 6a1bf02b86814f1b015bfc0a0979ecdca4106516 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Thu, 4 Oct 2018 14:22:09 -0400 -Subject: [PATCH] Reimplement boot_counter +Subject: [PATCH 159/220] Reimplement boot_counter This adds "increment" and "decrement" commands, and uses them to maintain our variables in 01_fallback_counter. It also simplifies the counter logic, so @@ -11,37 +11,39 @@ Apparently, this *really* wasn't tested well enough. Resolves: rhbz#1614637 Signed-off-by: Peter Jones +[lorbus: add comments and revert logic changes in 01_fallback_counting] +Signed-off-by: Christian Glombek --- Makefile.util.def | 6 +++ grub-core/Makefile.core.def | 5 ++ grub-core/commands/increment.c | 105 ++++++++++++++++++++++++++++++++++++ - util/grub.d/01_fallback_counting.in | 15 ++++++ - 4 files changed, 131 insertions(+) + util/grub.d/01_fallback_counting.in | 22 ++++++++ + 4 files changed, 138 insertions(+) create mode 100644 grub-core/commands/increment.c create mode 100644 util/grub.d/01_fallback_counting.in diff --git a/Makefile.util.def b/Makefile.util.def -index cba4d500198..c8cb91308d9 100644 +index 125ad62..2019ebd 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -448,6 +448,12 @@ script = { - installdir = grubconf; +@@ -458,6 +458,12 @@ script = { }; -+script = { + script = { + name = '01_fallback_counting'; + common = util/grub.d/01_fallback_counting.in; + installdir = grubconf; +}; + - script = { ++script = { name = '01_menu_auto_hide'; common = util/grub.d/01_menu_auto_hide.in; + installdir = grubconf; diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 701e5d32fa2..1bf666b5ec1 100644 +index 8bb1daf..65ca74f 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -364,6 +364,11 @@ kernel = { +@@ -395,6 +395,11 @@ kernel = { extra_dist = kern/mips/cache_flush.S; }; @@ -55,7 +57,7 @@ index 701e5d32fa2..1bf666b5ec1 100644 mansection = 1; diff --git a/grub-core/commands/increment.c b/grub-core/commands/increment.c new file mode 100644 -index 00000000000..79cf137656c +index 0000000..79cf137 --- /dev/null +++ b/grub-core/commands/increment.c @@ -0,0 +1,105 @@ @@ -166,22 +168,32 @@ index 00000000000..79cf137656c +} diff --git a/util/grub.d/01_fallback_counting.in b/util/grub.d/01_fallback_counting.in new file mode 100644 -index 00000000000..6ca13da03df +index 0000000..be0e770 --- /dev/null +++ b/util/grub.d/01_fallback_counting.in -@@ -0,0 +1,15 @@ +@@ -0,0 +1,22 @@ +#! /bin/sh -e + +# Boot Counting ++# The boot_counter env var can be used to count down boot attempts after an ++# OSTree upgrade and choose the rollback deployment when 0 is reached. Both ++# boot_counter and boot_success need to be (re-)set from userspace. +cat << EOF +insmod increment -+if [ -z "\${boot_counter}" ]; then -+ set boot_counter=0 -+elif [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then -+ increment default -+ set boot_counter=-1 -+else -+ decrement boot_counter ++# Check if boot_counter exists and boot_success=0 to activate this behaviour. ++if [ -n "\${boot_counter}" -a "\${boot_success}" = "0" ]; then ++ # if countdown has ended, choose to boot rollback deployment (default=1 on ++ # OSTree-based systems) ++ if [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then ++ set default=1 ++ set boot_counter=-1 ++ # otherwise decrement boot_counter ++ else ++ decrement boot_counter ++ fi ++ save_env boot_counter +fi -+save_env boot_counter +EOF +-- +1.8.3.1 + diff --git a/0159-TPM-Fix-compiler-warnings.patch b/0159-TPM-Fix-compiler-warnings.patch deleted file mode 100644 index b19d48477f4fd805e6fe917c7b06c4f03c6fedbe..0000000000000000000000000000000000000000 --- a/0159-TPM-Fix-compiler-warnings.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Fri, 15 Jun 2018 09:58:50 +0200 -Subject: [PATCH] TPM: Fix compiler warnings - -Stop defining our own Event type in tpm.c instead use the one from -the header, so that it matches the function prototype. -Note this requires some further code changes to go from all lowercaps -of the private Event type to the CamelCaps from the header. - -Also cast buf, which gets passed as a efi_physicall_address_t to an -integer, to avoid the compiler complaining about passing a pointer as -an integer. - -Signed-off-by: Hans de Goede ---- - grub-core/kern/efi/tpm.c | 24 ++++++++---------------- - 1 file changed, 8 insertions(+), 16 deletions(-) - -diff --git a/grub-core/kern/efi/tpm.c b/grub-core/kern/efi/tpm.c -index 36e1f69df16..0d3ebe22e57 100644 ---- a/grub-core/kern/efi/tpm.c -+++ b/grub-core/kern/efi/tpm.c -@@ -161,21 +161,12 @@ grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf, - } - } - --typedef struct { -- grub_uint32_t pcrindex; -- grub_uint32_t eventtype; -- grub_uint8_t digest[20]; -- grub_uint32_t eventsize; -- grub_uint8_t event[1]; --} Event; -- -- - static grub_err_t - grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf, - grub_size_t size, grub_uint8_t pcr, - const char *description) - { -- Event *event; -+ TCG_PCR_EVENT *event; - grub_efi_status_t status; - grub_efi_tpm_protocol_t *tpm; - grub_efi_physical_address_t lastevent; -@@ -188,18 +179,19 @@ grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf, - if (!grub_tpm_present(tpm)) - return 0; - -- event = grub_zalloc(sizeof (Event) + grub_strlen(description) + 1); -+ event = grub_zalloc(sizeof (TCG_PCR_EVENT) + grub_strlen(description) + 1); - if (!event) - return grub_error (GRUB_ERR_OUT_OF_MEMORY, - N_("cannot allocate TPM event buffer")); - -- event->pcrindex = pcr; -- event->eventtype = EV_IPL; -- event->eventsize = grub_strlen(description) + 1; -- grub_memcpy(event->event, description, event->eventsize); -+ event->PCRIndex = pcr; -+ event->EventType = EV_IPL; -+ event->EventSize = grub_strlen(description) + 1; -+ grub_memcpy(event->Event, description, event->EventSize); - - algorithm = TCG_ALG_SHA; -- status = efi_call_7 (tpm->log_extend_event, tpm, buf, (grub_uint64_t) size, -+ status = efi_call_7 (tpm->log_extend_event, tpm, -+ (unsigned long) buf, (grub_uint64_t) size, - algorithm, event, &eventnum, &lastevent); - - switch (status) { diff --git a/0160-Make-grub_strtol-end-pointers-have-safer-const-quali.patch b/0160-Make-grub_strtol-end-pointers-have-safer-const-quali.patch new file mode 100644 index 0000000000000000000000000000000000000000..234bf07c198f98ba8b944ebe4e97a52cb288295f --- /dev/null +++ b/0160-Make-grub_strtol-end-pointers-have-safer-const-quali.patch @@ -0,0 +1,990 @@ +From 9b30aea6e6282803165d852d2dc0e1d35836114f Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 19 Oct 2018 13:41:48 -0400 +Subject: [PATCH 160/220] Make grub_strtol() "end" pointers have safer const + qualifiers. (v2) + +Currently the string functions grub_strtol(), grub_strtoul(), and +grub_strtoull() don't declare the "end" pointer in such a way as to +require the pointer itself or the character array to be immutable to the +implementation, nor does the C standard do so in its similar functions, +though it does require us not to change any of it. + +The typical declarations of these functions follow this pattern: + +long +strtol(const char * restrict nptr, char ** restrict endptr, int base); + +Much of the reason for this is historic, and a discussion of that +follows below, after the explanation of this change. (GRUB currently +does not include the "restrict" qualifiers, and we name the arguments a +bit differently.) + +The implementation is semantically required to treat the character array +as immutable, but such accidental modifications aren't stopped by the +compiler, and the semantics for both the callers and the implementation +of these functions are sometimes also helped by adding that requirement. + +This patch changes these declarations to follow this pattern instead: + +long +strtol(const char * restrict nptr, + const char ** const restrict endptr, + int base); + +This means that if any modification to these functions accidentally +introduces either an errant modification to the underlying character +array, or an accidental assignment to endptr rather than *endptr, the +compiler should generate an error. (The two uses of "restrict" in this +case basically mean strtol() isn't allowed to modify the character array +by going through *endptr, and endptr isn't allowed to point inside the +array.) + +It also means the typical use case changes to: + + char *s = ...; + const char *end; + long l; + + l = strtol(s, &end, 10); + +Or even: + + const char *p = str; + while (p && *p) { + long l = strtol(p, &p, 10); + ... + } + +This fixes 26 places where we discard our attempts at treating the data +safely by doing: + + const char *p = str; + long l; + + l = strtol(p, (char **)&ptr, 10); + +It also adds 5 places where we do: + + char *p = str; + while (p && *p) { + long l = strtol(p, (const char ** const)&p, 10); + ... + /* more calls that need p not to be pointer-to-const */ + } + +While moderately distasteful, this is a better problem to have. + +With one minor exception, I have tested that all of this compiles +without relevant warnings or errors, and that /much/ of it behaves +correctly, with gcc 9 using 'gcc -W -Wall -Wextra'. The one exception +is the changes in grub-core/osdep/aros/hostdisk.c , which I have no idea +how to build. + +Because the C standard defined type-qualifiers in a way that can be +confusing, in the past there's been a slow but fairly regular stream of +churn within our patches, which add and remove the const qualifier in many +of the users of these functions. This change should help avoid that in +the future, and in order to help ensure this, I've added an explanation +in misc.h so that when someone does get a compiler warning about a type +error, they have the fix at hand. + +The reason we don't have "const" in these calls in the standard is +purely anachronistic: C78 (de facto) did not have type qualifiers in the +syntax, and the "const" type qualifier was added for C89 (I think; it +may have been later). strtol() appears to date from 4.3BSD in 1986, +which means it could not be added to those functions in the standard +without breaking compatibility, which is usually avoided. + +The syntax chosen for type qualifiers is what has led to the churn +regarding usage of const, and is especially confusing on string +functions due to the lack of a string type. Quoting from C99, the +syntax is: + + declarator: + pointer[opt] direct-declarator + direct-declarator: + identifier + ( declarator ) + direct-declarator [ type-qualifier-list[opt] assignment-expression[opt] ] + ... + direct-declarator [ type-qualifier-list[opt] * ] + ... + pointer: + * type-qualifier-list[opt] + * type-qualifier-list[opt] pointer + type-qualifier-list: + type-qualifier + type-qualifier-list type-qualifier + ... + type-qualifier: + const + restrict + volatile + +So the examples go like: + +const char foo; // immutable object +const char *foo; // mutable pointer to object +char * const foo; // immutable pointer to mutable object +const char * const foo; // immutable pointer to immutable object +const char const * const foo; // XXX extra const keyword in the middle +const char * const * const foo; // immutable pointer to immutable + // pointer to immutable object +const char ** const foo; // immutable pointer to mutable pointer + // to immutable object + +Making const left-associative for * and right-associative for everything +else may not have been the best choice ever, but here we are, and the +inevitable result is people using trying to use const (as they should!), +putting it at the wrong place, fighting with the compiler for a bit, and +then either removing it or typecasting something in a bad way. I won't +go into describing restrict, but its syntax has exactly the same issue +as with const. + +Anyway, the last example above actually represents the *behavior* that's +required of strtol()-like functions, so that's our choice for the "end" +pointer. + +Signed-off-by: Peter Jones +--- + grub-core/commands/date.c | 3 ++- + grub-core/commands/i386/cmostest.c | 2 +- + grub-core/commands/i386/pc/play.c | 2 +- + grub-core/commands/i386/rdmsr.c | 2 +- + grub-core/commands/i386/wrmsr.c | 2 +- + grub-core/commands/password_pbkdf2.c | 2 +- + grub-core/commands/pcidump.c | 13 ++++++------- + grub-core/commands/regexp.c | 2 +- + grub-core/commands/setpci.c | 21 ++++++++++----------- + grub-core/commands/test.c | 2 +- + grub-core/commands/videoinfo.c | 2 +- + grub-core/disk/diskfilter.c | 3 ++- + grub-core/disk/lvm.c | 9 +++++---- + grub-core/efiemu/pnvram.c | 5 +++-- + grub-core/gfxmenu/gui_circular_progress.c | 2 +- + grub-core/gfxmenu/theme_loader.c | 2 +- + grub-core/kern/fs.c | 2 +- + grub-core/kern/misc.c | 10 ++++++---- + grub-core/kern/partition.c | 2 +- + grub-core/lib/arg.c | 2 +- + grub-core/lib/legacy_parse.c | 2 +- + grub-core/lib/syslinux_parse.c | 6 +++--- + grub-core/loader/i386/bsd.c | 6 +++--- + grub-core/loader/i386/linux.c | 2 +- + grub-core/loader/i386/pc/linux.c | 2 +- + grub-core/loader/i386/xen_fileXX.c | 2 +- + grub-core/mmap/mmap.c | 4 ++-- + grub-core/net/http.c | 4 ++-- + grub-core/net/net.c | 8 ++++---- + grub-core/normal/menu.c | 3 +-- + grub-core/osdep/aros/hostdisk.c | 2 +- + grub-core/osdep/devmapper/hostdisk.c | 2 +- + grub-core/script/execute.c | 6 +++--- + grub-core/term/serial.c | 2 +- + grub-core/term/terminfo.c | 2 +- + grub-core/tests/strtoull_test.c | 2 +- + include/grub/misc.h | 24 +++++++++++++++++++++--- + util/grub-fstest.c | 2 +- + 38 files changed, 96 insertions(+), 75 deletions(-) + +diff --git a/grub-core/commands/date.c b/grub-core/commands/date.c +index 8e1f41f..5cb4faf 100644 +--- a/grub-core/commands/date.c ++++ b/grub-core/commands/date.c +@@ -59,7 +59,8 @@ grub_cmd_date (grub_command_t cmd __attribute__ ((unused)), + + for (; argc; argc--, args++) + { +- char *p, c; ++ const char *p; ++ char c; + int m1, ofs, n, cur_mask; + + p = args[0]; +diff --git a/grub-core/commands/i386/cmostest.c b/grub-core/commands/i386/cmostest.c +index c839b70..9f6b56a 100644 +--- a/grub-core/commands/i386/cmostest.c ++++ b/grub-core/commands/i386/cmostest.c +@@ -27,7 +27,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t + parse_args (int argc, char *argv[], int *byte, int *bit) + { +- char *rest; ++ const char *rest; + + if (argc != 1) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "address required"); +diff --git a/grub-core/commands/i386/pc/play.c b/grub-core/commands/i386/pc/play.c +index c818131..a980e46 100644 +--- a/grub-core/commands/i386/pc/play.c ++++ b/grub-core/commands/i386/pc/play.c +@@ -132,7 +132,7 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)), + } + else + { +- char *end; ++ const char *end; + unsigned tempo; + struct note note; + int i; +diff --git a/grub-core/commands/i386/rdmsr.c b/grub-core/commands/i386/rdmsr.c +index 15b9adf..46c4346 100644 +--- a/grub-core/commands/i386/rdmsr.c ++++ b/grub-core/commands/i386/rdmsr.c +@@ -44,7 +44,7 @@ grub_cmd_msr_read (grub_extcmd_context_t ctxt, int argc, char **argv) + { + grub_uint32_t manufacturer[3], max_cpuid, a, b, c, features, addr; + grub_uint64_t value; +- char *ptr; ++ const char *ptr; + char buf[sizeof("1122334455667788")]; + + /* +diff --git a/grub-core/commands/i386/wrmsr.c b/grub-core/commands/i386/wrmsr.c +index 9c5e510..fa76f5a 100644 +--- a/grub-core/commands/i386/wrmsr.c ++++ b/grub-core/commands/i386/wrmsr.c +@@ -37,7 +37,7 @@ grub_cmd_msr_write (grub_command_t cmd __attribute__ ((unused)), int argc, char + { + grub_uint32_t manufacturer[3], max_cpuid, a, b, c, features, addr; + grub_uint64_t value; +- char *ptr; ++ const char *ptr; + + /* + * The CPUID instruction should be used to determine whether MSRs +diff --git a/grub-core/commands/password_pbkdf2.c b/grub-core/commands/password_pbkdf2.c +index da636e6..ab845d2 100644 +--- a/grub-core/commands/password_pbkdf2.c ++++ b/grub-core/commands/password_pbkdf2.c +@@ -86,7 +86,7 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)), + int argc, char **args) + { + grub_err_t err; +- char *ptr, *ptr2; ++ const char *ptr, *ptr2; + grub_uint8_t *ptro; + struct pbkdf2_password *pass; + +diff --git a/grub-core/commands/pcidump.c b/grub-core/commands/pcidump.c +index f99ad4a..f72628f 100644 +--- a/grub-core/commands/pcidump.c ++++ b/grub-core/commands/pcidump.c +@@ -95,7 +95,7 @@ grub_cmd_pcidump (grub_extcmd_context_t ctxt, + if (ctxt->state[0].set) + { + ptr = ctxt->state[0].arg; +- ctx.pciid_check_value |= (grub_strtoul (ptr, (char **) &ptr, 16) & 0xffff); ++ ctx.pciid_check_value |= (grub_strtoul (ptr, &ptr, 16) & 0xffff); + if (grub_errno == GRUB_ERR_BAD_NUMBER) + { + grub_errno = GRUB_ERR_NONE; +@@ -108,8 +108,7 @@ grub_cmd_pcidump (grub_extcmd_context_t ctxt, + if (*ptr != ':') + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("missing `%c' symbol"), ':'); + ptr++; +- ctx.pciid_check_value |= (grub_strtoul (ptr, (char **) &ptr, 16) & 0xffff) +- << 16; ++ ctx.pciid_check_value |= (grub_strtoul (ptr, &ptr, 16) & 0xffff) << 16; + if (grub_errno == GRUB_ERR_BAD_NUMBER) + grub_errno = GRUB_ERR_NONE; + else +@@ -121,10 +120,10 @@ grub_cmd_pcidump (grub_extcmd_context_t ctxt, + if (ctxt->state[1].set) + { + const char *optr; +- ++ + ptr = ctxt->state[1].arg; + optr = ptr; +- ctx.bus = grub_strtoul (ptr, (char **) &ptr, 16); ++ ctx.bus = grub_strtoul (ptr, &ptr, 16); + if (grub_errno == GRUB_ERR_BAD_NUMBER) + { + grub_errno = GRUB_ERR_NONE; +@@ -138,7 +137,7 @@ grub_cmd_pcidump (grub_extcmd_context_t ctxt, + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("missing `%c' symbol"), ':'); + ptr++; + optr = ptr; +- ctx.device = grub_strtoul (ptr, (char **) &ptr, 16); ++ ctx.device = grub_strtoul (ptr, &ptr, 16); + if (grub_errno == GRUB_ERR_BAD_NUMBER) + { + grub_errno = GRUB_ERR_NONE; +@@ -149,7 +148,7 @@ grub_cmd_pcidump (grub_extcmd_context_t ctxt, + if (*ptr == '.') + { + ptr++; +- ctx.function = grub_strtoul (ptr, (char **) &ptr, 16); ++ ctx.function = grub_strtoul (ptr, &ptr, 16); + if (grub_errno) + return grub_errno; + ctx.check_function = 1; +diff --git a/grub-core/commands/regexp.c b/grub-core/commands/regexp.c +index f00b184..7c5c72f 100644 +--- a/grub-core/commands/regexp.c ++++ b/grub-core/commands/regexp.c +@@ -64,7 +64,7 @@ set_matches (char **varnames, char *str, grub_size_t nmatches, + { + int i; + char *p; +- char *q; ++ const char * q; + grub_err_t err; + unsigned long j; + +diff --git a/grub-core/commands/setpci.c b/grub-core/commands/setpci.c +index d5bc97d..e966af0 100644 +--- a/grub-core/commands/setpci.c ++++ b/grub-core/commands/setpci.c +@@ -169,7 +169,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) + if (ctxt->state[0].set) + { + ptr = ctxt->state[0].arg; +- pciid_check_value |= (grub_strtoul (ptr, (char **) &ptr, 16) & 0xffff); ++ pciid_check_value |= (grub_strtoul (ptr, &ptr, 16) & 0xffff); + if (grub_errno == GRUB_ERR_BAD_NUMBER) + { + grub_errno = GRUB_ERR_NONE; +@@ -182,8 +182,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) + if (*ptr != ':') + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("missing `%c' symbol"), ':'); + ptr++; +- pciid_check_value |= (grub_strtoul (ptr, (char **) &ptr, 16) & 0xffff) +- << 16; ++ pciid_check_value |= (grub_strtoul (ptr, &ptr, 16) & 0xffff) << 16; + if (grub_errno == GRUB_ERR_BAD_NUMBER) + grub_errno = GRUB_ERR_NONE; + else +@@ -197,10 +196,10 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) + if (ctxt->state[1].set) + { + const char *optr; +- ++ + ptr = ctxt->state[1].arg; + optr = ptr; +- bus = grub_strtoul (ptr, (char **) &ptr, 16); ++ bus = grub_strtoul (ptr, &ptr, 16); + if (grub_errno == GRUB_ERR_BAD_NUMBER) + { + grub_errno = GRUB_ERR_NONE; +@@ -214,7 +213,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("missing `%c' symbol"), ':'); + ptr++; + optr = ptr; +- device = grub_strtoul (ptr, (char **) &ptr, 16); ++ device = grub_strtoul (ptr, &ptr, 16); + if (grub_errno == GRUB_ERR_BAD_NUMBER) + { + grub_errno = GRUB_ERR_NONE; +@@ -225,7 +224,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) + if (*ptr == '.') + { + ptr++; +- function = grub_strtoul (ptr, (char **) &ptr, 16); ++ function = grub_strtoul (ptr, &ptr, 16); + if (grub_errno) + return grub_errno; + check_function = 1; +@@ -253,7 +252,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) + if (i == ARRAY_SIZE (pci_registers)) + { + regsize = 0; +- regaddr = grub_strtoul (ptr, (char **) &ptr, 16); ++ regaddr = grub_strtoul (ptr, &ptr, 16); + if (grub_errno) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown register"); + } +@@ -270,7 +269,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) + if (*ptr == '+') + { + ptr++; +- regaddr += grub_strtoul (ptr, (char **) &ptr, 16); ++ regaddr += grub_strtoul (ptr, &ptr, 16); + if (grub_errno) + return grub_errno; + } +@@ -302,14 +301,14 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv) + if (*ptr == '=') + { + ptr++; +- regwrite = grub_strtoul (ptr, (char **) &ptr, 16); ++ regwrite = grub_strtoul (ptr, &ptr, 16); + if (grub_errno) + return grub_errno; + write_mask = 0xffffffff; + if (*ptr == ':') + { + ptr++; +- write_mask = grub_strtoul (ptr, (char **) &ptr, 16); ++ write_mask = grub_strtoul (ptr, &ptr, 16); + if (grub_errno) + return grub_errno; + write_mask = 0xffffffff; +diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c +index 4e929e0..62d3fb3 100644 +--- a/grub-core/commands/test.c ++++ b/grub-core/commands/test.c +@@ -31,7 +31,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); + + /* A simple implementation for signed numbers. */ + static int +-grub_strtosl (char *arg, char **end, int base) ++grub_strtosl (char *arg, const char ** const end, int base) + { + if (arg[0] == '-') + return -grub_strtoul (arg + 1, end, base); +diff --git a/grub-core/commands/videoinfo.c b/grub-core/commands/videoinfo.c +index 4be8107..016a4d8 100644 +--- a/grub-core/commands/videoinfo.c ++++ b/grub-core/commands/videoinfo.c +@@ -136,7 +136,7 @@ grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)), + ctx.height = ctx.width = ctx.depth = 0; + if (argc) + { +- char *ptr; ++ const char *ptr; + ptr = args[0]; + ctx.width = grub_strtoul (ptr, &ptr, 0); + if (grub_errno) +diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c +index 1a3eb6b..3f264be 100644 +--- a/grub-core/disk/diskfilter.c ++++ b/grub-core/disk/diskfilter.c +@@ -971,7 +971,8 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg) + for (p = vgp->lvs; p; p = p->next) + { + int cur_num; +- char *num, *end; ++ char *num; ++ const char *end; + if (!p->fullname) + continue; + if (grub_strncmp (p->fullname, lv->fullname, len) != 0) +diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c +index 7b265c7..0cbd0dd 100644 +--- a/grub-core/disk/lvm.c ++++ b/grub-core/disk/lvm.c +@@ -38,7 +38,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); + at the number. In case STR is not found, *P will be NULL and the + return value will be 0. */ + static grub_uint64_t +-grub_lvm_getvalue (char **p, const char *str) ++grub_lvm_getvalue (const char ** const p, const char *str) + { + *p = grub_strstr (*p, str); + if (! *p) +@@ -63,12 +63,12 @@ grub_lvm_checkvalue (char **p, char *str, char *tmpl) + #endif + + static int +-grub_lvm_check_flag (char *p, const char *str, const char *flag) ++grub_lvm_check_flag (const char *p, const char *str, const char *flag) + { + grub_size_t len_str = grub_strlen (str), len_flag = grub_strlen (flag); + while (1) + { +- char *q; ++ const char *q; + p = grub_strstr (p, str); + if (! p) + return 0; +@@ -105,7 +105,8 @@ grub_lvm_detect (grub_disk_t disk, + char buf[GRUB_LVM_LABEL_SIZE]; + char vg_id[GRUB_LVM_ID_STRLEN+1]; + char pv_id[GRUB_LVM_ID_STRLEN+1]; +- char *metadatabuf, *p, *q, *vgname; ++ char *metadatabuf, *vgname; ++ const char *p, *q; + struct grub_lvm_label_header *lh = (struct grub_lvm_label_header *) buf; + struct grub_lvm_pv_header *pvh; + struct grub_lvm_disk_locn *dlocn; +diff --git a/grub-core/efiemu/pnvram.c b/grub-core/efiemu/pnvram.c +index c5c3d4b..dd42bc6 100644 +--- a/grub-core/efiemu/pnvram.c ++++ b/grub-core/efiemu/pnvram.c +@@ -39,7 +39,7 @@ static grub_size_t nvramsize; + + /* Parse signed value */ + static int +-grub_strtosl (const char *arg, char **end, int base) ++grub_strtosl (const char *arg, const char ** const end, int base) + { + if (arg[0] == '-') + return -grub_strtoul (arg + 1, end, base); +@@ -120,7 +120,8 @@ nvram_set (void * data __attribute__ ((unused))) + grub_memset (nvram, 0, nvramsize); + FOR_SORTED_ENV (var) + { +- char *guid, *attr, *name, *varname; ++ const char *guid; ++ char *attr, *name, *varname; + struct efi_variable *efivar; + int len = 0; + int i; +diff --git a/grub-core/gfxmenu/gui_circular_progress.c b/grub-core/gfxmenu/gui_circular_progress.c +index 354dd7b..7578bfb 100644 +--- a/grub-core/gfxmenu/gui_circular_progress.c ++++ b/grub-core/gfxmenu/gui_circular_progress.c +@@ -230,7 +230,7 @@ circprog_set_state (void *vself, int visible, int start, + static int + parse_angle (const char *value) + { +- char *ptr; ++ const char *ptr; + int angle; + + angle = grub_strtol (value, &ptr, 10); +diff --git a/grub-core/gfxmenu/theme_loader.c b/grub-core/gfxmenu/theme_loader.c +index d6829bb..eae8308 100644 +--- a/grub-core/gfxmenu/theme_loader.c ++++ b/grub-core/gfxmenu/theme_loader.c +@@ -484,7 +484,7 @@ parse_proportional_spec (const char *value, signed *abs, grub_fixed_signed_t *pr + ptr++; + } + +- num = grub_strtoul (ptr, (char **) &ptr, 0); ++ num = grub_strtoul (ptr, &ptr, 0); + if (grub_errno) + return grub_errno; + if (sig) +diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c +index 2b85f49..88d3936 100644 +--- a/grub-core/kern/fs.c ++++ b/grub-core/kern/fs.c +@@ -134,7 +134,7 @@ struct grub_fs_block + static grub_err_t + grub_fs_blocklist_open (grub_file_t file, const char *name) + { +- char *p = (char *) name; ++ const char *p = name; + unsigned num = 0; + unsigned i; + grub_disk_t disk = file->device->disk; +diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c +index 5c3899f..e21dd44 100644 +--- a/grub-core/kern/misc.c ++++ b/grub-core/kern/misc.c +@@ -383,7 +383,8 @@ grub_isspace (int c) + } + + unsigned long +-grub_strtoul (const char *str, char **end, int base) ++grub_strtoul (const char * restrict str, const char ** const restrict end, ++ int base) + { + unsigned long long num; + +@@ -400,7 +401,8 @@ grub_strtoul (const char *str, char **end, int base) + } + + unsigned long long +-grub_strtoull (const char *str, char **end, int base) ++grub_strtoull (const char * restrict str, const char ** const restrict end, ++ int base) + { + unsigned long long num = 0; + int found = 0; +@@ -901,14 +903,14 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, + { + if (fmt[0] == '0') + zerofill = '0'; +- format1 = grub_strtoul (fmt, (char **) &fmt, 10); ++ format1 = grub_strtoul (fmt, &fmt, 10); + } + + if (*fmt == '.') + fmt++; + + if (grub_isdigit (*fmt)) +- format2 = grub_strtoul (fmt, (char **) &fmt, 10); ++ format2 = grub_strtoul (fmt, &fmt, 10); + + if (*fmt == '$') + { +diff --git a/grub-core/kern/partition.c b/grub-core/kern/partition.c +index e499147..2c401b8 100644 +--- a/grub-core/kern/partition.c ++++ b/grub-core/kern/partition.c +@@ -126,7 +126,7 @@ grub_partition_probe (struct grub_disk *disk, const char *str) + while (*ptr && grub_isalpha (*ptr)) + ptr++; + partname_end = ptr; +- num = grub_strtoul (ptr, (char **) &ptr, 0) - 1; ++ num = grub_strtoul (ptr, &ptr, 0) - 1; + + curpart = 0; + /* Use the first partition map type found. */ +diff --git a/grub-core/lib/arg.c b/grub-core/lib/arg.c +index fd7744a..ccc1850 100644 +--- a/grub-core/lib/arg.c ++++ b/grub-core/lib/arg.c +@@ -375,7 +375,7 @@ grub_arg_parse (grub_extcmd_t cmd, int argc, char **argv, + + case ARG_TYPE_INT: + { +- char *tail; ++ const char * tail; + + grub_strtoull (option, &tail, 0); + if (tail == 0 || tail == option || *tail != '\0' || grub_errno) +diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c +index ef56150..05719ab 100644 +--- a/grub-core/lib/legacy_parse.c ++++ b/grub-core/lib/legacy_parse.c +@@ -418,7 +418,7 @@ adjust_file (const char *in, grub_size_t len) + } + if (*comma != ',') + return grub_legacy_escape (in, len); +- part = grub_strtoull (comma + 1, (char **) &rest, 0); ++ part = grub_strtoull (comma + 1, &rest, 0); + if (rest[0] == ',' && rest[1] >= 'a' && rest[1] <= 'z') + { + subpart = rest[1] - 'a'; +diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c +index 4afa992..de9fda0 100644 +--- a/grub-core/lib/syslinux_parse.c ++++ b/grub-core/lib/syslinux_parse.c +@@ -1062,7 +1062,7 @@ write_entry (struct output_buffer *outbuf, + if (ptr[0] == 'h' && ptr[1] == 'd') + { + is_fd = 0; +- devn = grub_strtoul (ptr + 2, &ptr, 0); ++ devn = grub_strtoul (ptr + 2, (const char **)&ptr, 0); + continue; + } + if (grub_strncasecmp (ptr, "file=", 5) == 0) +@@ -1086,12 +1086,12 @@ write_entry (struct output_buffer *outbuf, + if (ptr[0] == 'f' && ptr[1] == 'd') + { + is_fd = 1; +- devn = grub_strtoul (ptr + 2, &ptr, 0); ++ devn = grub_strtoul (ptr + 2, (const char **)&ptr, 0); + continue; + } + if (grub_isdigit (ptr[0])) + { +- part = grub_strtoul (ptr, &ptr, 0); ++ part = grub_strtoul (ptr, (const char **)&ptr, 0); + continue; + } + /* FIXME: isolinux, ntldr, cmldr, *dos, seg, hide +diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c +index 5b9b92d..50cca30 100644 +--- a/grub-core/loader/i386/bsd.c ++++ b/grub-core/loader/i386/bsd.c +@@ -1616,7 +1616,7 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[]) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "unknown disk type name"); + +- unit = grub_strtoul (arg, (char **) &arg, 10); ++ unit = grub_strtoul (arg, &arg, 10); + if (! (arg && *arg >= 'a' && *arg <= 'z')) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "only device specifications of form " +@@ -1634,7 +1634,7 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[]) + if (ctxt->state[OPENBSD_SERIAL_ARG].set) + { + struct grub_openbsd_bootarg_console serial; +- char *ptr; ++ const char *ptr; + unsigned port = 0; + unsigned speed = 9600; + +@@ -1736,7 +1736,7 @@ grub_cmd_netbsd (grub_extcmd_context_t ctxt, int argc, char *argv[]) + if (ctxt->state[NETBSD_SERIAL_ARG].set) + { + struct grub_netbsd_btinfo_serial serial; +- char *ptr; ++ const char *ptr; + + grub_memset (&serial, 0, sizeof (serial)); + grub_strcpy (serial.devname, "com"); +diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c +index 376c726..201e659 100644 +--- a/grub-core/loader/i386/linux.c ++++ b/grub-core/loader/i386/linux.c +@@ -954,7 +954,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + #endif /* GRUB_MACHINE_PCBIOS */ + if (grub_memcmp (argv[i], "mem=", 4) == 0) + { +- char *val = argv[i] + 4; ++ const char *val = argv[i] + 4; + + linux_mem_size = grub_strtoul (val, &val, 0); + +diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c +index fe3e1d4..0bf0e13 100644 +--- a/grub-core/loader/i386/pc/linux.c ++++ b/grub-core/loader/i386/pc/linux.c +@@ -272,7 +272,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + } + else if (grub_memcmp (argv[i], "mem=", 4) == 0) + { +- char *val = argv[i] + 4; ++ const char *val = argv[i] + 4; + + linux_mem_size = grub_strtoul (val, &val, 0); + +diff --git a/grub-core/loader/i386/xen_fileXX.c b/grub-core/loader/i386/xen_fileXX.c +index 6329ec0..27afcaa 100644 +--- a/grub-core/loader/i386/xen_fileXX.c ++++ b/grub-core/loader/i386/xen_fileXX.c +@@ -25,7 +25,7 @@ parse_xen_guest (grub_elf_t elf, struct grub_xen_file_info *xi, + grub_off_t off, grub_size_t sz) + { + char *buf; +- char *ptr; ++ const char *ptr; + int has_paddr = 0; + + grub_errno = GRUB_ERR_NONE; +diff --git a/grub-core/mmap/mmap.c b/grub-core/mmap/mmap.c +index 6a31cba..b569cb2 100644 +--- a/grub-core/mmap/mmap.c ++++ b/grub-core/mmap/mmap.c +@@ -423,7 +423,7 @@ static grub_err_t + grub_cmd_badram (grub_command_t cmd __attribute__ ((unused)), + int argc, char **args) + { +- char * str; ++ const char *str; + struct badram_entry entry; + + if (argc != 1) +@@ -465,7 +465,7 @@ static grub_uint64_t + parsemem (const char *str) + { + grub_uint64_t ret; +- char *ptr; ++ const char *ptr; + + ret = grub_strtoul (str, &ptr, 0); + +diff --git a/grub-core/net/http.c b/grub-core/net/http.c +index c9c5969..b52b558 100644 +--- a/grub-core/net/http.c ++++ b/grub-core/net/http.c +@@ -110,7 +110,7 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len) + return GRUB_ERR_NONE; + } + ptr += sizeof ("HTTP/1.1 ") - 1; +- code = grub_strtoul (ptr, &ptr, 10); ++ code = grub_strtoul (ptr, (const char **)&ptr, 10); + if (grub_errno) + return grub_errno; + switch (code) +@@ -137,7 +137,7 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len) + == 0 && !data->size_recv) + { + ptr += sizeof ("Content-Length: ") - 1; +- file->size = grub_strtoull (ptr, &ptr, 10); ++ file->size = grub_strtoull (ptr, (const char **)&ptr, 10); + data->size_recv = 1; + return GRUB_ERR_NONE; + } +diff --git a/grub-core/net/net.c b/grub-core/net/net.c +index 27a0a1d..aa56393 100644 +--- a/grub-core/net/net.c ++++ b/grub-core/net/net.c +@@ -411,7 +411,7 @@ parse_ip (const char *val, grub_uint32_t *ip, const char **rest) + for (i = 0; i < 4; i++) + { + unsigned long t; +- t = grub_strtoul (ptr, (char **) &ptr, 0); ++ t = grub_strtoul (ptr, &ptr, 0); + if (grub_errno) + { + grub_errno = GRUB_ERR_NONE; +@@ -465,7 +465,7 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) + ptr++; + continue; + } +- t = grub_strtoul (ptr, (char **) &ptr, 16); ++ t = grub_strtoul (ptr, &ptr, 16); + if (grub_errno) + { + grub_errno = GRUB_ERR_NONE; +@@ -577,7 +577,7 @@ grub_net_resolve_net_address (const char *name, + addr->type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; + if (*rest == '/') + { +- addr->ipv4.masksize = grub_strtoul (rest + 1, (char **) &rest, 0); ++ addr->ipv4.masksize = grub_strtoul (rest + 1, &rest, 0); + if (!grub_errno && *rest == 0) + return GRUB_ERR_NONE; + grub_errno = GRUB_ERR_NONE; +@@ -593,7 +593,7 @@ grub_net_resolve_net_address (const char *name, + addr->type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; + if (*rest == '/') + { +- addr->ipv6.masksize = grub_strtoul (rest + 1, (char **) &rest, 0); ++ addr->ipv6.masksize = grub_strtoul (rest + 1, &rest, 0); + if (!grub_errno && *rest == 0) + return GRUB_ERR_NONE; + grub_errno = GRUB_ERR_NONE; +diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c +index 046a1fb..37d753d 100644 +--- a/grub-core/normal/menu.c ++++ b/grub-core/normal/menu.c +@@ -194,8 +194,7 @@ menuentry_eq (const char *id, const char *spec) + static int + get_and_remove_first_entry_number (grub_menu_t menu, const char *name) + { +- const char *val; +- char *tail; ++ const char *val, *tail; + int entry; + int sz = 0; + +diff --git a/grub-core/osdep/aros/hostdisk.c b/grub-core/osdep/aros/hostdisk.c +index 2be654c..3b2c9de 100644 +--- a/grub-core/osdep/aros/hostdisk.c ++++ b/grub-core/osdep/aros/hostdisk.c +@@ -194,7 +194,7 @@ grub_util_fd_open (const char *dev, int flg) + p1 = dev + strlen (dev); + else + { +- unit = grub_strtoul (p1 + 1, (char **) &p2, 16); ++ unit = grub_strtoul (p1 + 1, &p2, 16); + if (p2 && *p2 == '/') + flags = grub_strtoul (p2 + 1, 0, 16); + } +diff --git a/grub-core/osdep/devmapper/hostdisk.c b/grub-core/osdep/devmapper/hostdisk.c +index a697bcb..a8afc0c 100644 +--- a/grub-core/osdep/devmapper/hostdisk.c ++++ b/grub-core/osdep/devmapper/hostdisk.c +@@ -113,7 +113,7 @@ grub_util_get_dm_node_linear_info (dev_t dev, + void *next = NULL; + uint64_t length, start; + char *target, *params; +- char *ptr; ++ const char *ptr; + int major = 0, minor = 0; + int first = 1; + grub_disk_addr_t partstart = 0; +diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c +index ba38b5e..c6d2c36 100644 +--- a/grub-core/script/execute.c ++++ b/grub-core/script/execute.c +@@ -146,7 +146,7 @@ replace_scope (struct grub_script_scope *new_scope) + grub_err_t + grub_script_break (grub_command_t cmd, int argc, char *argv[]) + { +- char *p = 0; ++ const char *p = NULL; + unsigned long count; + + if (argc == 0) +@@ -178,7 +178,7 @@ grub_err_t + grub_script_shift (grub_command_t cmd __attribute__((unused)), + int argc, char *argv[]) + { +- char *p = 0; ++ const char *p = NULL; + unsigned long n = 0; + + if (! scope) +@@ -239,7 +239,7 @@ grub_err_t + grub_script_return (grub_command_t cmd __attribute__((unused)), + int argc, char *argv[]) + { +- char *p; ++ const char *p = NULL; + unsigned long n; + + if (! scope || argc > 1) +diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c +index db80b3b..f9271b0 100644 +--- a/grub-core/term/serial.c ++++ b/grub-core/term/serial.c +@@ -269,7 +269,7 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args) + + if (state[OPTION_BASE_CLOCK].set) + { +- char *ptr; ++ const char *ptr; + config.base_clock = grub_strtoull (state[OPTION_BASE_CLOCK].arg, &ptr, 0); + if (grub_errno) + return grub_errno; +diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c +index 29df35e..537a5c0 100644 +--- a/grub-core/term/terminfo.c ++++ b/grub-core/term/terminfo.c +@@ -737,7 +737,7 @@ grub_cmd_terminfo (grub_extcmd_context_t ctxt, int argc, char **args) + + if (state[OPTION_GEOMETRY].set) + { +- char *ptr = state[OPTION_GEOMETRY].arg; ++ const char *ptr = state[OPTION_GEOMETRY].arg; + w = grub_strtoul (ptr, &ptr, 0); + if (grub_errno) + return grub_errno; +diff --git a/grub-core/tests/strtoull_test.c b/grub-core/tests/strtoull_test.c +index 7da615f..5488ab2 100644 +--- a/grub-core/tests/strtoull_test.c ++++ b/grub-core/tests/strtoull_test.c +@@ -25,7 +25,7 @@ static void + strtoull_testcase (const char *input, int base, unsigned long long expected, + int num_digits, grub_err_t error) + { +- char *output; ++ const char *output; + unsigned long long value; + grub_errno = 0; + value = grub_strtoull(input, &output, base); +diff --git a/include/grub/misc.h b/include/grub/misc.h +index 960097f..998e47e 100644 +--- a/include/grub/misc.h ++++ b/include/grub/misc.h +@@ -288,11 +288,29 @@ grub_strncasecmp (const char *s1, const char *s2, grub_size_t n) + - (int) grub_tolower ((grub_uint8_t) *s2); + } + +-unsigned long EXPORT_FUNC(grub_strtoul) (const char *str, char **end, int base); +-unsigned long long EXPORT_FUNC(grub_strtoull) (const char *str, char **end, int base); ++/* ++ * Note that these differ from the C standard's definitions of strtol, ++ * strtoul(), and strtoull() by the addition of two const qualifiers on the end ++ * pointer, which make the declaration match the *semantic* requirements of ++ * their behavior. This means that instead of: ++ * ++ * char *s = "1234 abcd"; ++ * char *end; ++ * unsigned long l; ++ * ++ * l = grub_strtoul(s, &end, 10); ++ * ++ * We must one of: ++ * ++ * const char *end; ++ * ... or ... ++ * l = grub_strtoul(s, (const char ** const)&end, 10); ++ */ ++unsigned long EXPORT_FUNC(grub_strtoul) (const char * restrict str, const char ** const restrict end, int base); ++unsigned long long EXPORT_FUNC(grub_strtoull) (const char * restrict str, const char ** const restrict end, int base); + + static inline long +-grub_strtol (const char *str, char **end, int base) ++grub_strtol (const char * restrict str, const char ** const restrict end, int base) + { + int negative = 0; + unsigned long long magnitude; +diff --git a/util/grub-fstest.c b/util/grub-fstest.c +index 88f9c5d..39bad1f 100644 +--- a/util/grub-fstest.c ++++ b/util/grub-fstest.c +@@ -538,7 +538,7 @@ void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version; + static error_t + argp_parser (int key, char *arg, struct argp_state *state) + { +- char *p; ++ const char *p; + + switch (key) + { +-- +1.8.3.1 + diff --git a/0160-grub-switch-to-blscfg.in-get-rid-of-a-bunch-of-bashi.patch b/0160-grub-switch-to-blscfg.in-get-rid-of-a-bunch-of-bashi.patch deleted file mode 100644 index 54c432258504b83c4f2b84f51c2df39d0fb2f8cf..0000000000000000000000000000000000000000 --- a/0160-grub-switch-to-blscfg.in-get-rid-of-a-bunch-of-bashi.patch +++ /dev/null @@ -1,113 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 22 Jun 2018 14:01:06 -0400 -Subject: [PATCH] grub-switch-to-blscfg.in: get rid of a bunch of bashisms - -Since this says /bin/sh at the top, it should work with dash. - -Signed-off-by: Peter Jones ---- - util/grub-switch-to-blscfg.in | 30 +++++++++++++++--------------- - 1 file changed, 15 insertions(+), 15 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 2482483a437..dac41e73836 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -151,18 +151,18 @@ done - - find_grub_cfg() { - local candidate="" -- while [[ -e "${candidate}" || $# -gt 0 ]] -+ while [ -e "${candidate}" -o $# -gt 0 ] - do -- if [[ ! -e "${candidate}" ]] ; then -+ if [ ! -e "${candidate}" ] ; then - candidate="$1" - shift - fi - -- if [[ -L "${candidate}" ]]; then -+ if [ -L "${candidate}" ]; then - candidate="$(realpath "${candidate}")" - fi - -- if [[ -f "${candidate}" ]]; then -+ if [ -f "${candidate}" ]; then - export GRUB_CONFIG_FILE="${candidate}" - return 0 - fi -@@ -175,11 +175,11 @@ if ! find_grub_cfg ${startlink} ${grubdir}/grub.cfg ; then - exit 1 - fi - --if [[ ! -d "${blsdir}" ]]; then -+if [ ! -d "${blsdir}" ]; then - install -m 700 -d "${blsdir}" - fi - --if [[ -f /etc/machine-id ]]; then -+if [ -f /etc/machine-id ]; then - MACHINE_ID=$(cat /etc/machine-id) - else - MACHINE_ID=$(dmesg | sha256sum) -@@ -194,9 +194,9 @@ mkbls() { - local debugid="" - local flavor="" - -- if [[ "$kernelver" == *\+* ]] ; then -+ if [ "$kernelver" == *\+* ] ; then - local flavor=-"${kernelver##*+}" -- if [[ "${flavor}" == "-debug" ]]; then -+ if [ "${flavor}" == "-debug" ]; then - local debugname=" with debugging" - local debugid="-debug" - fi -@@ -219,15 +219,15 @@ EOF - } - - for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do -- if [[ ! -d "/lib/modules/${kernelver}" ]] ; then -+ if [ ! -d "/lib/modules/${kernelver}" ] ; then - continue - fi -- if [[ ! -f "/boot/vmlinuz-${kernelver}" ]]; then -+ if [ ! -f "/boot/vmlinuz-${kernelver}" ]; then - continue - fi - bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf" - kernel_dir="/lib/modules/${kernelver}" -- if [[ -f "${kernel_dir}/bls.conf" ]]; then -+ if [ -f "${kernel_dir}/bls.conf" ]; then - cp -af "${kernel_dir}/bls.conf" "${bls_target}" - else - mkbls "${kernelver}" \ -@@ -240,7 +240,7 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - linux_relpath="$("${grub_mkrelpath}" /boot/$linux)" - initrd_relpath="$("${grub_mkrelpath}" /boot/$initrd)" - -- if [[ $linux != $linux_relpath ]]; then -+ if [ $linux != $linux_relpath ] ; then - sed -i -e "s,^linux.*,linux ${linux_relpath},g" "${bls_target}" - sed -i -e "s,^initrd.*,initrd ${initrd_relpath},g" "${bls_target}" - fi -@@ -257,8 +257,8 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - fi - done - --if [[ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]]; then -- if [[ $linux != $linux_relpath ]]; then -+if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then -+ if [ $linux != $linux_relpath ]; then - bootprefix="$(dirname ${linux_relpath})" - fi - mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" -@@ -282,7 +282,7 @@ elif ! grep -q '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" ; then - GENERATE=1 - fi - --if [[ "${GENERATE}" -eq 1 ]] ; then -+if [ "${GENERATE}" -eq 1 ] ; then - cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}" - if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then - cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}" diff --git a/0161-Fix-menu-entry-selection-based-on-ID-and-title.patch b/0161-Fix-menu-entry-selection-based-on-ID-and-title.patch new file mode 100644 index 0000000000000000000000000000000000000000..4cbd69820bd71582c55714de8b3f927af6681184 --- /dev/null +++ b/0161-Fix-menu-entry-selection-based-on-ID-and-title.patch @@ -0,0 +1,236 @@ +From 14470b5b42b1cc05979e8607fc0659418226b718 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 19 Oct 2018 10:57:52 -0400 +Subject: [PATCH 161/220] Fix menu entry selection based on ID and title + +Currently if grub_strtoul(saved_entry_value, NULL, 0) does not return an +error, we assume the value it has produced is a correct index into our +menu entry list, and do not try to interpret the value as the "id" or +"title" . In cases where "id" or "title" start with a numeral, this +makes them impossible to use as selection criteria. + +This patch splits the search into three phases - matching id, matching +title, and only once those have been exhausted, trying to interpret the +ID as a numeral. In that case, we also require that the entire string +is numeric, not merely a string with leading numeric characters. + +Resolves: rhbz#1640979 + +Signed-off-by: Peter Jones +[javierm: fix menu entry selection based on title] +Signed-off-by: Javier Martinez Canillas +--- + grub-core/normal/menu.c | 141 ++++++++++++++++++++++++------------------------ + 1 file changed, 71 insertions(+), 70 deletions(-) + +diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c +index 37d753d..ea714d2 100644 +--- a/grub-core/normal/menu.c ++++ b/grub-core/normal/menu.c +@@ -164,12 +164,12 @@ grub_menu_set_timeout (int timeout) + } + + static int +-menuentry_eq (const char *id, const char *spec) ++menuentry_eq (const char *id, const char *spec, int limit) + { + const char *ptr1, *ptr2; + ptr1 = id; + ptr2 = spec; +- while (1) ++ while (limit == -1 || ptr1 - id <= limit) + { + if (*ptr2 == '>' && ptr2[1] != '>' && *ptr1 == 0) + return ptr2 - spec; +@@ -178,7 +178,11 @@ menuentry_eq (const char *id, const char *spec) + if (*ptr2 == '>') + ptr2++; + if (*ptr1 != *ptr2) +- return 0; ++ { ++ if (limit > -1 && ptr1 - id == limit && !*ptr1 && grub_isspace(*ptr2)) ++ return ptr1 -id -1; ++ return 0; ++ } + if (*ptr1 == 0) + return ptr1 - id; + ptr1++; +@@ -187,6 +191,58 @@ menuentry_eq (const char *id, const char *spec) + return 0; + } + ++static int ++get_entry_number_helper(grub_menu_t menu, ++ const char * const val, const char ** const tail) ++{ ++ /* See if the variable matches the title of a menu entry. */ ++ int entry = -1; ++ grub_menu_entry_t e; ++ int i; ++ ++ for (i = 0, e = menu->entry_list; e; i++) ++ { ++ int l = 0; ++ while (val[l] && !grub_isspace(val[l])) ++ l++; ++ ++ if (menuentry_eq (e->id, val, l)) ++ { ++ if (tail) ++ *tail = val + l; ++ return i; ++ } ++ e = e->next; ++ } ++ ++ for (i = 0, e = menu->entry_list; e; i++) ++ { ++ ++ if (menuentry_eq (e->title, val, -1)) ++ { ++ if (tail) ++ *tail = NULL; ++ return i; ++ } ++ e = e->next; ++ } ++ ++ if (tail) ++ *tail = NULL; ++ ++ entry = (int) grub_strtoul (val, tail, 0); ++ if (grub_errno == GRUB_ERR_BAD_NUMBER || ++ (*tail && **tail && !grub_isspace(**tail))) ++ { ++ entry = -1; ++ if (tail) ++ *tail = NULL; ++ grub_errno = GRUB_ERR_NONE; ++ } ++ ++ return entry; ++} ++ + /* Get the first entry number from the value of the environment variable NAME, + which is a space-separated list of non-negative integers. The entry number + which is returned is stripped from the value of NAME. If no entry number +@@ -196,7 +252,6 @@ get_and_remove_first_entry_number (grub_menu_t menu, const char *name) + { + const char *val, *tail; + int entry; +- int sz = 0; + + val = grub_env_get (name); + if (! val) +@@ -204,50 +259,24 @@ get_and_remove_first_entry_number (grub_menu_t menu, const char *name) + + grub_error_push (); + +- entry = (int) grub_strtoul (val, &tail, 0); +- +- if (grub_errno == GRUB_ERR_BAD_NUMBER) +- { +- /* See if the variable matches the title of a menu entry. */ +- grub_menu_entry_t e = menu->entry_list; +- int i; +- +- for (i = 0; e; i++) +- { +- sz = menuentry_eq (e->title, val); +- if (sz < 1) +- sz = menuentry_eq (e->id, val); +- +- if (sz >= 1) +- { +- entry = i; +- break; +- } +- e = e->next; +- } ++ entry = get_entry_number_helper(menu, val, &tail); ++ if (!(*tail == 0 || grub_isspace(*tail))) ++ entry = -1; + +- if (sz > 0) +- grub_errno = GRUB_ERR_NONE; +- +- if (! e) +- entry = -1; +- } +- +- if (grub_errno == GRUB_ERR_NONE) ++ if (entry >= 0) + { +- if (sz > 0) +- tail += sz; +- + /* Skip whitespace to find the next entry. */ + while (*tail && grub_isspace (*tail)) + tail++; +- grub_env_set (name, tail); ++ if (*tail) ++ grub_env_set (name, tail); ++ else ++ grub_env_unset (name); + } + else + { + grub_env_unset (name); + grub_errno = GRUB_ERR_NONE; +- entry = -1; + } + + grub_error_pop (); +@@ -524,6 +553,7 @@ static int + get_entry_number (grub_menu_t menu, const char *name) + { + const char *val; ++ const char *tail; + int entry; + + val = grub_env_get (name); +@@ -531,38 +561,9 @@ get_entry_number (grub_menu_t menu, const char *name) + return -1; + + grub_error_push (); +- +- entry = (int) grub_strtoul (val, 0, 0); +- +- if (grub_errno == GRUB_ERR_BAD_NUMBER) +- { +- /* See if the variable matches the title of a menu entry. */ +- grub_menu_entry_t e = menu->entry_list; +- int i; +- +- grub_errno = GRUB_ERR_NONE; +- +- for (i = 0; e; i++) +- { +- if (menuentry_eq (e->title, val) +- || menuentry_eq (e->id, val)) +- { +- entry = i; +- break; +- } +- e = e->next; +- } +- +- if (! e) +- entry = -1; +- } +- +- if (grub_errno != GRUB_ERR_NONE) +- { +- grub_errno = GRUB_ERR_NONE; +- entry = -1; +- } +- ++ entry = get_entry_number_helper(menu, val, &tail); ++ if (tail && *tail != '\0') ++ entry = -1; + grub_error_pop (); + + return entry; +-- +1.8.3.1 + diff --git a/0161-grub-switch-to-blscfg.in-Better-boot-prefix-checking.patch b/0161-grub-switch-to-blscfg.in-Better-boot-prefix-checking.patch deleted file mode 100644 index 8437c68640c4e433bdda4983326e70bda2d239a3..0000000000000000000000000000000000000000 --- a/0161-grub-switch-to-blscfg.in-Better-boot-prefix-checking.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Fri, 22 Jun 2018 14:04:28 -0400 -Subject: [PATCH] grub-switch-to-blscfg.in: Better boot prefix checking - -Signed-off-by: Peter Jones ---- - util/grub-switch-to-blscfg.in | 36 +++++++++++++++++------------------- - 1 file changed, 17 insertions(+), 19 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index dac41e73836..884cf45b1e1 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -219,30 +219,31 @@ EOF - } - - for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do -- if [ ! -d "/lib/modules/${kernelver}" ] ; then -- continue -- fi -- if [ ! -f "/boot/vmlinuz-${kernelver}" ]; then -- continue -- fi - bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf" -+ linux="$(grep '^linux[ \t]' "${bls_target}" | sed -e 's,^linux[ \t]+,,')" - kernel_dir="/lib/modules/${kernelver}" -- if [ -f "${kernel_dir}/bls.conf" ]; then -+ -+ if [ ! -d "${kernel_dir}" ] ; then -+ continue -+ fi -+ if [ ! -f "${linux_path}" ]; then -+ continue -+ fi -+ -+ linux_relpath="$("${grub_mkrelpath}" "${linux}")" -+ bootprefix="${linux%%"${linux_relpath}"}" -+ -+ if [ -f "${kernel_dir}/bls.conf" ] ; then - cp -af "${kernel_dir}/bls.conf" "${bls_target}" - else - mkbls "${kernelver}" \ - "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \ -+ "${bootprefix}" \ - >"${bls_target}" - fi - -- linux="$(grep '^linux[ \t]' "${bls_target}" | sed -e 's,^linux[ \t]*,,')" -- initrd="$(grep '^initrd[ \t]' "${bls_target}" | sed -e 's,^initrd[ \t]*,,')" -- linux_relpath="$("${grub_mkrelpath}" /boot/$linux)" -- initrd_relpath="$("${grub_mkrelpath}" /boot/$initrd)" -- -- if [ $linux != $linux_relpath ] ; then -- sed -i -e "s,^linux.*,linux ${linux_relpath},g" "${bls_target}" -- sed -i -e "s,^initrd.*,initrd ${initrd_relpath},g" "${bls_target}" -+ if [ -n "${bootprefix}" ]; then -+ sed -i -e "s,\([ \t]\)${bootprefix},\1,g" "${bls_target}" - fi - - if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -@@ -257,10 +258,7 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - fi - done - --if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then -- if [ $linux != $linux_relpath ]; then -- bootprefix="$(dirname ${linux_relpath})" -- fi -+if [ -n "${bootprefix}" -a -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then - mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" - fi - diff --git a/0162-Make-the-menu-entry-users-option-argument-to-be-opti.patch b/0162-Make-the-menu-entry-users-option-argument-to-be-opti.patch new file mode 100644 index 0000000000000000000000000000000000000000..3c12b5f8047b34627c4d737cb9c6bb25635a8cf7 --- /dev/null +++ b/0162-Make-the-menu-entry-users-option-argument-to-be-opti.patch @@ -0,0 +1,50 @@ +From 5088373cfad54d6c61604cb7b266ef58aaaedb61 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Mon, 26 Nov 2018 10:06:42 +0100 +Subject: [PATCH 162/220] Make the menu entry users option argument to be + optional + +The --users option is used to restrict the access to specific menu entries +only to a set of users. But the option requires an argument to either be a +constant or a variable that has been set. So for example the following: + + menuentry "May be run by superusers or users in $users" --users $users { + linux /vmlinuz + } + +Would fail if $users is not defined and grub would discard the menu entry. +Instead, allow the --users option to have an optional argument and ignore +the option if the argument was not set. + +Related: rhbz#1652434 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/commands/menuentry.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c +index 9faf2be..29736f5 100644 +--- a/grub-core/commands/menuentry.c ++++ b/grub-core/commands/menuentry.c +@@ -29,7 +29,7 @@ static const struct grub_arg_option options[] = + { + {"class", 1, GRUB_ARG_OPTION_REPEATABLE, + N_("Menu entry type."), N_("STRING"), ARG_TYPE_STRING}, +- {"users", 2, 0, ++ {"users", 2, GRUB_ARG_OPTION_OPTIONAL, + N_("List of users allowed to boot this entry."), N_("USERNAME[,USERNAME]"), + ARG_TYPE_STRING}, + {"hotkey", 3, 0, +@@ -281,7 +281,7 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args) + if (! ctxt->state[3].set && ! ctxt->script) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "no menuentry definition"); + +- if (ctxt->state[1].set) ++ if (ctxt->state[1].set && ctxt->state[1].arg) + users = ctxt->state[1].arg; + else if (ctxt->state[5].set) + users = NULL; +-- +1.8.3.1 + diff --git a/0162-Use-boot-loader-entries-as-BLS-directory-path-also-o.patch b/0162-Use-boot-loader-entries-as-BLS-directory-path-also-o.patch deleted file mode 100644 index 88b9bc2e84b5a1f625ff10723547ee55a534035b..0000000000000000000000000000000000000000 --- a/0162-Use-boot-loader-entries-as-BLS-directory-path-also-o.patch +++ /dev/null @@ -1,152 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 25 Jun 2018 11:45:33 +0200 -Subject: [PATCH] Use /boot/loader/entries as BLS directory path also on EFI - systems - -For EFI systems, the BLS fragments were stored in the EFI System Partition -(ESP) while in non-EFI systems it was stored in /boot. - -For consistency, it's better to always store the BLS fragments in the same -path regardless of the firmware interface used. - -Also change the grub2-switch-to-blscfg script default BLS directory. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 48 ++++++++++++++++++++++++++++++++----------- - util/grub-switch-to-blscfg.in | 4 ++-- - 2 files changed, 38 insertions(+), 14 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 831cdcaccdf..70939a81826 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -381,9 +381,14 @@ static int bls_cmp(const void *p0, const void *p1, void *state UNUSED) - return rc; - } - -+struct read_entry_info { -+ const char *devid; -+ const char *dirname; -+}; -+ - static int read_entry ( - const char *filename, -- const struct grub_dirhook_info *info UNUSED, -+ const struct grub_dirhook_info *dirhook_info UNUSED, - void *data) - { - grub_size_t n; -@@ -391,8 +396,7 @@ static int read_entry ( - grub_file_t f = NULL; - grub_off_t sz; - struct bls_entry *entry; -- const char *dirname= (const char *)data; -- const char *devid = grub_env_get ("boot"); -+ struct read_entry_info *info = (struct read_entry_info *)data; - - grub_dprintf ("blscfg", "filename: \"%s\"\n", filename); - -@@ -406,7 +410,7 @@ static int read_entry ( - if (grub_strcmp (filename + n - 5, ".conf") != 0) - return 0; - -- p = grub_xasprintf ("(%s)%s/%s", devid, dirname, filename); -+ p = grub_xasprintf ("(%s)%s/%s", info->devid, info->dirname, filename); - - f = grub_file_open (p); - if (!f) -@@ -655,10 +659,13 @@ static int find_entry (const char *filename, - void *data) - { - struct find_entry_info *info = (struct find_entry_info *)data; -+ struct read_entry_info read_entry_info; - grub_file_t f = NULL; - char *grubenv_path = NULL; - grub_envblk_t env = NULL; - char *default_blsdir = NULL; -+ grub_fs_t blsdir_fs = NULL; -+ grub_device_t blsdir_dev = NULL; - const char *blsdir = NULL; - char *saved_env_buf = NULL; - int r = 0; -@@ -678,9 +685,6 @@ static int find_entry (const char *filename, - if (info->platform == PLATFORM_EMU) - default_blsdir = grub_xasprintf ("%s%s", GRUB_BOOT_DEVICE, - GRUB_BLS_CONFIG_PATH); -- else if (info->platform == PLATFORM_EFI) -- default_blsdir = grub_xasprintf ("/EFI/%s%s", filename, -- GRUB_BLS_CONFIG_PATH); - else - default_blsdir = grub_xasprintf ("%s", GRUB_BLS_CONFIG_PATH); - -@@ -744,16 +748,33 @@ static int find_entry (const char *filename, - goto finish; - - grub_dprintf ("blscfg", "blsdir: \"%s\"\n", blsdir); -- if (blsdir[0] != '/' && info->platform == PLATFORM_EFI) -- blsdir = grub_xasprintf ("/EFI/%s/%s/", filename, blsdir); -- else -- blsdir = grub_strdup (blsdir); -+ blsdir = grub_strdup (blsdir); - - if (!blsdir) - goto finish; - - grub_dprintf ("blscfg", "blsdir: \"%s\"\n", blsdir); -- r = info->fs->dir (info->dev, blsdir, read_entry, (char *)blsdir); -+ if (info->platform == PLATFORM_EFI) { -+ read_entry_info.devid = grub_env_get ("root"); -+ if (!read_entry_info.devid) -+ goto finish; -+ -+ blsdir_dev = grub_device_open (read_entry_info.devid); -+ if (!blsdir_dev) -+ goto finish; -+ -+ blsdir_fs = grub_fs_probe (blsdir_dev); -+ if (!blsdir_fs) -+ goto finish; -+ -+ } else { -+ read_entry_info.devid = devid; -+ blsdir_dev = info->dev; -+ blsdir_fs = info->fs; -+ } -+ read_entry_info.dirname = blsdir; -+ -+ r = blsdir_fs->dir (blsdir_dev, blsdir, read_entry, &read_entry_info); - if (r != 0) { - grub_dprintf ("blscfg", "read_entry returned error\n"); - grub_err_t e; -@@ -773,6 +794,9 @@ static int find_entry (const char *filename, - for (r = 0; r < nentries; r++) - bls_free_entry (entries[r]); - finish: -+ if (info->platform == PLATFORM_EFI && blsdir_dev) -+ grub_device_close (blsdir_dev); -+ - nentries = 0; - - grub_free (entries); -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 884cf45b1e1..2f37a1f740b 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -44,13 +44,13 @@ EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') - if [ -d /sys/firmware/efi/efivars/ ]; then - startlink=/etc/grub2-efi.cfg - grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'` -- blsdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/loader/entries" | sed 's,//*,/,g'` - else - startlink=/etc/grub2.cfg - grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'` -- blsdir=`echo "/@bootdirname@/loader/entries" | sed 's,//*,/,g'` - fi - -+blsdir=`echo "/@bootdirname@/loader/entries" | sed 's,//*,/,g'` -+ - backupsuffix=.bak - - export TEXTDOMAIN=@PACKAGE@ diff --git a/0163-Add-efi-export-env-and-efi-load-env-commands.patch b/0163-Add-efi-export-env-and-efi-load-env-commands.patch new file mode 100644 index 0000000000000000000000000000000000000000..d4b7ec004ea3a53fec042079f85b5b4be9023c0e --- /dev/null +++ b/0163-Add-efi-export-env-and-efi-load-env-commands.patch @@ -0,0 +1,363 @@ +From cdd189ff589f11629f67198755490e93974354d1 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 16 Jan 2019 13:21:46 -0500 +Subject: [PATCH 163/220] Add efi-export-env and efi-load-env commands + +This adds "efi-export-env VARIABLE" and "efi-load-env", which manipulate the +environment block stored in the EFI variable +GRUB_ENV-91376aff-cba6-42be-949d-06fde81128e8. + +Signed-off-by: Peter Jones +--- + grub-core/Makefile.core.def | 6 ++ + grub-core/commands/efi/env.c | 168 +++++++++++++++++++++++++++++++++++++++++++ + grub-core/kern/efi/efi.c | 3 + + grub-core/kern/efi/init.c | 5 -- + grub-core/lib/envblk.c | 43 +++++++++++ + include/grub/efi/efi.h | 5 ++ + include/grub/lib/envblk.h | 3 + + util/editenv.c | 2 - + util/grub-set-bootflag.c | 1 + + 9 files changed, 229 insertions(+), 7 deletions(-) + create mode 100644 grub-core/commands/efi/env.c + +diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def +index 65ca74f..6619946 100644 +--- a/grub-core/Makefile.core.def ++++ b/grub-core/Makefile.core.def +@@ -818,6 +818,12 @@ module = { + }; + + module = { ++ name = efienv; ++ common = commands/efi/env.c; ++ enable = efi; ++}; ++ ++module = { + name = efifwsetup; + efi = commands/efi/efifwsetup.c; + enable = efi; +diff --git a/grub-core/commands/efi/env.c b/grub-core/commands/efi/env.c +new file mode 100644 +index 0000000..a690797 +--- /dev/null ++++ b/grub-core/commands/efi/env.c +@@ -0,0 +1,168 @@ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 2012 Free Software Foundation, Inc. ++ * ++ * GRUB is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * GRUB is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with GRUB. If not, see . ++ */ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++GRUB_MOD_LICENSE ("GPLv3+"); ++ ++static const grub_efi_guid_t grub_env_guid = GRUB_EFI_GRUB_VARIABLE_GUID; ++ ++static grub_err_t ++grub_efi_export_env(grub_command_t cmd __attribute__ ((unused)), ++ int argc, char *argv[]) ++{ ++ const char *value; ++ char *old_value; ++ struct grub_envblk envblk_s = { NULL, 0 }; ++ grub_envblk_t envblk = &envblk_s; ++ grub_err_t err; ++ int changed = 1; ++ grub_efi_status_t status; ++ ++ grub_dprintf ("efienv", "argc:%d\n", argc); ++ for (int i = 0; i < argc; i++) ++ grub_dprintf ("efienv", "argv[%d]: %s\n", i, argv[i]); ++ ++ if (argc != 1) ++ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("variable name expected")); ++ ++ envblk_s.buf = grub_efi_get_variable ("GRUB_ENV", &grub_env_guid, ++ &envblk_s.size); ++ if (!envblk_s.buf || envblk_s.size < 1) ++ { ++ char *buf = grub_malloc (1025); ++ if (!buf) ++ return grub_errno; ++ ++ grub_memcpy (buf, GRUB_ENVBLK_SIGNATURE, sizeof (GRUB_ENVBLK_SIGNATURE) - 1); ++ grub_memset (buf + sizeof (GRUB_ENVBLK_SIGNATURE) - 1, '#', ++ DEFAULT_ENVBLK_SIZE - sizeof (GRUB_ENVBLK_SIGNATURE) + 1); ++ buf[1024] = '\0'; ++ ++ envblk_s.buf = buf; ++ envblk_s.size = 1024; ++ } ++ else ++ { ++ char *buf = grub_realloc (envblk_s.buf, envblk_s.size + 1); ++ if (!buf) ++ return grub_errno; ++ ++ envblk_s.buf = buf; ++ envblk_s.buf[envblk_s.size] = '\0'; ++ } ++ ++ err = grub_envblk_get(envblk, argv[0], &old_value); ++ if (err != GRUB_ERR_NONE) ++ { ++ grub_dprintf ("efienv", "grub_envblk_get returned %d\n", err); ++ return err; ++ } ++ ++ value = grub_env_get(argv[0]); ++ if ((!value && !old_value) || ++ (value && old_value && !grub_strcmp(old_value, value))) ++ changed = 0; ++ ++ if (old_value) ++ grub_free(old_value); ++ ++ if (changed == 0) ++ { ++ grub_dprintf ("efienv", "No changes necessary\n"); ++ return 0; ++ } ++ ++ if (value) ++ { ++ grub_dprintf ("efienv", "setting \"%s\" to \"%s\"\n", argv[0], value); ++ grub_envblk_set(envblk, argv[0], value); ++ } ++ else ++ { ++ grub_dprintf ("efienv", "deleting \"%s\" from envblk\n", argv[0]); ++ grub_envblk_delete(envblk, argv[0]); ++ } ++ ++ grub_dprintf ("efienv", "envblk is %lu bytes:\n\"%s\"\n", envblk_s.size, envblk_s.buf); ++ ++ grub_dprintf ("efienv", "removing GRUB_ENV\n"); ++ status = grub_efi_set_variable ("GRUB_ENV", &grub_env_guid, NULL, 0); ++ if (status != GRUB_EFI_SUCCESS) ++ grub_dprintf ("efienv", "removal returned %ld\n", status); ++ ++ grub_dprintf ("efienv", "setting GRUB_ENV\n"); ++ status = grub_efi_set_variable ("GRUB_ENV", &grub_env_guid, ++ envblk_s.buf, envblk_s.size); ++ if (status != GRUB_EFI_SUCCESS) ++ grub_dprintf ("efienv", "setting GRUB_ENV returned %ld\n", status); ++ ++ return 0; ++} ++ ++static int ++set_var (const char *name, const char *value, ++ void *whitelist __attribute__((__unused__))) ++{ ++ grub_env_set (name, value); ++ return 0; ++} ++ ++static grub_err_t ++grub_efi_load_env(grub_command_t cmd __attribute__ ((unused)), ++ int argc, char *argv[] __attribute__((__unused__))) ++{ ++ struct grub_envblk envblk_s = { NULL, 0 }; ++ grub_envblk_t envblk = &envblk_s; ++ ++ envblk_s.buf = grub_efi_get_variable ("GRUB_ENV", &grub_env_guid, ++ &envblk_s.size); ++ if (!envblk_s.buf || envblk_s.size < 1) ++ return 0; ++ ++ if (argc > 0) ++ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unexpected argument")); ++ ++ grub_envblk_iterate (envblk, NULL, set_var); ++ grub_free (envblk_s.buf); ++} ++ ++static grub_command_t export_cmd, loadenv_cmd; ++ ++GRUB_MOD_INIT(lsefi) ++{ ++ export_cmd = grub_register_command ("efi-export-env", grub_efi_export_env, ++ N_("VARIABLE_NAME"), N_("Export environment variable to UEFI.")); ++ loadenv_cmd = grub_register_command ("efi-load-env", grub_efi_load_env, ++ NULL, N_("Load the grub environment from UEFI.")); ++} ++ ++GRUB_MOD_FINI(lsefi) ++{ ++ grub_unregister_command (export_cmd); ++ grub_unregister_command (loadenv_cmd); ++} +diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c +index ada3004..279394d 100644 +--- a/grub-core/kern/efi/efi.c ++++ b/grub-core/kern/efi/efi.c +@@ -224,6 +224,9 @@ grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid, + if (status == GRUB_EFI_SUCCESS) + return GRUB_ERR_NONE; + ++ if (status == GRUB_EFI_NOT_FOUND && datasize == 0) ++ return GRUB_ERR_NONE; ++ + return grub_error (GRUB_ERR_IO, "could not set EFI variable `%s'", var); + } + +diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c +index e6183a4..d1afa3a 100644 +--- a/grub-core/kern/efi/init.c ++++ b/grub-core/kern/efi/init.c +@@ -29,11 +29,6 @@ + + grub_addr_t grub_modbase; + +-#define GRUB_EFI_GRUB_VARIABLE_GUID \ +- { 0x91376aff, 0xcba6, 0x42be, \ +- { 0x94, 0x9d, 0x06, 0xfd, 0xe8, 0x11, 0x28, 0xe8 } \ +- } +- + /* Helper for grub_efi_env_init */ + static int + set_var (const char *name, const char *value, +diff --git a/grub-core/lib/envblk.c b/grub-core/lib/envblk.c +index 230e0e9..f89d86d 100644 +--- a/grub-core/lib/envblk.c ++++ b/grub-core/lib/envblk.c +@@ -223,6 +223,49 @@ grub_envblk_delete (grub_envblk_t envblk, const char *name) + } + } + ++struct get_var_state { ++ const char * const name; ++ char * value; ++ int found; ++}; ++ ++static int ++get_var (const char * const name, const char * const value, void *statep) ++{ ++ struct get_var_state *state = (struct get_var_state *)statep; ++ ++ if (!grub_strcmp(state->name, name)) ++ { ++ state->found = 1; ++ state->value = grub_strdup(value); ++ if (!state->value) ++ grub_errno = grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ ++ return 1; ++ } ++ ++ return 0; ++} ++ ++grub_err_t ++grub_envblk_get (grub_envblk_t envblk, const char * const name, char ** const value) ++{ ++ struct get_var_state state = { ++ .name = name, ++ .value = NULL, ++ .found = 0, ++ }; ++ ++ grub_envblk_iterate(envblk, (void *)&state, get_var); ++ ++ *value = state.value; ++ ++ if (state.found && !state.value) ++ return grub_errno; ++ ++ return GRUB_ERR_NONE; ++} ++ + void + grub_envblk_iterate (grub_envblk_t envblk, + void *hook_data, +diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h +index 8ca3981..d24afba 100644 +--- a/include/grub/efi/efi.h ++++ b/include/grub/efi/efi.h +@@ -24,6 +24,11 @@ + #include + #include + ++#define GRUB_EFI_GRUB_VARIABLE_GUID \ ++ { 0x91376aff, 0xcba6, 0x42be, \ ++ { 0x94, 0x9d, 0x06, 0xfd, 0xe8, 0x11, 0x28, 0xe8 } \ ++ } ++ + /* Variables. */ + extern grub_efi_system_table_t *EXPORT_VAR(grub_efi_system_table); + extern grub_efi_handle_t EXPORT_VAR(grub_efi_image_handle); +diff --git a/include/grub/lib/envblk.h b/include/grub/lib/envblk.h +index c3e6559..ab969af 100644 +--- a/include/grub/lib/envblk.h ++++ b/include/grub/lib/envblk.h +@@ -22,6 +22,8 @@ + #define GRUB_ENVBLK_SIGNATURE "# GRUB Environment Block\n" + #define GRUB_ENVBLK_DEFCFG "grubenv" + ++#define DEFAULT_ENVBLK_SIZE 1024 ++ + #ifndef ASM_FILE + + struct grub_envblk +@@ -33,6 +35,7 @@ typedef struct grub_envblk *grub_envblk_t; + + grub_envblk_t grub_envblk_open (char *buf, grub_size_t size); + int grub_envblk_set (grub_envblk_t envblk, const char *name, const char *value); ++grub_err_t grub_envblk_get (grub_envblk_t envblk, const char * const name, char ** const value); + void grub_envblk_delete (grub_envblk_t envblk, const char *name); + void grub_envblk_iterate (grub_envblk_t envblk, + void *hook_data, +diff --git a/util/editenv.c b/util/editenv.c +index 1f7f6f3..66f99f9 100644 +--- a/util/editenv.c ++++ b/util/editenv.c +@@ -30,8 +30,6 @@ + #include + #include + +-#define DEFAULT_ENVBLK_SIZE 1024 +- + void + grub_util_create_envblk_file (const char *name) + { +diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c +index bb198f0..6a79ee6 100644 +--- a/util/grub-set-bootflag.c ++++ b/util/grub-set-bootflag.c +@@ -25,6 +25,7 @@ + + #include /* For *_DIR_NAME defines */ + #include ++#include + #include /* For GRUB_ENVBLK_DEFCFG define */ + #include + #include +-- +1.8.3.1 + diff --git a/0163-Use-BLS-fragment-filename-as-menu-entry-id-and-for-c.patch b/0163-Use-BLS-fragment-filename-as-menu-entry-id-and-for-c.patch deleted file mode 100644 index 7f765e76dd8283166ae385e67d8dbeb52711a106..0000000000000000000000000000000000000000 --- a/0163-Use-BLS-fragment-filename-as-menu-entry-id-and-for-c.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 26 Jun 2018 14:01:26 +0200 -Subject: [PATCH] Use BLS fragment filename as menu entry id and for criteria - to sort - -The BLS config filenames are guaranteed to be unique, so they can be -used as GRUB2 entry id and can also be used to sort the menu entries. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 62 +++++++++------------------------------------ - 1 file changed, 12 insertions(+), 50 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 70939a81826..cd8659384e4 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -70,6 +70,7 @@ struct bls_entry - { - struct keyval **keyvals; - int nkeyvals; -+ char *filename; - }; - - static struct bls_entry **entries; -@@ -166,6 +167,7 @@ static void bls_free_entry(struct bls_entry *entry) - - grub_free (entry->keyvals); - grub_memset (entry, 0, sizeof (*entry)); -+ grub_free (entry->filename); - grub_free (entry); - } - -@@ -327,58 +329,12 @@ finish: - - typedef int (*void_cmp_t)(void *, void *); - --static int nulcmp(char *s0, char *s1, void_cmp_t cmp) --{ -- grub_dprintf("blscfg", "%s got here\n", __func__); -- if (s1 && !s0) -- return 1; -- if (s0 && !s1) -- return -1; -- if (!s0 && !s1) -- return 0; -- if (cmp) -- return cmp(s0, s1); -- return grub_strcmp(s0, s1); --} -- --static int --bls_keyval_cmp(struct bls_entry *e0, struct bls_entry *e1, const char *keyname) --{ -- char *val0, *val1; -- -- val0 = bls_get_val (e0, keyname, NULL); -- val1 = bls_get_val (e1, keyname, NULL); -- -- if (val1 && !val0) -- return 1; -- -- if (val0 && !val1) -- return -1; -- -- if (!val0 && !val1) -- return 0; -- -- return nulcmp(val0, val1, (void_cmp_t)vercmp); --} -- - static int bls_cmp(const void *p0, const void *p1, void *state UNUSED) - { - struct bls_entry * e0 = *(struct bls_entry **)p0; - struct bls_entry * e1 = *(struct bls_entry **)p1; -- int rc = 0; - -- rc = bls_keyval_cmp (e0, e1, "id"); -- -- if (rc == 0) -- rc = bls_keyval_cmp (e0, e1, "version"); -- -- if (rc == 0) -- rc = bls_keyval_cmp (e0, e1, "title"); -- -- if (rc == 0) -- rc = bls_keyval_cmp (e0, e1, "linux"); -- -- return rc; -+ return vercmp(e0->filename, e1->filename); - } - - struct read_entry_info { -@@ -424,6 +380,12 @@ static int read_entry ( - if (!entry) - goto finish; - -+ entry->filename = grub_strndup(filename, n - 5); -+ if (!entry->filename) -+ goto finish; -+ -+ entry->filename[n - 5] = '\0'; -+ - for (;;) - { - char *buf; -@@ -548,7 +510,7 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - char *options = NULL; - char **initrds = NULL; - char *initrd = NULL; -- char *id = NULL; -+ char *id = entry->filename; - char *hotkey = NULL; - - char *users = NULL; -@@ -570,7 +532,6 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - title = bls_get_val (entry, "title", NULL); - options = bls_get_val (entry, "options", NULL); - initrds = bls_make_list (entry, "initrd", NULL); -- id = bls_get_val (entry, "id", NULL); - - hotkey = bls_get_val (entry, "grub_hotkey", NULL); - users = bls_get_val (entry, "grub_users", NULL); -@@ -584,7 +545,8 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - argv[i] = args[i-1]; - argv[argc] = NULL; - -- grub_dprintf ("blscfg", "adding menu entry for \"%s\"\n", title); -+ grub_dprintf ("blscfg", "adding menu entry for \"%s\" with id \"%s\"\n", -+ title, id); - if (initrds) - { - int initrd_size = sizeof (GRUB_INITRD_CMD); diff --git a/0164-Fix-grub-switch-to-blscfg-boot-prefix-handling.patch b/0164-Fix-grub-switch-to-blscfg-boot-prefix-handling.patch deleted file mode 100644 index be7d1a3f850c3855445ce70747a5c3828871aea4..0000000000000000000000000000000000000000 --- a/0164-Fix-grub-switch-to-blscfg-boot-prefix-handling.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Mon, 9 Jul 2018 12:19:03 +0200 -Subject: [PATCH] Fix grub-switch-to-blscfg boot prefix handling - -Commit b3ac18e3265f ("grub-switch-to-blscfg.in: Better boot prefix checking") -simplified the boot prefix checking, but unfortunately introduced a couple of -regressions on the script. Fix them. - -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 12 +++++++----- - 1 file changed, 7 insertions(+), 5 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 2f37a1f740b..40612e00686 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -220,7 +220,8 @@ EOF - - for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf" -- linux="$(grep '^linux[ \t]' "${bls_target}" | sed -e 's,^linux[ \t]+,,')" -+ linux="/vmlinuz-${kernelver}" -+ linux_path="/boot${linux}" - kernel_dir="/lib/modules/${kernelver}" - - if [ ! -d "${kernel_dir}" ] ; then -@@ -230,8 +231,8 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - continue - fi - -- linux_relpath="$("${grub_mkrelpath}" "${linux}")" -- bootprefix="${linux%%"${linux_relpath}"}" -+ linux_relpath="$("${grub_mkrelpath}" "${linux_path}")" -+ bootprefix="${linux_relpath%%"${linux}"}" - - if [ -f "${kernel_dir}/bls.conf" ] ; then - cp -af "${kernel_dir}/bls.conf" "${bls_target}" -@@ -243,7 +244,8 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - fi - - if [ -n "${bootprefix}" ]; then -- sed -i -e "s,\([ \t]\)${bootprefix},\1,g" "${bls_target}" -+ sed -i -e "s,^\(linux[^ \t]*[ \t]\+\).*,\1${bootprefix}${linux},g" "${bls_target}" -+ sed -i -e "/^initrd/ s,\([ \t]\+\)\([^ \t]\+\),\1${bootprefix}\2,g" "${bls_target}" - fi - - if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then -@@ -258,7 +260,7 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - fi - done - --if [ -n "${bootprefix}" -a -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then -+if [ -f "/boot/vmlinuz-0-rescue-${MACHINE_ID}" ]; then - mkbls "0-rescue-${MACHINE_ID}" "0" "${bootprefix}" >"${blsdir}/${MACHINE_ID}-0-rescue.conf" - fi - diff --git a/0164-Make-it-possible-to-subtract-conditions-from-debug.patch b/0164-Make-it-possible-to-subtract-conditions-from-debug.patch new file mode 100644 index 0000000000000000000000000000000000000000..9ae6b0025582f4d59027cd84f2590fd7f9bbc4a4 --- /dev/null +++ b/0164-Make-it-possible-to-subtract-conditions-from-debug.patch @@ -0,0 +1,48 @@ +From 735e69de93dc746ded8c03eed4c193b5299492cf Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 17 Jan 2019 13:10:39 -0500 +Subject: [PATCH 164/220] Make it possible to subtract conditions from debug= + +This makes it so you can do set debug to "all,-scripting,-lexer" and get the +obvious outcome. Any negation present will take preference over that +conditional, so "all,-scripting,scripting" is the same thing as +"all,-scripting". + +Signed-off-by: Peter Jones +--- + grub-core/kern/misc.c | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c +index e21dd44..18a7dbf 100644 +--- a/grub-core/kern/misc.c ++++ b/grub-core/kern/misc.c +@@ -163,12 +163,24 @@ int + grub_debug_enabled (const char * condition) + { + const char *debug; ++ char *negcond; ++ int negated = 0; + + debug = grub_env_get ("debug"); + if (!debug) + return 0; + +- if (grub_strword (debug, "all") || grub_strword (debug, condition)) ++ negcond = grub_zalloc (grub_strlen (condition) + 2); ++ if (negcond) ++ { ++ grub_strcpy (negcond, "-"); ++ grub_strcpy (negcond+1, condition); ++ negated = grub_strword (debug, negcond); ++ grub_free (negcond); ++ } ++ ++ if (!negated && ++ (grub_strword (debug, "all") || grub_strword (debug, condition))) + return 1; + + return 0; +-- +1.8.3.1 + diff --git a/0165-Export-all-variables-from-the-initial-context-when-c.patch b/0165-Export-all-variables-from-the-initial-context-when-c.patch new file mode 100644 index 0000000000000000000000000000000000000000..c0c028e5c999ed5a642c5c1c128789eae73a6c07 --- /dev/null +++ b/0165-Export-all-variables-from-the-initial-context-when-c.patch @@ -0,0 +1,47 @@ +From 7eeac73061708872cd41d3e03233d2ff8fe4167c Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 22 Jan 2019 15:40:25 +0100 +Subject: [PATCH 165/220] Export all variables from the initial context when + creating a submenu + +When a submenu is created, only the exported variables are copied to the +new menu context. But we want the variables to be global, so export lets +export all variables to the new created submenu. + +Also, don't unset the default variable when a new submenu is created. + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/normal/context.c | 2 +- + grub-core/normal/menu.c | 2 -- + 2 files changed, 1 insertion(+), 3 deletions(-) + +diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c +index ee53d4a..87edd25 100644 +--- a/grub-core/normal/context.c ++++ b/grub-core/normal/context.c +@@ -99,7 +99,7 @@ grub_env_new_context (int export_all) + grub_err_t + grub_env_context_open (void) + { +- return grub_env_new_context (0); ++ return grub_env_new_context (1); + } + + int grub_extractor_level = 0; +diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c +index ea714d2..d4832f1 100644 +--- a/grub-core/normal/menu.c ++++ b/grub-core/normal/menu.c +@@ -375,8 +375,6 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot) + + if (ptr && ptr[0] && ptr[1]) + grub_env_set ("default", ptr + 1); +- else +- grub_env_unset ("default"); + + grub_script_execute_new_scope (entry->sourcecode, entry->argc, entry->args); + +-- +1.8.3.1 + diff --git a/0165-Revert-trim-arp-packets-with-abnormal-size.patch b/0165-Revert-trim-arp-packets-with-abnormal-size.patch deleted file mode 100644 index 5a169d7eff8c5f80a6f257c946140183f6794203..0000000000000000000000000000000000000000 --- a/0165-Revert-trim-arp-packets-with-abnormal-size.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 18 May 2017 14:25:45 -0400 -Subject: [PATCH] Revert "trim arp packets with abnormal size" - -This reverts commit d11b2eb425d2125f67dd8d8e9b11d9be7d6f3f11. ---- - grub-core/net/arp.c | 6 ------ - 1 file changed, 6 deletions(-) - -diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c -index d1c69ed2b55..54306e3b16d 100644 ---- a/grub-core/net/arp.c -+++ b/grub-core/net/arp.c -@@ -150,12 +150,6 @@ grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card, - if (grub_net_addr_cmp (&inf->address, &target_addr) == 0 - && arp_packet->op == grub_cpu_to_be16_compile_time (ARP_REQUEST)) - { -- if ((nb->tail - nb->data) > 50) -- { -- grub_dprintf ("net", "arp packet with abnormal size (%ld bytes).\n", -- nb->tail - nb->data); -- nb->tail = nb->data + 50; -- } - grub_net_link_level_address_t target; - struct grub_net_buff nb_reply; - struct arppkt *arp_reply; diff --git a/0001-fix-grub-search-configfile-failed-in-net.patch b/0166-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch similarity index 30% rename from 0001-fix-grub-search-configfile-failed-in-net.patch rename to 0166-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch index cc51d3b8a45dbc05ed6409a64f01ce08d0194d24..f36868e3ec3fdbaba3a914bea65a4ec7145bbd21 100644 --- a/0001-fix-grub-search-configfile-failed-in-net.patch +++ b/0166-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch @@ -1,17 +1,31 @@ -From 288c6b760bc1e04893178e59b621aaea5bcbdac6 Mon Sep 17 00:00:00 2001 -From: Fedora Ninjas -Date: Wed, 10 Apr 2019 15:38:33 +0100 -Subject: [PATCH] fix grub search configfile failed in net +From d564918e5c24a056a75d43b59335d56bfa3478be Mon Sep 17 00:00:00 2001 +From: Masayoshi Mizuma +Date: Tue, 18 Dec 2018 21:27:45 -0500 +Subject: [PATCH 166/220] Fix the looking up grub.cfg-XXX while tftp booting. +Currently, grub doesn't look up grub.cfg-UUID, grub.cfg-MAC and grub.cfg-IP +while the boot is from tftp. That is because the uuid size is got by +grub_snprintf(, 0, ,), but the grub_snprintf() always returns 0, +so grub judges there's no available uuid in the client and give up +the looking up grub.cfg-XXX. + +This issue can be fixed by changing grub_snprintf(, 0, ,) behaivior +to like as snprintf() from glibc, however, somewhere may expect +such argument as the error, so it's risky. + +Let's use sizeof() and grub_strlen() to calculate the uuid size +instead of grub_snprintf(). + +Resolves: rhbz#1658500 --- - grub-core/net/net.c | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) + grub-core/net/net.c | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index a571ee9..55af4b0 100644 +index aa56393..15073dd 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c -@@ -1942,11 +1942,7 @@ grub_net_search_configfile (char *config) +@@ -1942,11 +1942,9 @@ grub_net_search_configfile (char *config) char *client_uuid_var; grub_size_t client_uuid_var_size; @@ -20,10 +34,12 @@ index a571ee9..55af4b0 100644 - if (client_uuid_var_size <= 0) - continue; - client_uuid_var_size += 1; -+ client_uuid_var_size = grub_strlen("net_") + grub_strlen(inf->name) + grub_strlen("_clientuuid") + 1; ++ client_uuid_var_size = sizeof ("net_") + grub_strlen (inf->name) + ++ sizeof ("_clientuuid") + 1; ++ client_uuid_var = grub_malloc(client_uuid_var_size); if (!client_uuid_var) continue; -- -2.19.1 +1.8.3.1 diff --git a/0166-Use-xid-to-match-DHCP-replies.patch b/0166-Use-xid-to-match-DHCP-replies.patch deleted file mode 100644 index 657ebb7842d28aa44cef5874f68d319603636a6b..0000000000000000000000000000000000000000 --- a/0166-Use-xid-to-match-DHCP-replies.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Andrzej Kacprowski -Date: Fri, 21 Apr 2017 09:20:38 +0200 -Subject: [PATCH] Use xid to match DHCP replies - -Transaction identifier (xid) from DHCP request -packet is stored in network level interface and used -to match request with the responses it generates. - -Resolves: rhbz#1370642 - -Signed-off-by: Andrzej Kacprowski ---- - grub-core/net/bootp.c | 3 ++- - grub-core/net/ip.c | 1 + - include/grub/net.h | 3 ++- - 3 files changed, 5 insertions(+), 2 deletions(-) - -diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index da3e454466b..2869482fe06 100644 ---- a/grub-core/net/bootp.c -+++ b/grub-core/net/bootp.c -@@ -777,7 +777,8 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), - grub_errno = GRUB_ERR_NONE; - t = 0; - } -- pack->ident = grub_cpu_to_be32 (t); -+ pack->xid = grub_cpu_to_be32 (t); -+ ifaces[j].dhcp_xid = pack->xid; - pack->seconds = grub_cpu_to_be16 (t); - - grub_memcpy (&pack->mac_addr, &ifaces[j].hwaddress.mac, 6); -diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c -index 7c95cc7464a..8411e0ecca3 100644 ---- a/grub-core/net/ip.c -+++ b/grub-core/net/ip.c -@@ -275,6 +275,7 @@ handle_dgram (struct grub_net_buff *nb, - FOR_NET_NETWORK_LEVEL_INTERFACES (inf) - if (inf->card == card - && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV -+ && inf->dhcp_xid == bootp->xid - && inf->hwaddress.type == GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET - && grub_memcmp (inf->hwaddress.mac, &bootp->mac_addr, - sizeof (inf->hwaddress.mac)) == 0) -diff --git a/include/grub/net.h b/include/grub/net.h -index f8f3ec13acc..de51894cbbf 100644 ---- a/include/grub/net.h -+++ b/include/grub/net.h -@@ -292,6 +292,7 @@ struct grub_net_network_level_interface - struct grub_net_bootp_packet *dhcp_ack; - grub_size_t dhcp_acklen; - grub_uint16_t vlantag; -+ grub_uint32_t dhcp_xid; - void *data; - }; - -@@ -429,7 +430,7 @@ struct grub_net_bootp_packet - grub_uint8_t hw_type; /* hardware type. */ - grub_uint8_t hw_len; /* hardware addr len. */ - grub_uint8_t gate_hops; /* zero it. */ -- grub_uint32_t ident; /* random number chosen by client. */ -+ grub_uint32_t xid; /* transaction id chosen by client. */ - grub_uint16_t seconds; /* seconds since did initial bootstrap. */ - grub_uint16_t flags; - grub_uint32_t client_ip; diff --git a/0167-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch b/0167-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch new file mode 100644 index 0000000000000000000000000000000000000000..9ee412721a79d0b108b2ab877b5fd004d9765892 --- /dev/null +++ b/0167-Don-t-make-grub_strtoull-print-an-error-if-no-conver.patch @@ -0,0 +1,34 @@ +From 46b860c3c423cefdf427aa547e43927400d02f8c Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Mon, 11 Feb 2019 15:14:10 +0100 +Subject: [PATCH 167/220] Don't make grub_strtoull() print an error if no + conversion is performed + +Callers can check if grub_errno was set to GRUB_ERR_BAD_NUMBER, so there's +no need to print an error if a conversion couldn't be performed. This just +pollutes the output with noisy error messages. + +Resolves: rhbz#1674512 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/kern/misc.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c +index 18a7dbf..87afb43 100644 +--- a/grub-core/kern/misc.c ++++ b/grub-core/kern/misc.c +@@ -475,8 +475,7 @@ grub_strtoull (const char * restrict str, const char ** const restrict end, + + if (! found) + { +- grub_error (GRUB_ERR_BAD_NUMBER, +- N_("unrecognized number")); ++ grub_errno = GRUB_ERR_BAD_NUMBER; + return 0; + } + +-- +1.8.3.1 + diff --git a/0168-Fix-the-type-of-grub_efi_status_t.patch b/0168-Fix-the-type-of-grub_efi_status_t.patch new file mode 100644 index 0000000000000000000000000000000000000000..2186ddfc6ee26822602fae06c5a8535ff309a1b9 --- /dev/null +++ b/0168-Fix-the-type-of-grub_efi_status_t.patch @@ -0,0 +1,82 @@ +From a9484492c1672abbae572d2bfae5b1dd8c91d4d2 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 21 Mar 2019 13:06:06 -0400 +Subject: [PATCH 168/220] Fix the type of grub_efi_status_t + +Currently, in some builds with some checkers, we see: + +1. grub-core/disk/efi/efidisk.c:601: error[shiftTooManyBitsSigned]: Shifting signed 64-bit value by 63 bits is undefined behaviour + +This is because grub_efi_status_t is defined as grub_efi_intn_t, which is +signed, and shifting into the sign bit is not defined behavior. UEFI fixed +this in the spec in 2.3: + +2.3 | Change the defined type of EFI_STATUS from INTN to UINTN | May 7, 2009 + +And the current EDK2 code has: +MdePkg/Include/Base.h-// +MdePkg/Include/Base.h-// Status codes common to all execution phases +MdePkg/Include/Base.h-// +MdePkg/Include/Base.h:typedef UINTN RETURN_STATUS; +MdePkg/Include/Base.h- +MdePkg/Include/Base.h-/** +MdePkg/Include/Base.h- Produces a RETURN_STATUS code with the highest bit set. +MdePkg/Include/Base.h- +MdePkg/Include/Base.h- @param StatusCode The status code value to convert into a warning code. +MdePkg/Include/Base.h- StatusCode must be in the range 0x00000000..0x7FFFFFFF. +MdePkg/Include/Base.h- +MdePkg/Include/Base.h- @return The value specified by StatusCode with the highest bit set. +MdePkg/Include/Base.h- +MdePkg/Include/Base.h-**/ +MdePkg/Include/Base.h-#define ENCODE_ERROR(StatusCode) ((RETURN_STATUS)(MAX_BIT | (StatusCode))) +MdePkg/Include/Base.h- +MdePkg/Include/Base.h-/** +MdePkg/Include/Base.h- Produces a RETURN_STATUS code with the highest bit clear. +MdePkg/Include/Base.h- +MdePkg/Include/Base.h- @param StatusCode The status code value to convert into a warning code. +MdePkg/Include/Base.h- StatusCode must be in the range 0x00000000..0x7FFFFFFF. +MdePkg/Include/Base.h- +MdePkg/Include/Base.h- @return The value specified by StatusCode with the highest bit clear. +MdePkg/Include/Base.h- +MdePkg/Include/Base.h-**/ +MdePkg/Include/Base.h-#define ENCODE_WARNING(StatusCode) ((RETURN_STATUS)(StatusCode)) +MdePkg/Include/Base.h- +MdePkg/Include/Base.h-/** +MdePkg/Include/Base.h- Returns TRUE if a specified RETURN_STATUS code is an error code. +MdePkg/Include/Base.h- +MdePkg/Include/Base.h- This function returns TRUE if StatusCode has the high bit set. Otherwise, FALSE is returned. +MdePkg/Include/Base.h- +MdePkg/Include/Base.h- @param StatusCode The status code value to evaluate. +MdePkg/Include/Base.h- +MdePkg/Include/Base.h- @retval TRUE The high bit of StatusCode is set. +MdePkg/Include/Base.h- @retval FALSE The high bit of StatusCode is clear. +MdePkg/Include/Base.h- +MdePkg/Include/Base.h-**/ +MdePkg/Include/Base.h-#define RETURN_ERROR(StatusCode) (((INTN)(RETURN_STATUS)(StatusCode)) < 0) +... +Uefi/UefiBaseType.h:typedef RETURN_STATUS EFI_STATUS; + +This patch makes grub's implementation match the Edk2 declaration with regards +to the signedness of the type. + +Signed-off-by: Peter Jones +--- + include/grub/efi/api.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h +index 2ed9c26..dec7b06 100644 +--- a/include/grub/efi/api.h ++++ b/include/grub/efi/api.h +@@ -536,7 +536,7 @@ typedef grub_uint64_t grub_efi_uint64_t; + typedef grub_uint8_t grub_efi_char8_t; + typedef grub_uint16_t grub_efi_char16_t; + +-typedef grub_efi_intn_t grub_efi_status_t; ++typedef grub_efi_uintn_t grub_efi_status_t; + /* Make grub_efi_status_t reasonably printable. */ + #if GRUB_CPU_SIZEOF_VOID_P == 8 + #define PRIxGRUB_EFI_STATUS "lx" +-- +1.8.3.1 + diff --git a/0169-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch b/0169-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch new file mode 100644 index 0000000000000000000000000000000000000000..e4f09ce98e7f07d7401ffbfc3d0e9f4f9af59d63 --- /dev/null +++ b/0169-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch @@ -0,0 +1,246 @@ +From d371c69fed702b24a9025309c5773abddc18d3d3 Mon Sep 17 00:00:00 2001 +From: Christian Glombek +Date: Tue, 2 Apr 2019 16:22:21 +0200 +Subject: [PATCH 169/220] grub.d: Split out boot success reset from menu auto + hide script + +Also rename fallback and menu auto hide script to be executed +before and after boot success reset script. +In menu auto hide script, rename last_boot_ok var to menu_hide_ok +--- + Makefile.util.def | 14 ++++++++--- + util/grub.d/01_fallback_counting.in | 22 ----------------- + util/grub.d/01_menu_auto_hide.in | 48 ------------------------------------ + util/grub.d/08_fallback_counting.in | 24 ++++++++++++++++++ + util/grub.d/10_reset_boot_success.in | 25 +++++++++++++++++++ + util/grub.d/12_menu_auto_hide.in | 35 ++++++++++++++++++++++++++ + 6 files changed, 94 insertions(+), 74 deletions(-) + delete mode 100644 util/grub.d/01_fallback_counting.in + delete mode 100644 util/grub.d/01_menu_auto_hide.in + create mode 100644 util/grub.d/08_fallback_counting.in + create mode 100644 util/grub.d/10_reset_boot_success.in + create mode 100644 util/grub.d/12_menu_auto_hide.in + +diff --git a/Makefile.util.def b/Makefile.util.def +index 2019ebd..1fa92ca 100644 +--- a/Makefile.util.def ++++ b/Makefile.util.def +@@ -458,14 +458,14 @@ script = { + }; + + script = { +- name = '01_fallback_counting'; +- common = util/grub.d/01_fallback_counting.in; ++ name = '08_fallback_counting'; ++ common = util/grub.d/08_fallback_counting.in; + installdir = grubconf; + }; + + script = { +- name = '01_menu_auto_hide'; +- common = util/grub.d/01_menu_auto_hide.in; ++ name = '12_menu_auto_hide'; ++ common = util/grub.d/12_menu_auto_hide.in; + installdir = grubconf; + }; + +@@ -525,6 +525,12 @@ script = { + }; + + script = { ++ name = '10_reset_boot_success'; ++ common = util/grub.d/10_reset_boot_success.in; ++ installdir = grubconf; ++}; ++ ++script = { + name = '10_xnu'; + common = util/grub.d/10_xnu.in; + installdir = grubconf; +diff --git a/util/grub.d/01_fallback_counting.in b/util/grub.d/01_fallback_counting.in +deleted file mode 100644 +index be0e770..0000000 +--- a/util/grub.d/01_fallback_counting.in ++++ /dev/null +@@ -1,22 +0,0 @@ +-#! /bin/sh -e +- +-# Boot Counting +-# The boot_counter env var can be used to count down boot attempts after an +-# OSTree upgrade and choose the rollback deployment when 0 is reached. Both +-# boot_counter and boot_success need to be (re-)set from userspace. +-cat << EOF +-insmod increment +-# Check if boot_counter exists and boot_success=0 to activate this behaviour. +-if [ -n "\${boot_counter}" -a "\${boot_success}" = "0" ]; then +- # if countdown has ended, choose to boot rollback deployment (default=1 on +- # OSTree-based systems) +- if [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then +- set default=1 +- set boot_counter=-1 +- # otherwise decrement boot_counter +- else +- decrement boot_counter +- fi +- save_env boot_counter +-fi +-EOF +diff --git a/util/grub.d/01_menu_auto_hide.in b/util/grub.d/01_menu_auto_hide.in +deleted file mode 100644 +index ad17587..0000000 +--- a/util/grub.d/01_menu_auto_hide.in ++++ /dev/null +@@ -1,48 +0,0 @@ +-#! /bin/sh +- +-# Disable / skip generating menu-auto-hide config parts on serial terminals +-for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do +- case "$x" in +- serial*) +- exit 0 +- ;; +- esac +-done +- +-cat << EOF +-if [ "\${boot_success}" = "1" -o "\${boot_indeterminate}" = "1" ]; then +- set last_boot_ok=1 +-else +- set last_boot_ok=0 +-fi +- +-# Reset boot_indeterminate after a successful boot +-if [ "\${boot_success}" = "1" ] ; then +- set boot_indeterminate=0 +-# Avoid boot_indeterminate causing the menu to be hidden more then once +-elif [ "\${boot_indeterminate}" = "1" ]; then +- set boot_indeterminate=2 +-fi +-set boot_success=0 +-save_env boot_success boot_indeterminate +- +-if [ x\$feature_timeout_style = xy ] ; then +- if [ "\${menu_show_once}" ]; then +- unset menu_show_once +- save_env menu_show_once +- set timeout_style=menu +- set timeout=60 +- elif [ "\${menu_auto_hide}" -a "\${last_boot_ok}" = "1" ]; then +- set orig_timeout_style=\${timeout_style} +- set orig_timeout=\${timeout} +- if [ "\${fastboot}" = "1" ]; then +- # timeout_style=menu + timeout=0 avoids the countdown code keypress check +- set timeout_style=menu +- set timeout=0 +- else +- set timeout_style=hidden +- set timeout=1 +- fi +- fi +-fi +-EOF +diff --git a/util/grub.d/08_fallback_counting.in b/util/grub.d/08_fallback_counting.in +new file mode 100644 +index 0000000..2e2c3ff +--- /dev/null ++++ b/util/grub.d/08_fallback_counting.in +@@ -0,0 +1,24 @@ ++#! /bin/sh -e ++# Fallback Countdown ++# ++# This snippet depends on 10_reset_boot_success and needs to be kept in sync. ++# ++# The boot_counter env var can be used to count down boot attempts after an ++# OSTree upgrade and choose the rollback deployment when 0 is reached. ++# Both boot_counter=X and boot_success=1 need to be set from userspace. ++cat << EOF ++insmod increment ++# Check if boot_counter exists and boot_success=0 to activate this behaviour. ++if [ -n "\${boot_counter}" -a "\${boot_success}" = "0" ]; then ++ # if countdown has ended, choose to boot rollback deployment, ++ # i.e. default=1 on OSTree-based systems. ++ if [ "\${boot_counter}" = "0" -o "\${boot_counter}" = "-1" ]; then ++ set default=1 ++ set boot_counter=-1 ++ # otherwise decrement boot_counter ++ else ++ decrement boot_counter ++ fi ++ save_env boot_counter ++fi ++EOF +diff --git a/util/grub.d/10_reset_boot_success.in b/util/grub.d/10_reset_boot_success.in +new file mode 100644 +index 0000000..6c88d93 +--- /dev/null ++++ b/util/grub.d/10_reset_boot_success.in +@@ -0,0 +1,25 @@ ++#! /bin/sh -e ++# Reset Boot Success ++# ++# The 08_fallback_counting and 12_menu_auto_hide snippets rely on this one ++# and need to be kept in sync. ++# ++# The boot_success var needs to be set to 1 from userspace to mark a boot successful. ++cat << EOF ++insmod increment ++# Hiding the menu is ok if last boot was ok or if this is a first boot attempt to boot the entry ++if [ "\${boot_success}" = "1" -o "\${boot_indeterminate}" = "1" ]; then ++ set menu_hide_ok=1 ++else ++ set menu_hide_ok=0 ++fi ++# Reset boot_indeterminate after a successful boot, increment otherwise ++if [ "\${boot_success}" = "1" ] ; then ++ set boot_indeterminate=0 ++else ++ increment boot_indeterminate ++fi ++# Reset boot_success for current boot ++set boot_success=0 ++save_env boot_success boot_indeterminate ++EOF +diff --git a/util/grub.d/12_menu_auto_hide.in b/util/grub.d/12_menu_auto_hide.in +new file mode 100644 +index 0000000..6a7c0fa +--- /dev/null ++++ b/util/grub.d/12_menu_auto_hide.in +@@ -0,0 +1,35 @@ ++#! /bin/sh ++# Menu Auto Hide ++# ++# This snippet depends on 10_reset_boot_success and needs to be kept in sync. ++# ++# Disable / skip generating menu-auto-hide config parts on serial terminals ++for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do ++ case "$x" in ++ serial*) ++ exit 0 ++ ;; ++ esac ++done ++ ++cat << EOF ++if [ x\$feature_timeout_style = xy ] ; then ++ if [ "\${menu_show_once}" ]; then ++ unset menu_show_once ++ save_env menu_show_once ++ set timeout_style=menu ++ set timeout=60 ++ elif [ "\${menu_auto_hide}" -a "\${menu_hide_ok}" = "1" ]; then ++ set orig_timeout_style=\${timeout_style} ++ set orig_timeout=\${timeout} ++ if [ "\${fastboot}" = "1" ]; then ++ # timeout_style=menu + timeout=0 avoids the countdown code keypress check ++ set timeout_style=menu ++ set timeout=0 ++ else ++ set timeout_style=hidden ++ set timeout=1 ++ fi ++ fi ++fi ++EOF +-- +1.8.3.1 + diff --git a/0170-Fix-systemctl-kexec-exit-status-check.patch b/0170-Fix-systemctl-kexec-exit-status-check.patch new file mode 100644 index 0000000000000000000000000000000000000000..afb9597afc52d1358d4ec754825263f446c426e4 --- /dev/null +++ b/0170-Fix-systemctl-kexec-exit-status-check.patch @@ -0,0 +1,40 @@ +From 425daec448d7ad73d0d2dc5e0918af823b4b11b3 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 9 Apr 2019 12:30:38 +0200 +Subject: [PATCH 170/220] Fix systemctl kexec exit status check + +There's always an error printed even when the systemctl kexec command does +succeed. That's because systemctl executes it asynchronously, but the emu +loader seems to expect it to be synchronous and that should never return. + +Also, it's wrong to test if kexecute == 1 since we already know that's the +case or otherwise the function wouldn't had called grub_fatal() earlier. + +Finally, systemctl kexec failing shouldn't be a fatal error since the emu +loader fallbacks to executing the kexec command in case of a failure. + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/loader/emu/linux.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/grub-core/loader/emu/linux.c b/grub-core/loader/emu/linux.c +index fda9e00..5b85b22 100644 +--- a/grub-core/loader/emu/linux.c ++++ b/grub-core/loader/emu/linux.c +@@ -71,8 +71,10 @@ grub_linux_boot (void) + (kexecute==1) ? "do-or-die" : "just-in-case"); + rc = grub_util_exec (systemctl); + +- if (kexecute == 1) +- grub_fatal (N_("Error trying to perform 'systemctl kexec'")); ++ if (rc == GRUB_ERR_NONE) ++ return rc; ++ ++ grub_error (rc, N_("Error trying to perform 'systemctl kexec'")); + + /* need to check read-only root before resetting hard!? */ + grub_printf("Performing 'kexec -e'"); +-- +1.8.3.1 + diff --git a/0170-net-read-bracketed-ipv6-addrs-and-port-numbers-pjone.patch b/0170-net-read-bracketed-ipv6-addrs-and-port-numbers-pjone.patch deleted file mode 100644 index a0f3859e48b86d61f05b1bdcb254f7153f2c78ae..0000000000000000000000000000000000000000 --- a/0170-net-read-bracketed-ipv6-addrs-and-port-numbers-pjone.patch +++ /dev/null @@ -1,105 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aaron Miller -Date: Fri, 29 Jul 2016 17:41:38 +0800 -Subject: [PATCH] net: read bracketed ipv6 addrs and port numbers (pjones - fixup) - -Various bug fixes related to previous patch. - -Signed-off-by: Peter Jones ---- - grub-core/net/http.c | 6 ++++-- - grub-core/net/net.c | 24 ++++++++++++------------ - 2 files changed, 16 insertions(+), 14 deletions(-) - -diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index f182d7b871d..00737c52750 100644 ---- a/grub-core/net/http.c -+++ b/grub-core/net/http.c -@@ -289,7 +289,9 @@ http_receive (grub_net_tcp_socket_t sock __attribute__ ((unused)), - nb2 = grub_netbuff_alloc (data->chunk_rem); - if (!nb2) - return grub_errno; -- grub_netbuff_put (nb2, data->chunk_rem); -+ err = grub_netbuff_put (nb2, data->chunk_rem); -+ if (err) -+ return grub_errno; - grub_memcpy (nb2->data, nb->data, data->chunk_rem); - if (file->device->net->packs.count >= 20) - { -@@ -405,7 +407,7 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) - data->filename, server, port ? port : HTTP_PORT); - data->sock = grub_net_tcp_open (server, - port ? port : HTTP_PORT, http_receive, -- http_err, http_err, -+ http_err, NULL, - file); - if (!data->sock) - { -diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 1f887d44b32..a0f4d00f0be 100644 ---- a/grub-core/net/net.c -+++ b/grub-core/net/net.c -@@ -441,10 +441,11 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) - int word, quaddot = -1; - int bracketed = 0; - -- if (ptr[0] == '[') { -- bracketed = 1; -- ptr++; -- } -+ if (ptr[0] == '[') -+ { -+ bracketed = 1; -+ ptr++; -+ } - - if (ptr[0] == ':' && ptr[1] != ':') - return 0; -@@ -483,9 +484,8 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) - grub_memset (&newip[quaddot], 0, (7 - word) * sizeof (newip[0])); - } - grub_memcpy (ip, newip, 16); -- if (bracketed && *ptr == ']') { -+ if (bracketed && *ptr == ']') - ptr++; -- } - if (rest) - *rest = ptr; - return 1; -@@ -1389,7 +1389,7 @@ grub_net_open_real (const char *name) - char* port_start; - /* ipv6 or port specified? */ - if ((port_start = grub_strchr (server, ':'))) -- { -+ { - char* ipv6_begin; - if((ipv6_begin = grub_strchr (server, '['))) - { -@@ -1461,14 +1461,13 @@ grub_net_open_real (const char *name) - { - grub_net_t ret = grub_zalloc (sizeof (*ret)); - if (!ret) -- return NULL; -- ret->protocol = proto; -- ret->server = grub_strdup (server); -- if (!ret->server) - { -- grub_free (ret); -+ grub_free (host); - return NULL; - } -+ ret->protocol = proto; -+ ret->port = port; -+ ret->server = host; - ret->fs = &grub_net_fs; - return ret; - } -@@ -1543,6 +1542,7 @@ grub_net_open_real (const char *name) - grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' not found"), - name); - -+ grub_free (host); - return NULL; - } - diff --git a/0171-Print-grub-emu-linux-loader-messages-as-debug.patch b/0171-Print-grub-emu-linux-loader-messages-as-debug.patch new file mode 100644 index 0000000000000000000000000000000000000000..55c2bbf25f6bc523e000a93f85409cfd56c87dc1 --- /dev/null +++ b/0171-Print-grub-emu-linux-loader-messages-as-debug.patch @@ -0,0 +1,37 @@ +From d82290c42e977165ed19c02e0a548f11b50db818 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 9 Apr 2019 12:42:37 +0200 +Subject: [PATCH 171/220] Print grub-emu linux loader messages as debug + +They just polute the output and should better be debug messages instead. + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/loader/emu/linux.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/loader/emu/linux.c b/grub-core/loader/emu/linux.c +index 5b85b22..22ab6af 100644 +--- a/grub-core/loader/emu/linux.c ++++ b/grub-core/loader/emu/linux.c +@@ -50,7 +50,7 @@ grub_linux_boot (void) + initrd_param = grub_xasprintf("%s", ""); + } + +- grub_printf("%serforming 'kexec -l %s %s %s'\n", ++ grub_dprintf ("linux", "%serforming 'kexec -l %s %s %s'\n", + (kexecute) ? "P" : "Not p", + kernel_path, initrd_param, boot_cmdline); + +@@ -67,7 +67,7 @@ grub_linux_boot (void) + if (kexecute < 1) + grub_fatal (N_("Use '"PACKAGE"-emu --kexec' to force a system restart.")); + +- grub_printf("Performing 'systemctl kexec' (%s) ", ++ grub_dprintf ("linux", "Performing 'systemctl kexec' (%s) ", + (kexecute==1) ? "do-or-die" : "just-in-case"); + rc = grub_util_exec (systemctl); + +-- +1.8.3.1 + diff --git a/0172-Don-t-assume-that-boot-commands-will-only-return-on-.patch b/0172-Don-t-assume-that-boot-commands-will-only-return-on-.patch new file mode 100644 index 0000000000000000000000000000000000000000..5ff8cb129e470e2a4fb1a48c64a1a8c51ae3b895 --- /dev/null +++ b/0172-Don-t-assume-that-boot-commands-will-only-return-on-.patch @@ -0,0 +1,83 @@ +From 8edc8d1d8e0f4a6f4a25c85e4821fbabc8fb2232 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 9 Apr 2019 13:12:40 +0200 +Subject: [PATCH 172/220] Don't assume that boot commands will only return on + fail + +While it's true that for most loaders the boot command never returns, it +may be the case that it does. For example the GRUB emulator boot command +calls to systemctl kexec which in turn does an asynchonous call to kexec. + +So in this case GRUB will wrongly assume that the boot command fails and +print a "Failed to boot both default and fallback entries" even when the +kexec call later succeeds. + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/normal/menu.c | 19 +++++++++++-------- + 1 file changed, 11 insertions(+), 8 deletions(-) + +diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c +index d4832f1..9ea1f41 100644 +--- a/grub-core/normal/menu.c ++++ b/grub-core/normal/menu.c +@@ -285,7 +285,7 @@ get_and_remove_first_entry_number (grub_menu_t menu, const char *name) + } + + /* Run a menu entry. */ +-static void ++static grub_err_t + grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot) + { + grub_err_t err = GRUB_ERR_NONE; +@@ -385,7 +385,7 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot) + + if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ()) + /* Implicit execution of boot, only if something is loaded. */ +- grub_command_execute ("boot", 0, 0); ++ err = grub_command_execute ("boot", 0, 0); + + if (errs_before != grub_err_printed_errors) + grub_wait_after_message (); +@@ -408,6 +408,8 @@ grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot) + else + grub_env_unset ("default"); + grub_env_unset ("timeout"); ++ ++ return err; + } + + /* Execute ENTRY from the menu MENU, falling back to entries specified +@@ -422,10 +424,13 @@ grub_menu_execute_with_fallback (grub_menu_t menu, + void *callback_data) + { + int fallback_entry; ++ grub_err_t err; + + callback->notify_booting (entry, callback_data); + +- grub_menu_execute_entry (entry, 1); ++ err = grub_menu_execute_entry (entry, 1); ++ if (err == GRUB_ERR_NONE) ++ return; + + /* Deal with fallback entries. */ + while ((fallback_entry = get_and_remove_first_entry_number (menu, "fallback")) +@@ -436,11 +441,9 @@ grub_menu_execute_with_fallback (grub_menu_t menu, + + entry = grub_menu_get_entry (menu, fallback_entry); + callback->notify_fallback (entry, callback_data); +- grub_menu_execute_entry (entry, 1); +- /* If the function call to execute the entry returns at all, then this is +- taken to indicate a boot failure. For menu entries that do something +- other than actually boot an operating system, this could assume +- incorrectly that something failed. */ ++ err = grub_menu_execute_entry (entry, 1); ++ if (err == GRUB_ERR_NONE) ++ return; + } + + if (!autobooted) +-- +1.8.3.1 + diff --git a/0172-Put-back-our-code-to-add-a-local-route.patch b/0172-Put-back-our-code-to-add-a-local-route.patch deleted file mode 100644 index e8da5894dc652ed7d125314ccaec725959039ade..0000000000000000000000000000000000000000 --- a/0172-Put-back-our-code-to-add-a-local-route.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 21 Jun 2018 18:32:26 -0400 -Subject: [PATCH] Put back our code to add a local route. - -This was removed by the previous patch. - -Signed-off-by: Peter Jones ---- - grub-core/net/bootp.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index ff1d7776e7f..242cd1f4cbd 100644 ---- a/grub-core/net/bootp.c -+++ b/grub-core/net/bootp.c -@@ -976,6 +976,7 @@ grub_net_configure_by_dhcpv6_reply (const char *name, - { - struct grub_net_network_level_interface *inf; - grub_dhcp6_options_t dhcp6; -+ int mask = -1; - - dhcp6 = grub_dhcp6_options_get (v6h, size); - if (!dhcp6) -@@ -1007,6 +1008,10 @@ grub_net_configure_by_dhcpv6_reply (const char *name, - } - - grub_dhcp6_options_free (dhcp6); -+ -+ if (inf) -+ grub_net_add_ipv6_local (inf, mask); -+ - return inf; - } - diff --git a/0173-Fix-undefined-references-for-fdt-when-building-with-.patch b/0173-Fix-undefined-references-for-fdt-when-building-with-.patch new file mode 100644 index 0000000000000000000000000000000000000000..7f5bc532dca221e7db9963e2ae26d593afc9cb20 --- /dev/null +++ b/0173-Fix-undefined-references-for-fdt-when-building-with-.patch @@ -0,0 +1,44 @@ +From b7e0553fec4b8e033d794e30b83565f5dd3652c6 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Wed, 1 May 2019 00:36:19 +0200 +Subject: [PATCH 173/220] Fix undefined references for fdt when building with + platform emu + +The fdt module isn't build for this platform, so adding the declarations +with platform emu will lead to the following undefined reference errors: + +BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x500): undefined reference to `grub_fdt_add_subnode' +BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x518): undefined reference to `grub_fdt_check_header' +BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x530): undefined reference to `grub_fdt_check_header_nosize' +BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x548): undefined reference to `grub_fdt_create_empty_tree' +BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x560): undefined reference to `grub_fdt_find_subnode' +BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x578): undefined reference to `grub_fdt_first_node' +BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x590): undefined reference to `grub_fdt_get_nodename' +BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x5a8): undefined reference to `grub_fdt_get_prop' +BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x5c0): undefined reference to `grub_fdt_next_node' +BUILDSTDERR: /usr/bin/ld: grub_emu_lite-symlist.o:(.data+0x5d8): undefined reference to `grub_fdt_set_prop' +BUILDSTDERR: collect2: error: ld returned 1 exit status +BUILDSTDERR: make[1]: *** [Makefile:27093: grub-emu-lite] Error 1 +BUILDSTDERR: make[1]: *** Waiting for unfinished jobs.... + +Signed-off-by: Javier Martinez Canillas +--- + include/grub/fdt.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/grub/fdt.h b/include/grub/fdt.h +index 22b7c54..2041341 100644 +--- a/include/grub/fdt.h ++++ b/include/grub/fdt.h +@@ -19,7 +19,7 @@ + #ifndef GRUB_FDT_HEADER + #define GRUB_FDT_HEADER 1 + +-#if defined(__arm__) || defined(__aarch64__) ++#if !defined(GRUB_MACHINE_EMU) && (defined(__arm__) || defined(__aarch64__)) + + #include + #include +-- +1.8.3.1 + diff --git a/0174-autogen.sh-use-find-wholename-for-long-path-matches.patch b/0174-autogen.sh-use-find-wholename-for-long-path-matches.patch new file mode 100644 index 0000000000000000000000000000000000000000..e2b3deed668cf6e8aceba98435f7159555d205c9 --- /dev/null +++ b/0174-autogen.sh-use-find-wholename-for-long-path-matches.patch @@ -0,0 +1,26 @@ +From 948006eab0c0414ebb2e197fbbf406808ac3dd10 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 29 Jul 2019 14:01:50 -0400 +Subject: [PATCH 174/220] autogen.sh: use find -wholename for long path matches + +Signed-off-by: Peter Jones +--- + autogen.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/autogen.sh b/autogen.sh +index ef43270..a1783d6 100755 +--- a/autogen.sh ++++ b/autogen.sh +@@ -13,7 +13,7 @@ fi + export LC_COLLATE=C + unset LC_ALL + +-find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' ! -ipath './gnulib/*' ! -iname './grub-core/lib/gnulib/*' |sort > po/POTFILES.in ++find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' ! -ipath './gnulib/*' ! -wholename './grub-core/lib/gnulib/*' |sort > po/POTFILES.in + find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in + + echo "Importing unicode..." +-- +1.8.3.1 + diff --git a/0175-Fix-build-error-with-the-fdt-module-on-risc-v.patch b/0175-Fix-build-error-with-the-fdt-module-on-risc-v.patch new file mode 100644 index 0000000000000000000000000000000000000000..dee1042ec9990b955b68e42ba2c66db00dd5489d --- /dev/null +++ b/0175-Fix-build-error-with-the-fdt-module-on-risc-v.patch @@ -0,0 +1,43 @@ +From 0982a417f60eeb8f117ae4d2931947c0f4515934 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 27 Aug 2019 10:34:24 +0200 +Subject: [PATCH 175/220] Fix build error with the fdt module on risc-v + +The risc-v architecture also uses Device Trees, but the symbols in the +fdt header aren't defined for this arch which lead to following error: + +BUILDSTDERR: ../../grub-core/loader/efi/fdt.c: In function 'grub_fdt_load': +BUILDSTDERR: ../../grub-core/loader/efi/fdt.c:48:39: warning: implicit declaration of function 'grub_fdt_get_totalsize' [-Wimplicit-function-declaration] +BUILDSTDERR: 48 | size = GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)); + +Signed-off-by: Javier Martinez Canillas +--- + include/grub/fdt.h | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/include/grub/fdt.h b/include/grub/fdt.h +index 2041341..3514aa4 100644 +--- a/include/grub/fdt.h ++++ b/include/grub/fdt.h +@@ -19,7 +19,8 @@ + #ifndef GRUB_FDT_HEADER + #define GRUB_FDT_HEADER 1 + +-#if !defined(GRUB_MACHINE_EMU) && (defined(__arm__) || defined(__aarch64__)) ++#if !defined(GRUB_MACHINE_EMU) && \ ++ (defined(__arm__) || defined(__aarch64__) || defined(__riscv)) + + #include + #include +@@ -146,6 +147,7 @@ int EXPORT_FUNC(grub_fdt_set_prop) (void *fdt, unsigned int nodeoffset, const ch + grub_fdt_set_prop ((fdt), (nodeoffset), "reg", reg_64, 16); \ + }) + +-#endif /* defined(__arm__) || defined(__aarch64__) */ ++#endif /* !defined(GRUB_MACHINE_EMU) && \ ++ (defined(__arm__) || defined(__aarch64__) || defined(__riscv)) */ + + #endif /* ! GRUB_FDT_HEADER */ +-- +1.8.3.1 + diff --git a/0176-RISC-V-Fix-computation-of-pc-relative-relocation-off.patch b/0176-RISC-V-Fix-computation-of-pc-relative-relocation-off.patch new file mode 100644 index 0000000000000000000000000000000000000000..89f42c585aa0bd5faca689418fa04245585a3623 --- /dev/null +++ b/0176-RISC-V-Fix-computation-of-pc-relative-relocation-off.patch @@ -0,0 +1,40 @@ +From bad3d7b8f5b050898b20f0ca10894e6d1c5bb161 Mon Sep 17 00:00:00 2001 +From: Andreas Schwab +Date: Wed, 26 Jun 2019 16:50:03 +0200 +Subject: [PATCH 176/220] RISC-V: Fix computation of pc-relative relocation + offset + +The offset calculation was missing the relocation addend. + +Signed-off-by: Andreas Schwab +Tested-by: Chester Lin +Reviewed-by: Daniel Kiper +--- + util/grub-mkimagexx.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c +index bc087c2..d16ec63 100644 +--- a/util/grub-mkimagexx.c ++++ b/util/grub-mkimagexx.c +@@ -1232,8 +1232,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, + grub_uint32_t *t32 = (grub_uint32_t *) target; + grub_uint16_t *t16 = (grub_uint16_t *) target; + grub_uint8_t *t8 = (grub_uint8_t *) target; +- grub_int64_t off = (long)sym_addr - target_section_addr - offset +- - image_target->vaddr_offset; ++ grub_int64_t off; + + /* + * Instructions and instruction encoding are documented in the RISC-V +@@ -1243,6 +1242,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, + */ + + sym_addr += addend; ++ off = sym_addr - target_section_addr - offset - image_target->vaddr_offset; + + switch (ELF_R_TYPE (info)) + { +-- +1.8.3.1 + diff --git a/0177-blscfg-Add-support-for-the-devicetree-field.patch b/0177-blscfg-Add-support-for-the-devicetree-field.patch new file mode 100644 index 0000000000000000000000000000000000000000..e0065d507d5fca6f1097c96d24297c5aed378936 --- /dev/null +++ b/0177-blscfg-Add-support-for-the-devicetree-field.patch @@ -0,0 +1,135 @@ +From a2d218b17e33e56829b9a23f73dded07ae5839a8 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Sun, 15 Sep 2019 09:37:45 +0200 +Subject: [PATCH 177/220] blscfg: Add support for the devicetree field + +The BootLoaderSpec mentions that a devicetree field can be used to pass a +Device Tree (DT) to the kernel, for the platforms that use it to describe +information about the hardware. + +Allow the blscfg module to parse this field and call the grub2 devicetree +command in that case. If there is a devicetree grub2 environment variable +defined, this will be used if the field is not defined in the BLS snippet. + +Resolves: rhbz#1751307 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/commands/blscfg.c | 60 ++++++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 57 insertions(+), 3 deletions(-) + +diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c +index 54458b1..1ec8987 100644 +--- a/grub-core/commands/blscfg.c ++++ b/grub-core/commands/blscfg.c +@@ -698,6 +698,8 @@ static void create_entry (struct bls_entry *entry) + const char *early_initrd = NULL; + char **early_initrds = NULL; + char *initrd_prefix = NULL; ++ char *devicetree = NULL; ++ char *dt = NULL; + char *id = entry->filename; + char *dotconf = id; + char *hotkey = NULL; +@@ -709,6 +711,7 @@ static void create_entry (struct bls_entry *entry) + + char *src = NULL; + int i, index; ++ bool add_dt_prefix = false; + + grub_dprintf("blscfg", "%s got here\n", __func__); + clinux = bls_get_val (entry, "linux", NULL); +@@ -736,6 +739,14 @@ static void create_entry (struct bls_entry *entry) + + initrds = bls_make_list (entry, "initrd", NULL); + ++ devicetree = expand_val (bls_get_val (entry, "devicetree", NULL)); ++ ++ if (!devicetree) ++ { ++ devicetree = expand_val (grub_env_get("devicetree")); ++ add_dt_prefix = true; ++ } ++ + hotkey = bls_get_val (entry, "grub_hotkey", NULL); + users = expand_val (bls_get_val (entry, "grub_users", NULL)); + classes = bls_make_list (entry, "grub_class", NULL); +@@ -801,7 +812,6 @@ static void create_entry (struct bls_entry *entry) + goto finish; + } + +- + tmp = grub_stpcpy(initrd, "initrd"); + for (i = 0; early_initrds != NULL && early_initrds[i] != NULL; i++) + { +@@ -821,21 +831,65 @@ static void create_entry (struct bls_entry *entry) + tmp = grub_stpcpy (tmp, "\n"); + } + ++ if (devicetree) ++ { ++ char *prefix = NULL; ++ int dt_size; ++ ++ if (add_dt_prefix) ++ { ++ prefix = grub_strrchr (clinux, '/'); ++ prefix = grub_strndup(clinux, prefix - clinux + 1); ++ if (!prefix) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ goto finish; ++ } ++ } ++ ++ dt_size = sizeof("devicetree " GRUB_BOOT_DEVICE) + grub_strlen(devicetree) + 1; ++ ++ if (add_dt_prefix) ++ { ++ dt_size += grub_strlen(prefix); ++ } ++ ++ dt = grub_malloc (dt_size); ++ if (!dt) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ goto finish; ++ } ++ char *tmp = dt; ++ tmp = grub_stpcpy (dt, "devicetree"); ++ tmp = grub_stpcpy (tmp, " " GRUB_BOOT_DEVICE); ++ if (add_dt_prefix) ++ tmp = grub_stpcpy (tmp, prefix); ++ tmp = grub_stpcpy (tmp, devicetree); ++ tmp = grub_stpcpy (tmp, "\n"); ++ ++ grub_free(prefix); ++ } ++ ++ grub_dprintf ("blscfg2", "devicetree %s for id:\"%s\"\n", dt, id); ++ + src = grub_xasprintf ("load_video\n" + "set gfxpayload=keep\n" + "insmod gzio\n" + "linux %s%s%s%s\n" +- "%s", ++ "%s%s", + GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", +- initrd ? initrd : ""); ++ initrd ? initrd : "", dt ? dt : ""); + + grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0, &index, entry); + grub_dprintf ("blscfg", "Added entry %d id:\"%s\"\n", index, id); + + finish: ++ grub_free (dt); + grub_free (initrd); + grub_free (initrd_prefix); + grub_free (early_initrds); ++ grub_free (devicetree); + grub_free (initrds); + grub_free (options); + grub_free (classes); +-- +1.8.3.1 + diff --git a/0178-Set-a-devicetree-var-in-a-BLS-config-if-GRUB_DEFAULT.patch b/0178-Set-a-devicetree-var-in-a-BLS-config-if-GRUB_DEFAULT.patch new file mode 100644 index 0000000000000000000000000000000000000000..21f7bf16c55f93783341a2d4b35637a727d6f501 --- /dev/null +++ b/0178-Set-a-devicetree-var-in-a-BLS-config-if-GRUB_DEFAULT.patch @@ -0,0 +1,41 @@ +From 6af4cfe6059cdce1ff72db3c72e77097e1285cc0 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Sun, 15 Sep 2019 10:05:29 +0200 +Subject: [PATCH 178/220] Set a devicetree var in a BLS config if + GRUB_DEFAULT_DTB is present + +The BootLoaderSpec mentions that a devicetree field can be used to pass a +Device Tree (DT) to the kernel, for the platforms that use it to describe +information about the hardware. + +The blscfg module supports parsing the field from the BLS snippets but it +allows to set a DT for all the entries if a devicetree env var is defined. + +Make the grub2-mkconfig tool to set this variable if GRUB_DEFAULT_DTB was +defined in the /etc/default/grub file. + +Resolves: rhbz#1751307 + +Signed-off-by: Javier Martinez Canillas +--- + util/grub.d/10_linux.in | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 301594a..1520b7e 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -138,6 +138,10 @@ EOF + if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then + ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" + fi ++ ++ if [ -n "${GRUB_DEFAULT_DTB}" ]; then ++ ${grub_editenv} - set devicetree="${GRUB_DEFAULT_DTB}" ++ fi + fi + + exit 0 +-- +1.8.3.1 + diff --git a/0179-Don-t-add-a-class-option-to-menu-entries-generated-f.patch b/0179-Don-t-add-a-class-option-to-menu-entries-generated-f.patch new file mode 100644 index 0000000000000000000000000000000000000000..26ad7360f9b0e4a6f70d6b4a744b70885f73dfb8 --- /dev/null +++ b/0179-Don-t-add-a-class-option-to-menu-entries-generated-f.patch @@ -0,0 +1,81 @@ +From 4207465e5a4866df6afde297e356057454c3d946 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Fri, 4 Oct 2019 16:43:05 +0200 +Subject: [PATCH 179/220] Don't add a class option to menu entries generated + for ppc64le + +For ppc64le a grub config file with menuentry commands is still generated +even when BLS support is enabled. That's because BLS support was added to +Petitboot 1.8.0 and any previous version won't be able to parse BLS files. + +To make the BLS snippets the source of truth, these are used to generate +the menuentry commands in the grub config file. + +And to keep it consistent across all ppc64le machines regardless of the +firmware used, the grub config file is also generated for machines with +OF that use grub2 and would have BLS support. + +The BLS snippets created by the kernel package have fields that are used +to specify the generated menuentry command users and class options. These +fields are not present in BLS snippets created by OSTree though, so the +script generating the menuentry commands will add options with an empty +argument which will lead to grub failing to parse them. + +We could check if the field is defined before attempting to add those, but +since the grub2 blscfg module also supports setting these to variables, it +could lead to an empty argument even if was defined in the BLS snippet if +the variable doesn't exist. + +So to make more robust, just don't add a class to the menuentry commands +generated by the script. It's better to not have a class for the menuentry +than grub2 failing to parse the command and not populating the boot menu. + +Resolves: rhbz#1758225 + +Signed-off-by: Javier Martinez Canillas +--- + util/grub.d/10_linux_bls.in | 10 +--------- + 1 file changed, 1 insertion(+), 9 deletions(-) + +diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in +index 1b75364..68fbedf 100644 +--- a/util/grub.d/10_linux_bls.in ++++ b/util/grub.d/10_linux_bls.in +@@ -127,9 +127,7 @@ read_config() + initrd="" + options="" + linux="" +- grub_users="" + grub_arg="" +- grub_class="" + + while read -r line + do +@@ -148,15 +146,9 @@ read_config() + "options") + options=${value} + ;; +- "grub_users") +- grub_users=${value} +- ;; + "grub_arg") + grub_arg=${value} + ;; +- "grub_class") +- grub_class=${value} +- ;; + esac + done < ${config_file} + } +@@ -180,7 +172,7 @@ populate_menu() + for bls in "${files[@]}" ; do + read_config "${blsdir}/${bls}.conf" + +- menu="${menu}menuentry '${title}' --class ${grub_class} ${grub_arg} --id=${bls} {\n" ++ menu="${menu}menuentry '${title}' ${grub_arg} --id=${bls} {\n" + menu="${menu}\t linux ${linux} ${options}\n" + if [ -n "${initrd}" ] ; then + menu="${menu}\t initrd ${boot_prefix}${initrd}\n" +-- +1.8.3.1 + diff --git a/0179-Fix-grub_net_hwaddr_to_str.patch b/0179-Fix-grub_net_hwaddr_to_str.patch deleted file mode 100644 index 6c17a323e5289597af05a93abbdb495807ff862f..0000000000000000000000000000000000000000 --- a/0179-Fix-grub_net_hwaddr_to_str.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Mark Salter -Date: Tue, 22 Aug 2017 12:21:12 -0400 -Subject: [PATCH] Fix grub_net_hwaddr_to_str - -commit 5c3b78c92f8 introduced support for larger network hw addresses. -However, grub_net_hwaddr_to_str() relies on GRUB_NET_MAX_STR_ADDRESS_SIZE -to prevent a spurious ':' at the end of the string. So now, if actual -hwaddr size is less than max, an extra ':' appears at the end of the -string. So calculate max string size based on actual hwaddr length to -fix the problem. - -Signed-off-by: Mark Salter ---- - grub-core/net/net.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index a0f4d00f0be..191e8e41bd6 100644 ---- a/grub-core/net/net.c -+++ b/grub-core/net/net.c -@@ -770,6 +770,7 @@ grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str) - { - char *ptr; - unsigned i; -+ int maxstr; - - if (addr->len > GRUB_NET_MAX_LINK_ADDRESS_SIZE) - { -@@ -778,9 +779,10 @@ grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str) - addr->type, addr->len); - return; - } -+ maxstr = addr->len * grub_strlen ("XX:"); - for (ptr = str, i = 0; i < addr->len; i++) - { -- ptr += grub_snprintf (ptr, GRUB_NET_MAX_STR_HWADDR_LEN - (ptr - str), -+ ptr += grub_snprintf (ptr, maxstr - (ptr - str), - "%02x:", addr->mac[i] & 0xff); - } - } diff --git a/0180-10_linux.in-Also-use-GRUB_CMDLINE_LINUX_DEFAULT-to-s.patch b/0180-10_linux.in-Also-use-GRUB_CMDLINE_LINUX_DEFAULT-to-s.patch new file mode 100644 index 0000000000000000000000000000000000000000..d40d7d1f16ed34462640eb196885efd2fde704cc --- /dev/null +++ b/0180-10_linux.in-Also-use-GRUB_CMDLINE_LINUX_DEFAULT-to-s.patch @@ -0,0 +1,48 @@ +From 867888c0e7570ed08c47ce546ccdc61b63e2a449 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 15 Oct 2019 09:08:25 +0200 +Subject: [PATCH 180/220] 10_linux.in: Also use GRUB_CMDLINE_LINUX_DEFAULT to + set kernelopts + +The GRUB documentation mentions that there are two variables to set the +linux kernel cmdline: GRUB_CMDLINE_LINUX and GRUB_CMDLINE_LINUX_DEFAULT. + +The former is added to all the menuentry commands and the latter is not +added to the recovery mode menu entries. But the blscfg module doesn't +populate recovery entries from the BLS snippets, so the values set in the +GRUB_CMDLINE_LINUX_DEFAULT variable should also be included in kernelopts. + +This is needed because the GRUB_CMDLINE_LINUX_DEFAULT option is mentioned +in the GRUB documentation so users assume that the kernel cmdline options +can be changed by setting this option and running the grub2-mkconfig tool. + +Signed-off-by: Javier Martinez Canillas +--- + util/grub.d/10_linux.in | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 1520b7e..0471464 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -118,7 +118,7 @@ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then + populate_header_warn + + cat << EOF +-set default_kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX}" ++set default_kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" + + insmod blscfg + blscfg +@@ -134,7 +134,7 @@ EOF + fi + fi + +- ${grub_editenv} - set kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX}" ++ ${grub_editenv} - set kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" + if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then + ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" + fi +-- +1.8.3.1 + diff --git a/0181-blscfg-Don-t-hardcode-an-env-var-as-fallback-for-the.patch b/0181-blscfg-Don-t-hardcode-an-env-var-as-fallback-for-the.patch new file mode 100644 index 0000000000000000000000000000000000000000..bce20a17887e2c9ce4af3bdf48062c5fb6b64f64 --- /dev/null +++ b/0181-blscfg-Don-t-hardcode-an-env-var-as-fallback-for-the.patch @@ -0,0 +1,66 @@ +From aefccfaac8af45dba1b9f08ecbf95c7343d8b4b6 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Mon, 14 Oct 2019 17:37:26 +0200 +Subject: [PATCH 181/220] blscfg: Don't hardcode an env var as fallback for the + BLS options field + +If the BLS fragments don't have an options field or if this was set to an +environment variable that was not defined in the grubenv file, the blscfg +module searches for an default_kernelopts variable that is defined in the +grub.cfg file. + +But the blscfg module shouldn't hardcode fallbacks variables and instead +this logic should be handled in the GRUB config file itself. + +Also, add a comment explaining where the kernelopts variable is supposed +to be defined and what is the process for the user to change its value. + +Resolves: rhbz#1710483 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/commands/blscfg.c | 4 ---- + util/grub.d/10_linux.in | 12 +++++++++++- + 2 files changed, 11 insertions(+), 5 deletions(-) + +diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c +index 1ec8987..471975f 100644 +--- a/grub-core/commands/blscfg.c ++++ b/grub-core/commands/blscfg.c +@@ -733,10 +733,6 @@ static void create_entry (struct bls_entry *entry) + + title = bls_get_val (entry, "title", NULL); + options = expand_val (bls_get_val (entry, "options", NULL)); +- +- if (!options) +- options = expand_val (grub_env_get("default_kernelopts")); +- + initrds = bls_make_list (entry, "initrd", NULL); + + devicetree = expand_val (bls_get_val (entry, "devicetree", NULL)); +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 0471464..21a6915 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -118,7 +118,17 @@ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then + populate_header_warn + + cat << EOF +-set default_kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ++# The kernelopts variable should be defined in the grubenv file. But to ensure that menu ++# entries populated from BootLoaderSpec files that use this variable work correctly even ++# without a grubenv file, define a fallback kernelopts variable if this has not been set. ++# ++# The kernelopts variable in the grubenv file can be modified using the grubby tool or by ++# executing the grub2-mkconfig tool. For the latter, the values of the GRUB_CMDLINE_LINUX ++# and GRUB_CMDLINE_LINUX_DEFAULT options from /etc/default/grub file are used to set both ++# the kernelopts variable in the grubenv file and the fallback kernelopts variable. ++if [ -z "\${kernelopts}" ]; then ++ set kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ++fi + + insmod blscfg + blscfg +-- +1.8.3.1 + diff --git a/0001-CVE-2019-14865.patch b/0182-grub-set-bootflag-Update-comment-about-running-as-ro.patch similarity index 79% rename from 0001-CVE-2019-14865.patch rename to 0182-grub-set-bootflag-Update-comment-about-running-as-ro.patch index cd4ef77508ceaef567291cd93af9b66cfd6e6317..abaf89c41b385cca272d5cac08ac6a2e51f68ed2 100644 --- a/0001-CVE-2019-14865.patch +++ b/0182-grub-set-bootflag-Update-comment-about-running-as-ro.patch @@ -1,8 +1,8 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 791c8d7fcd59c406f5d61e79950cdf08bd732617 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 13 Nov 2019 12:15:43 +0100 -Subject: [PATCH] grub-set-bootflag: Update comment about running as root - through pkexec +Subject: [PATCH 182/220] grub-set-bootflag: Update comment about running as + root through pkexec We have stopped using pkexec for grub-set-bootflag, instead it is now installed suid root, update the comment accordingly. @@ -13,7 +13,7 @@ Signed-off-by: Hans de Goede 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c -index 6a79ee67444..65d74ce010f 100644 +index 6a79ee6..65d74ce 100644 --- a/util/grub-set-bootflag.c +++ b/util/grub-set-bootflag.c @@ -18,7 +18,7 @@ @@ -25,3 +25,6 @@ index 6a79ee67444..65d74ce010f 100644 * use any grub library / util functions to allow for easy auditing. * The grub headers are only included to get certain defines. */ +-- +1.8.3.1 + diff --git a/0002-CVE-2019-14865.patch b/0183-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch similarity index 89% rename from 0002-CVE-2019-14865.patch rename to 0183-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch index 2f118912ae25e37eb6d43e3af0be37aec8f8037c..a97854dfbfc3c796fdd90ac842f87c2249d2bd9c 100644 --- a/0002-CVE-2019-14865.patch +++ b/0183-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch @@ -1,33 +1,33 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From d70d66650887f945e402dd0e1099c9d639d6dc8b Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 13 Nov 2019 13:02:01 +0100 -Subject: [PATCH] grub-set-bootflag: Write new env to tmpfile and then rename +Subject: [PATCH 183/220] grub-set-bootflag: Write new env to tmpfile and then + rename Make the grubenv writing code in grub-set-bootflag more robust by writing the modified grubenv to a tmpfile first and then renaming the tmpfile over the old grubenv (following symlinks). Signed-off-by: Hans de Goede - --- util/grub-set-bootflag.c | 87 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 78 insertions(+), 9 deletions(-) diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c -index 32f1c10..d3b80a0 100644 +index 65d74ce..d1c5e28 100644 --- a/util/grub-set-bootflag.c +++ b/util/grub-set-bootflag.c -@@ -26,7 +26,9 @@ - #include /* For *_DIR_NAME defines */ - #include +@@ -28,7 +28,9 @@ + #include #include /* For GRUB_ENVBLK_DEFCFG define */ + #include +#include #include +#include #include #include -@@ -52,8 +54,10 @@ int main(int argc, char *argv[]) +@@ -54,8 +56,10 @@ int main(int argc, char *argv[]) { /* NOTE buf must be at least the longest bootflag length + 4 bytes */ char env[GRUBENV_SIZE + 1], buf[64], *s; @@ -39,7 +39,7 @@ index 32f1c10..d3b80a0 100644 FILE *f; if (argc != 2) -@@ -75,7 +79,32 @@ int main(int argc, char *argv[]) +@@ -77,7 +81,32 @@ int main(int argc, char *argv[]) bootflag = bootflags[i]; len = strlen (bootflag); @@ -73,7 +73,7 @@ index 32f1c10..d3b80a0 100644 if (!f) { perror ("Error opening " GRUBENV " for reading"); -@@ -129,30 +158,70 @@ int main(int argc, char *argv[]) +@@ -132,30 +161,70 @@ int main(int argc, char *argv[]) snprintf(buf, sizeof(buf), "%s=1\n", bootflag); memcpy(s, buf, len + 3); diff --git a/0184-blscfg-add-a-space-char-when-appending-fields-for-va.patch b/0184-blscfg-add-a-space-char-when-appending-fields-for-va.patch new file mode 100644 index 0000000000000000000000000000000000000000..9f1eff986064e590700e022e6247e8d927540984 --- /dev/null +++ b/0184-blscfg-add-a-space-char-when-appending-fields-for-va.patch @@ -0,0 +1,79 @@ +From b6c9be5bfcfc8b7724f8a30b032ee1dcf58607d1 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 26 Nov 2019 09:51:41 +0100 +Subject: [PATCH 184/220] blscfg: add a space char when appending fields for + variable expansion + +The GRUB variables are expanded and replaced by their values before adding +menu entries, but they didn't include space characters after the values so +the result was not correct. + +For the common case this wasn't a problem but it is if there are variables +that are part of the values of other variables. + +Resolves: rhbz#1669252 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/commands/blscfg.c | 31 ++++++++++++++++++------------- + 1 file changed, 18 insertions(+), 13 deletions(-) + +diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c +index 471975f..d78cff7 100644 +--- a/grub-core/commands/blscfg.c ++++ b/grub-core/commands/blscfg.c +@@ -593,26 +593,29 @@ static char **bls_make_list (struct bls_entry *entry, const char *key, int *num) + + static char *field_append(bool is_var, char *buffer, char *start, char *end) + { +- char *temp = grub_strndup(start, end - start + 1); +- const char *field = temp; ++ char *tmp = grub_strndup(start, end - start + 1); ++ const char *field = tmp; ++ int term = is_var ? 2 : 1; + + if (is_var) { +- field = grub_env_get (temp); ++ field = grub_env_get (tmp); + if (!field) + return buffer; + } + +- if (!buffer) { +- buffer = grub_strdup(field); +- if (!buffer) +- return NULL; +- } else { +- buffer = grub_realloc (buffer, grub_strlen(buffer) + grub_strlen(field)); +- if (!buffer) +- return NULL; ++ if (!buffer) ++ buffer = grub_zalloc (grub_strlen(field) + term); ++ else ++ buffer = grub_realloc (buffer, grub_strlen(buffer) + grub_strlen(field) + term); + +- grub_stpcpy (buffer + grub_strlen(buffer), field); +- } ++ if (!buffer) ++ return NULL; ++ ++ tmp = buffer + grub_strlen(buffer); ++ tmp = grub_stpcpy (tmp, field); ++ ++ if (is_var) ++ tmp = grub_stpcpy (tmp, " "); + + return buffer; + } +@@ -642,6 +645,8 @@ static char *expand_val(char *value) + buffer = field_append(is_var, buffer, start, end); + is_var = false; + start = value; ++ if (*start == ' ') ++ start++; + } + } + +-- +1.8.3.1 + diff --git a/0185-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch b/0185-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch new file mode 100644 index 0000000000000000000000000000000000000000..5845ccf225144e714fd76450a213afb93ab3dab2 --- /dev/null +++ b/0185-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch @@ -0,0 +1,78 @@ +From cdefb84f0b4e7773ebf97259b6f89445f39a44d8 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Tue, 26 Nov 2019 09:51:41 +0100 +Subject: [PATCH 185/220] grub.d: Fix boot_indeterminate getting set on + boot_success=0 boot + +The "grub.d: Split out boot success reset from menu auto hide script" +not only moved the code to clear boot_success and boot_indeterminate +but for some reason also mixed in some broken changes to the +boot_indeterminate handling. + +The boot_indeterminate var is meant to suppress the boot menu after +a reboot from either a selinux-relabel or offline-updates. These +2 special boot scenarios do not set boot_success since there is no +successfull interaction with the user. Instead they increment +boot_indeterminate, and if it is 1 and only when it is 1, so the +first reboot after a "special" boot we suppress the menu. + +To ensure that we do show the menu if we somehow get stuck in a +"special" boot loop where we do special-boots without them +incrementing boot_indeterminate, the code before the +"grub.d: Split out boot success reset from menu auto hide script" +commit would increment boot_indeterminate once when it is 1, so that +even if the "special" boot reboot-loop immediately we would show the +menu on the next boot. + +That commit broke this however, because it not only moves the code, +it also changes it from only "incrementing" boot_indeterminate once to +always incrementing it, except when boot_success == 1 (and we reset it). + +This broken behavior causes the following problem: + +1. Boot a broken kernel, system hangs, power-cycle +2. boot_success now != 1, so we increment boot_indeterminate from 0 + (unset!) to 1. User either simply tries again, or makes some changes + but the end-result still is a system hang, power-cycle +3. Now boot_indeterminate==1 so we do not show the menu even though the + previous boot failed -> BAD + +This commit fixes this by restoring the behavior of setting +boot_indeterminate to 2 when it was 1 before. + +Fixes: "grub.d: Split out boot success reset from menu auto hide script" +Signed-off-by: Hans de Goede +--- + util/grub.d/10_reset_boot_success.in | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/util/grub.d/10_reset_boot_success.in b/util/grub.d/10_reset_boot_success.in +index 6c88d93..737e1ae 100644 +--- a/util/grub.d/10_reset_boot_success.in ++++ b/util/grub.d/10_reset_boot_success.in +@@ -6,18 +6,18 @@ + # + # The boot_success var needs to be set to 1 from userspace to mark a boot successful. + cat << EOF +-insmod increment + # Hiding the menu is ok if last boot was ok or if this is a first boot attempt to boot the entry + if [ "\${boot_success}" = "1" -o "\${boot_indeterminate}" = "1" ]; then + set menu_hide_ok=1 + else + set menu_hide_ok=0 + fi +-# Reset boot_indeterminate after a successful boot, increment otherwise ++# Reset boot_indeterminate after a successful boot + if [ "\${boot_success}" = "1" ] ; then + set boot_indeterminate=0 +-else +- increment boot_indeterminate ++# Avoid boot_indeterminate causing the menu to be hidden more then once ++elif [ "\${boot_indeterminate}" = "1" ]; then ++ set boot_indeterminate=2 + fi + # Reset boot_success for current boot + set boot_success=0 +-- +1.8.3.1 + diff --git a/0186-blscfg-Add-support-for-sorting-the-plus-higher-than-.patch b/0186-blscfg-Add-support-for-sorting-the-plus-higher-than-.patch new file mode 100644 index 0000000000000000000000000000000000000000..03b100c5cdd5d44fe1285ae070a7275827174b8c --- /dev/null +++ b/0186-blscfg-Add-support-for-sorting-the-plus-higher-than-.patch @@ -0,0 +1,62 @@ +From c8a79b3f43d083a70688067f095edea1a3dffb7b Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Mon, 4 Nov 2019 17:33:30 +0100 +Subject: [PATCH 186/220] blscfg: Add support for sorting the plus ('+') higher + than base version + +Handle plus separator. Concept is the same as tilde, except that if one of +the strings ends (base version), the other is considered as higher version. + +A plus character is used for example by the Linux kernel build system to +denote that is the base version plus some changes on top of it. + +Currently for example rpmvercmp("5.3.0", "5.3.0+") will return 0 even when +the two versions are not the same. + +Resolves: rhbz#1767395 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/commands/blscfg.c | 19 +++++++++++++++++-- + 1 file changed, 17 insertions(+), 2 deletions(-) + +diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c +index d78cff7..83b33c1 100644 +--- a/grub-core/commands/blscfg.c ++++ b/grub-core/commands/blscfg.c +@@ -163,8 +163,8 @@ static int vercmp(const char * a, const char * b) + + /* loop through each version segment of str1 and str2 and compare them */ + while (*one || *two) { +- while (*one && !grub_isalnum(*one) && *one != '~') one++; +- while (*two && !grub_isalnum(*two) && *two != '~') two++; ++ while (*one && !grub_isalnum(*one) && *one != '~' && *one != '+') one++; ++ while (*two && !grub_isalnum(*two) && *two != '~' && *two != '+') two++; + + /* handle the tilde separator, it sorts before everything else */ + if (*one == '~' || *two == '~') { +@@ -175,6 +175,21 @@ static int vercmp(const char * a, const char * b) + continue; + } + ++ /* ++ * Handle plus separator. Concept is the same as tilde, ++ * except that if one of the strings ends (base version), ++ * the other is considered as higher version. ++ */ ++ if (*one == '+' || *two == '+') { ++ if (!*one) return -1; ++ if (!*two) return 1; ++ if (*one != '+') goto_return (1); ++ if (*two != '+') goto_return (-1); ++ one++; ++ two++; ++ continue; ++ } ++ + /* If we ran to the end of either, we are finished with the loop */ + if (!(*one && *two)) break; + +-- +1.8.3.1 + diff --git a/0187-Fix-savedefault-with-blscfg.patch b/0187-Fix-savedefault-with-blscfg.patch new file mode 100644 index 0000000000000000000000000000000000000000..ef0d8e68a6103178af7c673331e9b9d29f5d791d --- /dev/null +++ b/0187-Fix-savedefault-with-blscfg.patch @@ -0,0 +1,53 @@ +From 51ba69910056d9720c114ed67d13da766c21a609 Mon Sep 17 00:00:00 2001 +From: Fritz Elfert +Date: Mon, 13 Jan 2020 19:29:58 +0100 +Subject: [PATCH 187/220] Fix savedefault with blscfg + +The GRUB_SAVEDEFAULT option was ignored on a BLS configuration. Fix it by +making the menu entries populated from the BLS files to call savedefault +if a save_default environment variable has been set to "true". + +This variable is set by grub2-mkconfig to the value in GRUB_SAVEDEFAULT. +--- + grub-core/commands/blscfg.c | 5 ++++- + util/grub.d/10_linux.in | 4 ++++ + 2 files changed, 8 insertions(+), 1 deletion(-) + +diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c +index 83b33c1..069db72 100644 +--- a/grub-core/commands/blscfg.c ++++ b/grub-core/commands/blscfg.c +@@ -889,11 +889,14 @@ static void create_entry (struct bls_entry *entry) + + grub_dprintf ("blscfg2", "devicetree %s for id:\"%s\"\n", dt, id); + +- src = grub_xasprintf ("load_video\n" ++ const char *sdval = grub_env_get("save_default"); ++ bool savedefault = ((NULL != sdval) && (grub_strcmp(sdval, "true") == 0)); ++ src = grub_xasprintf ("%sload_video\n" + "set gfxpayload=keep\n" + "insmod gzio\n" + "linux %s%s%s%s\n" + "%s%s", ++ savedefault ? "savedefault\n" : "", + GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", + initrd ? initrd : "", dt ? dt : ""); + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 21a6915..b70dca2 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -152,6 +152,10 @@ EOF + if [ -n "${GRUB_DEFAULT_DTB}" ]; then + ${grub_editenv} - set devicetree="${GRUB_DEFAULT_DTB}" + fi ++ ++ if [ -n "${GRUB_SAVEDEFAULT}" ]; then ++ ${grub_editenv} - set save_default="${GRUB_SAVEDEFAULT}" ++ fi + fi + + exit 0 +-- +1.8.3.1 + diff --git a/0188-Also-define-GRUB_EFI_MAX_ALLOCATION_ADDRESS-for-RISC.patch b/0188-Also-define-GRUB_EFI_MAX_ALLOCATION_ADDRESS-for-RISC.patch new file mode 100644 index 0000000000000000000000000000000000000000..5d109f038934532e0b4281734f589427c8750eb1 --- /dev/null +++ b/0188-Also-define-GRUB_EFI_MAX_ALLOCATION_ADDRESS-for-RISC.patch @@ -0,0 +1,28 @@ +From 2fbd48422e294322dbae05bf90d39c1e92c7846c Mon Sep 17 00:00:00 2001 +From: David Abdurachmanov +Date: Thu, 16 Jan 2020 13:10:10 +0100 +Subject: [PATCH 188/220] Also define GRUB_EFI_MAX_ALLOCATION_ADDRESS for + RISC-V + +The commit "Try to pick better locations for kernel and initrd" missed to +define this macro for the RISC-V (riscv64) architecture, so add it there. + +Signed-off-by: David Abdurachmanov +--- + include/grub/riscv64/efi/memory.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/include/grub/riscv64/efi/memory.h b/include/grub/riscv64/efi/memory.h +index c6cb324..acb61dc 100644 +--- a/include/grub/riscv64/efi/memory.h ++++ b/include/grub/riscv64/efi/memory.h +@@ -2,5 +2,6 @@ + #include + + #define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffffffULL ++#define GRUB_EFI_MAX_ALLOCATION_ADDRESS GRUB_EFI_MAX_USABLE_ADDRESS + + #endif /* ! GRUB_MEMORY_CPU_HEADER */ +-- +1.8.3.1 + diff --git a/0189-chainloader-Define-machine-types-for-RISC-V.patch b/0189-chainloader-Define-machine-types-for-RISC-V.patch new file mode 100644 index 0000000000000000000000000000000000000000..676c44fb2d285f706bca0ba264170dbc2f6a152e --- /dev/null +++ b/0189-chainloader-Define-machine-types-for-RISC-V.patch @@ -0,0 +1,34 @@ +From a41c6f6cd8ad540c6503610b2c438072ebde9117 Mon Sep 17 00:00:00 2001 +From: David Abdurachmanov +Date: Sat, 9 Nov 2019 18:06:32 +0000 +Subject: [PATCH 189/220] chainloader: Define machine types for RISC-V + +The commit "Add secureboot support on efi chainloader" didn't add machine +types for RISC-V, so this patch adds them. + +Note, that grub-core/loader/riscv/linux.c is skipped because Linux is not +supported yet. This patch might need a new revision once that's the case. + +Signed-off-by: David Abdurachmanov +--- + grub-core/loader/efi/chainloader.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index f4ddbed..2c529f7 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -316,6 +316,10 @@ static const grub_uint16_t machine_type __attribute__((__unused__)) = + GRUB_PE32_MACHINE_I386; + #elif defined(__ia64__) + GRUB_PE32_MACHINE_IA64; ++#elif defined(__riscv) && (__riscv_xlen == 32) ++ GRUB_PE32_MACHINE_RISCV32; ++#elif defined(__riscv) && (__riscv_xlen == 64) ++ GRUB_PE32_MACHINE_RISCV64; + #else + #error this architecture is not supported by grub2 + #endif +-- +1.8.3.1 + diff --git a/0190-Add-start-symbol-for-RISC-V.patch b/0190-Add-start-symbol-for-RISC-V.patch new file mode 100644 index 0000000000000000000000000000000000000000..b5538a1c511f6764d95262ca02a0cf8c4c1081b1 --- /dev/null +++ b/0190-Add-start-symbol-for-RISC-V.patch @@ -0,0 +1,31 @@ +From 02d1800799c3ada95d10af90af4d4ed3a479f2e3 Mon Sep 17 00:00:00 2001 +From: David Abdurachmanov +Date: Sat, 9 Nov 2019 19:51:57 +0000 +Subject: [PATCH 190/220] Add start symbol for RISC-V + +All other architectures have start symbol. + +Hopefully this resolves: + + BUILDSTDERR: ././grub-mkimage: error: undefined symbol start. + +Signed-off-by: David Abdurachmanov +--- + grub-core/kern/riscv/efi/startup.S | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/grub-core/kern/riscv/efi/startup.S b/grub-core/kern/riscv/efi/startup.S +index f2a7b2b..7817731 100644 +--- a/grub-core/kern/riscv/efi/startup.S ++++ b/grub-core/kern/riscv/efi/startup.S +@@ -29,6 +29,7 @@ + + .file "startup.S" + .text ++FUNCTION(start) + FUNCTION(_start) + /* + * EFI_SYSTEM_TABLE and EFI_HANDLE are passed in a1/a0. +-- +1.8.3.1 + diff --git a/0191-RISC-V-Add-__clzdi2-symbol.patch b/0191-RISC-V-Add-__clzdi2-symbol.patch new file mode 100644 index 0000000000000000000000000000000000000000..0ddf275924f8b3499eb36df83ebdfde6452ded81 --- /dev/null +++ b/0191-RISC-V-Add-__clzdi2-symbol.patch @@ -0,0 +1,46 @@ +From 679f2a9866b6cc770734e58fffa3e0a54ed7aded Mon Sep 17 00:00:00 2001 +From: Andreas Schwab +Date: Thu, 19 Sep 2019 09:39:04 +0200 +Subject: [PATCH 191/220] RISC-V: Add __clzdi2 symbol + +This is needed for the zstd module build for riscv64-emu. + +Signed-off-by: Andreas Schwab +Reviewed-by: Daniel Kiper +--- + configure.ac | 2 +- + include/grub/compiler-rt-emu.h | 5 +++++ + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 5076d63..eff160b 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1444,7 +1444,7 @@ fi + + # Check for libgcc symbols + if test x"$platform" = xemu; then +-AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms) ++AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __clzdi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms) + fi + + if test "x$TARGET_APPLE_LINKER" = x1 ; then +diff --git a/include/grub/compiler-rt-emu.h b/include/grub/compiler-rt-emu.h +index b21425d..fde620a 100644 +--- a/include/grub/compiler-rt-emu.h ++++ b/include/grub/compiler-rt-emu.h +@@ -74,6 +74,11 @@ unsigned + EXPORT_FUNC (__ctzsi2) (grub_uint32_t x); + #endif + ++#ifdef HAVE___CLZDI2 ++int ++EXPORT_FUNC (__clzdi2) (grub_uint64_t x); ++#endif ++ + #ifdef HAVE___AEABI_UIDIV + grub_uint32_t + EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b); +-- +1.8.3.1 + diff --git a/0192-grub-install-Define-default-platform-for-RISC-V.patch b/0192-grub-install-Define-default-platform-for-RISC-V.patch new file mode 100644 index 0000000000000000000000000000000000000000..ec8684e6ad5fd4a72e2ef40075a79bdefc0a6ed5 --- /dev/null +++ b/0192-grub-install-Define-default-platform-for-RISC-V.patch @@ -0,0 +1,34 @@ +From 06417565c4c66b670f72e5b0cc7ae9e7e147aaad Mon Sep 17 00:00:00 2001 +From: Andreas Schwab +Date: Thu, 15 Aug 2019 16:55:13 +0200 +Subject: [PATCH 192/220] grub-install: Define default platform for RISC-V + +Signed-off-by: Andreas Schwab +Reviewed-by: Daniel Kiper +Reviewed-by: Alexander Graf +--- + util/grub-install.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/util/grub-install.c b/util/grub-install.c +index 37fcdac..8b6a037 100644 +--- a/util/grub-install.c ++++ b/util/grub-install.c +@@ -324,6 +324,14 @@ get_default_platform (void) + return "arm64-efi"; + #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__) + return grub_install_get_default_x86_platform (); ++#elif defined (__riscv) ++#if __riscv_xlen == 32 ++ return "riscv32-efi"; ++#elif __riscv_xlen == 64 ++ return "riscv64-efi"; ++#else ++ return NULL; ++#endif + #else + return NULL; + #endif +-- +1.8.3.1 + diff --git a/0193-Fix-grub-setpassword-o-s-output-path.patch b/0193-Fix-grub-setpassword-o-s-output-path.patch deleted file mode 100644 index f26da574eafbfa90c96ffb2ea913aa8bf72b69ce..0000000000000000000000000000000000000000 --- a/0193-Fix-grub-setpassword-o-s-output-path.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Andy Lutomirski -Date: Sun, 11 Jun 2017 19:17:40 -0400 -Subject: [PATCH] Fix grub-setpassword -o's output path - -The output path is set up in the command line parsing, but completely ignored -in the code that actually writes the files. This patch fixes that. - -Signed-off-by: Peter Jones ---- - util/grub-setpassword.in | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/util/grub-setpassword.in b/util/grub-setpassword.in -index cf70257eed6..5ebf50576d6 100644 ---- a/util/grub-setpassword.in -+++ b/util/grub-setpassword.in -@@ -118,11 +118,11 @@ fi - - # on the ESP, these will fail to set the permissions, but it's okay because - # the directory is protected. --install -m 0600 /dev/null "${grubdir}/user.cfg" 2>/dev/null || : --chmod 0600 "${grubdir}/user.cfg" 2>/dev/null || : --echo "GRUB2_PASSWORD=${MYPASS}" > "${grubdir}/user.cfg" -+install -m 0600 /dev/null "${OUTPUT_PATH}/user.cfg" 2>/dev/null || : -+chmod 0600 "${OUTPUT_PATH}/user.cfg" 2>/dev/null || : -+echo "GRUB2_PASSWORD=${MYPASS}" > "${OUTPUT_PATH}/user.cfg" - --if ! grep -q "^### BEGIN /etc/grub.d/01_users ###$" "${grubdir}/grub.cfg"; then -+if ! grep -q "^### BEGIN /etc/grub.d/01_users ###$" "${OUTPUT_PATH}/grub.cfg"; then - echo "WARNING: The current configuration lacks password support!" - echo "Update your configuration with @grub_mkconfig@ to support this feature." - fi diff --git a/0193-blscfg-Always-use-the-root-variable-to-search-for-BL.patch b/0193-blscfg-Always-use-the-root-variable-to-search-for-BL.patch new file mode 100644 index 0000000000000000000000000000000000000000..612fc3bd051197a67003122560a4c44eba4a4d32 --- /dev/null +++ b/0193-blscfg-Always-use-the-root-variable-to-search-for-BL.patch @@ -0,0 +1,50 @@ +From 2dba8190a3e18837d37b316e82890b60993b18e5 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 14 Jan 2020 17:41:29 +0100 +Subject: [PATCH 193/220] blscfg: Always use the root variable to search for + BLS snippets + +The boot and root variables are set by grub2-mkconfig to tell GRUB what +are the devices and partitions used as the EFI System Partition (ESP) +and to store the /boot directory (or used as the /boot mount point). + +But the boot variable is not needed anymore, this was added because the +blscfg module used to search for the BLS snippets in the ESP, but was +later changed to always search for the BLS files in /boot even for EFI. + +When doing that change, the logic was made backwards and so the boot +variable is wrongly used for legacy BIOS. This only works because this +is set to the same value as the root variable. + +So the correct thing to do is to always use the root variable to search +the BLS snippets, since that is set to the partition that stores them. + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/commands/blscfg.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c +index 069db72..24e35a4 100644 +--- a/grub-core/commands/blscfg.c ++++ b/grub-core/commands/blscfg.c +@@ -1018,14 +1018,12 @@ bls_load_entries (const char *path) + if (!devid) { + #ifdef GRUB_MACHINE_EMU + devid = "host"; +-#elif defined(GRUB_MACHINE_EFI) +- devid = grub_env_get ("root"); + #else +- devid = grub_env_get ("boot"); ++ devid = grub_env_get ("root"); + #endif + if (!devid) + return grub_error (GRUB_ERR_FILE_NOT_FOUND, +- N_("variable `%s' isn't set"), "boot"); ++ N_("variable `%s' isn't set"), "root"); + } + + grub_dprintf ("blscfg", "opening %s\n", devid); +-- +1.8.3.1 + diff --git a/0194-Make-grub-set-password-be-named-like-all-the-other-g.patch b/0194-Make-grub-set-password-be-named-like-all-the-other-g.patch deleted file mode 100644 index 678b3adf4cf4bc966468e657adc5bdcc299e3ee6..0000000000000000000000000000000000000000 --- a/0194-Make-grub-set-password-be-named-like-all-the-other-g.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Sat, 23 Jun 2018 13:19:15 -0400 -Subject: [PATCH] Make grub-set-password be named like all the other grub - utilities - -Signed-off-by: Peter Jones ---- - configure.ac | 2 +- - Makefile.util.def | 4 ++-- - .gitignore | 4 ++-- - util/{grub-setpassword.8 => grub-set-password.8} | 8 ++++---- - util/{grub-setpassword.in => grub-set-password.in} | 0 - 5 files changed, 9 insertions(+), 9 deletions(-) - rename util/{grub-setpassword.8 => grub-set-password.8} (50%) - rename util/{grub-setpassword.in => grub-set-password.in} (100%) - -diff --git a/configure.ac b/configure.ac -index 359cac3c26b..5f47a9265f3 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -66,7 +66,7 @@ grub_TRANSFORM([grub-mkrelpath]) - grub_TRANSFORM([grub-mkrescue]) - grub_TRANSFORM([grub-probe]) - grub_TRANSFORM([grub-reboot]) --grub_TRANSFORM([grub-setpassword]) -+grub_TRANSFORM([grub-set-password]) - grub_TRANSFORM([grub-rpm-sort]) - grub_TRANSFORM([grub-script-check]) - grub_TRANSFORM([grub-set-default]) -diff --git a/Makefile.util.def b/Makefile.util.def -index 5da55393291..97cd8bdebd9 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -756,8 +756,8 @@ script = { - }; - - script = { -- name = grub-setpassword; -- common = util/grub-setpassword.in; -+ name = grub-set-password; -+ common = util/grub-set-password.in; - mansection = 8; - installdir = sbin; - }; -diff --git a/.gitignore b/.gitignore -index 6c4cfc53781..a999024652e 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -115,8 +115,8 @@ grub-*.tar.* - /grub*-set-bootflag.1 - /grub*-set-default - /grub*-set-default.8 --/grub*-setsetpassword --/grub*-setsetpassword.8 -+/grub*-set-password -+/grub*-set-password.8 - /grub*-shell - /grub*-shell-tester - /grub*-sparc64-setup -diff --git a/util/grub-setpassword.8 b/util/grub-set-password.8 -similarity index 50% -rename from util/grub-setpassword.8 -rename to util/grub-set-password.8 -index dc91dd6697b..9646546e43d 100644 ---- a/util/grub-setpassword.8 -+++ b/util/grub-set-password.8 -@@ -1,12 +1,12 @@ --.TH GRUB-SETPASSWORD 3 "Thu Jun 25 2015" -+.TH GRUB-SET-PASSWORD 3 "Thu Jun 25 2015" - .SH NAME --\fBgrub-setpassword\fR \(em Generate the user.cfg file containing the hashed grub bootloader password. -+\fBgrub-set-password\fR \(em Generate the user.cfg file containing the hashed grub bootloader password. - - .SH SYNOPSIS --\fBgrub-setpassword\fR [OPTION] -+\fBgrub-set-password\fR [OPTION] - - .SH DESCRIPTION --\fBgrub-setpassword\fR outputs the user.cfg file which contains the hashed GRUB bootloader password. This utility only supports configurations where there is a single root user. -+\fBgrub-set-password\fR outputs the user.cfg file which contains the hashed GRUB bootloader password. This utility only supports configurations where there is a single root user. - - The file has the format: - GRUB2_PASSWORD=<\fIhashed password\fR>. -diff --git a/util/grub-setpassword.in b/util/grub-set-password.in -similarity index 100% -rename from util/grub-setpassword.in -rename to util/grub-set-password.in diff --git a/0194-efi-http-Export-fw-http-_path-variables-to-make-them.patch b/0194-efi-http-Export-fw-http-_path-variables-to-make-them.patch new file mode 100644 index 0000000000000000000000000000000000000000..0fd459730438247063af5657d51ac3b1d89c3f7b --- /dev/null +++ b/0194-efi-http-Export-fw-http-_path-variables-to-make-them.patch @@ -0,0 +1,54 @@ +From 14623de497794581948d8df3e69d22833588da43 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Thu, 5 Mar 2020 16:21:47 +0100 +Subject: [PATCH 194/220] efi/http: Export {fw,http}_path variables to make + them global + +The fw_path environment variable is used by http_configure() function to +determine the HTTP path that should be used as prefix when using relative +HTTP paths. And this is stored in the http_path environment variable. + +Later, that variable is looked up by grub_efihttp_open() to generate the +complete path to be used in the HTTP request. + +But these variables are not exported, which means that are not global and +so are only found in the initial context. + +This can cause commands like configfile that create a new context to fail +because the fw_path and http_path variables will not be found. + +Resolves: rhbz#1616395 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/kern/main.c | 1 + + grub-core/net/efi/http.c | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c +index dcf4872..9bf6a8b 100644 +--- a/grub-core/kern/main.c ++++ b/grub-core/kern/main.c +@@ -142,6 +142,7 @@ grub_set_prefix_and_root (void) + if (fw_path) + { + grub_env_set ("fw_path", fw_path); ++ grub_env_export ("fw_path"); + grub_dprintf ("fw_path", "fw_path:\"%s\"\n", fw_path); + grub_free (fw_path); + } +diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c +index de351b2..755b7a6 100644 +--- a/grub-core/net/efi/http.c ++++ b/grub-core/net/efi/http.c +@@ -39,6 +39,7 @@ http_configure (struct grub_efi_net_device *dev, int prefer_ip6) + http_path++; + grub_env_unset ("http_path"); + grub_env_set ("http_path", http_path); ++ grub_env_export ("http_path"); + } + } + +-- +1.8.3.1 + diff --git a/0195-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch b/0195-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch new file mode 100644 index 0000000000000000000000000000000000000000..995d9c7c6f663488d25b610388a1b087d54618d3 --- /dev/null +++ b/0195-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch @@ -0,0 +1,118 @@ +From 0b3d15aa1bae1afbc7bd0b50a12e56d4f9b1248d Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Thu, 5 Mar 2020 16:21:58 +0100 +Subject: [PATCH 195/220] efi/http: Enclose literal IPv6 addresses in square + brackets + +According to RFC 2732 (https://www.ietf.org/rfc/rfc2732.txt), literal IPv6 +addresses must be enclosed in square brackets. But GRUB currently does not +do this and is causing HTTP servers to send Bad Request (400) responses. + +For example, the following is the HTTP stream when fetching a config file: + +HEAD /EFI/BOOT/grub.cfg HTTP/1.1 +Host: 2000:dead:beef:a::1 +Accept: */* +User-Agent: UefiHttpBoot/1.0 + +HTTP/1.1 400 Bad Request +Date: Thu, 05 Mar 2020 14:46:02 GMT +Server: Apache/2.4.41 (Fedora) OpenSSL/1.1.1d +Connection: close +Content-Type: text/html; charset=iso-8859-1 + +and after enclosing the IPv6 address the HTTP request is successful: + +HEAD /EFI/BOOT/grub.cfg HTTP/1.1 +Host: [2000:dead:beef:a::1] +Accept: */* +User-Agent: UefiHttpBoot/1.0 + +HTTP/1.1 200 OK +Date: Thu, 05 Mar 2020 14:48:04 GMT +Server: Apache/2.4.41 (Fedora) OpenSSL/1.1.1d +Last-Modified: Thu, 27 Feb 2020 17:45:58 GMT +ETag: "206-59f924b24b1da" +Accept-Ranges: bytes +Content-Length: 518 + +Resolves: rhbz#1732765 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/net/efi/http.c | 37 ++++++++++++++++++++++++++++--------- + 1 file changed, 28 insertions(+), 9 deletions(-) + +diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c +index 755b7a6..fc8cb25 100644 +--- a/grub-core/net/efi/http.c ++++ b/grub-core/net/efi/http.c +@@ -158,13 +158,7 @@ efihttp_request (grub_efi_http_t *http, char *server, char *name, int use_https, + grub_efi_status_t status; + grub_efi_boot_services_t *b = grub_efi_system_table->boot_services; + char *url = NULL; +- +- request_headers[0].field_name = (grub_efi_char8_t *)"Host"; +- request_headers[0].field_value = (grub_efi_char8_t *)server; +- request_headers[1].field_name = (grub_efi_char8_t *)"Accept"; +- request_headers[1].field_value = (grub_efi_char8_t *)"*/*"; +- request_headers[2].field_name = (grub_efi_char8_t *)"User-Agent"; +- request_headers[2].field_value = (grub_efi_char8_t *)"UefiHttpBoot/1.0"; ++ char *hostname = NULL; + + { + grub_efi_ipv6_address_t address; +@@ -174,9 +168,24 @@ efihttp_request (grub_efi_http_t *http, char *server, char *name, int use_https, + const char *protocol = (use_https == 1) ? "https" : "http"; + + if (grub_efi_string_to_ip6_address (server, &address, &rest) && *rest == 0) +- url = grub_xasprintf ("%s://[%s]%s", protocol, server, name); ++ { ++ hostname = grub_xasprintf ("[%s]", server); ++ if (!hostname) ++ return GRUB_ERR_OUT_OF_MEMORY; ++ ++ server = hostname; ++ ++ url = grub_xasprintf ("%s://%s%s", protocol, server, name); ++ if (!url) ++ { ++ grub_free (hostname); ++ return GRUB_ERR_OUT_OF_MEMORY; ++ } ++ } + else +- url = grub_xasprintf ("%s://%s%s", protocol, server, name); ++ { ++ url = grub_xasprintf ("%s://%s%s", protocol, server, name); ++ } + + if (!url) + { +@@ -199,6 +208,13 @@ efihttp_request (grub_efi_http_t *http, char *server, char *name, int use_https, + request_data.url = ucs2_url; + } + ++ request_headers[0].field_name = (grub_efi_char8_t *)"Host"; ++ request_headers[0].field_value = (grub_efi_char8_t *)server; ++ request_headers[1].field_name = (grub_efi_char8_t *)"Accept"; ++ request_headers[1].field_value = (grub_efi_char8_t *)"*/*"; ++ request_headers[2].field_name = (grub_efi_char8_t *)"User-Agent"; ++ request_headers[2].field_value = (grub_efi_char8_t *)"UefiHttpBoot/1.0"; ++ + request_data.method = (headeronly > 0) ? GRUB_EFI_HTTPMETHODHEAD : GRUB_EFI_HTTPMETHODGET; + + request_message.data.request = &request_data; +@@ -228,6 +244,9 @@ efihttp_request (grub_efi_http_t *http, char *server, char *name, int use_https, + + status = efi_call_2 (http->request, http, &request_token); + ++ if (hostname) ++ grub_free (hostname); ++ + if (status != GRUB_EFI_SUCCESS) + { + efi_call_1 (b->close_event, request_token.event); +-- +1.8.3.1 + diff --git a/0196-00_menu_auto_hide-Use-a-timeout-of-60s-for-menu_show.patch b/0196-00_menu_auto_hide-Use-a-timeout-of-60s-for-menu_show.patch deleted file mode 100644 index 367fc6ca6623a4ab5664b2a6c77555b6ee90133a..0000000000000000000000000000000000000000 --- a/0196-00_menu_auto_hide-Use-a-timeout-of-60s-for-menu_show.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Tue, 26 Jun 2018 12:44:29 +0200 -Subject: [PATCH] 00_menu_auto_hide: Use a timeout of 60s for menu_show_once, - rather then no timeout - -On some UEFI systems with fastboot enabled (USB) keyboards don't work at -all, not even when explictly asking for keyboard input. - -So lets change the timeout from not set (no timeout) to 60 seconds, so -that on such systems if the menu was requested we continue with the -default choice after 60 seconds. - -Signed-off-by: Hans de Goede ---- - util/grub.d/00_menu_auto_hide.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/util/grub.d/00_menu_auto_hide.in b/util/grub.d/00_menu_auto_hide.in -index a10fe45bb2c..ca95c0d1c9f 100644 ---- a/util/grub.d/00_menu_auto_hide.in -+++ b/util/grub.d/00_menu_auto_hide.in -@@ -33,7 +33,7 @@ if [ x\$feature_timeout_style = xy ] ; then - unset menu_show_once - save_env menu_show_once - set timeout_style=menu -- unset timeout -+ set timeout=60 - elif [ "\${menu_auto_hide}" -a "\${last_boot_ok}" = "1" ]; then - set orig_timeout_style=\${timeout_style} - set orig_timeout=\${timeout} diff --git a/0196-efi-net-Allow-to-specify-a-port-number-in-addresses.patch b/0196-efi-net-Allow-to-specify-a-port-number-in-addresses.patch new file mode 100644 index 0000000000000000000000000000000000000000..79750fcb295a0e14013f5856124722a923e8fbe1 --- /dev/null +++ b/0196-efi-net-Allow-to-specify-a-port-number-in-addresses.patch @@ -0,0 +1,51 @@ +From f1933ae113b13658743a43e1bbbcca76d88e45e3 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Mon, 9 Mar 2020 15:29:45 +0100 +Subject: [PATCH 196/220] efi/net: Allow to specify a port number in addresses + +The grub_efi_net_parse_address() function is not covering the case where a +port number is specified in an IPv4 or IPv6 address, so will fail to parse +the network address. + +For most cases the issue is harmless, because the function is only used to +match an address with a network interface and if fails the default is used. + +But still is a bug that has to be fixed and it causes error messages to be +printed like the following: + +error: net/efi/net.c:782:unrecognised network address '192.168.122.1:8080' + +error: net/efi/net.c:781:unrecognised network address '[2000:dead:beef:a::1]:8080' + +Resolves: rhbz#1732765 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/net/efi/net.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c +index 6603cd8..8457393 100644 +--- a/grub-core/net/efi/net.c ++++ b/grub-core/net/efi/net.c +@@ -742,7 +742,7 @@ grub_efi_net_parse_address (const char *address, + return GRUB_ERR_NONE; + } + } +- else if (*rest == 0) ++ else if (*rest == 0 || *rest == ':') + { + grub_uint32_t subnet_mask = 0xffffffffU; + grub_memcpy (ip4->subnet_mask, &subnet_mask, sizeof (ip4->subnet_mask)); +@@ -768,7 +768,7 @@ grub_efi_net_parse_address (const char *address, + return GRUB_ERR_NONE; + } + } +- else if (*rest == 0) ++ else if (*rest == 0 || *rest == ':') + { + ip6->prefix_length = 128; + ip6->is_anycast = 0; +-- +1.8.3.1 + diff --git a/0197-00_menu_auto_hide-Reduce-number-of-save_env-calls.patch b/0197-00_menu_auto_hide-Reduce-number-of-save_env-calls.patch deleted file mode 100644 index 6993508283edbc010770a525e7daa88830b0a692..0000000000000000000000000000000000000000 --- a/0197-00_menu_auto_hide-Reduce-number-of-save_env-calls.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Wed, 27 Jun 2018 13:33:43 +0200 -Subject: [PATCH] 00_menu_auto_hide: Reduce number of save_env calls - -Normally boot_success will be 1 on every boot (as normally the -previous boot will have been successful). This means that we end -up in the code-path to set boot_indeterminate to 0 every boot. - -So we do 2 separate save_env calls each boot, one for boot_indeterminate -and one for boot_success. This results in 2 writes to the disk. - -This commit makes us save both boot_success and boot_indeterminate -in a single call, reducing the number of writes, this reducing wear -and tear on the underlying storage. - -Signed-off-by: Hans de Goede ---- - util/grub.d/00_menu_auto_hide.in | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) - -diff --git a/util/grub.d/00_menu_auto_hide.in b/util/grub.d/00_menu_auto_hide.in -index ca95c0d1c9f..ad175870a54 100644 ---- a/util/grub.d/00_menu_auto_hide.in -+++ b/util/grub.d/00_menu_auto_hide.in -@@ -19,14 +19,12 @@ fi - # Reset boot_indeterminate after a successful boot - if [ "\${boot_success}" = "1" ] ; then - set boot_indeterminate=0 -- save_env boot_indeterminate - # Avoid boot_indeterminate causing the menu to be hidden more then once - elif [ "\${boot_indeterminate}" = "1" ]; then - set boot_indeterminate=2 -- save_env boot_indeterminate - fi - set boot_success=0 --save_env boot_success -+save_env boot_success boot_indeterminate - - if [ x\$feature_timeout_style = xy ] ; then - if [ "\${menu_show_once}" ]; then diff --git a/0197-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch b/0197-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch new file mode 100644 index 0000000000000000000000000000000000000000..cb8da9f3d7577d0214a151b619d6b000dfbd9fde --- /dev/null +++ b/0197-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch @@ -0,0 +1,51 @@ +From 9c470c8bc1921a38d15c568f25aada9e2bdb3c71 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Mon, 9 Mar 2020 15:30:05 +0100 +Subject: [PATCH 197/220] efi/ip4_config: Improve check to detect literal IPv6 + addresses + +The grub_efi_string_to_ip4_address() function wrongly assumes that an IPv6 +address is an IPv4 address, because it doesn't take into account the case +of a caller passing an IPv6 address as a string. + +This leads to the grub_efi_net_parse_address() function to fail and print +the following error message: + +error: net/efi/net.c:785:unrecognised network address '2000:dead:beef:a::1' + +Resolves: rhbz#1732765 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/net/efi/ip4_config.c | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/grub-core/net/efi/ip4_config.c b/grub-core/net/efi/ip4_config.c +index b711a5d..313c818 100644 +--- a/grub-core/net/efi/ip4_config.c ++++ b/grub-core/net/efi/ip4_config.c +@@ -56,9 +56,20 @@ int + grub_efi_string_to_ip4_address (const char *val, grub_efi_ipv4_address_t *address, const char **rest) + { + grub_uint32_t newip = 0; +- int i; ++ int i, ncolon = 0; + const char *ptr = val; + ++ /* Check that is not an IPv6 address */ ++ for (i = 0; i < grub_strlen(ptr); i++) ++ { ++ if (ptr[i] == '[' && i == 0) ++ return 0; ++ ++ if (ptr[i] == ':') ++ if (i == 0 || ++ncolon == 2) ++ return 0; ++ } ++ + for (i = 0; i < 4; i++) + { + unsigned long t; +-- +1.8.3.1 + diff --git a/0198-30_uefi-firmware-fix-use-with-sys-firmware-efi-efiva.patch b/0198-30_uefi-firmware-fix-use-with-sys-firmware-efi-efiva.patch deleted file mode 100644 index e713d69f2a8fffed10b1b3875a2d96f1091637ff..0000000000000000000000000000000000000000 --- a/0198-30_uefi-firmware-fix-use-with-sys-firmware-efi-efiva.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Fri, 29 Jun 2018 10:08:22 +0200 -Subject: [PATCH] 30_uefi-firmware: fix use with /sys/firmware/efi/efivars - -Fix 30_uefi-firmware checking for the obsolete /sys/firmware/efi/vars -instead of for the new efivarfs mounted at /sys/firmware/efi/efivars. - -Which goes to show that I really should have tested this before blindly -importing it from Ubuntu. - -Signed-off-by: Hans de Goede ---- - util/grub.d/30_uefi-firmware.in | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/util/grub.d/30_uefi-firmware.in b/util/grub.d/30_uefi-firmware.in -index 3c9f533d8c6..93ececffea7 100644 ---- a/util/grub.d/30_uefi-firmware.in -+++ b/util/grub.d/30_uefi-firmware.in -@@ -26,12 +26,12 @@ export TEXTDOMAINDIR="@localedir@" - - . "@datadir@/@PACKAGE@/grub-mkconfig_lib" - --efi_vars_dir=/sys/firmware/efi/vars -+efi_vars_dir=/sys/firmware/efi/efivars - EFI_GLOBAL_VARIABLE=8be4df61-93ca-11d2-aa0d-00e098032b8c --OsIndications="$efi_vars_dir/OsIndicationsSupported-$EFI_GLOBAL_VARIABLE/data" -+OsIndications="$efi_vars_dir/OsIndicationsSupported-$EFI_GLOBAL_VARIABLE" - - if [ -e "$OsIndications" ] && \ -- [ "$(( $(printf 0x%x \'"$(cat $OsIndications | cut -b1)") & 1 ))" = 1 ]; then -+ [ "$(( $(printf 0x%x \'"$(cat $OsIndications | cut -b5)") & 1 ))" = 1 ]; then - LABEL="System setup" - - gettext_printf "Adding boot menu entry for EFI firmware configuration\n" >&2 diff --git a/0198-efi-net-Print-a-debug-message-if-parsing-the-address.patch b/0198-efi-net-Print-a-debug-message-if-parsing-the-address.patch new file mode 100644 index 0000000000000000000000000000000000000000..b38c6a75edbd649ae32edb057847e734bac882ce --- /dev/null +++ b/0198-efi-net-Print-a-debug-message-if-parsing-the-address.patch @@ -0,0 +1,72 @@ +From 51b1f81e7744031f7b3ad96a8264e493be5b069c Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 10 Mar 2020 11:23:49 +0100 +Subject: [PATCH 198/220] efi/net: Print a debug message if parsing the address + fails + +Currently if parsing the address fails an error message is printed. But in +most cases this isn't a fatal error since the grub_efi_net_parse_address() +function is only used to match an address with a network interface to use. + +And if this fails, the default interface is used which is good enough for +most cases. So instead of printing an error that would pollute the console +just print a debug message if the address is not parsed correctly. + +A user can enable debug messages for the efinet driver to have information +about the failure and the fact that the default interface is being used. + +Related: rhbz#1732765 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/net/efi/net.c | 18 +++++++++++------- + 1 file changed, 11 insertions(+), 7 deletions(-) + +diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c +index 8457393..a3f0535 100644 +--- a/grub-core/net/efi/net.c ++++ b/grub-core/net/efi/net.c +@@ -778,9 +778,9 @@ grub_efi_net_parse_address (const char *address, + } + } + +- return grub_error (GRUB_ERR_NET_BAD_ADDRESS, +- N_("unrecognised network address `%s'"), +- address); ++ grub_dprintf ("efinet", "unrecognised network address '%s'\n", address); ++ ++ return GRUB_ERR_NET_BAD_ADDRESS; + } + + static grub_efi_net_interface_t * +@@ -795,10 +795,7 @@ match_route (const char *server) + err = grub_efi_net_parse_address (server, &ip4, &ip6, &is_ip6, 0); + + if (err) +- { +- grub_print_error (); + return NULL; +- } + + if (is_ip6) + { +@@ -1233,8 +1230,15 @@ grub_net_open_real (const char *name __attribute__ ((unused))) + /*FIXME: Use DNS translate name to address */ + net_interface = match_route (server); + ++ if (!net_interface && net_default_interface) ++ { ++ net_interface = net_default_interface; ++ grub_dprintf ("efinet", "interface lookup failed, using default '%s'\n", ++ net_interface->name); ++ } ++ + /*XXX: should we check device with default gateway ? */ +- if (!net_interface && !(net_interface = net_default_interface)) ++ if (!net_interface) + { + grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' no route found"), + name); +-- +1.8.3.1 + diff --git a/0199-blscfg-return-NULL-instead-of-a-zero-length-array-in.patch b/0199-blscfg-return-NULL-instead-of-a-zero-length-array-in.patch new file mode 100644 index 0000000000000000000000000000000000000000..c27f78940a42c51e92068281e05c8ce854e16f5b --- /dev/null +++ b/0199-blscfg-return-NULL-instead-of-a-zero-length-array-in.patch @@ -0,0 +1,41 @@ +From 2b8388901cc52d875baa490a97dd314ef51ed0d9 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Mon, 16 Mar 2020 13:51:45 +0100 +Subject: [PATCH 199/220] blscfg: return NULL instead of a zero-length array in + bls_make_list() + +The bls_make_list() function returns a list of all the values for a given +key and if there is none a NULL pointer should be returned. But currently +is returnin a zero-length array instead. + +This makes the callers to wrongly assume that there are values for a key +and populate wrong menu entries. For example menu entries are populated +with an initrd command even if there is no initrd fiel in the BLS file. + +Resolves: rhbz#1806022 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/commands/blscfg.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c +index 24e35a4..9263a5c 100644 +--- a/grub-core/commands/blscfg.c ++++ b/grub-core/commands/blscfg.c +@@ -600,6 +600,12 @@ static char **bls_make_list (struct bls_entry *entry, const char *key, int *num) + list[nlist] = NULL; + } + ++ if (!nlist) ++ { ++ grub_free (list); ++ return NULL; ++ } ++ + if (num) + *num = nlist; + +-- +1.8.3.1 + diff --git a/0200-grub-switch-to-blscfg-Update-grub2-binary-in-ESP-for.patch b/0200-grub-switch-to-blscfg-Update-grub2-binary-in-ESP-for.patch new file mode 100644 index 0000000000000000000000000000000000000000..b06d6c93e6c1f32b7ce2ebcbef627995072876f8 --- /dev/null +++ b/0200-grub-switch-to-blscfg-Update-grub2-binary-in-ESP-for.patch @@ -0,0 +1,40 @@ +From 8695bfa3538b24635c77242669cb35a70603e599 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Thu, 26 Mar 2020 15:08:30 +0100 +Subject: [PATCH 200/220] grub-switch-to-blscfg: Update grub2 binary in ESP for + OSTree systems + +The grub2 EFI binary in the ESP isn't updated as a part of an OSTree update +transaction. So let's make the script to update this and also create a file +to indicate that the installed version has support for the blscfg module. + +Related: rhbz#1751272 + +Signed-off-by: Javier Martinez Canillas +--- + util/grub-switch-to-blscfg.in | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in +index 49b3985..a05a8d9 100644 +--- a/util/grub-switch-to-blscfg.in ++++ b/util/grub-switch-to-blscfg.in +@@ -266,6 +266,15 @@ copy_bls() { + fi + } + ++# The grub2 EFI binary is not copied to the ESP as a part of an ostree ++# transaction. Make sure a grub2 version with BLS support is installed. ++if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars/; then ++ grub_binary="$(find /usr/lib/ostree-boot/efi/EFI/${EFIDIR}/ -name grub*.efi)" ++ cp ${grub_binary} ${grubdir} || exit 1 ++ # Create a hidden file to indicate that grub2 now has BLS support. ++ touch /boot/grub2/.grub2-blscfg-supported ++fi ++ + GENERATE=0 + if grep '^GRUB_ENABLE_BLSCFG=.*' "${etcdefaultgrub}" \ + | grep -vq '^GRUB_ENABLE_BLSCFG="*true"*\s*$' ; then +-- +1.8.3.1 + diff --git a/0201-blscfg-remove-unused-typedef.patch b/0201-blscfg-remove-unused-typedef.patch deleted file mode 100644 index 819a144e54bb04934424d7b0122c72fe747d3496..0000000000000000000000000000000000000000 --- a/0201-blscfg-remove-unused-typedef.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Wed, 11 Jul 2018 14:59:52 +0100 -Subject: [PATCH] blscfg: remove unused typedef -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This is unused since ‘Use BLS fragment filename as menu entry id and for -criteria to sort’. - -Signed-off-by: Will Thompson ---- - grub-core/commands/blscfg.c | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index cd8659384e4..82fb6cdd182 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -327,8 +327,6 @@ finish: - return ret; - } - --typedef int (*void_cmp_t)(void *, void *); -- - static int bls_cmp(const void *p0, const void *p1, void *state UNUSED) - { - struct bls_entry * e0 = *(struct bls_entry **)p0; diff --git a/0201-grub-switch-to-blscfg-Only-mark-GRUB-as-BLS-supporte.patch b/0201-grub-switch-to-blscfg-Only-mark-GRUB-as-BLS-supporte.patch new file mode 100644 index 0000000000000000000000000000000000000000..920606a995e9f349881db7de742c256319328a16 --- /dev/null +++ b/0201-grub-switch-to-blscfg-Only-mark-GRUB-as-BLS-supporte.patch @@ -0,0 +1,40 @@ +From 96e237b59b621bcfe6f5fa888fe583def382d415 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Thu, 2 Apr 2020 11:07:24 +0200 +Subject: [PATCH 201/220] grub-switch-to-blscfg: Only mark GRUB as BLS + supported if blsdir isn't set + +If the user set the blsdir environemnt variable to a path that is not the +default where ostree writes the BLS snippets, the blscfg module won't be +able to parse them and can lead to not having any menu entries on boot. + +So to minimize the risk of things going wrong when dropping the 15_ostree +script used by ostree to create the menu entries, only mark the bootloader +as BLS supported if the blsdir variable has not been set. + +Signed-off-by: Javier Martinez Canillas +--- + util/grub-switch-to-blscfg.in | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in +index a05a8d9..4bbed8e 100644 +--- a/util/grub-switch-to-blscfg.in ++++ b/util/grub-switch-to-blscfg.in +@@ -267,8 +267,11 @@ copy_bls() { + } + + # The grub2 EFI binary is not copied to the ESP as a part of an ostree +-# transaction. Make sure a grub2 version with BLS support is installed. +-if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars/; then ++# transaction. Make sure a grub2 version with BLS support is installed ++# but only do this if the blsdir is not set, to make sure that the BLS ++# parsing module will search for the BLS snippets in the default path. ++if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars && \ ++ ! ${grub_editenv} - list | grep -q blsdir; then + grub_binary="$(find /usr/lib/ostree-boot/efi/EFI/${EFIDIR}/ -name grub*.efi)" + cp ${grub_binary} ${grubdir} || exit 1 + # Create a hidden file to indicate that grub2 now has BLS support. +-- +1.8.3.1 + diff --git a/0202-10_linux.in-Merge-logic-from-10_linux_bls-and-drop-t.patch b/0202-10_linux.in-Merge-logic-from-10_linux_bls-and-drop-t.patch new file mode 100644 index 0000000000000000000000000000000000000000..576503bc0583dd9ef45ed5e148b79ec2750ab837 --- /dev/null +++ b/0202-10_linux.in-Merge-logic-from-10_linux_bls-and-drop-t.patch @@ -0,0 +1,665 @@ +From 25d1ed30a9330c8b3d84fdc3e0812ef5d1db5238 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 31 Mar 2020 12:35:42 +0200 +Subject: [PATCH 202/220] 10_linux.in: Merge logic from 10_linux_bls and drop + that script + +There's a 10_linux_bls snippet that's used in ppc64le machines to generate +a set of menuentry commands by parsing BLS configs in /boot/loader/entries. + +This was made because on PowerNV ppc64le machines that boot using the OPAL +firmware, there could be an old version of the Petitboot bootloader that +doesn't have support to parse BLS snippets. + +But there is no need to have a separate GRUB script for that and the logic +could just be part of the usual 10_linux snippet. + +Also the BLS files could be used directly if the bootloader has support to +parse them, which is the case for GRUB that's used in ppc64le OF or if the +Petitboot used in ppc64le OPAL machines is version 1.8.0 or newer. + +So only generate the menuentry commands from the BLS snippets in the case +of OPAL machines with an old Petitboot version. + +Signed-off-by: Javier Martinez Canillas +--- + Makefile.util.def | 7 - + util/grub.d/10_linux.in | 97 ++++++++- + util/grub.d/10_linux_bls.in | 470 -------------------------------------------- + 3 files changed, 96 insertions(+), 478 deletions(-) + delete mode 100644 util/grub.d/10_linux_bls.in + +diff --git a/Makefile.util.def b/Makefile.util.def +index 1fa92ca..f3a6996 100644 +--- a/Makefile.util.def ++++ b/Makefile.util.def +@@ -518,13 +518,6 @@ script = { + }; + + script = { +- name = '10_linux_bls'; +- common = util/grub.d/10_linux_bls.in; +- installdir = grubconf; +- condition = COND_HOST_LINUX; +-}; +- +-script = { + name = '10_reset_boot_success'; + common = util/grub.d/10_reset_boot_success.in; + installdir = grubconf; +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index b70dca2..c72cc32 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -84,18 +84,86 @@ esac + + populate_header_warn() + { ++if [ "x${BLS_POPULATE_MENU}" = "xtrue" ]; then ++ bls_parser="10_linux script" ++else ++ bls_parser="blscfg command" ++fi + cat <&2 ++ ++ files=($(for bls in ${blsdir}/*.conf ; do ++ if ! [[ -e "${bls}" ]] ; then ++ continue ++ fi ++ bls="${bls%.conf}" ++ bls="${bls##*/}" ++ echo "${bls}" ++ done | ${kernel_sort} | tac)) || : ++ ++ for bls in "${files[@]}" ; do ++ read_config "${blsdir}/${bls}.conf" ++ ++ menu="${menu}menuentry '${title}' ${grub_arg} --id=${bls} {\n" ++ menu="${menu}\t linux ${linux} ${options}\n" ++ if [ -n "${initrd}" ] ; then ++ menu="${menu}\t initrd ${boot_prefix}${initrd}\n" ++ fi ++ menu="${menu}}\n\n" ++ done ++ # The printf command seems to be more reliable across shells for special character (\n, \t) evaluation ++ printf "$menu" ++} ++ + if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then + if [ x$dirname = x/ ]; then + if [ -z "${prepare_root_cache}" ]; then +@@ -115,6 +183,26 @@ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then + prepare_grub_to_access_device_with_variable boot ${boot_device} + fi + ++ arch="$(uname -m)" ++ if [ "x${arch}" = "xppc64le" ] && [ -d /sys/firmware/opal ]; then ++ ++ petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot" ++ ++ if test -e ${petitboot_path}; then ++ read -a petitboot_version < ${petitboot_path} ++ petitboot_version="$(echo ${petitboot_version//v})" ++ major_version="$(echo ${petitboot_version} | cut -d . -f1)" ++ minor_version="$(echo ${petitboot_version} | cut -d . -f2)" ++ ++ if test -z ${petitboot_version} || test ${major_version} -lt 1 || \ ++ test ${major_version} -eq 1 -a ${minor_version} -lt 8; then ++ BLS_POPULATE_MENU="true" ++ fi ++ else ++ BLS_POPULATE_MENU="true" ++ fi ++ fi ++ + populate_header_warn + + cat << EOF +@@ -129,10 +217,17 @@ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then + if [ -z "\${kernelopts}" ]; then + set kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" + fi ++EOF ++ ++ if [ "x${BLS_POPULATE_MENU}" = "xtrue" ]; then ++ populate_menu ++ else ++ cat << EOF + + insmod blscfg + blscfg + EOF ++ fi + + if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then + blsdir="/boot/loader/entries" +diff --git a/util/grub.d/10_linux_bls.in b/util/grub.d/10_linux_bls.in +deleted file mode 100644 +index 68fbedf..0000000 +--- a/util/grub.d/10_linux_bls.in ++++ /dev/null +@@ -1,470 +0,0 @@ +-#! /bin/sh +-set -e +- +-# grub-mkconfig helper script. +-# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc. +-# +-# GRUB is free software: you can redistribute it and/or modify +-# it under the terms of the GNU General Public License as published by +-# the Free Software Foundation, either version 3 of the License, or +-# (at your option) any later version. +-# +-# GRUB is distributed in the hope that it will be useful, +-# but WITHOUT ANY WARRANTY; without even the implied warranty of +-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-# GNU General Public License for more details. +-# +-# You should have received a copy of the GNU General Public License +-# along with GRUB. If not, see . +- +-prefix="@prefix@" +-exec_prefix="@exec_prefix@" +-datarootdir="@datarootdir@" +- +-. "$pkgdatadir/grub-mkconfig_lib" +- +-export TEXTDOMAIN=@PACKAGE@ +-export TEXTDOMAINDIR="@localedir@" +- +-CLASS="--class gnu-linux --class gnu --class os --unrestricted" +- +-if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then +- OS="$(eval $(grep PRETTY_NAME /etc/os-release) ; echo ${PRETTY_NAME})" +- CLASS="--class $(eval $(grep '^ID_LIKE=\|^ID=' /etc/os-release) ; [ -n "${ID_LIKE}" ] && echo ${ID_LIKE} || echo ${ID}) ${CLASS}" +-else +- OS="${GRUB_DISTRIBUTOR}" +- CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}" +-fi +- +-# loop-AES arranges things so that /dev/loop/X can be our root device, but +-# the initrds that Linux uses don't like that. +-case ${GRUB_DEVICE} in +- /dev/loop/*|/dev/loop[0-9]) +- GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"` +- ;; +-esac +- +-# Default to disabling partition uuid support to maintian compatibility with +-# older kernels. +-GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true} +- +-# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter +-# and mounting btrfs requires user space scanning, so force UUID in this case. +-if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] ) \ +- || ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ +- && [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \ +- || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ +- && ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \ +- || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then +- LINUX_ROOT_DEVICE=${GRUB_DEVICE} +-elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \ +- || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then +- LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID} +-else +- LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} +-fi +- +-case x"$GRUB_FS" in +- xbtrfs) +- if [ "x${SUSE_BTRFS_SNAPSHOT_BOOTING}" = "xtrue" ]; then +- GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} \${extra_cmdline}" +- else +- rootsubvol="`make_system_path_relative_to_its_root /`" +- rootsubvol="${rootsubvol#/}" +- if [ "x${rootsubvol}" != x ]; then +- GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" +- fi +- fi;; +- xzfs) +- rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` +- bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`" +- LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}" +- ;; +-esac +- +-mktitle () +-{ +- local title_type +- local version +- local OS_NAME +- local OS_VERS +- +- title_type=$1 && shift +- version=$1 && shift +- +- OS_NAME="$(eval $(grep ^NAME= /etc/os-release) ; echo ${NAME})" +- OS_VERS="$(eval $(grep ^VERSION= /etc/os-release) ; echo ${VERSION})" +- +- case $title_type in +- recovery) +- title=$(printf '%s (%s) %s (recovery mode)' \ +- "${OS_NAME}" "${version}" "${OS_VERS}") +- ;; +- *) +- title=$(printf '%s (%s) %s' \ +- "${OS_NAME}" "${version}" "${OS_VERS}") +- ;; +- esac +- echo -n ${title} +-} +- +-title_correction_code= +- +-populate_header_warn() +-{ +-cat <&2 +- +- files=($(for bls in ${blsdir}/*.conf ; do +- if ! [[ -e "${bls}" ]] ; then +- continue +- fi +- bls="${bls%.conf}" +- bls="${bls##*/}" +- echo "${bls}" +- done | ${kernel_sort} | tac)) || : +- +- for bls in "${files[@]}" ; do +- read_config "${blsdir}/${bls}.conf" +- +- menu="${menu}menuentry '${title}' ${grub_arg} --id=${bls} {\n" +- menu="${menu}\t linux ${linux} ${options}\n" +- if [ -n "${initrd}" ] ; then +- menu="${menu}\t initrd ${boot_prefix}${initrd}\n" +- fi +- menu="${menu}}\n\n" +- done +- # The printf command seems to be more reliable across shells for special character (\n, \t) evaluation +- printf "$menu" +-} +- +-linux_entry () +-{ +- os="$1" +- version="$2" +- type="$3" +- isdebug="$4" +- args="$5" +- +- if [ -z "$boot_device_id" ]; then +- boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" +- fi +- +- if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then +- if [ x$dirname = x/ ]; then +- if [ -z "${prepare_root_cache}" ]; then +- prepare_grub_to_access_device ${GRUB_DEVICE} +- fi +- else +- if [ -z "${prepare_boot_cache}" ]; then +- prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} +- fi +- fi +- +- if [ -d /sys/firmware/efi ]; then +- bootefi_device="`${grub_probe} --target=device /boot/efi/`" +- prepare_grub_to_access_device_with_variable boot ${bootefi_device} +- else +- boot_device="`${grub_probe} --target=device /boot/`" +- prepare_grub_to_access_device_with_variable boot ${boot_device} +- fi +- +- populate_header_warn +- populate_menu +- +- if [ "x${GRUB_GRUBENV_UPDATE}" = "xyes" ]; then +- blsdir="/boot/loader/entries" +- [ -d "${blsdir}" ] && GRUB_BLS_FS="$(${grub_probe} --target=fs ${blsdir})" +- if [ "x${GRUB_BLS_FS}" = "xbtrfs" ] || [ "x${GRUB_BLS_FS}" = "xzfs" ]; then +- blsdir=$(make_system_path_relative_to_its_root "${blsdir}") +- if [ "x${blsdir}" != "x/loader/entries" ] && [ "x${blsdir}" != "x/boot/loader/entries" ]; then +- ${grub_editenv} - set blsdir="${blsdir}" +- fi +- fi +- +- ${grub_editenv} - set kernelopts="root=${linux_root_device_thisversion} ro ${args}" +- if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then +- ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" +- fi +- fi +- +- exit 0 +- fi +- +- if [ x$type != xsimple ] ; then +- title=$(mktitle "$type" "$version") +- if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then +- replacement_title="$(echo "Advanced options for ${OS}" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')" +- quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)" +- title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;" +- fi +- if [ x$isdebug = xdebug ]; then +- title="$title${GRUB_LINUX_DEBUG_TITLE_POSTFIX}" +- fi +- echo "menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-$version-$type-$boot_device_id' {" | sed "s/^/$submenu_indentation/" +- else +- echo "menuentry '$(echo "$os" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnulinux-simple-$boot_device_id' {" | sed "s/^/$submenu_indentation/" +- fi +- if [ x$type != xrecovery ] ; then +- save_default_entry | grub_add_tab +- fi +- +- # Use ELILO's generic "efifb" when it's known to be available. +- # FIXME: We need an interface to select vesafb in case efifb can't be used. +- if [ "x$GRUB_GFXPAYLOAD_LINUX" = x ]; then +- echo " load_video" | sed "s/^/$submenu_indentation/" +- if grep -qx "CONFIG_FB_EFI=y" "${config}" 2> /dev/null \ +- && grep -qx "CONFIG_VT_HW_CONSOLE_BINDING=y" "${config}" 2> /dev/null; then +- echo " set gfxpayload=keep" | sed "s/^/$submenu_indentation/" +- fi +- else +- if [ "x$GRUB_GFXPAYLOAD_LINUX" != xtext ]; then +- echo " load_video" | sed "s/^/$submenu_indentation/" +- fi +- echo " set gfxpayload=$GRUB_GFXPAYLOAD_LINUX" | sed "s/^/$submenu_indentation/" +- fi +- +- echo " insmod gzio" | sed "s/^/$submenu_indentation/" +- +- if [ x$dirname = x/ ]; then +- if [ -z "${prepare_root_cache}" ]; then +- prepare_root_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE} | grub_add_tab)" +- fi +- printf '%s\n' "${prepare_root_cache}" | sed "s/^/$submenu_indentation/" +- else +- if [ -z "${prepare_boot_cache}" ]; then +- prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | grub_add_tab)" +- fi +- printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/" +- fi +- sed "s/^/$submenu_indentation/" << EOF +- linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} +-EOF +- if test -n "${initrd}" ; then +- initrd_path= +- for i in ${initrd}; do +- initrd_path="${initrd_path} ${rel_dirname}/${i}" +- done +- sed "s/^/$submenu_indentation/" << EOF +- initrd $(echo $initrd_path) +-EOF +- fi +- if test -n "${fdt}" ; then +- sed "s/^/$submenu_indentation/" << EOF +- devicetree ${rel_dirname}/${fdt} +-EOF +- fi +- sed "s/^/$submenu_indentation/" << EOF +-} +-EOF +-} +- +-machine=`uname -m` +-case "x$machine" in +- xi?86 | xx86_64) +- list= +- for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do +- if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi +- done ;; +- *) +- list= +- for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do +- if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi +- done ;; +-esac +- +-if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then +- for i in /boot/ostree/*/vmlinuz-* ; do +- if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi +- done +-fi +- +-case "$machine" in +- i?86) GENKERNEL_ARCH="x86" ;; +- mips|mips64) GENKERNEL_ARCH="mips" ;; +- mipsel|mips64el) GENKERNEL_ARCH="mipsel" ;; +- arm*) GENKERNEL_ARCH="arm" ;; +- *) GENKERNEL_ARCH="$machine" ;; +-esac +- +-prepare_boot_cache= +-prepare_root_cache= +-boot_device_id= +-title_correction_code= +- +-# Extra indentation to add to menu entries in a submenu. We're not in a submenu +-# yet, so it's empty. In a submenu it will be equal to '\t' (one tab). +-submenu_indentation="" +- +-is_top_level=true +-while [ "x$list" != "x" ] ; do +- linux=`version_find_latest $list` +- if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then +- gettext_printf "Found linux image: %s\n" "$linux" >&2 +- fi +- +- basename=`basename $linux` +- dirname=`dirname $linux` +- rel_dirname=`make_system_path_relative_to_its_root $dirname` +- version=`echo $basename | sed -e "s,^[^0-9]*-,,g"` +- alt_version=`echo $version | sed -e "s,\.old$,,g"` +- linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" +- +- initrd_early= +- for i in ${GRUB_EARLY_INITRD_LINUX_STOCK} \ +- ${GRUB_EARLY_INITRD_LINUX_CUSTOM}; do +- if test -e "${dirname}/${i}" ; then +- initrd_early="${initrd_early} ${i}" +- fi +- done +- +- 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" \ +- "initrd-${alt_version}" "initramfs-${alt_version}.img" \ +- "initramfs-genkernel-${version}" \ +- "initramfs-genkernel-${alt_version}" \ +- "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \ +- "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do +- if test -e "${dirname}/${i}" ; then +- initrd_real="${i}" +- break +- fi +- done +- +- 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 +- if [ "x${GRUB_ENABLE_BLSCFG}" != "xtrue" ]; then +- gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 +- fi +- fi +- +- fdt= +- for i in "dtb-${version}" "dtb-${alt_version}"; do +- if test -f "${dirname}/${i}/${GRUB_DEFAULT_DTB}" ; then +- fdt="${i}/${GRUB_DEFAULT_DTB}" +- break +- fi +- done +- +- config= +- for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do +- if test -e "${i}" ; then +- config="${i}" +- break +- fi +- done +- +- initramfs= +- if test -n "${config}" ; then +- initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"` +- fi +- +- if test -z "${initramfs}" && test -z "${initrd_real}" ; then +- # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs. Since there's +- # no initrd or builtin initramfs, it can't work here. +- if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \ +- || [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then +- +- linux_root_device_thisversion=${GRUB_DEVICE} +- else +- linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID} +- fi +- fi +- +- if [ "x${GRUB_DISABLE_SUBMENU}" = "xyes" ] || [ "x${GRUB_DISABLE_SUBMENU}" = "xy" ]; then +- GRUB_DISABLE_SUBMENU="true" +- fi +- +- if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then +- linux_entry "${OS}" "${version}" simple standard \ +- "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" +- if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then +- linux_entry "${OS}" "${version}" simple debug \ +- "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}" +- fi +- +- submenu_indentation="$grub_tab" +- +- if [ -z "$boot_device_id" ]; then +- boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" +- fi +- # TRANSLATORS: %s is replaced with an OS name +- echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnulinux-advanced-$boot_device_id' {" +- is_top_level=false +- fi +- +- linux_entry "${OS}" "${version}" advanced standard \ +- "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" +- if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then +- linux_entry "${OS}" "${version}" advanced debug \ +- "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX_DEBUG}" +- fi +- +- if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then +- linux_entry "${OS}" "${version}" recovery standard \ +- "single ${GRUB_CMDLINE_LINUX}" +- fi +- +- list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '` +-done +- +-# If at least one kernel was found, then we need to +-# add a closing '}' for the submenu command. +-if [ x"$is_top_level" != xtrue ]; then +- echo '}' +-fi +- +-echo "$title_correction_code" +-- +1.8.3.1 + diff --git a/0202-blscfg-don-t-dynamically-allocate-default_blsdir.patch b/0202-blscfg-don-t-dynamically-allocate-default_blsdir.patch deleted file mode 100644 index ab076ecc1e410b5b6ea1ce439ccd027fbdb6bc78..0000000000000000000000000000000000000000 --- a/0202-blscfg-don-t-dynamically-allocate-default_blsdir.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Wed, 11 Jul 2018 15:01:45 +0100 -Subject: [PATCH] blscfg: don't dynamically allocate default_blsdir - -Signed-off-by: Will Thompson ---- - grub-core/commands/blscfg.c | 9 +++------ - 1 file changed, 3 insertions(+), 6 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 82fb6cdd182..b61dddb7f43 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -623,7 +623,7 @@ static int find_entry (const char *filename, - grub_file_t f = NULL; - char *grubenv_path = NULL; - grub_envblk_t env = NULL; -- char *default_blsdir = NULL; -+ const char *default_blsdir = NULL; - grub_fs_t blsdir_fs = NULL; - grub_device_t blsdir_dev = NULL; - const char *blsdir = NULL; -@@ -643,10 +643,9 @@ static int find_entry (const char *filename, - - // set a default blsdir - if (info->platform == PLATFORM_EMU) -- default_blsdir = grub_xasprintf ("%s%s", GRUB_BOOT_DEVICE, -- GRUB_BLS_CONFIG_PATH); -+ default_blsdir = GRUB_BOOT_DEVICE GRUB_BLS_CONFIG_PATH; - else -- default_blsdir = grub_xasprintf ("%s", GRUB_BLS_CONFIG_PATH); -+ default_blsdir = GRUB_BLS_CONFIG_PATH; - - grub_env_set ("blsdir", default_blsdir); - grub_dprintf ("blscfg", "default_blsdir: \"%s\"\n", default_blsdir); -@@ -788,8 +787,6 @@ finish: - if (f) - grub_file_close (f); - -- grub_free (default_blsdir); -- - return 0; - } - diff --git a/0203-blscfg-sort-BLS-entries-by-version-field.patch b/0203-blscfg-sort-BLS-entries-by-version-field.patch deleted file mode 100644 index 0ee94af6e3fb5162d39f4e98dad786e6c6775048..0000000000000000000000000000000000000000 --- a/0203-blscfg-sort-BLS-entries-by-version-field.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Wed, 11 Jul 2018 15:41:09 +0100 -Subject: [PATCH] blscfg: sort BLS entries by 'version' field -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This partially reverts ‘Use BLS fragment filename as menu entry id and -for criteria to sort’. Sorting by filename only gives the correct order -if the BLS entries are generated by a version of ostree after this patch -https://github.com/ostreedev/ostree/commit/9f48e212a3bf9ed418fb3216e4f834d581bc520e -to use the version (higher is newer) in the filename. Older ostrees, -including all releases at the time of writing, use the index (lower is -newer) in the filename, so sorting by filename produces the reverse -order. - -Sorting by 'version' field matches libostree's own -compare_boot_loader_configs(), so I think it's more correct than relying -on the filename, particularly since we've already gone to the trouble of -parsing all the fields in the file. - -Signed-off-by: Will Thompson ---- - grub-core/commands/blscfg.c | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index b61dddb7f43..9c928dda470 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -327,10 +327,26 @@ finish: - return ret; - } - -+/* return 1: p0 is newer than p1 */ -+/* 0: p0 and p1 are the same version */ -+/* -1: p1 is newer than p0 */ - static int bls_cmp(const void *p0, const void *p1, void *state UNUSED) - { - struct bls_entry * e0 = *(struct bls_entry **)p0; - struct bls_entry * e1 = *(struct bls_entry **)p1; -+ const char *v0, *v1; -+ int r; -+ -+ v0 = bls_get_val(e0, "version", NULL); -+ v1 = bls_get_val(e1, "version", NULL); -+ -+ if (v0 && !v1) -+ return -1; -+ if (!v0 && v1) -+ return 1; -+ -+ if ((r = vercmp(v0, v1)) != 0) -+ return r; - - return vercmp(e0->filename, e1->filename); - } diff --git a/0203-grub-switch-to-blscfg-Use-install-to-copy-GRUB-binar.patch b/0203-grub-switch-to-blscfg-Use-install-to-copy-GRUB-binar.patch new file mode 100644 index 0000000000000000000000000000000000000000..217876caedd33ad950a293fde63c44ca65b0034b --- /dev/null +++ b/0203-grub-switch-to-blscfg-Use-install-to-copy-GRUB-binar.patch @@ -0,0 +1,49 @@ +From 06b00bced8807fe8c16f2abdfad956f59e053ca8 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Thu, 16 Apr 2020 18:53:03 +0200 +Subject: [PATCH 203/220] grub-switch-to-blscfg: Use install to copy GRUB + binary, modules and config + +By default the cp command truncates the destination before copying from the +source, so if interrupted it can lead to a file that's half written. + +This behavior can be modified using the --remove-destination option, but is +usually a better choice to use the install tool for this. So let's do that. + +Signed-off-by: Javier Martinez Canillas +--- + util/grub-switch-to-blscfg.in | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in +index 4bbed8e..3333a62 100644 +--- a/util/grub-switch-to-blscfg.in ++++ b/util/grub-switch-to-blscfg.in +@@ -273,7 +273,7 @@ copy_bls() { + if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars && \ + ! ${grub_editenv} - list | grep -q blsdir; then + grub_binary="$(find /usr/lib/ostree-boot/efi/EFI/${EFIDIR}/ -name grub*.efi)" +- cp ${grub_binary} ${grubdir} || exit 1 ++ install -m 700 ${grub_binary} ${grubdir} || exit 1 + # Create a hidden file to indicate that grub2 now has BLS support. + touch /boot/grub2/.grub2-blscfg-supported + fi +@@ -307,13 +307,13 @@ if [ "${GENERATE}" -eq 1 ] ; then + + if [ -n "${mod_dir}" ]; then + for mod in blscfg increment; do +- cp ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1 ++ install -m 700 ${prefix}/lib/grub/${mod_dir}/${mod}.mod ${grubdir}/$mod_dir/ || exit 1 + done + fi + + cp -af "${GRUB_CONFIG_FILE}" "${GRUB_CONFIG_FILE}${backupsuffix}" + if ! grub2-mkconfig -o "${GRUB_CONFIG_FILE}" ; then +- cp -af "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}" ++ install -m 700 "${GRUB_CONFIG_FILE}${backupsuffix}" "${GRUB_CONFIG_FILE}" + sed -i"${backupsuffix}" \ + -e 's,^GRUB_ENABLE_BLSCFG=.*,GRUB_ENABLE_BLSCFG=false,' \ + "${etcdefaultgrub}" +-- +1.8.3.1 + diff --git a/0204-10_linux.in-Enable-BLS-configuration-if-new-kernel-p.patch b/0204-10_linux.in-Enable-BLS-configuration-if-new-kernel-p.patch new file mode 100644 index 0000000000000000000000000000000000000000..a7af8ac375f4eba2270c34a3e7acd4749608117a --- /dev/null +++ b/0204-10_linux.in-Enable-BLS-configuration-if-new-kernel-p.patch @@ -0,0 +1,42 @@ +From 4522b79934cf8777fbd4bdc437497ed22f77a9f0 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Thu, 16 Apr 2020 18:53:05 +0200 +Subject: [PATCH 204/220] 10_linux.in: Enable BLS configuration if + new-kernel-pkg isn't present + +Currently if the the GRUB_ENABLE_BLSCFG option in /etc/default/grub hasn't +been set, the 10_linux script will generate a GRUB configuration that does +not include the blscfg command to populate the menu entries from BLS files. + +But on kernel install the /usr/lib/kernel/install.d/20-grub.install script +will only add menuentry commands to the GRUB config file if the old grubby +tool and new-kernel-pkg script are installed. + +So a configuration with the GRUB_ENABLE_BLSCFG option will lead to a setup +where new kernel entries are not added. Make a BLS config the default if +that option wasn't set and the new-kernel-pkg script is not present. + +Signed-off-by: Javier Martinez Canillas +--- + util/grub.d/10_linux.in | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index c72cc32..847646b 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -164,6 +164,11 @@ populate_menu() + printf "$menu" + } + ++# Make BLS the default if GRUB_ENABLE_BLSCFG was not set and grubby is not installed. ++if [ -z "${GRUB_ENABLE_BLSCFG}" ] && [ -z "$(which new-kernel-pkg 2> /dev/null)" ]; then ++ GRUB_ENABLE_BLSCFG="true" ++fi ++ + if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then + if [ x$dirname = x/ ]; then + if [ -z "${prepare_root_cache}" ]; then +-- +1.8.3.1 + diff --git a/0204-blscfg-remove-NULL-guards-around-grub_free.patch b/0204-blscfg-remove-NULL-guards-around-grub_free.patch deleted file mode 100644 index add176633f39004df06e432e7ca7c02093915437..0000000000000000000000000000000000000000 --- a/0204-blscfg-remove-NULL-guards-around-grub_free.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Thu, 12 Jul 2018 10:14:43 +0100 -Subject: [PATCH] blscfg: remove NULL guards around grub_free() - -The internal implementation of grub_free() is NULL-safe. In emu builds, -it just delegates to the host's free(), which is specified by ANSI C to -be NULL-safe. - -Signed-off-by: Will Thompson ---- - grub-core/commands/blscfg.c | 23 ++++++----------------- - 1 file changed, 6 insertions(+), 17 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 9c928dda470..bd78559ef68 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -600,23 +600,12 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - grub_normal_add_menu_entry (argc, argv, classes, id, users, hotkey, NULL, src, 0); - - finish: -- if (initrd) -- grub_free (initrd); -- -- if (initrds) -- grub_free (initrds); -- -- if (classes) -- grub_free (classes); -- -- if (args) -- grub_free (args); -- -- if (argv) -- grub_free (argv); -- -- if (src) -- grub_free (src); -+ grub_free (initrd); -+ grub_free (initrds); -+ grub_free (classes); -+ grub_free (args); -+ grub_free (argv); -+ grub_free (src); - } - - struct find_entry_info { diff --git a/0205-blscfg-fix-filename-in-no-linux-key-error.patch b/0205-blscfg-fix-filename-in-no-linux-key-error.patch deleted file mode 100644 index 37795f6c4aeac7820f3aab91a450566b2513ca12..0000000000000000000000000000000000000000 --- a/0205-blscfg-fix-filename-in-no-linux-key-error.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Thu, 12 Jul 2018 10:38:27 +0100 -Subject: [PATCH] blscfg: fix filename in "no 'linux' key" error - -In find_entry(), 'filename' is either NULL or a directory in the ESP. -But previously it was passed to create_entry(), which uses it in an -error message as if it's the filename of the BLS entry in question. - -Since bls_entry now has a 'filename' field, just use that. - -Signed-off-by: Will Thompson ---- - grub-core/commands/blscfg.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index bd78559ef68..a45f40fe67e 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -514,7 +514,7 @@ static char **bls_make_list (struct bls_entry *entry, const char *key, int *num) - return list; - } - --static void create_entry (struct bls_entry *entry, const char *cfgfile) -+static void create_entry (struct bls_entry *entry) - { - int argc = 0; - const char **argv = NULL; -@@ -539,7 +539,7 @@ static void create_entry (struct bls_entry *entry, const char *cfgfile) - clinux = bls_get_val (entry, "linux", NULL); - if (!clinux) - { -- grub_dprintf ("blscfg", "Skipping file %s with no 'linux' key.\n", cfgfile); -+ grub_dprintf ("blscfg", "Skipping file %s with no 'linux' key.\n", entry->filename); - goto finish; - } - -@@ -753,7 +753,7 @@ static int find_entry (const char *filename, - - grub_dprintf ("blscfg", "%s Creating %d entries from bls\n", __func__, nentries); - for (r = nentries - 1; r >= 0; r--) -- create_entry(entries[r], filename); -+ create_entry(entries[r]); - - for (r = 0; r < nentries; r++) - bls_free_entry (entries[r]); diff --git a/0205-efi-Set-image-base-address-before-jumping-to-the-PE-.patch b/0205-efi-Set-image-base-address-before-jumping-to-the-PE-.patch new file mode 100644 index 0000000000000000000000000000000000000000..a2987a420f1b2b43b53a6930cdf0ee6d44fe9f0d --- /dev/null +++ b/0205-efi-Set-image-base-address-before-jumping-to-the-PE-.patch @@ -0,0 +1,63 @@ +From c565dc1a029d823a601716a30d06f9d6626d4a93 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Thu, 23 Apr 2020 15:06:46 +0200 +Subject: [PATCH 205/220] efi: Set image base address before jumping to the + PE/COFF entry point + +Upstream GRUB uses the EFI LoadImage() and StartImage() to boot the Linux +kernel. But our custom EFI loader that supports Secure Boot instead uses +the EFI handover protocol (for x86) or jumping directly to the PE/COFF +entry point (for aarch64). + +This is done to allow the bootloader to verify the images using the shim +lock protocol to avoid booting untrusted binaries. + +Since the bootloader loads the kernel from the boot media instead of using +LoadImage(), it is responsible to set the Loaded Image base address before +booting the kernel. + +Otherwise the kernel EFI stub will complain that it was not set correctly +and print the following warning message: + +EFI stub: ERROR: FIRMWARE BUG: efi_loaded_image_t::image_base has bogus value + +Resolves: rhbz#1825411 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/loader/efi/linux.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index b56ea0b..e09f824 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -72,6 +72,7 @@ grub_err_t + grub_efi_linux_boot (void *kernel_addr, grub_off_t handover_offset, + void *kernel_params) + { ++ grub_efi_loaded_image_t *loaded_image = NULL; + handover_func hf; + int offset = 0; + +@@ -79,6 +80,17 @@ grub_efi_linux_boot (void *kernel_addr, grub_off_t handover_offset, + offset = 512; + #endif + ++ /* ++ * Since the EFI loader is not calling the LoadImage() and StartImage() ++ * services for loading the kernel and booting respectively, it has to ++ * set the Loaded Image base address. ++ */ ++ loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); ++ if (loaded_image) ++ loaded_image->image_base = kernel_addr; ++ else ++ grub_dprintf ("linux", "Loaded Image base address could not be set\n"); ++ + grub_dprintf ("linux", "kernel_addr: %p handover_offset: %p params: %p\n", + kernel_addr, (void *)(grub_efi_uintn_t)handover_offset, kernel_params); + hf = (handover_func)((char *)kernel_addr + handover_offset + offset); +-- +1.8.3.1 + diff --git a/0206-blscfg-Lookup-default_kernelopts-variable-as-fallbac.patch b/0206-blscfg-Lookup-default_kernelopts-variable-as-fallbac.patch new file mode 100644 index 0000000000000000000000000000000000000000..caeb3f8fb5c173b407a82d84c44f5bed52de26e9 --- /dev/null +++ b/0206-blscfg-Lookup-default_kernelopts-variable-as-fallbac.patch @@ -0,0 +1,43 @@ +From 79e6846f6f4a4c097d88e83c9544b96334a6ea9e Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Wed, 29 Apr 2020 20:08:27 +0200 +Subject: [PATCH 206/220] blscfg: Lookup default_kernelopts variable as + fallback for options + +The 10_linux script sets a variable that contains the kernel command line +parameters. This is done so the entries will still have a kernel cmdline +defined even if the grubenv can't be read. + +But older versions of the script used to set a default_kernelopts variable +while newer versions just sets the kernelopts, which is what's defined in +the BLS snippets. + +The blscfg module needs to keep looking for the default_kernelops since it +may be that a user doesn't have a grubenv file and has an older grub.cfg +that sets this variable instead of kernelopts. + +Related: rhbz#1765297 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/commands/blscfg.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c +index 9263a5c..4ec6504 100644 +--- a/grub-core/commands/blscfg.c ++++ b/grub-core/commands/blscfg.c +@@ -759,6 +759,10 @@ static void create_entry (struct bls_entry *entry) + + title = bls_get_val (entry, "title", NULL); + options = expand_val (bls_get_val (entry, "options", NULL)); ++ ++ if (!options) ++ options = expand_val (grub_env_get("default_kernelopts")); ++ + initrds = bls_make_list (entry, "initrd", NULL); + + devicetree = expand_val (bls_get_val (entry, "devicetree", NULL)); +-- +1.8.3.1 + diff --git a/0206-blscfg-don-t-leak-bls_entry.filename.patch b/0206-blscfg-don-t-leak-bls_entry.filename.patch deleted file mode 100644 index 5080e2e4e6f6e529b219aaf6dd600964fa07a381..0000000000000000000000000000000000000000 --- a/0206-blscfg-don-t-leak-bls_entry.filename.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Thu, 12 Jul 2018 10:59:10 +0100 -Subject: [PATCH] blscfg: don't leak bls_entry.filename - -Zeroing the bls_entry struct before calling grub_free() on one of its -fields is not going to work too well. - -Signed-off-by: Will Thompson ---- - grub-core/commands/blscfg.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index a45f40fe67e..11a356de81a 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -166,8 +166,8 @@ static void bls_free_entry(struct bls_entry *entry) - } - - grub_free (entry->keyvals); -- grub_memset (entry, 0, sizeof (*entry)); - grub_free (entry->filename); -+ grub_memset (entry, 0, sizeof (*entry)); - grub_free (entry); - } - diff --git a/0207-10_linux.in-fix-early-exit-due-error-when-reading-pe.patch b/0207-10_linux.in-fix-early-exit-due-error-when-reading-pe.patch new file mode 100644 index 0000000000000000000000000000000000000000..bebd24038857c94dcf07a5c2f2366197c615b9a0 --- /dev/null +++ b/0207-10_linux.in-fix-early-exit-due-error-when-reading-pe.patch @@ -0,0 +1,36 @@ +From 35181b2c411954a96e3ed9a0ebc6ce470d037595 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Thu, 30 Apr 2020 15:45:31 +0200 +Subject: [PATCH 207/220] 10_linux.in: fix early exit due error when reading + petitboot version + +The script uses bash's read built-in command to get the petitboot version +version, but this command has a non-zero exit status if the EOF is found. + +Since the /sys/firmware/devicetree/base/ibm,firmware-versions/petitboot +string ends with a NUL character, use the empty string as read delimiter +to prevent the command to read to the end-of-file and exit with an error. + +Resolves: rhbz#1827397 + +Signed-off-by: Javier Martinez Canillas +--- + util/grub.d/10_linux.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 847646b..09adfce 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -194,7 +194,7 @@ if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then + petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot" + + if test -e ${petitboot_path}; then +- read -a petitboot_version < ${petitboot_path} ++ read -r -d '' petitboot_version < ${petitboot_path} + petitboot_version="$(echo ${petitboot_version//v})" + major_version="$(echo ${petitboot_version} | cut -d . -f1)" + minor_version="$(echo ${petitboot_version} | cut -d . -f2)" +-- +1.8.3.1 + diff --git a/0207-blscfg-fix-compilation-on-EFI-and-EMU.patch b/0207-blscfg-fix-compilation-on-EFI-and-EMU.patch deleted file mode 100644 index 04aadc36d3042c8e4b26a8df103bd5588dad0dbb..0000000000000000000000000000000000000000 --- a/0207-blscfg-fix-compilation-on-EFI-and-EMU.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Thu, 12 Jul 2018 19:00:42 +0100 -Subject: [PATCH] blscfg: fix compilation on !EFI and !EMU -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Neither GRUB_MACHINE_EFI nor GRUB_MACHINE_EMU are defined when compiling -for (eg) i386-pc. In this case, #elif GRUB_MACHINE_EMU is an error: - - commands/blscfg.c: In function ‘grub_cmd_blscfg’: - commands/blscfg.c:835:7: error: "GRUB_MACHINE_EMU" is not defined [-Werror=undef] - #elif GRUB_MACHINE_EMU - ^~~~~~~~~~~~~~~~ - -Signed-off-by: Will Thompson ---- - grub-core/commands/blscfg.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 11a356de81a..53676576ba5 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -843,7 +843,7 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - info.platform = PLATFORM_EFI; - grub_dprintf ("blscfg", "scanning /EFI/\n"); - r = fs->dir (dev, "/EFI/", find_entry, &info); --#elif GRUB_MACHINE_EMU -+#elif defined(GRUB_MACHINE_EMU) - info.platform = PLATFORM_EMU; - grub_dprintf ("blscfg", "scanning %s%s\n", GRUB_BOOT_DEVICE, - GRUB_BLS_CONFIG_PATH); diff --git a/0208-Add-loadenv-to-blscfg-and-loadenv-source-file-list.patch b/0208-Add-loadenv-to-blscfg-and-loadenv-source-file-list.patch deleted file mode 100644 index 76df19c11932d01dc277992efb20bbb69dc1c6c7..0000000000000000000000000000000000000000 --- a/0208-Add-loadenv-to-blscfg-and-loadenv-source-file-list.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Will Thompson -Date: Fri, 13 Jul 2018 05:51:54 +0100 -Subject: [PATCH] Add loadenv to blscfg and loadenv source file list -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Without this, `make distcheck` fails because loadenv.h is not included -in the source tarball. - -This broke in ‘Add blscfg command support to parse BootLoaderSpec config -fragments’. - -Signed-off-by: Will Thompson ---- - grub-core/Makefile.core.def | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 2851437e098..aa44d66aca4 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -781,6 +781,7 @@ module = { - module = { - name = blscfg; - common = commands/blscfg.c; -+ common = commands/loadenv.h; - enable = efi; - enable = i386_pc; - enable = emu; -@@ -947,6 +948,7 @@ module = { - module = { - name = loadenv; - common = commands/loadenv.c; -+ common = commands/loadenv.h; - common = lib/envblk.c; - }; - diff --git a/0208-envblk-Fix-buffer-overrun-when-attempting-to-shrink-.patch b/0208-envblk-Fix-buffer-overrun-when-attempting-to-shrink-.patch new file mode 100644 index 0000000000000000000000000000000000000000..586cc71695b2017789d96e71cc6c01151ebb8b78 --- /dev/null +++ b/0208-envblk-Fix-buffer-overrun-when-attempting-to-shrink-.patch @@ -0,0 +1,63 @@ +From aecc9de8fc2345cb582d0587fc89d01891ae2650 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 12 May 2020 01:00:51 +0200 +Subject: [PATCH 208/220] envblk: Fix buffer overrun when attempting to shrink + a variable value +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +If an existing variable is set with a value whose length is smaller than +the current value, a memory corruption can happen due copying padding '#' +characters outside of the environment block buffer. + +This is caused by a wrong calculation of the previous free space position +after moving backward the characters that followed the old variable value. + +That position is calculated to fill the remaining of the buffer with the +padding '#' characters. But since isn't calculated correctly, it can lead +to copies outside of the buffer. + +The issue can be reproduced by creating a variable with a large value and +then try to set a new value that is much smaller: + +$ grub2-editenv --version +grub2-editenv (GRUB) 2.04 + +$ grub2-editenv env create + +$ grub2-editenv env set a="$(for i in {1..500}; do var="b$var"; done; echo $var)" + +$ wc -c env +1024 grubenv + +$ grub2-editenv env set a="$(for i in {1..50}; do var="b$var"; done; echo $var)" +malloc(): corrupted top size +Aborted (core dumped) + +$ wc -c env +0 grubenv + +Reported-by: Renaud Métrich +Signed-off-by: Javier Martinez Canillas +Patch-cc: Daniel Kiper +--- + grub-core/lib/envblk.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/lib/envblk.c b/grub-core/lib/envblk.c +index f89d86d..874506d 100644 +--- a/grub-core/lib/envblk.c ++++ b/grub-core/lib/envblk.c +@@ -143,7 +143,7 @@ grub_envblk_set (grub_envblk_t envblk, const char *name, const char *value) + /* Move the following characters backward, and fill the new + space with harmless characters. */ + grub_memmove (p + vl, p + len, pend - (p + len)); +- grub_memset (space + len - vl, '#', len - vl); ++ grub_memset (space - (len - vl), '#', len - vl); + } + else + /* Move the following characters forward. */ +-- +1.8.3.1 + diff --git a/0209-10_linux.in-Store-cmdline-in-BLS-snippets-instead-of.patch b/0209-10_linux.in-Store-cmdline-in-BLS-snippets-instead-of.patch new file mode 100644 index 0000000000000000000000000000000000000000..6c3fc7970d0e193d4cf6c399fb567d24eed7daeb --- /dev/null +++ b/0209-10_linux.in-Store-cmdline-in-BLS-snippets-instead-of.patch @@ -0,0 +1,163 @@ +From 9140d0e92dc51839ff77634d4b030bf4f88f248a Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Wed, 13 May 2020 19:40:10 +0200 +Subject: [PATCH 209/220] 10_linux.in: Store cmdline in BLS snippets instead of + using a variable + +The kernel cmdline was stored as a kernelopts variable in the grubenv file +and the BLS snippets used that. But this turned out to be fragile since the +grubenv file could be removed or get corrupted easily. + +To prevent the entries to not have a cmdline if the grubenv can't be read, +a fallback variable was set in the GRUB config file. But this still caused +issues since the config needs to be re-generated to change the parameters. + +Instead, let's store the cmdline in the BLS snippets. This will make the +configuration more robust, since it will work even without the grubenv +file and the BLS entries will contain all the information needed to boot. + +Signed-off-by: Javier Martinez Canillas +--- + util/grub-switch-to-blscfg.in | 30 ++++++++++-------------------- + util/grub.d/10_linux.in | 41 +++++++++++++++++++++++++++++++---------- + 2 files changed, 41 insertions(+), 30 deletions(-) + +diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in +index 3333a62..cb22912 100644 +--- a/util/grub-switch-to-blscfg.in ++++ b/util/grub-switch-to-blscfg.in +@@ -190,7 +190,7 @@ fi + mkbls() { + local kernelver=$1 && shift + local datetime=$1 && shift +- local bootprefix=$1 && shift ++ local kernelopts=$1 && shift + + local debugname="" + local debugid="" +@@ -209,10 +209,9 @@ mkbls() { + cat <"${bls_target}" +- fi ++ mkbls "${kernelver}" \ ++ "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \ ++ "${bootprefix}" "${cmdline}" >"${bls_target}" + + if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then + bls_debug="$(echo ${bls_target} | sed -e "s/${kernelver}/${kernelver}~debug/")" + cp -aT "${bls_target}" "${bls_debug}" + title="$(grep '^title[ \t]' "${bls_debug}" | sed -e 's/^title[ \t]*//')" +- blsid="$(grep '^id[ \t]' "${bls_debug}" | sed -e "s/\.${ARCH}/-debug.${arch}/")" ++ options="$(echo "${cmdline} ${GRUB_CMDLINE_LINUX_DEBUG}" | sed -e 's/\//\\\//g')" + sed -i -e "s/^title.*/title ${title}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${bls_debug}" +- sed -i -e "s/^id.*/${blsid}/" "${bls_debug}" +- sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${bls_debug}" ++ sed -i -e "s/^options.*/options ${options}/" "${bls_debug}" + fi + done + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 09adfce..80299ec 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -134,23 +134,43 @@ read_config() + done < ${config_file} + } + +-populate_menu() ++blsdir="/boot/loader/entries" ++ ++get_sorted_bls() + { +- blsdir="/boot/loader/entries" +- local -a files + local IFS=$'\n' +- gettext_printf "Generating boot entries from BLS files...\n" >&2 + +- files=($(for bls in ${blsdir}/*.conf ; do +- if ! [[ -e "${bls}" ]] ; then +- continue +- fi ++ files=($(for bls in ${blsdir}/*.conf; do + bls="${bls%.conf}" + bls="${bls##*/}" + echo "${bls}" + done | ${kernel_sort} | tac)) || : + +- for bls in "${files[@]}" ; do ++ echo "${files[@]}" ++} ++ ++update_bls_cmdline() ++{ ++ local cmdline="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" ++ local -a files=($(get_sorted_bls)) ++ ++ for bls in "${files[@]}"; do ++ local options="${cmdline}" ++ if [ -z "${bls##*debug*}" ]; then ++ options="${options} ${GRUB_CMDLINE_LINUX_DEBUG}" ++ fi ++ options="$(echo "${options}" | sed -e 's/\//\\\//g')" ++ sed -i -e "s/^options.*/options ${options}/" "${blsdir}/${bls}.conf" ++ done ++} ++ ++populate_menu() ++{ ++ local -a files=($(get_sorted_bls)) ++ ++ gettext_printf "Generating boot entries from BLS files...\n" >&2 ++ ++ for bls in "${files[@]}"; do + read_config "${blsdir}/${bls}.conf" + + menu="${menu}menuentry '${title}' ${grub_arg} --id=${bls} {\n" +@@ -224,6 +244,8 @@ if [ -z "\${kernelopts}" ]; then + fi + EOF + ++ update_bls_cmdline ++ + if [ "x${BLS_POPULATE_MENU}" = "xtrue" ]; then + populate_menu + else +@@ -244,7 +266,6 @@ EOF + fi + fi + +- ${grub_editenv} - set kernelopts="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" + if [ -n "${GRUB_EARLY_INITRD_LINUX_CUSTOM}" ]; then + ${grub_editenv} - set early_initrd="${GRUB_EARLY_INITRD_LINUX_CUSTOM}" + fi +-- +1.8.3.1 + diff --git a/0209-blscfg-Get-rid-of-the-linuxefi-linux16-linux-distinc.patch b/0209-blscfg-Get-rid-of-the-linuxefi-linux16-linux-distinc.patch deleted file mode 100644 index df63ac6e1f195b237f1d9582552734fd48a43582..0000000000000000000000000000000000000000 --- a/0209-blscfg-Get-rid-of-the-linuxefi-linux16-linux-distinc.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 16 Jul 2018 11:00:50 -0400 -Subject: [PATCH] blscfg: Get rid of the linuxefi/linux16/linux distinction - -Signed-off-by: Peter Jones ---- - grub-core/commands/blscfg.c | 14 +++----------- - 1 file changed, 3 insertions(+), 11 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 53676576ba5..c6addc4dc12 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -43,14 +43,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #define GRUB_BOOT_DEVICE "($root)" - #endif - --#ifdef GRUB_MACHINE_EFI --#define GRUB_LINUX_CMD "linuxefi" --#define GRUB_INITRD_CMD "initrdefi" --#else --#define GRUB_LINUX_CMD "linux" --#define GRUB_INITRD_CMD "initrd" --#endif -- - enum - { - PLATFORM_EFI, -@@ -563,7 +555,7 @@ static void create_entry (struct bls_entry *entry) - title, id); - if (initrds) - { -- int initrd_size = sizeof (GRUB_INITRD_CMD); -+ int initrd_size = sizeof ("initrd"); - char *tmp; - - for (i = 0; initrds != NULL && initrds[i] != NULL; i++) -@@ -579,7 +571,7 @@ static void create_entry (struct bls_entry *entry) - } - - -- tmp = grub_stpcpy(initrd, GRUB_INITRD_CMD); -+ tmp = grub_stpcpy(initrd, "initrd "); - for (i = 0; initrds != NULL && initrds[i] != NULL; i++) - { - grub_dprintf ("blscfg", "adding initrd %s\n", initrds[i]); -@@ -592,7 +584,7 @@ static void create_entry (struct bls_entry *entry) - src = grub_xasprintf ("load_video\n" - "set gfx_payload=keep\n" - "insmod gzio\n" -- GRUB_LINUX_CMD " %s%s%s%s\n" -+ "linux %s%s%s%s\n" - "%s", - GRUB_BOOT_DEVICE, clinux, options ? " " : "", options ? options : "", - initrd ? initrd : ""); diff --git a/0210-10_linux.in-restore-existence-check-in-get_sorted_bl.patch b/0210-10_linux.in-restore-existence-check-in-get_sorted_bl.patch new file mode 100644 index 0000000000000000000000000000000000000000..ae262249170542c3f74b7fa85fac032575eedee9 --- /dev/null +++ b/0210-10_linux.in-restore-existence-check-in-get_sorted_bl.patch @@ -0,0 +1,36 @@ +From e635565f71e4a2ee106b6d8ef71e989452af90f8 Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Thu, 14 May 2020 17:52:53 -0700 +Subject: [PATCH 210/220] 10_linux.in: restore existence check in + `get_sorted_bls` + +This is necessary to handle `/boot/loader/entries` not existing +at all (or possibly existing but being empty - not sure about +that case). Without this check, this function gets pretty wacky +and winds up returning the contents of the current working +directory, which of course causes whatever called it to break. + +Resolves: rhbz#1836020 + +Signed-off-by: Adam Williamson +--- + util/grub.d/10_linux.in | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 80299ec..519e2d9 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -141,6 +141,9 @@ get_sorted_bls() + local IFS=$'\n' + + files=($(for bls in ${blsdir}/*.conf; do ++ if ! [[ -e "${bls}" ]] ; then ++ continue ++ fi + bls="${bls%.conf}" + bls="${bls##*/}" + echo "${bls}" +-- +1.8.3.1 + diff --git a/0210-grub-switch-to-blscfg-Only-fix-boot-prefix-for-non-g.patch b/0210-grub-switch-to-blscfg-Only-fix-boot-prefix-for-non-g.patch deleted file mode 100644 index 9b996bc86f73c1992c2dfc2222e9d03e15463bec..0000000000000000000000000000000000000000 --- a/0210-grub-switch-to-blscfg-Only-fix-boot-prefix-for-non-g.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 18 Jul 2018 08:07:37 +0200 -Subject: [PATCH] grub-switch-to-blscfg: Only fix boot prefix for non-generated - BLS files - -The BLS files are either copied from /lib/modules/$kernelver/bls.conf or -generated if this file doesn't exist. The shipped bls.conf default path -for the kernel and initramfs is relative to the boot partition. - -But in some setups /boot may not be a mount point so in that case the -boot prefix has to be added to the BLS. But we already provide this -prefix for generated BLS files so attempting to add a boot prefix will -lead to a path that contains the boot prefix twice (i.e: /boot/boot). - -Reported-by: Hans de Goede -Signed-off-by: Javier Martinez Canillas ---- - util/grub-switch-to-blscfg.in | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in -index 40612e00686..9cf64f8e725 100644 ---- a/util/grub-switch-to-blscfg.in -+++ b/util/grub-switch-to-blscfg.in -@@ -236,6 +236,10 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - - if [ -f "${kernel_dir}/bls.conf" ] ; then - cp -af "${kernel_dir}/bls.conf" "${bls_target}" -+ if [ -n "${bootprefix}" ]; then -+ sed -i -e "s,^\(linux[^ \t]*[ \t]\+\).*,\1${bootprefix}${linux},g" "${bls_target}" -+ sed -i -e "/^initrd/ s,\([ \t]\+\)\([^ \t]\+\),\1${bootprefix}\2,g" "${bls_target}" -+ fi - else - mkbls "${kernelver}" \ - "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${kernel_dir}")")" \ -@@ -243,11 +247,6 @@ for kernelver in $(cd /lib/modules/ ; ls -1) "" ; do - >"${bls_target}" - fi - -- if [ -n "${bootprefix}" ]; then -- sed -i -e "s,^\(linux[^ \t]*[ \t]\+\).*,\1${bootprefix}${linux},g" "${bls_target}" -- sed -i -e "/^initrd/ s,\([ \t]\+\)\([^ \t]\+\),\1${bootprefix}\2,g" "${bls_target}" -- fi -- - if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then - arch="$(uname -m)" - bls_debug="$(echo ${bls_target} | sed -e "s/\.${arch}/-debug.${arch}/")" diff --git a/0211-blscfg-Expand-the-BLS-options-field-instead-of-showi.patch b/0211-blscfg-Expand-the-BLS-options-field-instead-of-showi.patch deleted file mode 100644 index 3dca942523ccf0fe3cc7cd36c335305d390f1ffc..0000000000000000000000000000000000000000 --- a/0211-blscfg-Expand-the-BLS-options-field-instead-of-showi.patch +++ /dev/null @@ -1,130 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 18 Jul 2018 08:08:02 +0200 -Subject: [PATCH] blscfg: Expand the BLS options field instead of showing its - variables - -The values of the BLS fragment fields can either be string literals or -grub2 environment variables, the latter will be expanded by grub2 when -the boot entry is selected. - -But from a usability point of view, is much more convenient if the BLS -parse code expand any variables that are present in the options field. - -That will allow users to select an entry in the menu by pressing the e -key and edit the kernel command line parameters. So for example instead -of showing the following: - -kernel /boot/vmlinuz-4.17.0 $kernelopts - -It would show something like the following: - -kernel /boot/vmlinuz-4.17.0 root=UUID=cec677c9-c890-4103-b94a-bcc191642935 - -Suggested-by: Hans de Goede -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 69 ++++++++++++++++++++++++++++++++++++++++++++- - 1 file changed, 68 insertions(+), 1 deletion(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index c6addc4dc12..80d8814fc3f 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -32,6 +32,8 @@ - #include - #include - -+#include -+ - GRUB_MOD_LICENSE ("GPLv3+"); - - #include "loadenv.h" -@@ -506,6 +508,70 @@ static char **bls_make_list (struct bls_entry *entry, const char *key, int *num) - return list; - } - -+static char *field_append(bool is_var, char *buffer, char *start, char *end) -+{ -+ char *temp = grub_strndup(start, end - start + 1); -+ const char *field = temp; -+ -+ if (is_var) { -+ field = grub_env_get (temp); -+ if (!field) -+ return buffer; -+ } -+ -+ if (!buffer) { -+ buffer = grub_strdup(field); -+ if (!buffer) -+ return NULL; -+ } else { -+ buffer = grub_realloc (buffer, grub_strlen(buffer) + grub_strlen(field)); -+ if (!buffer) -+ return NULL; -+ -+ grub_stpcpy (buffer + grub_strlen(buffer), field); -+ } -+ -+ return buffer; -+} -+ -+static char *expand_val(char *value) -+{ -+ char *buffer = NULL; -+ char *start = value; -+ char *end = value; -+ bool is_var = false; -+ -+ while (*value) { -+ if (*value == '$') { -+ if (start != end) { -+ buffer = field_append(is_var, buffer, start, end); -+ if (!buffer) -+ return NULL; -+ } -+ -+ is_var = true; -+ start = value + 1; -+ } else if (is_var) { -+ if (!grub_isalnum(*value) && *value != '_') { -+ buffer = field_append(is_var, buffer, start, end); -+ is_var = false; -+ start = value; -+ } -+ } -+ -+ end = value; -+ value++; -+ } -+ -+ if (start != end) { -+ buffer = field_append(is_var, buffer, start, end); -+ if (!buffer) -+ return NULL; -+ } -+ -+ return buffer; -+} -+ - static void create_entry (struct bls_entry *entry) - { - int argc = 0; -@@ -536,7 +602,7 @@ static void create_entry (struct bls_entry *entry) - } - - title = bls_get_val (entry, "title", NULL); -- options = bls_get_val (entry, "options", NULL); -+ options = expand_val (bls_get_val (entry, "options", NULL)); - initrds = bls_make_list (entry, "initrd", NULL); - - hotkey = bls_get_val (entry, "grub_hotkey", NULL); -@@ -594,6 +660,7 @@ static void create_entry (struct bls_entry *entry) - finish: - grub_free (initrd); - grub_free (initrds); -+ grub_free (options); - grub_free (classes); - grub_free (args); - grub_free (argv); diff --git a/0211-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch b/0211-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch new file mode 100644 index 0000000000000000000000000000000000000000..34d34c829f88fa598f11fd21760bb8b8006a98fb --- /dev/null +++ b/0211-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch @@ -0,0 +1,65 @@ +From cf02c5792d50eb41f390dd82f8849d75ae7f2208 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Sat, 16 May 2020 11:33:18 +0200 +Subject: [PATCH 211/220] tpm: Don't propagate TPM measurement errors to the + verifiers layer + +Currently if the EFI firmware fails to do a TPM measurement for a file, +the error will be propagated to the verifiers framework and so opening +the file will not succeed. + +This mean that buggy firmwares will prevent the system to boot since the +loader won't be able to open any file. But failing to do TPM measurements +shouldn't be a fatal error and the system should still be able to boot. + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/commands/tpm.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/grub-core/commands/tpm.c b/grub-core/commands/tpm.c +index 1441c49..dbaeae4 100644 +--- a/grub-core/commands/tpm.c ++++ b/grub-core/commands/tpm.c +@@ -49,7 +49,8 @@ grub_tpm_verify_init (grub_file_t io, + static grub_err_t + grub_tpm_verify_write (void *context, void *buf, grub_size_t size) + { +- return grub_tpm_measure (buf, size, GRUB_BINARY_PCR, context); ++ grub_tpm_measure (buf, size, GRUB_BINARY_PCR, context); ++ return GRUB_ERR_NONE; + } + + static grub_err_t +@@ -57,7 +58,6 @@ grub_tpm_verify_string (char *str, enum grub_verify_string_type type) + { + const char *prefix = NULL; + char *description; +- grub_err_t status; + + switch (type) + { +@@ -73,15 +73,15 @@ grub_tpm_verify_string (char *str, enum grub_verify_string_type type) + } + description = grub_malloc (grub_strlen (str) + grub_strlen (prefix) + 1); + if (!description) +- return grub_errno; ++ return GRUB_ERR_NONE; + grub_memcpy (description, prefix, grub_strlen (prefix)); + grub_memcpy (description + grub_strlen (prefix), str, + grub_strlen (str) + 1); +- status = +- grub_tpm_measure ((unsigned char *) str, grub_strlen (str), +- GRUB_STRING_PCR, description); ++ ++ grub_tpm_measure ((unsigned char *) str, grub_strlen (str), GRUB_STRING_PCR, ++ description); + grub_free (description); +- return status; ++ return GRUB_ERR_NONE; + } + + struct grub_file_verifier grub_tpm_verifier = { +-- +1.8.3.1 + diff --git a/0212-blscfg-Fallback-to-search-BLS-snippets-in-boot-loade.patch b/0212-blscfg-Fallback-to-search-BLS-snippets-in-boot-loade.patch deleted file mode 100644 index d04928f82703ddb0dcb3a2289cbba8771376da20..0000000000000000000000000000000000000000 --- a/0212-blscfg-Fallback-to-search-BLS-snippets-in-boot-loade.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 18 Jul 2018 08:08:06 +0200 -Subject: [PATCH] blscfg: Fallback to search BLS snippets in - /boot/loader/entries - -The default path to search the BLS snippets is /loader/entries, this is -only a correct assumption if $root ($root) is a boot partition but it's -not true if /boot isn't a mount point. - -A user can set a blsdir grub environment variable to choose a different -path, but instead of failing when /boot is a directory inside the root -partition fallback to search the BLS in /boot/loader/entries to cover -that case as well. - -Reported-by: Hans de Goede -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 13 ++++++++++++- - 1 file changed, 12 insertions(+), 1 deletion(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 80d8814fc3f..321c93069f2 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -692,6 +692,7 @@ static int find_entry (const char *filename, - grub_device_t blsdir_dev = NULL; - const char *blsdir = NULL; - char *saved_env_buf = NULL; -+ int fallback = 0; - int r = 0; - const char *devid = grub_env_get ("boot"); - -@@ -797,7 +798,9 @@ static int find_entry (const char *filename, - } - read_entry_info.dirname = blsdir; - -- r = blsdir_fs->dir (blsdir_dev, blsdir, read_entry, &read_entry_info); -+read_fallback: -+ r = blsdir_fs->dir (blsdir_dev, read_entry_info.dirname, read_entry, -+ &read_entry_info); - if (r != 0) { - grub_dprintf ("blscfg", "read_entry returned error\n"); - grub_err_t e; -@@ -807,6 +810,14 @@ static int find_entry (const char *filename, - } while (e); - } - -+ if (!nentries && !fallback && info->platform != PLATFORM_EMU) { -+ read_entry_info.dirname = "/boot" GRUB_BLS_CONFIG_PATH; -+ grub_dprintf ("blscfg", "Entries weren't found in %s, fallback to %s\n", -+ blsdir, read_entry_info.dirname); -+ fallback = 1; -+ goto read_fallback; -+ } -+ - grub_dprintf ("blscfg", "Sorting %d entries\n", nentries); - grub_qsort(&entries[0], nentries, sizeof (struct bls_entry *), bls_cmp, NULL); - diff --git a/0212-tpm-Enable-module-for-all-EFI-platforms.patch b/0212-tpm-Enable-module-for-all-EFI-platforms.patch new file mode 100644 index 0000000000000000000000000000000000000000..db25a35c85b9bbbe6370f504920ddd3f98327c63 --- /dev/null +++ b/0212-tpm-Enable-module-for-all-EFI-platforms.patch @@ -0,0 +1,29 @@ +From 605c3bd42fbec1fa1c09e35bb93c6c577110b870 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Mon, 18 May 2020 12:56:27 +0200 +Subject: [PATCH 212/220] tpm: Enable module for all EFI platforms + +The tpm module is only enabled for x86_64, but there's nothing specific to +that architecture in the code and could be enabled for all EFI platforms. + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/Makefile.core.def | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def +index 6619946..b283c50 100644 +--- a/grub-core/Makefile.core.def ++++ b/grub-core/Makefile.core.def +@@ -2512,7 +2512,7 @@ module = { + name = tpm; + common = commands/tpm.c; + efi = commands/efi/tpm.c; +- enable = x86_64_efi; ++ enable = efi; + }; + + module = { +-- +1.8.3.1 + diff --git a/0213-10_linux.in-Don-t-update-BLS-files-that-aren-t-manag.patch b/0213-10_linux.in-Don-t-update-BLS-files-that-aren-t-manag.patch new file mode 100644 index 0000000000000000000000000000000000000000..3df6cb46db844becfbac0cece1fcf22cbe781505 --- /dev/null +++ b/0213-10_linux.in-Don-t-update-BLS-files-that-aren-t-manag.patch @@ -0,0 +1,59 @@ +From b72f41efc2b25d77e8530d0ed412acc03d6911d3 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Wed, 20 May 2020 12:23:27 +0200 +Subject: [PATCH 213/220] 10_linux.in: Don't update BLS files that aren't + managed by GRUB scripts + +The script is updating all BLS files present in the /boot/loader/entries +directory, but it should only update the BLS that belong to the machine. + +Otherwise if a user is sharing the same boot partition between different +operating systems, the grub2-mkconfig tool will wrongly update BLS files +that were created by a different OS. + +There are also cases where the BLS snippets are not managed by the GRUB +scripts at all, for example in OSTree based systems. So it's also wrong +to update the BLS snippets created by OSTree. + +Resolves: rhbz#1837783 + +Signed-off-by: Javier Martinez Canillas +--- + util/grub.d/10_linux.in | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in +index 519e2d9..e61b6c9 100644 +--- a/util/grub.d/10_linux.in ++++ b/util/grub.d/10_linux.in +@@ -138,16 +138,25 @@ blsdir="/boot/loader/entries" + + get_sorted_bls() + { ++ if ! [ -d "${blsdir}" ] || ! [ -e /etc/machine-id ]; then ++ return ++ fi ++ ++ read machine_id < /etc/machine-id ++ if [ -z "${machine_id}" ]; then ++ return ++ fi ++ + local IFS=$'\n' + +- files=($(for bls in ${blsdir}/*.conf; do ++ files=($(for bls in ${blsdir}/${machine_id}-*.conf; do + if ! [[ -e "${bls}" ]] ; then + continue + fi + bls="${bls%.conf}" + bls="${bls##*/}" + echo "${bls}" +- done | ${kernel_sort} | tac)) || : ++ done | ${kernel_sort} 2>/dev/null | tac)) || : + + echo "${files[@]}" + } +-- +1.8.3.1 + diff --git a/0213-blscfg-Don-t-attempt-to-sort-by-version-if-not-prese.patch b/0213-blscfg-Don-t-attempt-to-sort-by-version-if-not-prese.patch deleted file mode 100644 index 60b609db3a182f14451f908474e766f5e7669539..0000000000000000000000000000000000000000 --- a/0213-blscfg-Don-t-attempt-to-sort-by-version-if-not-prese.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Wed, 18 Jul 2018 00:58:44 +0200 -Subject: [PATCH] blscfg: Don't attempt to sort by version if not present in - all BLS files - -Commit a16805341cc ("blscfg: sort BLS entries by 'version' field") made to -sort by the version field take precedence over the BLS fragment file name. - -But it also uses the lack of the version field in one BLS fragment as sort -criterion, which means that entries could be wrongly sorted if one of them -doesn't have a version field and others do. - -So only sort by version if all the BLS entries have this field defined, -otherwise just fallback to sorting by the BLS file name. - -Reported-by: Hans de Goede -Suggested-by: Will Thompson -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 27 ++++++++++++++++----------- - 1 file changed, 16 insertions(+), 11 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 321c93069f2..69bfb5db295 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -324,23 +324,21 @@ finish: - /* return 1: p0 is newer than p1 */ - /* 0: p0 and p1 are the same version */ - /* -1: p1 is newer than p0 */ --static int bls_cmp(const void *p0, const void *p1, void *state UNUSED) -+static int bls_cmp(const void *p0, const void *p1, void *state) - { - struct bls_entry * e0 = *(struct bls_entry **)p0; - struct bls_entry * e1 = *(struct bls_entry **)p1; -+ bool use_version = *(bool *)state; - const char *v0, *v1; - int r; - -- v0 = bls_get_val(e0, "version", NULL); -- v1 = bls_get_val(e1, "version", NULL); -+ if (use_version) { -+ v0 = bls_get_val(e0, "version", NULL); -+ v1 = bls_get_val(e1, "version", NULL); - -- if (v0 && !v1) -- return -1; -- if (!v0 && v1) -- return 1; -- -- if ((r = vercmp(v0, v1)) != 0) -- return r; -+ if ((r = vercmp(v0, v1)) != 0) -+ return r; -+ } - - return vercmp(e0->filename, e1->filename); - } -@@ -692,6 +690,7 @@ static int find_entry (const char *filename, - grub_device_t blsdir_dev = NULL; - const char *blsdir = NULL; - char *saved_env_buf = NULL; -+ bool use_version = true; - int fallback = 0; - int r = 0; - const char *devid = grub_env_get ("boot"); -@@ -819,7 +818,13 @@ read_fallback: - } - - grub_dprintf ("blscfg", "Sorting %d entries\n", nentries); -- grub_qsort(&entries[0], nentries, sizeof (struct bls_entry *), bls_cmp, NULL); -+ -+ for (r = 0; r < nentries && use_version; r++) { -+ if (!bls_get_val(entries[r], "version", NULL)) -+ use_version = false; -+ } -+ -+ grub_qsort(&entries[0], nentries, sizeof (struct bls_entry *), bls_cmp, &use_version); - - grub_dprintf ("blscfg", "%s Creating %d entries from bls\n", __func__, nentries); - for (r = nentries - 1; r >= 0; r--) diff --git a/0214-blscfg-remove-logic-to-read-the-grubenv-file-and-set.patch b/0214-blscfg-remove-logic-to-read-the-grubenv-file-and-set.patch deleted file mode 100644 index f32b620a8ac04fc0c98fdf6c147c196993255358..0000000000000000000000000000000000000000 --- a/0214-blscfg-remove-logic-to-read-the-grubenv-file-and-set.patch +++ /dev/null @@ -1,292 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Sat, 28 Jul 2018 23:57:15 +0200 -Subject: [PATCH] blscfg: remove logic to read the grubenv file and set the - blsdir variable - -The BLS grub2 support has a blsdir environment variable that can be set by -users to override the BLS fragment default path. - -Currently the BLS parsing code reads the grubenv file and sets the blsdir -variable, but it shouldn't be the responsability of the blscfg module to -do this and instead just use it if the variable has been set (either from -the grub.cfg file or the grub shell). - -This makes the find_entry() function much simpler and consistent for EFI, -BIOS and grub-emu. It also fixes a bug that caused having menu entries to -be repeated for each sub-directory that existed under the /EFI directory. - -So for example having three different operating systems sharing the ESP, -would lead to the boot menu entries being repeated three times for grub. - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/blscfg.c | 179 ++++---------------------------------------- - 1 file changed, 16 insertions(+), 163 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index 69bfb5db295..bdb1c5a95aa 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -45,13 +45,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #define GRUB_BOOT_DEVICE "($root)" - #endif - --enum -- { -- PLATFORM_EFI, -- PLATFORM_EMU, -- PLATFORM_BIOS, -- }; -- - #define grub_free(x) ({grub_dprintf("blscfg", "%s freeing %p\n", __func__, x); grub_free(x); }) - - struct keyval -@@ -666,137 +659,37 @@ finish: - } - - struct find_entry_info { -+ const char *devid; - grub_device_t dev; - grub_fs_t fs; - int platform; - }; - - /* -- * filename: if the directory is /EFI/something/ , filename is "something" -- * info: unused -- * data: the filesystem object the file is on. -+ * info: the filesystem object the file is on. - */ --static int find_entry (const char *filename, -- const struct grub_dirhook_info *dirhook_info UNUSED, -- void *data) -+static int find_entry (struct find_entry_info *info) - { -- struct find_entry_info *info = (struct find_entry_info *)data; - struct read_entry_info read_entry_info; -- grub_file_t f = NULL; -- char *grubenv_path = NULL; -- grub_envblk_t env = NULL; -- const char *default_blsdir = NULL; - grub_fs_t blsdir_fs = NULL; - grub_device_t blsdir_dev = NULL; - const char *blsdir = NULL; -- char *saved_env_buf = NULL; - bool use_version = true; - int fallback = 0; - int r = 0; -- const char *devid = grub_env_get ("boot"); -- -- grub_dprintf("blscfg", "%s got here\n", __func__); -- if (filename && (!grub_strcmp (filename, ".") || -- !grub_strcmp (filename, ".."))) -- return 0; -- -- if (info->platform == PLATFORM_EFI && !grub_strcasecmp (filename, "boot")) -- return 0; -- -- saved_env_buf = grub_malloc (512); -- -- // set a default blsdir -- if (info->platform == PLATFORM_EMU) -- default_blsdir = GRUB_BOOT_DEVICE GRUB_BLS_CONFIG_PATH; -- else -- default_blsdir = GRUB_BLS_CONFIG_PATH; -- -- grub_env_set ("blsdir", default_blsdir); -- grub_dprintf ("blscfg", "default_blsdir: \"%s\"\n", default_blsdir); -- -- /* -- * try to load a grubenv from /EFI/wherever/grubenv -- */ -- if (info->platform == PLATFORM_EFI) -- grubenv_path = grub_xasprintf ("(%s)/EFI/%s/grubenv", devid, filename); -- else -- grubenv_path = grub_xasprintf ("(%s)/grub2/grubenv", devid); -- -- grub_dprintf ("blscfg", "looking for \"%s\"\n", grubenv_path); -- f = grub_file_open (grubenv_path); -- -- grub_dprintf ("blscfg", "%s it\n", f ? "found" : "did not find"); -- grub_free (grubenv_path); -- if (f) -- { -- grub_off_t sz; -- -- grub_dprintf ("blscfg", "getting size\n"); -- sz = grub_file_size (f); -- if (sz == GRUB_FILE_SIZE_UNKNOWN || sz > 1024*1024) -- goto finish; -- -- grub_dprintf ("blscfg", "reading env\n"); -- env = read_envblk_file (f); -- if (!env) -- goto finish; -- grub_dprintf ("blscfg", "read env file\n"); -- -- grub_memset (saved_env_buf, '#', 512); -- grub_memcpy (saved_env_buf, GRUB_ENVBLK_SIGNATURE, -- sizeof (GRUB_ENVBLK_SIGNATURE)); -- grub_dprintf ("blscfg", "saving env\n"); -- saved_env = grub_envblk_open (saved_env_buf, 512); -- if (!saved_env) -- goto finish; -- -- // save everything listed in "env" with values from our existing grub env -- grub_envblk_iterate (env, NULL, save_var); -- // set everything from our loaded grubenv into the real grub env -- grub_envblk_iterate (env, NULL, set_var); -- } -- else -- { -- grub_err_t e; -- grub_dprintf ("blscfg", "no such file\n"); -- do -- { -- e = grub_error_pop(); -- } while (e); -- -- } - - blsdir = grub_env_get ("blsdir"); - if (!blsdir) -- goto finish; -+ blsdir = GRUB_BLS_CONFIG_PATH; - -- grub_dprintf ("blscfg", "blsdir: \"%s\"\n", blsdir); -- blsdir = grub_strdup (blsdir); -- -- if (!blsdir) -- goto finish; -- -- grub_dprintf ("blscfg", "blsdir: \"%s\"\n", blsdir); -- if (info->platform == PLATFORM_EFI) { -- read_entry_info.devid = grub_env_get ("root"); -- if (!read_entry_info.devid) -- goto finish; -- -- blsdir_dev = grub_device_open (read_entry_info.devid); -- if (!blsdir_dev) -- goto finish; -- -- blsdir_fs = grub_fs_probe (blsdir_dev); -- if (!blsdir_fs) -- goto finish; -- -- } else { -- read_entry_info.devid = devid; -- blsdir_dev = info->dev; -- blsdir_fs = info->fs; -- } - read_entry_info.dirname = blsdir; - -+ grub_dprintf ("blscfg", "scanning blsdir: %s\n", GRUB_BLS_CONFIG_PATH); -+ -+ blsdir_dev = info->dev; -+ blsdir_fs = info->fs; -+ read_entry_info.devid = info->devid; -+ - read_fallback: - r = blsdir_fs->dir (blsdir_dev, read_entry_info.dirname, read_entry, - &read_entry_info); -@@ -809,7 +702,7 @@ read_fallback: - } while (e); - } - -- if (!nentries && !fallback && info->platform != PLATFORM_EMU) { -+ if (!nentries && !fallback) { - read_entry_info.dirname = "/boot" GRUB_BLS_CONFIG_PATH; - grub_dprintf ("blscfg", "Entries weren't found in %s, fallback to %s\n", - blsdir, read_entry_info.dirname); -@@ -832,41 +725,12 @@ read_fallback: - - for (r = 0; r < nentries; r++) - bls_free_entry (entries[r]); --finish: -- if (info->platform == PLATFORM_EFI && blsdir_dev) -- grub_device_close (blsdir_dev); - - nentries = 0; - - grub_free (entries); - entries = NULL; - -- grub_free ((char *)blsdir); -- -- grub_env_unset ("blsdir"); -- -- if (saved_env) -- { -- // remove everything from the real environment that's defined in env -- grub_envblk_iterate (env, NULL, unset_var); -- -- // re-set the things from our original environment -- grub_envblk_iterate (saved_env, NULL, set_var); -- grub_envblk_close (saved_env); -- saved_env = NULL; -- } -- else if (saved_env_buf) -- { -- // if we have a saved environment, grub_envblk_close() freed this. -- grub_free (saved_env_buf); -- } -- -- if (env) -- grub_envblk_close (env); -- -- if (f) -- grub_file_close (f); -- - return 0; - } - -@@ -883,7 +747,6 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - { - .dev = NULL, - .fs = NULL, -- .platform = PLATFORM_BIOS, - }; - - -@@ -891,13 +754,14 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - - #ifdef GRUB_MACHINE_EMU - devid = "host"; -- grub_env_set ("boot", devid); -+#elif defined(GRUB_MACHINE_EFI) -+ devid = grub_env_get ("root"); - #else - devid = grub_env_get ("boot"); -+#endif - if (!devid) - return grub_error (GRUB_ERR_FILE_NOT_FOUND, - N_("variable `%s' isn't set"), "boot"); --#endif - - grub_dprintf ("blscfg", "opening %s\n", devid); - dev = grub_device_open (devid); -@@ -912,21 +776,10 @@ grub_cmd_blscfg (grub_extcmd_context_t ctxt UNUSED, - goto finish; - } - -+ info.devid = devid; - info.dev = dev; - info.fs = fs; --#ifdef GRUB_MACHINE_EFI -- info.platform = PLATFORM_EFI; -- grub_dprintf ("blscfg", "scanning /EFI/\n"); -- r = fs->dir (dev, "/EFI/", find_entry, &info); --#elif defined(GRUB_MACHINE_EMU) -- info.platform = PLATFORM_EMU; -- grub_dprintf ("blscfg", "scanning %s%s\n", GRUB_BOOT_DEVICE, -- GRUB_BLS_CONFIG_PATH); -- find_entry(NULL, NULL, &info); --#else -- grub_dprintf ("blscfg", "scanning %s\n", GRUB_BLS_CONFIG_PATH); -- find_entry(NULL, NULL, &info); --#endif -+ find_entry(&info); - - finish: - if (dev) diff --git a/0214-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch b/0214-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch new file mode 100644 index 0000000000000000000000000000000000000000..a445031a924efac924c5b46051e9801e4637164f --- /dev/null +++ b/0214-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch @@ -0,0 +1,43 @@ +From c9ea6acded92ff5a4dfb336965da35e3b3407934 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 26 May 2020 16:59:28 +0200 +Subject: [PATCH 214/220] x86-efi: Reduce maximum bounce buffer size to 16 MiB + +The EFI linux loader allocates a bounce buffer to copy the initrd since in +some machines doing DMA on addresses above 4GB is not possible during EFI. + +But the verifiers framework also allocates a buffer to copy the initrd in +its grub_file_open() handler. It does this since the data to verify has to +be passed as a single chunk to modules that use the verifiers framework. + +If the initrd image size is big there may not be enough memory in the heap +to allocate two buffers of that size. This causes an allocation failure in +the verifiers framework and leads to the initrd not being read. + +To prevent these allocation failures, let's reduce the maximum size of the +bounce buffer used in the EFI loader. Since the data read can be copied to +the actual initrd address in multilple chunks. + +Resolves: rhbz#1838633 + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/loader/i386/efi/linux.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index 50b7798..e5b2736 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -144,7 +144,7 @@ grub_linuxefi_unload (void) + return GRUB_ERR_NONE; + } + +-#define BOUNCE_BUFFER_MAX 0x10000000ull ++#define BOUNCE_BUFFER_MAX 0x1000000ull + + static grub_ssize_t + read(grub_file_t file, grub_uint8_t *bufp, grub_size_t len) +-- +1.8.3.1 + diff --git a/0215-Rename-00_menu_auto_hide.in-to-01_menu_auto_hide.in.patch b/0215-Rename-00_menu_auto_hide.in-to-01_menu_auto_hide.in.patch deleted file mode 100644 index 14cc004b1e28e1ca5850cfc9291cf74ab77a4061..0000000000000000000000000000000000000000 --- a/0215-Rename-00_menu_auto_hide.in-to-01_menu_auto_hide.in.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Christian Glombek -Date: Tue, 31 Jul 2018 11:11:01 +0200 -Subject: [PATCH] Rename 00_menu_auto_hide.in to 01_menu_auto_hide.in - -This is necessary to accommodate the fallback counting script which -needs to run before this one because the menu auto hide script sets -boot_success = 0, which will be used by the boot counting script ---- - Makefile.util.def | 4 ++-- - util/grub.d/{00_menu_auto_hide.in => 01_menu_auto_hide.in} | 0 - 2 files changed, 2 insertions(+), 2 deletions(-) - rename util/grub.d/{00_menu_auto_hide.in => 01_menu_auto_hide.in} (100%) - -diff --git a/Makefile.util.def b/Makefile.util.def -index 97cd8bdebd9..cba4d500198 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -449,8 +449,8 @@ script = { - }; - - script = { -- name = '00_menu_auto_hide'; -- common = util/grub.d/00_menu_auto_hide.in; -+ name = '01_menu_auto_hide'; -+ common = util/grub.d/01_menu_auto_hide.in; - installdir = grubconf; - }; - -diff --git a/util/grub.d/00_menu_auto_hide.in b/util/grub.d/01_menu_auto_hide.in -similarity index 100% -rename from util/grub.d/00_menu_auto_hide.in -rename to util/grub.d/01_menu_auto_hide.in diff --git a/0215-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch b/0215-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch new file mode 100644 index 0000000000000000000000000000000000000000..a1afac786a374a50e15bfc845a2eba4a47908bbe --- /dev/null +++ b/0215-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch @@ -0,0 +1,50 @@ +From 38e8b235d4fdb4ff0d615d83cb03e716c7fde08b Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 2 Jun 2020 13:25:01 +0200 +Subject: [PATCH 215/220] http: Prepend prefix when the HTTP path is relative + as done in efi/http + +There are two different HTTP drivers that can be used when requesting an +HTTP resource: the efi/http that uses the EFI_HTTP_PROTOCOL and the http +that uses GRUB's HTTP and TCP/IP implementation. + +The efi/http driver appends a prefix that is defined in the variable +http_path, but the http driver doesn't. + +So using this driver and attempting to fetch a resource using a relative +path fails. + +Signed-off-by: Javier Martinez Canillas +--- + grub-core/net/http.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/grub-core/net/http.c b/grub-core/net/http.c +index b52b558..7f878b5 100644 +--- a/grub-core/net/http.c ++++ b/grub-core/net/http.c +@@ -501,13 +501,20 @@ http_open (struct grub_file *file, const char *filename) + { + grub_err_t err; + struct http_data *data; ++ const char *http_path; + + data = grub_zalloc (sizeof (*data)); + if (!data) + return grub_errno; + file->size = GRUB_FILE_SIZE_UNKNOWN; + +- data->filename = grub_strdup (filename); ++ /* If path is relative, prepend http_path */ ++ http_path = grub_env_get ("http_path"); ++ if (http_path && filename[0] != '/') ++ data->filename = grub_xasprintf ("%s/%s", http_path, filename); ++ else ++ data->filename = grub_strdup (filename); ++ + if (!data->filename) + { + grub_free (data); +-- +1.8.3.1 + diff --git a/0216-fix-build-with-rpm-4.16.patch b/0216-fix-build-with-rpm-4.16.patch new file mode 100644 index 0000000000000000000000000000000000000000..4fe21917a072ecb3e54eddce4ae523ea203ffac9 --- /dev/null +++ b/0216-fix-build-with-rpm-4.16.patch @@ -0,0 +1,33 @@ +From 975515d9a2ccab6ca78f9d2dd9e916e444f568ae Mon Sep 17 00:00:00 2001 +From: Thierry Vignaud +Date: Mon, 8 Jun 2020 06:50:21 +0200 +Subject: [PATCH 216/220] fix build with rpm-4.16 + +Signed-off-by: Thierry Vignaud +--- + configure.ac | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/configure.ac b/configure.ac +index eff160b..5d33161 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1887,6 +1887,15 @@ if test x"$rpm_sort_excuse" = x ; then + [Define to 1 if you have the rpm library.]) + fi + ++if test x"$LIBRPM" = x ; then ++ # Check for rpm library. ++ AC_CHECK_LIB([rpmio], [rpmvercmp], [], ++ [rpm_sort_excuse="rpmio missing rpmvercmp"]) ++ LIBRPM="-lrpmio"; ++ AC_DEFINE([HAVE_RPMIO], [1], ++ [Define to 1 if you have the rpm library.]) ++fi ++ + AC_SUBST([LIBRPM]) + + LIBGEOM= +-- +1.8.3.1 + diff --git a/0217-Only-mark-GRUB-as-BLS-supported-in-OSTree-systems-wi.patch b/0217-Only-mark-GRUB-as-BLS-supported-in-OSTree-systems-wi.patch new file mode 100644 index 0000000000000000000000000000000000000000..c27df449b956e822819dc7b32ac00aab2dd13221 --- /dev/null +++ b/0217-Only-mark-GRUB-as-BLS-supported-in-OSTree-systems-wi.patch @@ -0,0 +1,38 @@ +From 077d33c5035a51c50fa256330bbc82cde106855e Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Thu, 18 Jun 2020 11:19:00 +0200 +Subject: [PATCH 217/220] Only mark GRUB as BLS supported in OSTree systems + with a boot partition + +The script grub2-switch-to-blscfg updates the grub2 EFI binary in OSTree +systems and marks that has BLS support, to indicate that's not necessary +to add menuentry commands since the BLS snippets can be used to populate +the GRUB boot menu. + +But OSTree doesn't support installations that don't have a boot partition, +the BLS snippets assume that there will be one so this has to be checked +and only mark the bootloader as supporting BLS in OSTree installations +that have /boot as a mountpoint. + +Signed-off-by: Javier Martinez Canillas +--- + util/grub-switch-to-blscfg.in | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in +index cb22912..a851424 100644 +--- a/util/grub-switch-to-blscfg.in ++++ b/util/grub-switch-to-blscfg.in +@@ -261,7 +261,8 @@ copy_bls() { + # but only do this if the blsdir is not set, to make sure that the BLS + # parsing module will search for the BLS snippets in the default path. + if test -f /run/ostree-booted && test -d /sys/firmware/efi/efivars && \ +- ! ${grub_editenv} - list | grep -q blsdir; then ++ ! ${grub_editenv} - list | grep -q blsdir && \ ++ mountpoint -q /boot; then + grub_binary="$(find /usr/lib/ostree-boot/efi/EFI/${EFIDIR}/ -name grub*.efi)" + install -m 700 ${grub_binary} ${grubdir} || exit 1 + # Create a hidden file to indicate that grub2 now has BLS support. +-- +1.8.3.1 + diff --git a/0218-Disable-multiboot-multiboot2-and-linux16-modules-on-.patch b/0218-Disable-multiboot-multiboot2-and-linux16-modules-on-.patch deleted file mode 100644 index 9dccf5a0615c6648c61f309be7096ea3999ac92e..0000000000000000000000000000000000000000 --- a/0218-Disable-multiboot-multiboot2-and-linux16-modules-on-.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 11 Jul 2018 13:48:48 -0400 -Subject: [PATCH] Disable multiboot, multiboot2, and linux16 modules on EFI - builds. - -Signed-off-by: Peter Jones ---- - grub-core/Makefile.core.def | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index aa44d66aca4..d3e3bfd4d7a 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -1680,7 +1680,7 @@ module = { - - common = loader/multiboot.c; - common = loader/multiboot_mbi2.c; -- enable = x86; -+ enable = i386_pc; - enable = mips; - }; - -@@ -1689,7 +1689,7 @@ module = { - common = loader/multiboot.c; - x86 = loader/i386/multiboot_mbi.c; - extra_dist = loader/multiboot_elfxx.c; -- enable = x86; -+ enable = i386_pc; - }; - - module = { diff --git a/0218-support-TPM2.0-in-grub2-both-legacy-and-efi.patch b/0218-support-TPM2.0-in-grub2-both-legacy-and-efi.patch new file mode 100644 index 0000000000000000000000000000000000000000..d5fbdf7a85dfb186154f2b89a89733f141dddade --- /dev/null +++ b/0218-support-TPM2.0-in-grub2-both-legacy-and-efi.patch @@ -0,0 +1,27 @@ +From ca6d4093a87c9aa6059ad4e396a50ff485cc0066 Mon Sep 17 00:00:00 2001 +From: linyanly +Date: Fri, 3 Nov 2017 15:53:29 +0800 +Subject: [PATCH 218/220] backport 'support TPM2.0 in grub2, both legacy and + efi' + +--- + grub-core/kern/emu/mm.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/grub-core/kern/emu/mm.c b/grub-core/kern/emu/mm.c +index f262e95..43b31fa 100644 +--- a/grub-core/kern/emu/mm.c ++++ b/grub-core/kern/emu/mm.c +@@ -50,7 +50,8 @@ grub_zalloc (grub_size_t size) + void + grub_free (void *ptr) + { +- free (ptr); ++ if (ptr) ++ free (ptr); + } + + void * +-- +1.8.3.1 + diff --git a/0219-Force-everything-to-use-python3.patch b/0219-Force-everything-to-use-python3.patch deleted file mode 100644 index b4b0d74cc2aee8724f9df71242bec8b849436c86..0000000000000000000000000000000000000000 --- a/0219-Force-everything-to-use-python3.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Tue, 10 Jul 2018 16:54:02 -0400 -Subject: [PATCH] Force everything to use python3 - -But this still means you need to do PYTHON=python=3 ./autogen.sh if you -run the world's worst tooling before you patch. - -Signed-off-by: Peter Jones ---- - conf/Makefile.common | 4 ++-- - gentpl.py | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/conf/Makefile.common b/conf/Makefile.common -index c75848f5c06..1ecb921db65 100644 ---- a/conf/Makefile.common -+++ b/conf/Makefile.common -@@ -128,11 +128,11 @@ BUILT_SOURCES = - - .PRECIOUS: $(top_srcdir)/Makefile.util.am - $(top_srcdir)/Makefile.util.am: $(top_srcdir)/gentpl.py $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.utilgcry.def -- python $^ > $@.new || (rm -f $@.new; exit 1) -+ python3 $^ > $@.new || (rm -f $@.new; exit 1) - mv $@.new $@ - - .PRECIOUS: $(top_srcdir)/grub-core/Makefile.core.am - $(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/gentpl.py $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def - if [ "x$$GRUB_CONTRIB" != x ]; then echo "You need to run ./autogen.sh manually." >&2; exit 1; fi -- python $^ > $@.new || (rm -f $@.new; exit 1) -+ python3 $^ > $@.new || (rm -f $@.new; exit 1) - mv $@.new $@ -diff --git a/gentpl.py b/gentpl.py -index baac6a2af69..6409736e81c 100644 ---- a/gentpl.py -+++ b/gentpl.py -@@ -1,4 +1,4 @@ --#! /usr/bin/python -+#! /usr/bin/env python3 - # GRUB -- GRand Unified Bootloader - # Copyright (C) 2010,2011,2012,2013 Free Software Foundation, Inc. - # diff --git a/Workaround-for-EFI-Bug-Plan3.patch b/0219-Workaround-for-EFI-Bug-Plan3.patch similarity index 92% rename from Workaround-for-EFI-Bug-Plan3.patch rename to 0219-Workaround-for-EFI-Bug-Plan3.patch index c37636c41bf4b9ac0accf3618953c94b05019a2c..a1cd9bd1d3a2cb363f83db2480f4b5cde302a35a 100644 --- a/Workaround-for-EFI-Bug-Plan3.patch +++ b/0219-Workaround-for-EFI-Bug-Plan3.patch @@ -1,7 +1,7 @@ -From cd19beea0f46f2648e8fbf145bc6014e7096e693 Mon Sep 17 00:00:00 2001 +From 55f6c378c70e139d28f1d8b60bb0197946659fb1 Mon Sep 17 00:00:00 2001 From: Zhao Lei Date: Mon, 25 Feb 2019 18:04:10 +0800 -Subject: [PATCH] Workaround for EFI Bug (Plan3) +Subject: [PATCH 219/220] Workaround for EFI Bug (Plan3) Signed-off-by: Zhao Lei --- @@ -9,7 +9,7 @@ Signed-off-by: Zhao Lei 1 file changed, 107 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c -index f04f20b..3786438 100644 +index 54c227b..abb98aa 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -27,12 +27,19 @@ @@ -32,7 +32,7 @@ index f04f20b..3786438 100644 struct grub_efidisk_data *next; }; -@@ -92,6 +99,7 @@ make_devices (void) +@@ -107,6 +114,7 @@ make_devices (void) d->device_path = dp; d->last_device_path = ldp; d->block_io = bio; @@ -40,7 +40,7 @@ index f04f20b..3786438 100644 d->next = devices; devices = d; } -@@ -519,8 +527,9 @@ grub_efidisk_close (struct grub_disk *disk __attribute__ ((unused))) +@@ -540,8 +548,9 @@ grub_efidisk_close (struct grub_disk *disk __attribute__ ((unused))) grub_dprintf ("efidisk", "closing %s\n", disk->name); } @@ -51,7 +51,7 @@ index f04f20b..3786438 100644 grub_size_t size, char *buf, int wr) { struct grub_efidisk_data *d; -@@ -563,6 +572,103 @@ grub_efidisk_readwrite (struct grub_disk *disk, grub_disk_addr_t sector, +@@ -584,6 +593,103 @@ grub_efidisk_readwrite (struct grub_disk *disk, grub_disk_addr_t sector, return status; } @@ -155,3 +155,6 @@ index f04f20b..3786438 100644 static grub_err_t grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector, grub_size_t size, char *buf) +-- +1.8.3.1 + diff --git a/0220-Fix-an-8-year-old-typo.patch b/0220-Fix-an-8-year-old-typo.patch deleted file mode 100644 index 642e46a7918dc278966b6e95e8e68ca487a2d81a..0000000000000000000000000000000000000000 --- a/0220-Fix-an-8-year-old-typo.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 26 Jul 2018 14:54:44 -0400 -Subject: [PATCH] Fix an 8 year old typo. - -Signed-off-by: Peter Jones ---- - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index 5f47a9265f3..9ab683fefac 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -307,7 +307,7 @@ fi - - AC_SUBST(bootdirname) - AC_DEFINE_UNQUOTED(GRUB_BOOT_DIR_NAME, "$bootdirname", -- [Default boot directory name]") -+ [Default boot directory name]) - - AC_ARG_WITH([grubdir], - AS_HELP_STRING([--with-grubdir=DIR], diff --git a/bugfix-remove-excess-qutos.patch b/0220-bugfix-remove-excess-qutos.patch similarity index 71% rename from bugfix-remove-excess-qutos.patch rename to 0220-bugfix-remove-excess-qutos.patch index 8dd31fef7983b2da4c78096c8c7957e7fba1be3f..f1a1e42b85fb929b568d9ef10d4cab5aa0c111fe 100644 --- a/bugfix-remove-excess-qutos.patch +++ b/0220-bugfix-remove-excess-qutos.patch @@ -1,24 +1,24 @@ -From a8107bb28cc702806ab74dd8a826d59c2ae7be6a Mon Sep 17 00:00:00 2001 +From 2332d14570ed41a15c36ff264b9790d832106607 Mon Sep 17 00:00:00 2001 From: fengtao Date: Tue, 10 Sep 2019 21:43:31 +0800 -Subject: [PATCH] fix grub2-setpassword errors for openEuler +Subject: [PATCH 220/220] fix grub2-setpassword errors for openEuler --- util/grub-set-password.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-set-password.in b/util/grub-set-password.in -index 5ebf505..4b88dee 100644 +index c0b5ebb..487fbb1 100644 --- a/util/grub-set-password.in +++ b/util/grub-set-password.in @@ -1,6 +1,6 @@ #!/bin/sh -e --EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/') -+EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/' | tr -d '"') +-EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/' -e 's/\"//g') ++EFIDIR=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/' -e 's/\"//g' | tr -d '"') if [ -d /sys/firmware/efi/efivars/ ]; then grubdir=`echo "/@bootdirname@/efi/EFI/${EFIDIR}/" | sed 's,//*,/,g'` else -- -2.19.1 +1.8.3.1 diff --git a/0221-autogen-don-t-run-autoreconf-in-the-topdir.patch b/0221-autogen-don-t-run-autoreconf-in-the-topdir.patch deleted file mode 100644 index e5b7c33db85aee5df555878b96a531ccf52408ee..0000000000000000000000000000000000000000 --- a/0221-autogen-don-t-run-autoreconf-in-the-topdir.patch +++ /dev/null @@ -1,21 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 26 Jul 2018 15:47:48 -0400 -Subject: [PATCH] autogen: don't run autoreconf in the topdir - -Signed-off-by: Peter Jones ---- - autogen.sh | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/autogen.sh b/autogen.sh -index 7537561ad0d..f608b9467a0 100755 ---- a/autogen.sh -+++ b/autogen.sh -@@ -82,6 +82,4 @@ done - echo "Saving timestamps..." - echo timestamp > stamp-h.in - --echo "Running autoreconf..." --autoreconf -vi - exit 0 diff --git a/0221-yylex-Make-lexer-fatal-errors-actually-be-fatal.patch b/0221-yylex-Make-lexer-fatal-errors-actually-be-fatal.patch new file mode 100644 index 0000000000000000000000000000000000000000..ca9fbe1686ef15eb0748766c68f3d9ebe67c8701 --- /dev/null +++ b/0221-yylex-Make-lexer-fatal-errors-actually-be-fatal.patch @@ -0,0 +1,69 @@ +From a4d3fbdff1e3ca8f87642af2ac8752c30c617a3e Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 15 Apr 2020 15:45:02 -0400 +Subject: [PATCH 01/27] yylex: Make lexer fatal errors actually be fatal + +When presented with a command that can't be tokenized to anything +smaller than YYLMAX characters, the parser calls YY_FATAL_ERROR(errmsg), +expecting that will stop further processing, as such: + + #define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + if ( yyleng >= YYLMAX ) \ + YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \ + yy_flex_strncpy( yytext, yyg->yytext_ptr, yyleng + 1 , yyscanner); \ + yyg->yy_c_buf_p = yy_cp; + +The code flex generates expects that YY_FATAL_ERROR() will either return +for it or do some form of longjmp(), or handle the error in some way at +least, and so the strncpy() call isn't in an "else" clause, and thus if +YY_FATAL_ERROR() is *not* actually fatal, it does the call with the +questionable limit, and predictable results ensue. + +Unfortunately, our implementation of YY_FATAL_ERROR() is: + + #define YY_FATAL_ERROR(msg) \ + do { \ + grub_printf (_("fatal error: %s\n"), _(msg)); \ + } while (0) + +The same pattern exists in yyless(), and similar problems exist in users +of YY_INPUT(), several places in the main parsing loop, +yy_get_next_buffer(), yy_load_buffer_state(), yyensure_buffer_stack, +yy_scan_buffer(), etc. + +All of these callers expect YY_FATAL_ERROR() to actually be fatal, and +the things they do if it returns after calling it are wildly unsafe. + +Fixes: CVE-2020-10713 + +Signed-off-by: Peter Jones +Reviewed-by: Daniel Kiper +--- + grub-core/script/yylex.l | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l +index 7b44c37..b7203c8 100644 +--- a/grub-core/script/yylex.l ++++ b/grub-core/script/yylex.l +@@ -37,11 +37,11 @@ + + /* + * As we don't have access to yyscanner, we cannot do much except to +- * print the fatal error. ++ * print the fatal error and exit. + */ + #define YY_FATAL_ERROR(msg) \ + do { \ +- grub_printf (_("fatal error: %s\n"), _(msg)); \ ++ grub_fatal (_("fatal error: %s\n"), _(msg));\ + } while (0) + + #define COPY(str, hint) \ +-- +2.23.0 + diff --git a/0222-safemath-Add-some-arithmetic-primitives-that-check-f.patch b/0222-safemath-Add-some-arithmetic-primitives-that-check-f.patch new file mode 100644 index 0000000000000000000000000000000000000000..0cb63df816d1f61bb893d8452822143dd287471b --- /dev/null +++ b/0222-safemath-Add-some-arithmetic-primitives-that-check-f.patch @@ -0,0 +1,89 @@ +From 68708c4503018d61dbcce7ac11cbb511d6425f4d Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 15 Jun 2020 10:58:42 -0400 +Subject: [PATCH 02/27] safemath: Add some arithmetic primitives that check for + overflow + +This adds a new header, include/grub/safemath.h, that includes easy to +use wrappers for __builtin_{add,sub,mul}_overflow() declared like: + + bool OP(a, b, res) + +where OP is grub_add, grub_sub or grub_mul. OP() returns true in the +case where the operation would overflow and res is not modified. +Otherwise, false is returned and the operation is executed. + +These arithmetic primitives require newer compiler versions. So, bump +these requirements in the INSTALL file too. + +Signed-off-by: Peter Jones +Reviewed-by: Daniel Kiper +--- + include/grub/compiler.h | 8 ++++++++ + include/grub/safemath.h | 37 +++++++++++++++++++++++++++++++++++++ + 2 files changed, 45 insertions(+) + create mode 100644 include/grub/safemath.h + +diff --git a/include/grub/compiler.h b/include/grub/compiler.h +index 9859ff4..61c0cb3 100644 +--- a/include/grub/compiler.h ++++ b/include/grub/compiler.h +@@ -50,4 +50,12 @@ + + #define UNUSED __attribute__((__unused__)) + ++#if defined(__clang__) && defined(__clang_major__) && defined(__clang_minor__) ++# define CLANG_PREREQ(maj,min) \ ++ ((__clang_major__ > (maj)) || \ ++ (__clang_major__ == (maj) && __clang_minor__ >= (min))) ++#else ++# define CLANG_PREREQ(maj,min) 0 ++#endif ++ + #endif /* ! GRUB_COMPILER_HEADER */ +diff --git a/include/grub/safemath.h b/include/grub/safemath.h +new file mode 100644 +index 0000000..c17b89b +--- /dev/null ++++ b/include/grub/safemath.h +@@ -0,0 +1,37 @@ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 2020 Free Software Foundation, Inc. ++ * ++ * GRUB is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * GRUB is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with GRUB. If not, see . ++ * ++ * Arithmetic operations that protect against overflow. ++ */ ++ ++#ifndef GRUB_SAFEMATH_H ++#define GRUB_SAFEMATH_H 1 ++ ++#include ++ ++/* These appear in gcc 5.1 and clang 3.8. */ ++#if GNUC_PREREQ(5, 1) || CLANG_PREREQ(3, 8) ++ ++#define grub_add(a, b, res) __builtin_add_overflow(a, b, res) ++#define grub_sub(a, b, res) __builtin_sub_overflow(a, b, res) ++#define grub_mul(a, b, res) __builtin_mul_overflow(a, b, res) ++ ++#else ++#error gcc 5.1 or newer or clang 3.8 or newer is required ++#endif ++ ++#endif /* GRUB_SAFEMATH_H */ +-- +2.23.0 + diff --git a/0223-calloc-Make-sure-we-always-have-an-overflow-checking.patch b/0223-calloc-Make-sure-we-always-have-an-overflow-checking.patch new file mode 100644 index 0000000000000000000000000000000000000000..bdfeb09db4bec5d98ff252bcb746d0dd945e90c8 --- /dev/null +++ b/0223-calloc-Make-sure-we-always-have-an-overflow-checking.patch @@ -0,0 +1,242 @@ +From 64e26162ebfe68317c143ca5ec996c892019f8f8 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 15 Jun 2020 12:15:29 -0400 +Subject: [PATCH 03/27] calloc: Make sure we always have an overflow-checking + calloc() available + +This tries to make sure that everywhere in this source tree, we always have +an appropriate version of calloc() (i.e. grub_calloc(), xcalloc(), etc.) +available, and that they all safely check for overflow and return NULL when +it would occur. + +Signed-off-by: Peter Jones +Reviewed-by: Daniel Kiper +--- + grub-core/kern/emu/misc.c | 12 +++++++++ + grub-core/kern/emu/mm.c | 10 ++++++++ + grub-core/kern/mm.c | 40 ++++++++++++++++++++++++++++++ + grub-core/lib/libgcrypt_wrap/mem.c | 11 ++++++-- + grub-core/lib/posix_wrap/stdlib.h | 8 +++++- + include/grub/emu/misc.h | 1 + + include/grub/mm.h | 6 +++++ + 7 files changed, 85 insertions(+), 3 deletions(-) + +diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c +index 7a8d9e6..f08a1bb 100644 +--- a/grub-core/kern/emu/misc.c ++++ b/grub-core/kern/emu/misc.c +@@ -86,6 +86,18 @@ grub_util_error (const char *fmt, ...) + grub_exit (1); + } + ++void * ++xcalloc (grub_size_t nmemb, grub_size_t size) ++{ ++ void *p; ++ ++ p = calloc (nmemb, size); ++ if (!p) ++ grub_util_error ("%s", _("out of memory")); ++ ++ return p; ++} ++ + void * + xmalloc (grub_size_t size) + { +diff --git a/grub-core/kern/emu/mm.c b/grub-core/kern/emu/mm.c +index 43b31fa..4d1046a 100644 +--- a/grub-core/kern/emu/mm.c ++++ b/grub-core/kern/emu/mm.c +@@ -25,6 +25,16 @@ + #include + #include + ++void * ++grub_calloc (grub_size_t nmemb, grub_size_t size) ++{ ++ void *ret; ++ ret = calloc (nmemb, size); ++ if (!ret) ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ return ret; ++} ++ + void * + grub_malloc (grub_size_t size) + { +diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c +index 002cbfa..80d0720 100644 +--- a/grub-core/kern/mm.c ++++ b/grub-core/kern/mm.c +@@ -67,8 +67,10 @@ + #include + #include + #include ++#include + + #ifdef MM_DEBUG ++# undef grub_calloc + # undef grub_malloc + # undef grub_zalloc + # undef grub_realloc +@@ -375,6 +377,30 @@ grub_memalign (grub_size_t align, grub_size_t size) + return 0; + } + ++/* ++ * Allocate NMEMB instances of SIZE bytes and return the pointer, or error on ++ * integer overflow. ++ */ ++void * ++grub_calloc (grub_size_t nmemb, grub_size_t size) ++{ ++ void *ret; ++ grub_size_t sz = 0; ++ ++ if (grub_mul (nmemb, size, &sz)) ++ { ++ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); ++ return NULL; ++ } ++ ++ ret = grub_memalign (0, sz); ++ if (!ret) ++ return NULL; ++ ++ grub_memset (ret, 0, sz); ++ return ret; ++} ++ + /* Allocate SIZE bytes and return the pointer. */ + void * + grub_malloc (grub_size_t size) +@@ -561,6 +587,20 @@ grub_mm_dump (unsigned lineno) + grub_printf ("\n"); + } + ++void * ++grub_debug_calloc (const char *file, int line, grub_size_t nmemb, grub_size_t size) ++{ ++ void *ptr; ++ ++ if (grub_mm_debug) ++ grub_printf ("%s:%d: calloc (0x%" PRIxGRUB_SIZE ", 0x%" PRIxGRUB_SIZE ") = ", ++ file, line, size); ++ ptr = grub_calloc (nmemb, size); ++ if (grub_mm_debug) ++ grub_printf ("%p\n", ptr); ++ return ptr; ++} ++ + void * + grub_debug_malloc (const char *file, int line, grub_size_t size) + { +diff --git a/grub-core/lib/libgcrypt_wrap/mem.c b/grub-core/lib/libgcrypt_wrap/mem.c +index beeb661..74c6eaf 100644 +--- a/grub-core/lib/libgcrypt_wrap/mem.c ++++ b/grub-core/lib/libgcrypt_wrap/mem.c +@@ -4,6 +4,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -36,7 +37,10 @@ void * + gcry_xcalloc (size_t n, size_t m) + { + void *ret; +- ret = grub_zalloc (n * m); ++ size_t sz; ++ if (grub_mul (n, m, &sz)) ++ grub_fatal ("gcry_xcalloc would overflow"); ++ ret = grub_zalloc (sz); + if (!ret) + grub_fatal ("gcry_xcalloc failed"); + return ret; +@@ -56,7 +60,10 @@ void * + gcry_xcalloc_secure (size_t n, size_t m) + { + void *ret; +- ret = grub_zalloc (n * m); ++ size_t sz; ++ if (grub_mul (n, m, &sz)) ++ grub_fatal ("gcry_xcalloc would overflow"); ++ ret = grub_zalloc (sz); + if (!ret) + grub_fatal ("gcry_xcalloc failed"); + return ret; +diff --git a/grub-core/lib/posix_wrap/stdlib.h b/grub-core/lib/posix_wrap/stdlib.h +index 3b46f47..7a8d385 100644 +--- a/grub-core/lib/posix_wrap/stdlib.h ++++ b/grub-core/lib/posix_wrap/stdlib.h +@@ -21,6 +21,7 @@ + + #include + #include ++#include + + static inline void + free (void *ptr) +@@ -37,7 +38,12 @@ malloc (grub_size_t size) + static inline void * + calloc (grub_size_t size, grub_size_t nelem) + { +- return grub_zalloc (size * nelem); ++ grub_size_t sz; ++ ++ if (grub_mul (size, nelem, &sz)) ++ return NULL; ++ ++ return grub_zalloc (sz); + } + + static inline void * +diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h +index 5ef4f79..0105695 100644 +--- a/include/grub/emu/misc.h ++++ b/include/grub/emu/misc.h +@@ -47,6 +47,7 @@ grub_util_device_is_mapped (const char *dev); + #define GRUB_HOST_PRIuLONG_LONG "llu" + #define GRUB_HOST_PRIxLONG_LONG "llx" + ++void * EXPORT_FUNC(xcalloc) (grub_size_t nmemb, grub_size_t size) WARN_UNUSED_RESULT; + void * EXPORT_FUNC(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT; + void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) WARN_UNUSED_RESULT; + char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT; +diff --git a/include/grub/mm.h b/include/grub/mm.h +index 28e2e53..9c38dd3 100644 +--- a/include/grub/mm.h ++++ b/include/grub/mm.h +@@ -29,6 +29,7 @@ + #endif + + void grub_mm_init_region (void *addr, grub_size_t size); ++void *EXPORT_FUNC(grub_calloc) (grub_size_t nmemb, grub_size_t size); + void *EXPORT_FUNC(grub_malloc) (grub_size_t size); + void *EXPORT_FUNC(grub_zalloc) (grub_size_t size); + void EXPORT_FUNC(grub_free) (void *ptr); +@@ -48,6 +49,9 @@ extern int EXPORT_VAR(grub_mm_debug); + void grub_mm_dump_free (void); + void grub_mm_dump (unsigned lineno); + ++#define grub_calloc(nmemb, size) \ ++ grub_debug_calloc (GRUB_FILE, __LINE__, nmemb, size) ++ + #define grub_malloc(size) \ + grub_debug_malloc (GRUB_FILE, __LINE__, size) + +@@ -63,6 +67,8 @@ void grub_mm_dump (unsigned lineno); + #define grub_free(ptr) \ + grub_debug_free (GRUB_FILE, __LINE__, ptr) + ++void *EXPORT_FUNC(grub_debug_calloc) (const char *file, int line, ++ grub_size_t nmemb, grub_size_t size); + void *EXPORT_FUNC(grub_debug_malloc) (const char *file, int line, + grub_size_t size); + void *EXPORT_FUNC(grub_debug_zalloc) (const char *file, int line, +-- +2.23.0 + diff --git a/0224-calloc-Use-calloc-at-most-places.patch b/0224-calloc-Use-calloc-at-most-places.patch new file mode 100644 index 0000000000000000000000000000000000000000..d806057826c2673b280743f8ffe9eae856fb9382 --- /dev/null +++ b/0224-calloc-Use-calloc-at-most-places.patch @@ -0,0 +1,1836 @@ +From f725fa7cb2ece547c5af01eeeecfe8d95802ed41 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 15 Jun 2020 12:26:01 -0400 +Subject: [PATCH 04/27] calloc: Use calloc() at most places + +This modifies most of the places we do some form of: + + X = malloc(Y * Z); + +to use calloc(Y, Z) instead. + +Among other issues, this fixes: + - allocation of integer overflow in grub_png_decode_image_header() + reported by Chris Coulson, + - allocation of integer overflow in luks_recover_key() + reported by Chris Coulson, + - allocation of integer overflow in grub_lvm_detect() + reported by Chris Coulson. + +Fixes: CVE-2020-14308 + +Signed-off-by: Peter Jones +Reviewed-by: Daniel Kiper +--- + grub-core/bus/usb/usbhub.c | 8 ++++---- + grub-core/commands/efi/lsefisystab.c | 3 ++- + grub-core/commands/legacycfg.c | 6 +++--- + grub-core/commands/menuentry.c | 2 +- + grub-core/commands/nativedisk.c | 2 +- + grub-core/commands/parttool.c | 12 +++++++++--- + grub-core/commands/regexp.c | 2 +- + grub-core/commands/search_wrap.c | 2 +- + grub-core/disk/diskfilter.c | 4 ++-- + grub-core/disk/ieee1275/ofdisk.c | 2 +- + grub-core/disk/ldm.c | 14 +++++++------- + grub-core/disk/luks.c | 2 +- + grub-core/disk/lvm.c | 8 ++++---- + grub-core/disk/xen/xendisk.c | 2 +- + grub-core/efiemu/loadcore.c | 2 +- + grub-core/efiemu/mm.c | 6 +++--- + grub-core/font/font.c | 3 +-- + grub-core/fs/affs.c | 6 +++--- + grub-core/fs/btrfs.c | 6 +++--- + grub-core/fs/hfs.c | 2 +- + grub-core/fs/hfsplus.c | 6 +++--- + grub-core/fs/iso9660.c | 2 +- + grub-core/fs/ntfs.c | 4 ++-- + grub-core/fs/sfs.c | 2 +- + grub-core/fs/tar.c | 2 +- + grub-core/fs/udf.c | 4 ++-- + grub-core/fs/zfs/zfs.c | 4 ++-- + grub-core/gfxmenu/gui_string_util.c | 2 +- + grub-core/gfxmenu/widget-box.c | 4 ++-- + grub-core/io/gzio.c | 2 +- + grub-core/kern/efi/efi.c | 6 +++--- + grub-core/kern/emu/hostdisk.c | 2 +- + grub-core/kern/fs.c | 2 +- + grub-core/kern/misc.c | 2 +- + grub-core/kern/parser.c | 2 +- + grub-core/kern/uboot/uboot.c | 2 +- + grub-core/lib/libgcrypt/cipher/ac.c | 8 ++++---- + grub-core/lib/libgcrypt/cipher/primegen.c | 4 ++-- + grub-core/lib/libgcrypt/cipher/pubkey.c | 4 ++-- + grub-core/lib/priority_queue.c | 2 +- + grub-core/lib/reed_solomon.c | 7 +++---- + grub-core/lib/relocator.c | 10 +++++----- + grub-core/lib/zstd/fse_decompress.c | 2 +- + grub-core/loader/arm/linux.c | 2 +- + grub-core/loader/efi/chainloader.c | 2 +- + grub-core/loader/i386/bsdXX.c | 2 +- + grub-core/loader/i386/xnu.c | 4 ++-- + grub-core/loader/macho.c | 2 +- + grub-core/loader/multiboot_elfxx.c | 2 +- + grub-core/loader/xnu.c | 2 +- + grub-core/mmap/mmap.c | 4 ++-- + grub-core/net/bootp.c | 2 +- + grub-core/net/dns.c | 10 +++++----- + grub-core/net/net.c | 4 ++-- + grub-core/normal/charset.c | 10 +++++----- + grub-core/normal/cmdline.c | 14 +++++++------- + grub-core/normal/menu_entry.c | 14 +++++++------- + grub-core/normal/menu_text.c | 4 ++-- + grub-core/normal/term.c | 4 ++-- + grub-core/osdep/linux/getroot.c | 6 +++--- + grub-core/osdep/unix/config.c | 2 +- + grub-core/osdep/windows/getroot.c | 2 +- + grub-core/osdep/windows/hostdisk.c | 4 ++-- + grub-core/osdep/windows/init.c | 2 +- + grub-core/osdep/windows/platform.c | 4 ++-- + grub-core/osdep/windows/relpath.c | 2 +- + grub-core/partmap/gpt.c | 2 +- + grub-core/partmap/msdos.c | 2 +- + grub-core/script/execute.c | 2 +- + grub-core/tests/fake_input.c | 2 +- + grub-core/tests/video_checksum.c | 6 +++--- + grub-core/video/capture.c | 2 +- + grub-core/video/emu/sdl.c | 2 +- + grub-core/video/i386/pc/vga.c | 2 +- + grub-core/video/readers/png.c | 2 +- + include/grub/unicode.h | 4 ++-- + util/getroot.c | 2 +- + util/grub-file.c | 2 +- + util/grub-fstest.c | 4 ++-- + util/grub-install-common.c | 2 +- + util/grub-install.c | 4 ++-- + util/grub-mkimagexx.c | 6 ++---- + util/grub-mkrescue.c | 4 ++-- + util/grub-mkstandalone.c | 2 +- + util/grub-pe2elf.c | 12 +++++------- + util/grub-probe.c | 4 ++-- + 86 files changed, 176 insertions(+), 175 deletions(-) + +diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c +index 34a7ff1..a06cce3 100644 +--- a/grub-core/bus/usb/usbhub.c ++++ b/grub-core/bus/usb/usbhub.c +@@ -149,8 +149,8 @@ grub_usb_add_hub (grub_usb_device_t dev) + grub_usb_set_configuration (dev, 1); + + dev->nports = hubdesc.portcnt; +- dev->children = grub_zalloc (hubdesc.portcnt * sizeof (dev->children[0])); +- dev->ports = grub_zalloc (dev->nports * sizeof (dev->ports[0])); ++ dev->children = grub_calloc (hubdesc.portcnt, sizeof (dev->children[0])); ++ dev->ports = grub_calloc (dev->nports, sizeof (dev->ports[0])); + if (!dev->children || !dev->ports) + { + grub_free (dev->children); +@@ -268,8 +268,8 @@ grub_usb_controller_dev_register_iter (grub_usb_controller_t controller, void *d + + /* Query the number of ports the root Hub has. */ + hub->nports = controller->dev->hubports (controller); +- hub->devices = grub_zalloc (sizeof (hub->devices[0]) * hub->nports); +- hub->ports = grub_zalloc (sizeof (hub->ports[0]) * hub->nports); ++ hub->devices = grub_calloc (hub->nports, sizeof (hub->devices[0])); ++ hub->ports = grub_calloc (hub->nports, sizeof (hub->ports[0])); + if (!hub->devices || !hub->ports) + { + grub_free (hub->devices); +diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c +index df10302..cd81507 100644 +--- a/grub-core/commands/efi/lsefisystab.c ++++ b/grub-core/commands/efi/lsefisystab.c +@@ -71,7 +71,8 @@ grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)), + grub_printf ("Vendor: "); + + for (vendor_utf16 = st->firmware_vendor; *vendor_utf16; vendor_utf16++); +- vendor = grub_malloc (4 * (vendor_utf16 - st->firmware_vendor) + 1); ++ /* Allocate extra 3 bytes to simplify math. */ ++ vendor = grub_calloc (4, vendor_utf16 - st->firmware_vendor + 1); + if (!vendor) + return grub_errno; + *grub_utf16_to_utf8 ((grub_uint8_t *) vendor, st->firmware_vendor, +diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c +index 891eac5..da5143d 100644 +--- a/grub-core/commands/legacycfg.c ++++ b/grub-core/commands/legacycfg.c +@@ -315,7 +315,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), + if (argc < 2) + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); + +- cutargs = grub_malloc (sizeof (cutargs[0]) * (argc - 1)); ++ cutargs = grub_calloc (argc - 1, sizeof (cutargs[0])); + if (!cutargs) + return grub_errno; + cutargc = argc - 1; +@@ -437,7 +437,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), + { + char rbuf[3] = "-r"; + bsdargc = cutargc + 2; +- bsdargs = grub_malloc (sizeof (bsdargs[0]) * bsdargc); ++ bsdargs = grub_calloc (bsdargc, sizeof (bsdargs[0])); + if (!bsdargs) + { + err = grub_errno; +@@ -560,7 +560,7 @@ grub_cmd_legacy_initrdnounzip (struct grub_command *mycmd __attribute__ ((unused + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"), + "module"); + +- newargs = grub_malloc ((argc + 1) * sizeof (newargs[0])); ++ newargs = grub_calloc (argc + 1, sizeof (newargs[0])); + if (!newargs) + return grub_errno; + grub_memcpy (newargs + 1, args, argc * sizeof (newargs[0])); +diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c +index 29736f5..84edfc0 100644 +--- a/grub-core/commands/menuentry.c ++++ b/grub-core/commands/menuentry.c +@@ -157,7 +157,7 @@ grub_normal_add_menu_entry (int argc, const char **args, + grub_dprintf ("menu", "menu_id:\"%s\"\n", menu_id); + + /* Save argc, args to pass as parameters to block arg later. */ +- menu_args = grub_malloc (sizeof (char*) * (argc + 1)); ++ menu_args = grub_calloc (argc + 1, sizeof (char *)); + if (! menu_args) + goto fail; + +diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c +index 699447d..7c8f97f 100644 +--- a/grub-core/commands/nativedisk.c ++++ b/grub-core/commands/nativedisk.c +@@ -195,7 +195,7 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)), + else + path_prefix = prefix; + +- mods = grub_malloc (argc * sizeof (mods[0])); ++ mods = grub_calloc (argc, sizeof (mods[0])); + if (!mods) + return grub_errno; + +diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c +index 22b46b1..051e313 100644 +--- a/grub-core/commands/parttool.c ++++ b/grub-core/commands/parttool.c +@@ -59,7 +59,13 @@ grub_parttool_register(const char *part_name, + for (nargs = 0; args[nargs].name != 0; nargs++); + cur->nargs = nargs; + cur->args = (struct grub_parttool_argdesc *) +- grub_malloc ((nargs + 1) * sizeof (struct grub_parttool_argdesc)); ++ grub_calloc (nargs + 1, sizeof (struct grub_parttool_argdesc)); ++ if (!cur->args) ++ { ++ grub_free (cur); ++ curhandle--; ++ return -1; ++ } + grub_memcpy (cur->args, args, + (nargs + 1) * sizeof (struct grub_parttool_argdesc)); + +@@ -257,7 +263,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), + return err; + } + +- parsed = (int *) grub_zalloc (argc * sizeof (int)); ++ parsed = (int *) grub_calloc (argc, sizeof (int)); + + for (i = 1; i < argc; i++) + if (! parsed[i]) +@@ -290,7 +296,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), + } + ptool = cur; + pargs = (struct grub_parttool_args *) +- grub_zalloc (ptool->nargs * sizeof (struct grub_parttool_args)); ++ grub_calloc (ptool->nargs, sizeof (struct grub_parttool_args)); + for (j = i; j < argc; j++) + if (! parsed[j]) + { +diff --git a/grub-core/commands/regexp.c b/grub-core/commands/regexp.c +index 7c5c72f..612003f 100644 +--- a/grub-core/commands/regexp.c ++++ b/grub-core/commands/regexp.c +@@ -116,7 +116,7 @@ grub_cmd_regexp (grub_extcmd_context_t ctxt, int argc, char **args) + if (ret) + goto fail; + +- matches = grub_zalloc (sizeof (*matches) * (regex.re_nsub + 1)); ++ matches = grub_calloc (regex.re_nsub + 1, sizeof (*matches)); + if (! matches) + goto fail; + +diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c +index d7fd26b..47fc8eb 100644 +--- a/grub-core/commands/search_wrap.c ++++ b/grub-core/commands/search_wrap.c +@@ -122,7 +122,7 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args) + for (i = 0; state[SEARCH_HINT_BAREMETAL].args[i]; i++) + nhints++; + +- hints = grub_malloc (sizeof (hints[0]) * nhints); ++ hints = grub_calloc (nhints, sizeof (hints[0])); + if (!hints) + return grub_errno; + j = 0; +diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c +index 3f264be..88784dc 100644 +--- a/grub-core/disk/diskfilter.c ++++ b/grub-core/disk/diskfilter.c +@@ -1137,7 +1137,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, + array->lvs->segments->node_count = nmemb; + array->lvs->segments->raid_member_size = disk_size; + array->lvs->segments->nodes +- = grub_zalloc (nmemb * sizeof (array->lvs->segments->nodes[0])); ++ = grub_calloc (nmemb, sizeof (array->lvs->segments->nodes[0])); + array->lvs->segments->stripe_size = stripe_size; + for (i = 0; i < nmemb; i++) + { +@@ -1230,7 +1230,7 @@ insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id, + grub_partition_t p; + for (p = disk->partition; p; p = p->parent) + s++; +- pv->partmaps = xmalloc (s * sizeof (pv->partmaps[0])); ++ pv->partmaps = xcalloc (s, sizeof (pv->partmaps[0])); + s = 0; + for (p = disk->partition; p; p = p->parent) + pv->partmaps[s++] = xstrdup (p->partmap->name); +diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c +index f73257e..03674cb 100644 +--- a/grub-core/disk/ieee1275/ofdisk.c ++++ b/grub-core/disk/ieee1275/ofdisk.c +@@ -297,7 +297,7 @@ dev_iterate (const struct grub_ieee1275_devalias *alias) + /* Power machines documentation specify 672 as maximum SAS disks in + one system. Using a slightly larger value to be safe. */ + table_size = 768; +- table = grub_malloc (table_size * sizeof (grub_uint64_t)); ++ table = grub_calloc (table_size, sizeof (grub_uint64_t)); + + if (!table) + { +diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c +index 2a22d2d..e632370 100644 +--- a/grub-core/disk/ldm.c ++++ b/grub-core/disk/ldm.c +@@ -323,8 +323,8 @@ make_vg (grub_disk_t disk, + lv->segments->type = GRUB_DISKFILTER_MIRROR; + lv->segments->node_count = 0; + lv->segments->node_alloc = 8; +- lv->segments->nodes = grub_zalloc (sizeof (*lv->segments->nodes) +- * lv->segments->node_alloc); ++ lv->segments->nodes = grub_calloc (lv->segments->node_alloc, ++ sizeof (*lv->segments->nodes)); + if (!lv->segments->nodes) + goto fail2; + ptr = vblk[i].dynamic; +@@ -543,8 +543,8 @@ make_vg (grub_disk_t disk, + { + comp->segment_alloc = 8; + comp->segment_count = 0; +- comp->segments = grub_malloc (sizeof (*comp->segments) +- * comp->segment_alloc); ++ comp->segments = grub_calloc (comp->segment_alloc, ++ sizeof (*comp->segments)); + if (!comp->segments) + goto fail2; + } +@@ -590,8 +590,8 @@ make_vg (grub_disk_t disk, + } + comp->segments->node_count = read_int (ptr + 1, *ptr); + comp->segments->node_alloc = comp->segments->node_count; +- comp->segments->nodes = grub_zalloc (sizeof (*comp->segments->nodes) +- * comp->segments->node_alloc); ++ comp->segments->nodes = grub_calloc (comp->segments->node_alloc, ++ sizeof (*comp->segments->nodes)); + if (!lv->segments->nodes) + goto fail2; + } +@@ -1017,7 +1017,7 @@ grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors, + *nsectors = lv->size; + if (*nsectors > max_nsectors) + *nsectors = max_nsectors; +- *sectors = grub_malloc (*nsectors * sizeof (**sectors)); ++ *sectors = grub_calloc (*nsectors, sizeof (**sectors)); + if (!*sectors) + return grub_errno; + for (i = 0; i < *nsectors; i++) +diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c +index 86c50c6..18b3a8b 100644 +--- a/grub-core/disk/luks.c ++++ b/grub-core/disk/luks.c +@@ -336,7 +336,7 @@ luks_recover_key (grub_disk_t source, + && grub_be_to_cpu32 (header.keyblock[i].stripes) > max_stripes) + max_stripes = grub_be_to_cpu32 (header.keyblock[i].stripes); + +- split_key = grub_malloc (keysize * max_stripes); ++ split_key = grub_calloc (keysize, max_stripes); + if (!split_key) + return grub_errno; + +diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c +index 0cbd0dd..8e76d1a 100644 +--- a/grub-core/disk/lvm.c ++++ b/grub-core/disk/lvm.c +@@ -174,7 +174,7 @@ grub_lvm_detect (grub_disk_t disk, + first one. */ + + /* Allocate buffer space for the circular worst-case scenario. */ +- metadatabuf = grub_malloc (2 * mda_size); ++ metadatabuf = grub_calloc (2, mda_size); + if (! metadatabuf) + goto fail; + +@@ -427,7 +427,7 @@ grub_lvm_detect (grub_disk_t disk, + #endif + goto lvs_fail; + } +- lv->segments = grub_zalloc (sizeof (*seg) * lv->segment_count); ++ lv->segments = grub_calloc (lv->segment_count, sizeof (*seg)); + seg = lv->segments; + + for (i = 0; i < lv->segment_count; i++) +@@ -484,8 +484,8 @@ grub_lvm_detect (grub_disk_t disk, + if (seg->node_count != 1) + seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = "); + +- seg->nodes = grub_zalloc (sizeof (*stripe) +- * seg->node_count); ++ seg->nodes = grub_calloc (seg->node_count, ++ sizeof (*stripe)); + stripe = seg->nodes; + + p = grub_strstr (p, "stripes = ["); +diff --git a/grub-core/disk/xen/xendisk.c b/grub-core/disk/xen/xendisk.c +index 48476cb..d6612ee 100644 +--- a/grub-core/disk/xen/xendisk.c ++++ b/grub-core/disk/xen/xendisk.c +@@ -426,7 +426,7 @@ grub_xendisk_init (void) + if (!ctr) + return; + +- virtdisks = grub_malloc (ctr * sizeof (virtdisks[0])); ++ virtdisks = grub_calloc (ctr, sizeof (virtdisks[0])); + if (!virtdisks) + return; + if (grub_xenstore_dir ("device/vbd", fill, &ctr)) +diff --git a/grub-core/efiemu/loadcore.c b/grub-core/efiemu/loadcore.c +index 44085ef..2b92462 100644 +--- a/grub-core/efiemu/loadcore.c ++++ b/grub-core/efiemu/loadcore.c +@@ -201,7 +201,7 @@ grub_efiemu_count_symbols (const Elf_Ehdr *e) + + grub_efiemu_nelfsyms = (unsigned) s->sh_size / (unsigned) s->sh_entsize; + grub_efiemu_elfsyms = (struct grub_efiemu_elf_sym *) +- grub_malloc (sizeof (struct grub_efiemu_elf_sym) * grub_efiemu_nelfsyms); ++ grub_calloc (grub_efiemu_nelfsyms, sizeof (struct grub_efiemu_elf_sym)); + + /* Relocators */ + for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); +diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c +index 52a032f..9b8e0d0 100644 +--- a/grub-core/efiemu/mm.c ++++ b/grub-core/efiemu/mm.c +@@ -554,11 +554,11 @@ grub_efiemu_mmap_sort_and_uniq (void) + /* Initialize variables*/ + grub_memset (present, 0, sizeof (int) * GRUB_EFI_MAX_MEMORY_TYPE); + scanline_events = (struct grub_efiemu_mmap_scan *) +- grub_malloc (sizeof (struct grub_efiemu_mmap_scan) * 2 * mmap_num); ++ grub_calloc (mmap_num, sizeof (struct grub_efiemu_mmap_scan) * 2); + + /* Number of chunks can't increase more than by factor of 2 */ + result = (grub_efi_memory_descriptor_t *) +- grub_malloc (sizeof (grub_efi_memory_descriptor_t) * 2 * mmap_num); ++ grub_calloc (mmap_num, sizeof (grub_efi_memory_descriptor_t) * 2); + if (!result || !scanline_events) + { + grub_free (result); +@@ -660,7 +660,7 @@ grub_efiemu_mm_do_alloc (void) + + /* Preallocate mmap */ + efiemu_mmap = (grub_efi_memory_descriptor_t *) +- grub_malloc (mmap_reserved_size * sizeof (grub_efi_memory_descriptor_t)); ++ grub_calloc (mmap_reserved_size, sizeof (grub_efi_memory_descriptor_t)); + if (!efiemu_mmap) + { + grub_efiemu_unload (); +diff --git a/grub-core/font/font.c b/grub-core/font/font.c +index 85a2925..8e118b3 100644 +--- a/grub-core/font/font.c ++++ b/grub-core/font/font.c +@@ -293,8 +293,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct + font->num_chars = sect_length / FONT_CHAR_INDEX_ENTRY_SIZE; + + /* Allocate the character index array. */ +- font->char_index = grub_malloc (font->num_chars +- * sizeof (struct char_index_entry)); ++ font->char_index = grub_calloc (font->num_chars, sizeof (struct char_index_entry)); + if (!font->char_index) + return 1; + font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t)); +diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c +index 6b6a2bc..220b371 100644 +--- a/grub-core/fs/affs.c ++++ b/grub-core/fs/affs.c +@@ -301,7 +301,7 @@ grub_affs_read_symlink (grub_fshelp_node_t node) + return 0; + } + latin1[symlink_size] = 0; +- utf8 = grub_malloc (symlink_size * GRUB_MAX_UTF8_PER_LATIN1 + 1); ++ utf8 = grub_calloc (GRUB_MAX_UTF8_PER_LATIN1 + 1, symlink_size); + if (!utf8) + { + grub_free (latin1); +@@ -422,7 +422,7 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir, + return 1; + } + +- hashtable = grub_zalloc (data->htsize * sizeof (*hashtable)); ++ hashtable = grub_calloc (data->htsize, sizeof (*hashtable)); + if (!hashtable) + return 1; + +@@ -628,7 +628,7 @@ grub_affs_label (grub_device_t device, char **label) + len = file.namelen; + if (len > sizeof (file.name)) + len = sizeof (file.name); +- *label = grub_malloc (len * GRUB_MAX_UTF8_PER_LATIN1 + 1); ++ *label = grub_calloc (GRUB_MAX_UTF8_PER_LATIN1 + 1, len); + if (*label) + *grub_latin1_to_utf8 ((grub_uint8_t *) *label, file.name, len) = '\0'; + } +diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c +index 9cd7f4b..ba080fd 100644 +--- a/grub-core/fs/btrfs.c ++++ b/grub-core/fs/btrfs.c +@@ -442,7 +442,7 @@ lower_bound (struct grub_btrfs_data *data, + { + desc->allocated = 16; + desc->depth = 0; +- desc->data = grub_malloc (sizeof (desc->data[0]) * desc->allocated); ++ desc->data = grub_calloc (desc->allocated, sizeof (desc->data[0])); + if (!desc->data) + return grub_errno; + } +@@ -781,7 +781,7 @@ raid56_read_retry (struct grub_btrfs_data *data, + grub_err_t ret = GRUB_ERR_OUT_OF_MEMORY; + grub_uint64_t i, failed_devices; + +- buffers = grub_zalloc (sizeof(*buffers) * nstripes); ++ buffers = grub_calloc (nstripes, sizeof (*buffers)); + if (!buffers) + goto cleanup; + +@@ -2477,7 +2477,7 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)), + *nsectors = 64 * 2 - 1; + if (*nsectors > max_nsectors) + *nsectors = max_nsectors; +- *sectors = grub_malloc (*nsectors * sizeof (**sectors)); ++ *sectors = grub_calloc (*nsectors, sizeof (**sectors)); + if (!*sectors) + return grub_errno; + for (i = 0; i < *nsectors; i++) +diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c +index ac0a409..3fe842b 100644 +--- a/grub-core/fs/hfs.c ++++ b/grub-core/fs/hfs.c +@@ -1360,7 +1360,7 @@ grub_hfs_label (grub_device_t device, char **label) + grub_size_t len = data->sblock.volname[0]; + if (len > sizeof (data->sblock.volname) - 1) + len = sizeof (data->sblock.volname) - 1; +- *label = grub_malloc (len * MAX_UTF8_PER_MAC_ROMAN + 1); ++ *label = grub_calloc (MAX_UTF8_PER_MAC_ROMAN + 1, len); + if (*label) + macroman_to_utf8 (*label, data->sblock.volname + 1, + len + 1, 0); +diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c +index 54786bb..dae43be 100644 +--- a/grub-core/fs/hfsplus.c ++++ b/grub-core/fs/hfsplus.c +@@ -720,7 +720,7 @@ list_nodes (void *record, void *hook_arg) + if (! filename) + return 0; + +- keyname = grub_malloc (grub_be_to_cpu16 (catkey->namelen) * sizeof (*keyname)); ++ keyname = grub_calloc (grub_be_to_cpu16 (catkey->namelen), sizeof (*keyname)); + if (!keyname) + { + grub_free (filename); +@@ -1007,7 +1007,7 @@ grub_hfsplus_label (grub_device_t device, char **label) + grub_hfsplus_btree_recptr (&data->catalog_tree, node, ptr); + + label_len = grub_be_to_cpu16 (catkey->namelen); +- label_name = grub_malloc (label_len * sizeof (*label_name)); ++ label_name = grub_calloc (label_len, sizeof (*label_name)); + if (!label_name) + { + grub_free (node); +@@ -1029,7 +1029,7 @@ grub_hfsplus_label (grub_device_t device, char **label) + } + } + +- *label = grub_malloc (label_len * GRUB_MAX_UTF8_PER_UTF16 + 1); ++ *label = grub_calloc (label_len, GRUB_MAX_UTF8_PER_UTF16 + 1); + if (! *label) + { + grub_free (label_name); +diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c +index 49c0c63..4f1b52a 100644 +--- a/grub-core/fs/iso9660.c ++++ b/grub-core/fs/iso9660.c +@@ -331,7 +331,7 @@ grub_iso9660_convert_string (grub_uint8_t *us, int len) + int i; + grub_uint16_t t[MAX_NAMELEN / 2 + 1]; + +- p = grub_malloc (len * GRUB_MAX_UTF8_PER_UTF16 + 1); ++ p = grub_calloc (len, GRUB_MAX_UTF8_PER_UTF16 + 1); + if (! p) + return NULL; + +diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c +index fc4e1f6..2f34f76 100644 +--- a/grub-core/fs/ntfs.c ++++ b/grub-core/fs/ntfs.c +@@ -556,8 +556,8 @@ get_utf8 (grub_uint8_t *in, grub_size_t len) + grub_uint16_t *tmp; + grub_size_t i; + +- buf = grub_malloc (len * GRUB_MAX_UTF8_PER_UTF16 + 1); +- tmp = grub_malloc (len * sizeof (tmp[0])); ++ buf = grub_calloc (len, GRUB_MAX_UTF8_PER_UTF16 + 1); ++ tmp = grub_calloc (len, sizeof (tmp[0])); + if (!buf || !tmp) + { + grub_free (buf); +diff --git a/grub-core/fs/sfs.c b/grub-core/fs/sfs.c +index 50c1fe7..90f7fb3 100644 +--- a/grub-core/fs/sfs.c ++++ b/grub-core/fs/sfs.c +@@ -266,7 +266,7 @@ grub_sfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) + node->next_extent = node->block; + node->cache_size = 0; + +- node->cache = grub_malloc (sizeof (node->cache[0]) * cache_size); ++ node->cache = grub_calloc (cache_size, sizeof (node->cache[0])); + if (!node->cache) + { + grub_errno = 0; +diff --git a/grub-core/fs/tar.c b/grub-core/fs/tar.c +index 7d63e0c..c551ed6 100644 +--- a/grub-core/fs/tar.c ++++ b/grub-core/fs/tar.c +@@ -120,7 +120,7 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name, + if (data->linkname_alloc < linksize + 1) + { + char *n; +- n = grub_malloc (2 * (linksize + 1)); ++ n = grub_calloc (2, linksize + 1); + if (!n) + return grub_errno; + grub_free (data->linkname); +diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c +index dc8b6e2..a837616 100644 +--- a/grub-core/fs/udf.c ++++ b/grub-core/fs/udf.c +@@ -873,7 +873,7 @@ read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf) + { + unsigned i; + utf16len = sz - 1; +- utf16 = grub_malloc (utf16len * sizeof (utf16[0])); ++ utf16 = grub_calloc (utf16len, sizeof (utf16[0])); + if (!utf16) + return NULL; + for (i = 0; i < utf16len; i++) +@@ -883,7 +883,7 @@ read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf) + { + unsigned i; + utf16len = (sz - 1) / 2; +- utf16 = grub_malloc (utf16len * sizeof (utf16[0])); ++ utf16 = grub_calloc (utf16len, sizeof (utf16[0])); + if (!utf16) + return NULL; + for (i = 0; i < utf16len; i++) +diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c +index 2f72e42..381dde5 100644 +--- a/grub-core/fs/zfs/zfs.c ++++ b/grub-core/fs/zfs/zfs.c +@@ -3325,7 +3325,7 @@ dnode_get_fullpath (const char *fullpath, struct subvolume *subvol, + } + subvol->nkeys = 0; + zap_iterate (&keychain_dn, 8, count_zap_keys, &ctx, data); +- subvol->keyring = grub_zalloc (subvol->nkeys * sizeof (subvol->keyring[0])); ++ subvol->keyring = grub_calloc (subvol->nkeys, sizeof (subvol->keyring[0])); + if (!subvol->keyring) + { + grub_free (fsname); +@@ -4336,7 +4336,7 @@ grub_zfs_embed (grub_device_t device __attribute__ ((unused)), + *nsectors = (VDEV_BOOT_SIZE >> GRUB_DISK_SECTOR_BITS); + if (*nsectors > max_nsectors) + *nsectors = max_nsectors; +- *sectors = grub_malloc (*nsectors * sizeof (**sectors)); ++ *sectors = grub_calloc (*nsectors, sizeof (**sectors)); + if (!*sectors) + return grub_errno; + for (i = 0; i < *nsectors; i++) +diff --git a/grub-core/gfxmenu/gui_string_util.c b/grub-core/gfxmenu/gui_string_util.c +index a9a415e..ba1e1ea 100644 +--- a/grub-core/gfxmenu/gui_string_util.c ++++ b/grub-core/gfxmenu/gui_string_util.c +@@ -55,7 +55,7 @@ canonicalize_path (const char *path) + if (*p == '/') + components++; + +- char **path_array = grub_malloc (components * sizeof (*path_array)); ++ char **path_array = grub_calloc (components, sizeof (*path_array)); + if (! path_array) + return 0; + +diff --git a/grub-core/gfxmenu/widget-box.c b/grub-core/gfxmenu/widget-box.c +index b606028..470597d 100644 +--- a/grub-core/gfxmenu/widget-box.c ++++ b/grub-core/gfxmenu/widget-box.c +@@ -303,10 +303,10 @@ grub_gfxmenu_create_box (const char *pixmaps_prefix, + box->content_height = 0; + box->raw_pixmaps = + (struct grub_video_bitmap **) +- grub_malloc (BOX_NUM_PIXMAPS * sizeof (struct grub_video_bitmap *)); ++ grub_calloc (BOX_NUM_PIXMAPS, sizeof (struct grub_video_bitmap *)); + box->scaled_pixmaps = + (struct grub_video_bitmap **) +- grub_malloc (BOX_NUM_PIXMAPS * sizeof (struct grub_video_bitmap *)); ++ grub_calloc (BOX_NUM_PIXMAPS, sizeof (struct grub_video_bitmap *)); + + /* Initialize all pixmap pointers to NULL so that proper destruction can + be performed if an error is encountered partway through construction. */ +diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c +index 6208a97..43d98a7 100644 +--- a/grub-core/io/gzio.c ++++ b/grub-core/io/gzio.c +@@ -554,7 +554,7 @@ huft_build (unsigned *b, /* code lengths in bits (all assumed <= BMAX) */ + z = 1 << j; /* table entries for j-bit table */ + + /* allocate and link in new table */ +- q = (struct huft *) grub_zalloc ((z + 1) * sizeof (struct huft)); ++ q = (struct huft *) grub_calloc (z + 1, sizeof (struct huft)); + if (! q) + { + if (h) +diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c +index 279394d..ab133fe 100644 +--- a/grub-core/kern/efi/efi.c ++++ b/grub-core/kern/efi/efi.c +@@ -207,7 +207,7 @@ grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid, + + len = grub_strlen (var); + len16 = len * GRUB_MAX_UTF16_PER_UTF8; +- var16 = grub_malloc ((len16 + 1) * sizeof (var16[0])); ++ var16 = grub_calloc (len16 + 1, sizeof (var16[0])); + if (!var16) + return grub_errno; + len16 = grub_utf8_to_utf16 (var16, len16, (grub_uint8_t *) var, len, NULL); +@@ -245,7 +245,7 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, + + len = grub_strlen (var); + len16 = len * GRUB_MAX_UTF16_PER_UTF8; +- var16 = grub_malloc ((len16 + 1) * sizeof (var16[0])); ++ var16 = grub_calloc (len16 + 1, sizeof (var16[0])); + if (!var16) + return NULL; + len16 = grub_utf8_to_utf16 (var16, len16, (grub_uint8_t *) var, len, NULL); +@@ -401,7 +401,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) + while (len > 0 && fp->path_name[len - 1] == 0) + len--; + +- dup_name = grub_malloc (len * sizeof (*dup_name)); ++ dup_name = grub_calloc (len, sizeof (*dup_name)); + if (!dup_name) + { + grub_free (name); +diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c +index e9ec680..d975265 100644 +--- a/grub-core/kern/emu/hostdisk.c ++++ b/grub-core/kern/emu/hostdisk.c +@@ -615,7 +615,7 @@ static char * + grub_util_path_concat_real (size_t n, int ext, va_list ap) + { + size_t totlen = 0; +- char **l = xmalloc ((n + ext) * sizeof (l[0])); ++ char **l = xcalloc (n + ext, sizeof (l[0])); + char *r, *p, *pi; + size_t i; + int first = 1; +diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c +index 88d3936..fb30da9 100644 +--- a/grub-core/kern/fs.c ++++ b/grub-core/kern/fs.c +@@ -151,7 +151,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name) + while (p); + + /* Allocate a block list. */ +- blocks = grub_zalloc (sizeof (struct grub_fs_block) * (num + 1)); ++ blocks = grub_calloc (num + 1, sizeof (struct grub_fs_block)); + if (! blocks) + return 0; + +diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c +index 87afb43..dc5e10b 100644 +--- a/grub-core/kern/misc.c ++++ b/grub-core/kern/misc.c +@@ -750,7 +750,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args, + args->ptr = args->prealloc; + else + { +- args->ptr = grub_malloc (args->count * sizeof (args->ptr[0])); ++ args->ptr = grub_calloc (args->count, sizeof (args->ptr[0])); + if (!args->ptr) + { + grub_errno = GRUB_ERR_NONE; +diff --git a/grub-core/kern/parser.c b/grub-core/kern/parser.c +index 78175aa..619db31 100644 +--- a/grub-core/kern/parser.c ++++ b/grub-core/kern/parser.c +@@ -213,7 +213,7 @@ grub_parser_split_cmdline (const char *cmdline, + return grub_errno; + grub_memcpy (args, buffer, bp - buffer); + +- *argv = grub_malloc (sizeof (char *) * (*argc + 1)); ++ *argv = grub_calloc (*argc + 1, sizeof (char *)); + if (!*argv) + { + grub_free (args); +diff --git a/grub-core/kern/uboot/uboot.c b/grub-core/kern/uboot/uboot.c +index be4816f..aac8f9a 100644 +--- a/grub-core/kern/uboot/uboot.c ++++ b/grub-core/kern/uboot/uboot.c +@@ -133,7 +133,7 @@ grub_uboot_dev_enum (void) + return num_devices; + + max_devices = 2; +- enum_devices = grub_malloc (sizeof(struct device_info) * max_devices); ++ enum_devices = grub_calloc (max_devices, sizeof(struct device_info)); + if (!enum_devices) + return 0; + +diff --git a/grub-core/lib/libgcrypt/cipher/ac.c b/grub-core/lib/libgcrypt/cipher/ac.c +index f5e946a..63f6fcd 100644 +--- a/grub-core/lib/libgcrypt/cipher/ac.c ++++ b/grub-core/lib/libgcrypt/cipher/ac.c +@@ -185,7 +185,7 @@ ac_data_mpi_copy (gcry_ac_mpi_t *data_mpis, unsigned int data_mpis_n, + gcry_mpi_t mpi; + char *label; + +- data_mpis_new = gcry_malloc (sizeof (*data_mpis_new) * data_mpis_n); ++ data_mpis_new = gcry_calloc (data_mpis_n, sizeof (*data_mpis_new)); + if (! data_mpis_new) + { + err = gcry_error_from_errno (errno); +@@ -572,7 +572,7 @@ _gcry_ac_data_to_sexp (gcry_ac_data_t data, gcry_sexp_t *sexp, + } + + /* Add MPI list. */ +- arg_list = gcry_malloc (sizeof (*arg_list) * (data_n + 1)); ++ arg_list = gcry_calloc (data_n + 1, sizeof (*arg_list)); + if (! arg_list) + { + err = gcry_error_from_errno (errno); +@@ -1283,7 +1283,7 @@ ac_data_construct (const char *identifier, int include_flags, + /* We build a list of arguments to pass to + gcry_sexp_build_array(). */ + data_length = _gcry_ac_data_length (data); +- arg_list = gcry_malloc (sizeof (*arg_list) * (data_length * 2)); ++ arg_list = gcry_calloc (data_length, sizeof (*arg_list) * 2); + if (! arg_list) + { + err = gcry_error_from_errno (errno); +@@ -1593,7 +1593,7 @@ _gcry_ac_key_pair_generate (gcry_ac_handle_t handle, unsigned int nbits, + arg_list_n += 2; + + /* Allocate list. */ +- arg_list = gcry_malloc (sizeof (*arg_list) * arg_list_n); ++ arg_list = gcry_calloc (arg_list_n, sizeof (*arg_list)); + if (! arg_list) + { + err = gcry_error_from_errno (errno); +diff --git a/grub-core/lib/libgcrypt/cipher/primegen.c b/grub-core/lib/libgcrypt/cipher/primegen.c +index 2788e34..b12e79b 100644 +--- a/grub-core/lib/libgcrypt/cipher/primegen.c ++++ b/grub-core/lib/libgcrypt/cipher/primegen.c +@@ -383,7 +383,7 @@ prime_generate_internal (int need_q_factor, + } + + /* Allocate an array to track pool usage. */ +- pool_in_use = gcry_malloc (n * sizeof *pool_in_use); ++ pool_in_use = gcry_calloc (n, sizeof *pool_in_use); + if (!pool_in_use) + { + err = gpg_err_code_from_errno (errno); +@@ -765,7 +765,7 @@ gen_prime (unsigned int nbits, int secret, int randomlevel, + if (nbits < 16) + log_fatal ("can't generate a prime with less than %d bits\n", 16); + +- mods = gcry_xmalloc( no_of_small_prime_numbers * sizeof *mods ); ++ mods = gcry_xcalloc( no_of_small_prime_numbers, sizeof *mods); + /* Make nbits fit into gcry_mpi_t implementation. */ + val_2 = mpi_alloc_set_ui( 2 ); + val_3 = mpi_alloc_set_ui( 3); +diff --git a/grub-core/lib/libgcrypt/cipher/pubkey.c b/grub-core/lib/libgcrypt/cipher/pubkey.c +index 9109821..ca087ad 100644 +--- a/grub-core/lib/libgcrypt/cipher/pubkey.c ++++ b/grub-core/lib/libgcrypt/cipher/pubkey.c +@@ -2941,7 +2941,7 @@ gcry_pk_encrypt (gcry_sexp_t *r_ciph, gcry_sexp_t s_data, gcry_sexp_t s_pkey) + * array to a format string, so we have to do it this way :-(. */ + /* FIXME: There is now such a format specifier, so we can + change the code to be more clear. */ +- arg_list = malloc (nelem * sizeof *arg_list); ++ arg_list = calloc (nelem, sizeof *arg_list); + if (!arg_list) + { + rc = gpg_err_code_from_syserror (); +@@ -3233,7 +3233,7 @@ gcry_pk_sign (gcry_sexp_t *r_sig, gcry_sexp_t s_hash, gcry_sexp_t s_skey) + } + strcpy (p, "))"); + +- arg_list = malloc (nelem * sizeof *arg_list); ++ arg_list = calloc (nelem, sizeof *arg_list); + if (!arg_list) + { + rc = gpg_err_code_from_syserror (); +diff --git a/grub-core/lib/priority_queue.c b/grub-core/lib/priority_queue.c +index 659be0b..7d5e7c0 100644 +--- a/grub-core/lib/priority_queue.c ++++ b/grub-core/lib/priority_queue.c +@@ -92,7 +92,7 @@ grub_priority_queue_new (grub_size_t elsize, + { + struct grub_priority_queue *ret; + void *els; +- els = grub_malloc (elsize * 8); ++ els = grub_calloc (8, elsize); + if (!els) + return 0; + ret = (struct grub_priority_queue *) grub_malloc (sizeof (*ret)); +diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c +index 19c2008..79037c0 100644 +--- a/grub-core/lib/reed_solomon.c ++++ b/grub-core/lib/reed_solomon.c +@@ -20,6 +20,7 @@ + #include + #include + #include ++#define xcalloc calloc + #define xmalloc malloc + #define grub_memset memset + #define grub_memcpy memcpy +@@ -158,11 +159,9 @@ rs_encode (gf_single_t *data, grub_size_t s, grub_size_t rs) + gf_single_t *rs_polynomial; + unsigned int i, j; + gf_single_t *m; +- m = xmalloc ((s + rs) * sizeof (gf_single_t)); ++ m = xcalloc (s + rs, sizeof (gf_single_t)); + grub_memcpy (m, data, s * sizeof (gf_single_t)); +- grub_memset (m + s, 0, rs * sizeof (gf_single_t)); +- rs_polynomial = xmalloc ((rs + 1) * sizeof (gf_single_t)); +- grub_memset (rs_polynomial, 0, (rs + 1) * sizeof (gf_single_t)); ++ rs_polynomial = xcalloc (rs + 1, sizeof (gf_single_t)); + rs_polynomial[rs] = 1; + /* Multiply with X - a^r */ + for (j = 0; j < rs; j++) +diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c +index ea3ebc7..5847aac 100644 +--- a/grub-core/lib/relocator.c ++++ b/grub-core/lib/relocator.c +@@ -495,9 +495,9 @@ malloc_in_range (struct grub_relocator *rel, + } + #endif + +- eventt = grub_malloc (maxevents * sizeof (events[0])); ++ eventt = grub_calloc (maxevents, sizeof (events[0])); + counter = grub_malloc ((DIGITSORT_MASK + 2) * sizeof (counter[0])); +- events = grub_malloc (maxevents * sizeof (events[0])); ++ events = grub_calloc (maxevents, sizeof (events[0])); + if (!events || !eventt || !counter) + { + grub_dprintf ("relocator", "events or counter allocation failed %d\n", +@@ -963,7 +963,7 @@ malloc_in_range (struct grub_relocator *rel, + #endif + unsigned cural = 0; + int oom = 0; +- res->subchunks = grub_malloc (sizeof (res->subchunks[0]) * nallocs); ++ res->subchunks = grub_calloc (nallocs, sizeof (res->subchunks[0])); + if (!res->subchunks) + oom = 1; + res->nsubchunks = nallocs; +@@ -1562,8 +1562,8 @@ grub_relocator_prepare_relocs (struct grub_relocator *rel, grub_addr_t addr, + count[(chunk->src & 0xff) + 1]++; + } + } +- from = grub_malloc (nchunks * sizeof (sorted[0])); +- to = grub_malloc (nchunks * sizeof (sorted[0])); ++ from = grub_calloc (nchunks, sizeof (sorted[0])); ++ to = grub_calloc (nchunks, sizeof (sorted[0])); + if (!from || !to) + { + grub_free (from); +diff --git a/grub-core/lib/zstd/fse_decompress.c b/grub-core/lib/zstd/fse_decompress.c +index 72bbead..2227b84 100644 +--- a/grub-core/lib/zstd/fse_decompress.c ++++ b/grub-core/lib/zstd/fse_decompress.c +@@ -82,7 +82,7 @@ + FSE_DTable* FSE_createDTable (unsigned tableLog) + { + if (tableLog > FSE_TABLELOG_ABSOLUTE_MAX) tableLog = FSE_TABLELOG_ABSOLUTE_MAX; +- return (FSE_DTable*)malloc( FSE_DTABLE_SIZE_U32(tableLog) * sizeof (U32) ); ++ return (FSE_DTable*)calloc( FSE_DTABLE_SIZE_U32(tableLog), sizeof (U32) ); + } + + void FSE_freeDTable (FSE_DTable* dt) +diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c +index 5168491..d70c174 100644 +--- a/grub-core/loader/arm/linux.c ++++ b/grub-core/loader/arm/linux.c +@@ -78,7 +78,7 @@ linux_prepare_atag (void *target_atag) + + /* some place for cmdline, initrd and terminator. */ + tmp_size = get_atag_size (atag_orig) + 20 + (arg_size) / 4; +- tmp_atag = grub_malloc (tmp_size * sizeof (grub_uint32_t)); ++ tmp_atag = grub_calloc (tmp_size, sizeof (grub_uint32_t)); + if (!tmp_atag) + return grub_errno; + +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index 2c529f7..7365051 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -125,7 +125,7 @@ copy_file_path (grub_efi_file_path_device_path_t *fp, + fp->header.type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE; + fp->header.subtype = GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE; + +- path_name = grub_malloc (len * GRUB_MAX_UTF16_PER_UTF8 * sizeof (*path_name)); ++ path_name = grub_calloc (len, GRUB_MAX_UTF16_PER_UTF8 * sizeof (*path_name)); + if (!path_name) + return; + +diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c +index af6741d..a8d8bf7 100644 +--- a/grub-core/loader/i386/bsdXX.c ++++ b/grub-core/loader/i386/bsdXX.c +@@ -48,7 +48,7 @@ read_headers (grub_file_t file, const char *filename, Elf_Ehdr *e, char **shdr) + if (e->e_ident[EI_CLASS] != SUFFIX (ELFCLASS)) + return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic")); + +- *shdr = grub_malloc ((grub_uint32_t) e->e_shnum * e->e_shentsize); ++ *shdr = grub_calloc (e->e_shnum, e->e_shentsize); + if (! *shdr) + return grub_errno; + +diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c +index e64ed08..b7d176b 100644 +--- a/grub-core/loader/i386/xnu.c ++++ b/grub-core/loader/i386/xnu.c +@@ -295,7 +295,7 @@ grub_xnu_devprop_add_property_utf8 (struct grub_xnu_devprop_device_descriptor *d + return grub_errno; + + len = grub_strlen (name); +- utf16 = grub_malloc (sizeof (grub_uint16_t) * len); ++ utf16 = grub_calloc (len, sizeof (grub_uint16_t)); + if (!utf16) + { + grub_free (utf8); +@@ -331,7 +331,7 @@ grub_xnu_devprop_add_property_utf16 (struct grub_xnu_devprop_device_descriptor * + grub_uint16_t *utf16; + grub_err_t err; + +- utf16 = grub_malloc (sizeof (grub_uint16_t) * namelen); ++ utf16 = grub_calloc (namelen, sizeof (grub_uint16_t)); + if (!utf16) + return grub_errno; + grub_memcpy (utf16, name, sizeof (grub_uint16_t) * namelen); +diff --git a/grub-core/loader/macho.c b/grub-core/loader/macho.c +index 085f9c6..05710c4 100644 +--- a/grub-core/loader/macho.c ++++ b/grub-core/loader/macho.c +@@ -97,7 +97,7 @@ grub_macho_file (grub_file_t file, const char *filename, int is_64bit) + if (grub_file_seek (macho->file, sizeof (struct grub_macho_fat_header)) + == (grub_off_t) -1) + goto fail; +- archs = grub_malloc (sizeof (struct grub_macho_fat_arch) * narchs); ++ archs = grub_calloc (narchs, sizeof (struct grub_macho_fat_arch)); + if (!archs) + goto fail; + if (grub_file_read (macho->file, archs, +diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c +index 70cd1db..cc68536 100644 +--- a/grub-core/loader/multiboot_elfxx.c ++++ b/grub-core/loader/multiboot_elfxx.c +@@ -217,7 +217,7 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) + { + grub_uint8_t *shdr, *shdrptr; + +- shdr = grub_malloc ((grub_uint32_t) ehdr->e_shnum * ehdr->e_shentsize); ++ shdr = grub_calloc (ehdr->e_shnum, ehdr->e_shentsize); + if (!shdr) + return grub_errno; + +diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c +index e0f47e7..2f0ebd0 100644 +--- a/grub-core/loader/xnu.c ++++ b/grub-core/loader/xnu.c +@@ -801,7 +801,7 @@ grub_cmd_xnu_mkext (grub_command_t cmd __attribute__ ((unused)), + if (grub_be_to_cpu32 (head.magic) == GRUB_MACHO_FAT_MAGIC) + { + narchs = grub_be_to_cpu32 (head.nfat_arch); +- archs = grub_malloc (sizeof (struct grub_macho_fat_arch) * narchs); ++ archs = grub_calloc (narchs, sizeof (struct grub_macho_fat_arch)); + if (! archs) + { + grub_file_close (file); +diff --git a/grub-core/mmap/mmap.c b/grub-core/mmap/mmap.c +index b569cb2..64684c2 100644 +--- a/grub-core/mmap/mmap.c ++++ b/grub-core/mmap/mmap.c +@@ -143,9 +143,9 @@ grub_mmap_iterate (grub_memory_hook_t hook, void *hook_data) + + /* Initialize variables. */ + ctx.scanline_events = (struct grub_mmap_scan *) +- grub_malloc (sizeof (struct grub_mmap_scan) * 2 * mmap_num); ++ grub_calloc (mmap_num, sizeof (struct grub_mmap_scan) * 2); + +- present = grub_zalloc (sizeof (present[0]) * current_priority); ++ present = grub_calloc (current_priority, sizeof (present[0])); + + if (! ctx.scanline_events || !present) + { +diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c +index 2e46842..5a5ebbf 100644 +--- a/grub-core/net/bootp.c ++++ b/grub-core/net/bootp.c +@@ -1629,7 +1629,7 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), + if (ncards == 0) + return grub_error (GRUB_ERR_NET_NO_CARD, N_("no network card found")); + +- ifaces = grub_zalloc (ncards * sizeof (ifaces[0])); ++ ifaces = grub_calloc (ncards, sizeof (ifaces[0])); + if (!ifaces) + return grub_errno; + +diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c +index 5d9afe0..e332d5e 100644 +--- a/grub-core/net/dns.c ++++ b/grub-core/net/dns.c +@@ -285,8 +285,8 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)), + ptr++; + ptr += 4; + } +- *data->addresses = grub_malloc (sizeof ((*data->addresses)[0]) +- * grub_be_to_cpu16 (head->ancount)); ++ *data->addresses = grub_calloc (grub_be_to_cpu16 (head->ancount), ++ sizeof ((*data->addresses)[0])); + if (!*data->addresses) + { + grub_errno = GRUB_ERR_NONE; +@@ -406,8 +406,8 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)), + dns_cache[h].addresses = 0; + dns_cache[h].name = grub_strdup (data->oname); + dns_cache[h].naddresses = *data->naddresses; +- dns_cache[h].addresses = grub_malloc (*data->naddresses +- * sizeof (dns_cache[h].addresses[0])); ++ dns_cache[h].addresses = grub_calloc (*data->naddresses, ++ sizeof (dns_cache[h].addresses[0])); + dns_cache[h].limit_time = grub_get_time_ms () + 1000 * ttl_all; + if (!dns_cache[h].addresses || !dns_cache[h].name) + { +@@ -479,7 +479,7 @@ grub_net_dns_lookup (const char *name, + } + } + +- sockets = grub_malloc (sizeof (sockets[0]) * n_servers); ++ sockets = grub_calloc (n_servers, sizeof (sockets[0])); + if (!sockets) + return grub_errno; + +diff --git a/grub-core/net/net.c b/grub-core/net/net.c +index 15073dd..ad024c9 100644 +--- a/grub-core/net/net.c ++++ b/grub-core/net/net.c +@@ -338,8 +338,8 @@ grub_cmd_ipv6_autoconf (struct grub_command *cmd __attribute__ ((unused)), + ncards++; + } + +- ifaces = grub_zalloc (ncards * sizeof (ifaces[0])); +- slaacs = grub_zalloc (ncards * sizeof (slaacs[0])); ++ ifaces = grub_calloc (ncards, sizeof (ifaces[0])); ++ slaacs = grub_calloc (ncards, sizeof (slaacs[0])); + if (!ifaces || !slaacs) + { + grub_free (ifaces); +diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c +index b0ab47d..d57fb72 100644 +--- a/grub-core/normal/charset.c ++++ b/grub-core/normal/charset.c +@@ -203,7 +203,7 @@ grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg, + { + grub_size_t msg_len = grub_strlen (msg); + +- *unicode_msg = grub_malloc (msg_len * sizeof (grub_uint32_t)); ++ *unicode_msg = grub_calloc (msg_len, sizeof (grub_uint32_t)); + + if (!*unicode_msg) + return -1; +@@ -488,7 +488,7 @@ grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen, + } + else + { +- n = grub_malloc (sizeof (n[0]) * (out->ncomb + 1)); ++ n = grub_calloc (out->ncomb + 1, sizeof (n[0])); + if (!n) + { + grub_errno = GRUB_ERR_NONE; +@@ -842,7 +842,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical, + } \ + } + +- visual = grub_malloc (sizeof (visual[0]) * logical_len); ++ visual = grub_calloc (logical_len, sizeof (visual[0])); + if (!visual) + return -1; + +@@ -1165,8 +1165,8 @@ grub_bidi_logical_to_visual (const grub_uint32_t *logical, + { + const grub_uint32_t *line_start = logical, *ptr; + struct grub_unicode_glyph *visual_ptr; +- *visual_out = visual_ptr = grub_malloc (3 * sizeof (visual_ptr[0]) +- * (logical_len + 2)); ++ *visual_out = visual_ptr = grub_calloc (logical_len + 2, ++ 3 * sizeof (visual_ptr[0])); + if (!visual_ptr) + return -1; + for (ptr = logical; ptr <= logical + logical_len; ptr++) +diff --git a/grub-core/normal/cmdline.c b/grub-core/normal/cmdline.c +index c037d50..c57242e 100644 +--- a/grub-core/normal/cmdline.c ++++ b/grub-core/normal/cmdline.c +@@ -41,7 +41,7 @@ grub_err_t + grub_set_history (int newsize) + { + grub_uint32_t **old_hist_lines = hist_lines; +- hist_lines = grub_malloc (sizeof (grub_uint32_t *) * newsize); ++ hist_lines = grub_calloc (newsize, sizeof (grub_uint32_t *)); + + /* Copy the old lines into the new buffer. */ + if (old_hist_lines) +@@ -114,7 +114,7 @@ static void + grub_history_set (int pos, grub_uint32_t *s, grub_size_t len) + { + grub_free (hist_lines[pos]); +- hist_lines[pos] = grub_malloc ((len + 1) * sizeof (grub_uint32_t)); ++ hist_lines[pos] = grub_calloc (len + 1, sizeof (grub_uint32_t)); + if (!hist_lines[pos]) + { + grub_print_error (); +@@ -349,7 +349,7 @@ grub_cmdline_get (const char *prompt_translated) + char *ret; + unsigned nterms; + +- buf = grub_malloc (max_len * sizeof (grub_uint32_t)); ++ buf = grub_calloc (max_len, sizeof (grub_uint32_t)); + if (!buf) + return 0; + +@@ -377,7 +377,7 @@ grub_cmdline_get (const char *prompt_translated) + FOR_ACTIVE_TERM_OUTPUTS(cur) + nterms++; + +- cl_terms = grub_malloc (sizeof (cl_terms[0]) * nterms); ++ cl_terms = grub_calloc (nterms, sizeof (cl_terms[0])); + if (!cl_terms) + { + grub_free (buf); +@@ -385,7 +385,7 @@ grub_cmdline_get (const char *prompt_translated) + } + cl_term_cur = cl_terms; + +- unicode_msg = grub_malloc (msg_len * sizeof (grub_uint32_t)); ++ unicode_msg = grub_calloc (msg_len, sizeof (grub_uint32_t)); + if (!unicode_msg) + { + grub_free (buf); +@@ -495,7 +495,7 @@ grub_cmdline_get (const char *prompt_translated) + grub_uint32_t *insert; + + insertlen = grub_strlen (insertu8); +- insert = grub_malloc ((insertlen + 1) * sizeof (grub_uint32_t)); ++ insert = grub_calloc (insertlen + 1, sizeof (grub_uint32_t)); + if (!insert) + { + grub_free (insertu8); +@@ -602,7 +602,7 @@ grub_cmdline_get (const char *prompt_translated) + + grub_free (kill_buf); + +- kill_buf = grub_malloc ((n + 1) * sizeof(grub_uint32_t)); ++ kill_buf = grub_calloc (n + 1, sizeof (grub_uint32_t)); + if (grub_errno) + { + grub_print_error (); +diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c +index 5785f67..f31487c 100644 +--- a/grub-core/normal/menu_entry.c ++++ b/grub-core/normal/menu_entry.c +@@ -95,8 +95,8 @@ init_line (struct screen *screen, struct line *linep) + { + linep->len = 0; + linep->max_len = 80; +- linep->buf = grub_malloc ((linep->max_len + 1) * sizeof (linep->buf[0])); +- linep->pos = grub_zalloc (screen->nterms * sizeof (linep->pos[0])); ++ linep->buf = grub_calloc (linep->max_len + 1, sizeof (linep->buf[0])); ++ linep->pos = grub_calloc (screen->nterms, sizeof (linep->pos[0])); + if (! linep->buf || !linep->pos) + { + grub_free (linep->buf); +@@ -287,7 +287,7 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen, + pos = linep->pos + (term_screen - screen->terms); + + if (!*pos) +- *pos = grub_zalloc ((linep->len + 1) * sizeof (**pos)); ++ *pos = grub_calloc (linep->len + 1, sizeof (**pos)); + + if (i == region_start || linep == screen->lines + screen->line + || (i > region_start && mode == ALL_LINES)) +@@ -471,7 +471,7 @@ insert_string (struct screen *screen, const char *s, int update) + + /* Insert the string. */ + current_linep = screen->lines + screen->line; +- unicode_msg = grub_malloc ((p - s) * sizeof (grub_uint32_t)); ++ unicode_msg = grub_calloc (p - s, sizeof (grub_uint32_t)); + + if (!unicode_msg) + return 0; +@@ -1023,7 +1023,7 @@ complete (struct screen *screen, int continuous, int update) + if (completion_buffer.buf) + { + buflen = grub_strlen (completion_buffer.buf); +- ucs4 = grub_malloc (sizeof (grub_uint32_t) * (buflen + 1)); ++ ucs4 = grub_calloc (buflen + 1, sizeof (grub_uint32_t)); + + if (!ucs4) + { +@@ -1265,7 +1265,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) + for (i = 0; i < (unsigned) screen->num_lines; i++) + { + grub_free (screen->lines[i].pos); +- screen->lines[i].pos = grub_zalloc (screen->nterms * sizeof (screen->lines[i].pos[0])); ++ screen->lines[i].pos = grub_calloc (screen->nterms, sizeof (screen->lines[i].pos[0])); + if (! screen->lines[i].pos) + { + grub_print_error (); +@@ -1275,7 +1275,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) + } + } + +- screen->terms = grub_zalloc (screen->nterms * sizeof (screen->terms[0])); ++ screen->terms = grub_calloc (screen->nterms, sizeof (screen->terms[0])); + if (!screen->terms) + { + grub_print_error (); +diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c +index 7681f7d..ca13562 100644 +--- a/grub-core/normal/menu_text.c ++++ b/grub-core/normal/menu_text.c +@@ -78,7 +78,7 @@ grub_print_message_indented_real (const char *msg, int margin_left, + grub_size_t msg_len = grub_strlen (msg) + 2; + int ret = 0; + +- unicode_msg = grub_malloc (msg_len * sizeof (grub_uint32_t)); ++ unicode_msg = grub_calloc (msg_len, sizeof (grub_uint32_t)); + + if (!unicode_msg) + return 0; +@@ -167,7 +167,7 @@ print_entry (int y, int highlight, grub_menu_entry_t entry, + + title = entry ? entry->title : ""; + title_len = grub_strlen (title); +- unicode_title = grub_malloc (title_len * sizeof (*unicode_title)); ++ unicode_title = grub_calloc (title_len, sizeof (*unicode_title)); + if (! unicode_title) + /* XXX How to show this error? */ + return; +diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c +index a1e5c5a..cc8c173 100644 +--- a/grub-core/normal/term.c ++++ b/grub-core/normal/term.c +@@ -264,7 +264,7 @@ grub_term_save_pos (void) + FOR_ACTIVE_TERM_OUTPUTS(cur) + cnt++; + +- ret = grub_malloc (cnt * sizeof (ret[0])); ++ ret = grub_calloc (cnt, sizeof (ret[0])); + if (!ret) + return NULL; + +@@ -1013,7 +1013,7 @@ grub_xnputs (const char *str, grub_size_t msg_len) + + grub_error_push (); + +- unicode_str = grub_malloc (msg_len * sizeof (grub_uint32_t)); ++ unicode_str = grub_calloc (msg_len, sizeof (grub_uint32_t)); + + grub_error_pop (); + +diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c +index 36429a7..f0c503f 100644 +--- a/grub-core/osdep/linux/getroot.c ++++ b/grub-core/osdep/linux/getroot.c +@@ -176,7 +176,7 @@ grub_util_raid_getmembers (const char *name, int bootable) + if (ret != 0) + grub_util_error (_("ioctl GET_ARRAY_INFO error: %s"), strerror (errno)); + +- devicelist = xmalloc ((info.nr_disks + 1) * sizeof (char *)); ++ devicelist = xcalloc (info.nr_disks + 1, sizeof (char *)); + + for (i = 0, j = 0; j < info.nr_disks; i++) + { +@@ -249,7 +249,7 @@ grub_find_root_devices_from_btrfs (const char *dir) + return NULL; + } + +- ret = xmalloc ((fsi.num_devices + 1) * sizeof (ret[0])); ++ ret = xcalloc (fsi.num_devices + 1, sizeof (ret[0])); + + for (i = 1; i <= fsi.max_id && j < fsi.num_devices; i++) + { +@@ -508,7 +508,7 @@ grub_find_root_devices_from_mountinfo (const char *dir, char **relroot) + if (relroot) + *relroot = NULL; + +- entries = xmalloc (entry_max * sizeof (*entries)); ++ entries = xcalloc (entry_max, sizeof (*entries)); + + again: + fp = grub_util_fopen ("/proc/self/mountinfo", "r"); +diff --git a/grub-core/osdep/unix/config.c b/grub-core/osdep/unix/config.c +index b637c58..46a8815 100644 +--- a/grub-core/osdep/unix/config.c ++++ b/grub-core/osdep/unix/config.c +@@ -102,7 +102,7 @@ grub_util_load_config (struct grub_util_config *cfg) + argv[0] = "sh"; + argv[1] = "-c"; + +- script = xmalloc (4 * strlen (cfgfile) + 300); ++ script = xcalloc (4, strlen (cfgfile) + 300); + + ptr = script; + memcpy (ptr, ". '", 3); +diff --git a/grub-core/osdep/windows/getroot.c b/grub-core/osdep/windows/getroot.c +index 661d954..eada663 100644 +--- a/grub-core/osdep/windows/getroot.c ++++ b/grub-core/osdep/windows/getroot.c +@@ -59,7 +59,7 @@ grub_get_mount_point (const TCHAR *path) + + for (ptr = path; *ptr; ptr++); + allocsize = (ptr - path + 10) * 2; +- out = xmalloc (allocsize * sizeof (out[0])); ++ out = xcalloc (allocsize, sizeof (out[0])); + + /* When pointing to EFI system partition GetVolumePathName fails + for ESP root and returns abberant information for everything +diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c +index 87a106c..29cf427 100644 +--- a/grub-core/osdep/windows/hostdisk.c ++++ b/grub-core/osdep/windows/hostdisk.c +@@ -111,7 +111,7 @@ grub_util_get_windows_path_real (const char *path) + + while (1) + { +- fpa = xmalloc (alloc * sizeof (fpa[0])); ++ fpa = xcalloc (alloc, sizeof (fpa[0])); + + len = GetFullPathName (tpath, alloc, fpa, NULL); + if (len >= alloc) +@@ -405,7 +405,7 @@ grub_util_fd_opendir (const char *name) + for (l = 0; name_windows[l]; l++); + for (l--; l >= 0 && (name_windows[l] == '\\' || name_windows[l] == '/'); l--); + l++; +- pattern = xmalloc ((l + 3) * sizeof (pattern[0])); ++ pattern = xcalloc (l + 3, sizeof (pattern[0])); + memcpy (pattern, name_windows, l * sizeof (pattern[0])); + pattern[l] = '\\'; + pattern[l + 1] = '*'; +diff --git a/grub-core/osdep/windows/init.c b/grub-core/osdep/windows/init.c +index e8ffd62..6297de6 100644 +--- a/grub-core/osdep/windows/init.c ++++ b/grub-core/osdep/windows/init.c +@@ -161,7 +161,7 @@ grub_util_host_init (int *argc __attribute__ ((unused)), + LPWSTR *targv; + + targv = CommandLineToArgvW (tcmdline, argc); +- *argv = xmalloc ((*argc + 1) * sizeof (argv[0])); ++ *argv = xcalloc (*argc + 1, sizeof (argv[0])); + + for (i = 0; i < *argc; i++) + (*argv)[i] = grub_util_tchar_to_utf8 (targv[i]); +diff --git a/grub-core/osdep/windows/platform.c b/grub-core/osdep/windows/platform.c +index 7eb53fe..1ef86bf 100644 +--- a/grub-core/osdep/windows/platform.c ++++ b/grub-core/osdep/windows/platform.c +@@ -225,8 +225,8 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, + grub_util_error ("%s", _("no EFI routines are available when running in BIOS mode")); + + distrib8_len = grub_strlen (efi_distributor); +- distributor16 = xmalloc ((distrib8_len + 1) * GRUB_MAX_UTF16_PER_UTF8 +- * sizeof (grub_uint16_t)); ++ distributor16 = xcalloc (distrib8_len + 1, ++ GRUB_MAX_UTF16_PER_UTF8 * sizeof (grub_uint16_t)); + distrib16_len = grub_utf8_to_utf16 (distributor16, distrib8_len * GRUB_MAX_UTF16_PER_UTF8, + (const grub_uint8_t *) efi_distributor, + distrib8_len, 0); +diff --git a/grub-core/osdep/windows/relpath.c b/grub-core/osdep/windows/relpath.c +index cb08617..478e8ef 100644 +--- a/grub-core/osdep/windows/relpath.c ++++ b/grub-core/osdep/windows/relpath.c +@@ -72,7 +72,7 @@ grub_make_system_path_relative_to_its_root (const char *path) + if (dirwindows[0] && dirwindows[1] == ':') + offset = 2; + } +- ret = xmalloc (sizeof (ret[0]) * (flen - offset + 2)); ++ ret = xcalloc (flen - offset + 2, sizeof (ret[0])); + if (dirwindows[offset] != '\\' + && dirwindows[offset] != '/' + && dirwindows[offset]) +diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c +index 103f679..72a2e37 100644 +--- a/grub-core/partmap/gpt.c ++++ b/grub-core/partmap/gpt.c +@@ -199,7 +199,7 @@ gpt_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors, + *nsectors = ctx.len; + if (*nsectors > max_nsectors) + *nsectors = max_nsectors; +- *sectors = grub_malloc (*nsectors * sizeof (**sectors)); ++ *sectors = grub_calloc (*nsectors, sizeof (**sectors)); + if (!*sectors) + return grub_errno; + for (i = 0; i < *nsectors; i++) +diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c +index 7b8e450..ee3f249 100644 +--- a/grub-core/partmap/msdos.c ++++ b/grub-core/partmap/msdos.c +@@ -337,7 +337,7 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors, + avail_nsectors = *nsectors; + if (*nsectors > max_nsectors) + *nsectors = max_nsectors; +- *sectors = grub_malloc (*nsectors * sizeof (**sectors)); ++ *sectors = grub_calloc (*nsectors, sizeof (**sectors)); + if (!*sectors) + return grub_errno; + for (i = 0; i < *nsectors; i++) +diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c +index c6d2c36..b55e171 100644 +--- a/grub-core/script/execute.c ++++ b/grub-core/script/execute.c +@@ -587,7 +587,7 @@ gettext_append (struct grub_script_argv *result, const char *orig_str) + for (iptr = orig_str; *iptr; iptr++) + if (*iptr == '$') + dollar_cnt++; +- ctx.allowed_strings = grub_malloc (sizeof (ctx.allowed_strings[0]) * dollar_cnt); ++ ctx.allowed_strings = grub_calloc (dollar_cnt, sizeof (ctx.allowed_strings[0])); + + if (parse_string (orig_str, gettext_save_allow, &ctx, 0)) + goto fail; +diff --git a/grub-core/tests/fake_input.c b/grub-core/tests/fake_input.c +index 2d60852..b5eb516 100644 +--- a/grub-core/tests/fake_input.c ++++ b/grub-core/tests/fake_input.c +@@ -49,7 +49,7 @@ grub_terminal_input_fake_sequence (int *seq_in, int nseq_in) + saved = grub_term_inputs; + if (seq) + grub_free (seq); +- seq = grub_malloc (nseq_in * sizeof (seq[0])); ++ seq = grub_calloc (nseq_in, sizeof (seq[0])); + if (!seq) + return; + +diff --git a/grub-core/tests/video_checksum.c b/grub-core/tests/video_checksum.c +index 74d5b65..44d0810 100644 +--- a/grub-core/tests/video_checksum.c ++++ b/grub-core/tests/video_checksum.c +@@ -336,7 +336,7 @@ grub_video_capture_write_bmp (const char *fname, + { + case 4: + { +- grub_uint8_t *buffer = xmalloc (mode_info->width * 3); ++ grub_uint8_t *buffer = xcalloc (3, mode_info->width); + grub_uint32_t rmask = ((1 << mode_info->red_mask_size) - 1); + grub_uint32_t gmask = ((1 << mode_info->green_mask_size) - 1); + grub_uint32_t bmask = ((1 << mode_info->blue_mask_size) - 1); +@@ -367,7 +367,7 @@ grub_video_capture_write_bmp (const char *fname, + } + case 3: + { +- grub_uint8_t *buffer = xmalloc (mode_info->width * 3); ++ grub_uint8_t *buffer = xcalloc (3, mode_info->width); + grub_uint32_t rmask = ((1 << mode_info->red_mask_size) - 1); + grub_uint32_t gmask = ((1 << mode_info->green_mask_size) - 1); + grub_uint32_t bmask = ((1 << mode_info->blue_mask_size) - 1); +@@ -407,7 +407,7 @@ grub_video_capture_write_bmp (const char *fname, + } + case 2: + { +- grub_uint8_t *buffer = xmalloc (mode_info->width * 3); ++ grub_uint8_t *buffer = xcalloc (3, mode_info->width); + grub_uint16_t rmask = ((1 << mode_info->red_mask_size) - 1); + grub_uint16_t gmask = ((1 << mode_info->green_mask_size) - 1); + grub_uint16_t bmask = ((1 << mode_info->blue_mask_size) - 1); +diff --git a/grub-core/video/capture.c b/grub-core/video/capture.c +index 4f83c74..4d3195e 100644 +--- a/grub-core/video/capture.c ++++ b/grub-core/video/capture.c +@@ -89,7 +89,7 @@ grub_video_capture_start (const struct grub_video_mode_info *mode_info, + framebuffer.mode_info = *mode_info; + framebuffer.mode_info.blit_format = grub_video_get_blit_format (&framebuffer.mode_info); + +- framebuffer.ptr = grub_malloc (framebuffer.mode_info.height * framebuffer.mode_info.pitch); ++ framebuffer.ptr = grub_calloc (framebuffer.mode_info.height, framebuffer.mode_info.pitch); + if (!framebuffer.ptr) + return grub_errno; + +diff --git a/grub-core/video/emu/sdl.c b/grub-core/video/emu/sdl.c +index a2f639f..0ebab6f 100644 +--- a/grub-core/video/emu/sdl.c ++++ b/grub-core/video/emu/sdl.c +@@ -172,7 +172,7 @@ grub_video_sdl_set_palette (unsigned int start, unsigned int count, + if (start + count > mode_info.number_of_colors) + count = mode_info.number_of_colors - start; + +- tmp = grub_malloc (count * sizeof (tmp[0])); ++ tmp = grub_calloc (count, sizeof (tmp[0])); + for (i = 0; i < count; i++) + { + tmp[i].r = palette_data[i].r; +diff --git a/grub-core/video/i386/pc/vga.c b/grub-core/video/i386/pc/vga.c +index 01f4711..b2f776c 100644 +--- a/grub-core/video/i386/pc/vga.c ++++ b/grub-core/video/i386/pc/vga.c +@@ -127,7 +127,7 @@ grub_video_vga_setup (unsigned int width, unsigned int height, + + vga_height = height ? : 480; + +- framebuffer.temporary_buffer = grub_malloc (vga_height * VGA_WIDTH); ++ framebuffer.temporary_buffer = grub_calloc (vga_height, VGA_WIDTH); + framebuffer.front_page = 0; + framebuffer.back_page = 0; + if (!framebuffer.temporary_buffer) +diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c +index 777e713..61bd645 100644 +--- a/grub-core/video/readers/png.c ++++ b/grub-core/video/readers/png.c +@@ -309,7 +309,7 @@ grub_png_decode_image_header (struct grub_png_data *data) + if (data->is_16bit || data->is_gray || data->is_palette) + #endif + { +- data->image_data = grub_malloc (data->image_height * data->row_bytes); ++ data->image_data = grub_calloc (data->image_height, data->row_bytes); + if (grub_errno) + return grub_errno; + +diff --git a/include/grub/unicode.h b/include/grub/unicode.h +index a0403e9..4de986a 100644 +--- a/include/grub/unicode.h ++++ b/include/grub/unicode.h +@@ -293,7 +293,7 @@ grub_unicode_glyph_dup (const struct grub_unicode_glyph *in) + grub_memcpy (out, in, sizeof (*in)); + if (in->ncomb > ARRAY_SIZE (out->combining_inline)) + { +- out->combining_ptr = grub_malloc (in->ncomb * sizeof (out->combining_ptr[0])); ++ out->combining_ptr = grub_calloc (in->ncomb, sizeof (out->combining_ptr[0])); + if (!out->combining_ptr) + { + grub_free (out); +@@ -315,7 +315,7 @@ grub_unicode_set_glyph (struct grub_unicode_glyph *out, + grub_memcpy (out, in, sizeof (*in)); + if (in->ncomb > ARRAY_SIZE (out->combining_inline)) + { +- out->combining_ptr = grub_malloc (in->ncomb * sizeof (out->combining_ptr[0])); ++ out->combining_ptr = grub_calloc (in->ncomb, sizeof (out->combining_ptr[0])); + if (!out->combining_ptr) + return; + grub_memcpy (out->combining_ptr, in->combining_ptr, +diff --git a/util/getroot.c b/util/getroot.c +index fa3460d..6feb2a4 100644 +--- a/util/getroot.c ++++ b/util/getroot.c +@@ -219,7 +219,7 @@ make_device_name (const char *drive) + char *ret, *ptr; + const char *iptr; + +- ret = xmalloc (strlen (drive) * 2); ++ ret = xcalloc (2, strlen (drive)); + ptr = ret; + for (iptr = drive; *iptr; iptr++) + { +diff --git a/util/grub-file.c b/util/grub-file.c +index 50c18b6..b2e7dd6 100644 +--- a/util/grub-file.c ++++ b/util/grub-file.c +@@ -54,7 +54,7 @@ main (int argc, char *argv[]) + + grub_util_host_init (&argc, &argv); + +- argv2 = xmalloc (argc * sizeof (argv2[0])); ++ argv2 = xcalloc (argc, sizeof (argv2[0])); + + if (argc == 2 && strcmp (argv[1], "--version") == 0) + { +diff --git a/util/grub-fstest.c b/util/grub-fstest.c +index 39bad1f..bfcef85 100644 +--- a/util/grub-fstest.c ++++ b/util/grub-fstest.c +@@ -650,7 +650,7 @@ argp_parser (int key, char *arg, struct argp_state *state) + if (args_count < num_disks) + { + if (args_count == 0) +- images = xmalloc (num_disks * sizeof (images[0])); ++ images = xcalloc (num_disks, sizeof (images[0])); + images[args_count] = grub_canonicalize_file_name (arg); + args_count++; + return 0; +@@ -734,7 +734,7 @@ main (int argc, char *argv[]) + + grub_util_host_init (&argc, &argv); + +- args = xmalloc (argc * sizeof (args[0])); ++ args = xcalloc (argc, sizeof (args[0])); + + argp_parse (&argp, argc, argv, 0, 0, 0); + +diff --git a/util/grub-install-common.c b/util/grub-install-common.c +index ca0ac61..0295d40 100644 +--- a/util/grub-install-common.c ++++ b/util/grub-install-common.c +@@ -286,7 +286,7 @@ handle_install_list (struct install_list *il, const char *val, + il->n_entries++; + } + il->n_alloc = il->n_entries + 1; +- il->entries = xmalloc (il->n_alloc * sizeof (il->entries[0])); ++ il->entries = xcalloc (il->n_alloc, sizeof (il->entries[0])); + ptr = val; + for (ce = il->entries; ; ce++) + { +diff --git a/util/grub-install.c b/util/grub-install.c +index 8b6a037..dddb757 100644 +--- a/util/grub-install.c ++++ b/util/grub-install.c +@@ -634,7 +634,7 @@ device_map_check_duplicates (const char *dev_map) + if (! fp) + return; + +- d = xmalloc (alloced * sizeof (d[0])); ++ d = xcalloc (alloced, sizeof (d[0])); + + while (fgets (buf, sizeof (buf), fp)) + { +@@ -1263,7 +1263,7 @@ main (int argc, char *argv[]) + ndev++; + } + +- grub_drives = xmalloc (sizeof (grub_drives[0]) * (ndev + 1)); ++ grub_drives = xcalloc (ndev + 1, sizeof (grub_drives[0])); + + for (curdev = grub_devices, curdrive = grub_drives; *curdev; curdev++, + curdrive++) +diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c +index d16ec63..52bc9c8 100644 +--- a/util/grub-mkimagexx.c ++++ b/util/grub-mkimagexx.c +@@ -2294,10 +2294,8 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, + + grub_host_to_target16 (e->e_shstrndx) * smd.section_entsize); + smd.strtab = (char *) e + grub_host_to_target_addr (s->sh_offset); + +- smd.addrs = xmalloc (sizeof (*smd.addrs) * smd.num_sections); +- memset (smd.addrs, 0, sizeof (*smd.addrs) * smd.num_sections); +- smd.vaddrs = xmalloc (sizeof (*smd.vaddrs) * smd.num_sections); +- memset (smd.vaddrs, 0, sizeof (*smd.vaddrs) * smd.num_sections); ++ smd.addrs = xcalloc (smd.num_sections, sizeof (*smd.addrs)); ++ smd.vaddrs = xcalloc (smd.num_sections, sizeof (*smd.vaddrs)); + + SUFFIX (locate_sections) (e, kernel_path, &smd, layout, image_target); + +diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c +index ce2cbc4..5183102 100644 +--- a/util/grub-mkrescue.c ++++ b/util/grub-mkrescue.c +@@ -441,8 +441,8 @@ main (int argc, char *argv[]) + xorriso = xstrdup ("xorriso"); + label_font = grub_util_path_concat (2, pkgdatadir, "unicode.pf2"); + +- argp_argv = xmalloc (sizeof (argp_argv[0]) * argc); +- xorriso_tail_argv = xmalloc (sizeof (argp_argv[0]) * argc); ++ argp_argv = xcalloc (argc, sizeof (argp_argv[0])); ++ xorriso_tail_argv = xcalloc (argc, sizeof (argp_argv[0])); + + xorriso_tail_argc = 0; + /* Program name */ +diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c +index 4907d44..edf3097 100644 +--- a/util/grub-mkstandalone.c ++++ b/util/grub-mkstandalone.c +@@ -296,7 +296,7 @@ main (int argc, char *argv[]) + grub_util_host_init (&argc, &argv); + grub_util_disable_fd_syncs (); + +- files = xmalloc ((argc + 1) * sizeof (files[0])); ++ files = xcalloc (argc + 1, sizeof (files[0])); + + argp_parse (&argp, argc, argv, 0, 0, 0); + +diff --git a/util/grub-pe2elf.c b/util/grub-pe2elf.c +index 0d4084a..1133129 100644 +--- a/util/grub-pe2elf.c ++++ b/util/grub-pe2elf.c +@@ -100,9 +100,9 @@ write_section_data (FILE* fp, const char *name, char *image, + char *pe_strtab = (image + pe_chdr->symtab_offset + + pe_chdr->num_symbols * sizeof (struct grub_pe32_symbol)); + +- section_map = xmalloc ((2 * pe_chdr->num_sections + 5) * sizeof (int)); ++ section_map = xcalloc (2 * pe_chdr->num_sections + 5, sizeof (int)); + section_map[0] = 0; +- shdr = xmalloc ((2 * pe_chdr->num_sections + 5) * sizeof (shdr[0])); ++ shdr = xcalloc (2 * pe_chdr->num_sections + 5, sizeof (shdr[0])); + idx = 1; + idx_reloc = pe_chdr->num_sections + 1; + +@@ -233,7 +233,7 @@ write_reloc_section (FILE* fp, const char *name, char *image, + + pe_sec = pe_shdr + shdr[i].sh_link; + pe_rel = (struct grub_pe32_reloc *) (image + pe_sec->relocations_offset); +- rel = (elf_reloc_t *) xmalloc (pe_sec->num_relocations * sizeof (elf_reloc_t)); ++ rel = (elf_reloc_t *) xcalloc (pe_sec->num_relocations, sizeof (elf_reloc_t)); + num_rels = 0; + modified = 0; + +@@ -365,12 +365,10 @@ write_symbol_table (FILE* fp, const char *name, char *image, + pe_symtab = (struct grub_pe32_symbol *) (image + pe_chdr->symtab_offset); + pe_strtab = (char *) (pe_symtab + pe_chdr->num_symbols); + +- symtab = (Elf_Sym *) xmalloc ((pe_chdr->num_symbols + 1) * +- sizeof (Elf_Sym)); +- memset (symtab, 0, (pe_chdr->num_symbols + 1) * sizeof (Elf_Sym)); ++ symtab = (Elf_Sym *) xcalloc (pe_chdr->num_symbols + 1, sizeof (Elf_Sym)); + num_syms = 1; + +- symtab_map = (int *) xmalloc (pe_chdr->num_symbols * sizeof (int)); ++ symtab_map = (int *) xcalloc (pe_chdr->num_symbols, sizeof (int)); + + for (i = 0; i < (int) pe_chdr->num_symbols; + i += pe_symtab->num_aux + 1, pe_symtab += pe_symtab->num_aux + 1) +diff --git a/util/grub-probe.c b/util/grub-probe.c +index 7481e48..cf4291c 100644 +--- a/util/grub-probe.c ++++ b/util/grub-probe.c +@@ -361,8 +361,8 @@ probe (const char *path, char **device_names, char delim) + grub_util_pull_device (*curdev); + ndev++; + } +- +- drives_names = xmalloc (sizeof (drives_names[0]) * (ndev + 1)); ++ ++ drives_names = xcalloc (ndev + 1, sizeof (drives_names[0])); + + for (curdev = device_names, curdrive = drives_names; *curdev; curdev++, + curdrive++) +-- +2.23.0 + diff --git a/0224-grub-module-verifier-report-the-filename-or-modname-.patch b/0224-grub-module-verifier-report-the-filename-or-modname-.patch deleted file mode 100644 index c27d06549653667a715e3c88af768bbd32d701b5..0000000000000000000000000000000000000000 --- a/0224-grub-module-verifier-report-the-filename-or-modname-.patch +++ /dev/null @@ -1,250 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 1 Aug 2018 10:12:47 -0400 -Subject: [PATCH] grub-module-verifier: report the filename or modname in - errors. - -Make it so that when grub-module-verifier complains of an issue, it tells you -which module the issue was with. - -Signed-off-by: Peter Jones ---- - util/grub-module-verifier.c | 6 ++--- - util/grub-module-verifierXX.c | 58 ++++++++++++++++++++++-------------------- - include/grub/module_verifier.h | 4 +-- - 3 files changed, 36 insertions(+), 32 deletions(-) - -diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c -index a79271f6631..03ba1ab437a 100644 ---- a/util/grub-module-verifier.c -+++ b/util/grub-module-verifier.c -@@ -157,7 +157,7 @@ main (int argc, char **argv) - if (strcmp(archs[arch].name, argv[2]) == 0) - break; - if (arch == ARRAY_SIZE(archs)) -- grub_util_error("unknown arch: %s", argv[2]); -+ grub_util_error("%s: unknown arch: %s", argv[1], argv[2]); - - for (whitelist = 0; whitelist < ARRAY_SIZE(whitelists); whitelist++) - if (strcmp(whitelists[whitelist].arch, argv[2]) == 0 -@@ -169,8 +169,8 @@ main (int argc, char **argv) - module_size = grub_util_get_image_size (argv[1]); - module_img = grub_util_read_image (argv[1]); - if (archs[arch].voidp_sizeof == 8) -- grub_module_verify64(module_img, module_size, &archs[arch], whitelist_empty); -+ grub_module_verify64(argv[1], module_img, module_size, &archs[arch], whitelist_empty); - else -- grub_module_verify32(module_img, module_size, &archs[arch], whitelist_empty); -+ grub_module_verify32(argv[1], module_img, module_size, &archs[arch], whitelist_empty); - return 0; - } -diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c -index 597ded14362..a98e2f9b1ac 100644 ---- a/util/grub-module-verifierXX.c -+++ b/util/grub-module-verifierXX.c -@@ -160,14 +160,15 @@ find_section (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e, const c - } - - static void --check_license (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) -+check_license (const char * const filename, -+ const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) - { - Elf_Shdr *s = find_section (arch, e, ".module_license"); - if (s && (strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv3") == 0 - || strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv3+") == 0 - || strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv2+") == 0)) - return; -- grub_util_error ("incompatible license"); -+ grub_util_error ("%s: incompatible license", filename); - } - - static Elf_Sym * -@@ -233,10 +234,10 @@ check_symbols (const struct grub_module_verifier_arch *arch, - s = find_section (arch, e, ".moddeps"); - - if (!s) -- grub_util_error ("no symbol table and no .moddeps section"); -+ grub_util_error ("%s: no symbol table and no .moddeps section", modname); - - if (!s->sh_size) -- grub_util_error ("no symbol table and empty .moddeps section"); -+ grub_util_error ("%s: no symbol table and empty .moddeps section", modname); - - return; - } -@@ -257,7 +258,7 @@ check_symbols (const struct grub_module_verifier_arch *arch, - break; - - default: -- return grub_util_error ("unknown symbol type `%d'", (int) type); -+ return grub_util_error ("%s: unknown symbol type `%d'", modname, (int) type); - } - } - } -@@ -283,7 +284,8 @@ is_symbol_local(Elf_Sym *sym) - } - - static void --section_check_relocations (const struct grub_module_verifier_arch *arch, void *ehdr, -+section_check_relocations (const char * const modname, -+ const struct grub_module_verifier_arch *arch, void *ehdr, - Elf_Shdr *s, size_t target_seg_size) - { - Elf_Rel *rel, *max; -@@ -292,7 +294,7 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e - - symtab = get_symtab (arch, ehdr, &symtabsize, &symtabentsize); - if (!symtab) -- grub_util_error ("relocation without symbol table"); -+ grub_util_error ("%s: relocation without symbol table", modname); - - for (rel = (Elf_Rel *) ((char *) ehdr + grub_target_to_host (s->sh_offset)), - max = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_size)); -@@ -303,7 +305,7 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e - unsigned i; - - if (target_seg_size < grub_target_to_host (rel->r_offset)) -- grub_util_error ("reloc offset is out of the segment"); -+ grub_util_error ("%s: reloc offset is out of the segment", modname); - - grub_uint32_t type = ELF_R_TYPE (grub_target_to_host (rel->r_info)); - -@@ -316,17 +318,17 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e - if (arch->supported_relocations[i] != -1) - continue; - if (!arch->short_relocations) -- grub_util_error ("unsupported relocation 0x%x", type); -+ grub_util_error ("%s: unsupported relocation 0x%x", modname, type); - for (i = 0; arch->short_relocations[i] != -1; i++) - if (type == arch->short_relocations[i]) - break; - if (arch->short_relocations[i] == -1) -- grub_util_error ("unsupported relocation 0x%x", type); -+ grub_util_error ("%s: unsupported relocation 0x%x", modname, type); - sym = (Elf_Sym *) ((char *) symtab + symtabentsize * ELF_R_SYM (grub_target_to_host (rel->r_info))); - - if (is_symbol_local (sym)) - continue; -- grub_util_error ("relocation 0x%x is not module-local", type); -+ grub_util_error ("%s: relocation 0x%x is not module-local", modname, type); - } - #if defined(MODULEVERIFIER_ELF64) - if (arch->machine == EM_AARCH64) -@@ -351,11 +353,11 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e - && ELF_R_TYPE (rel2->r_info) == R_AARCH64_LD64_GOT_LO12_NC) - break; - if (rel2 >= (Elf_Rela *) max) -- grub_util_error ("ADR_GOT_PAGE without matching LD64_GOT_LO12_NC"); -+ grub_util_error ("%s: ADR_GOT_PAGE without matching LD64_GOT_LO12_NC", modname); - break; - case R_AARCH64_LD64_GOT_LO12_NC: - if (unmatched_adr_got_page == 0) -- grub_util_error ("LD64_GOT_LO12_NC without matching ADR_GOT_PAGE"); -+ grub_util_error ("%s: LD64_GOT_LO12_NC without matching ADR_GOT_PAGE", modname); - unmatched_adr_got_page--; - break; - } -@@ -365,7 +367,8 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e - } - - static void --check_relocations (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) -+check_relocations (const char * const modname, -+ const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) - { - Elf_Shdr *s; - unsigned i; -@@ -378,21 +381,22 @@ check_relocations (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) - Elf_Shdr *ts; - - if (grub_target_to_host32 (s->sh_type) == SHT_REL && !(arch->flags & GRUB_MODULE_VERIFY_SUPPORTS_REL)) -- grub_util_error ("unsupported SHT_REL"); -+ grub_util_error ("%s: unsupported SHT_REL", modname); - if (grub_target_to_host32 (s->sh_type) == SHT_RELA && !(arch->flags & GRUB_MODULE_VERIFY_SUPPORTS_RELA)) -- grub_util_error ("unsupported SHT_RELA"); -+ grub_util_error ("%s: unsupported SHT_RELA", modname); - - /* Find the target segment. */ - if (grub_target_to_host32 (s->sh_info) >= grub_target_to_host16 (e->e_shnum)) -- grub_util_error ("orphaned reloc section"); -+ grub_util_error ("%s: orphaned reloc section", modname); - ts = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff) + grub_target_to_host32 (s->sh_info) * grub_target_to_host16 (e->e_shentsize)); - -- section_check_relocations (arch, e, s, grub_target_to_host (ts->sh_size)); -+ section_check_relocations (modname, arch, e, s, grub_target_to_host (ts->sh_size)); - } - } - - void --SUFFIX(grub_module_verify) (void *module_img, size_t size, -+SUFFIX(grub_module_verify) (const char * const filename, -+ void *module_img, size_t size, - const struct grub_module_verifier_arch *arch, - const char **whitelist_empty) - { -@@ -400,7 +404,7 @@ SUFFIX(grub_module_verify) (void *module_img, size_t size, - - /* Check the header size. */ - if (size < sizeof (Elf_Ehdr)) -- grub_util_error ("ELF header smaller than expected"); -+ grub_util_error ("%s: ELF header smaller than expected", filename); - - /* Check the magic numbers. */ - if (e->e_ident[EI_MAG0] != ELFMAG0 -@@ -409,36 +413,36 @@ SUFFIX(grub_module_verify) (void *module_img, size_t size, - || e->e_ident[EI_MAG3] != ELFMAG3 - || e->e_ident[EI_VERSION] != EV_CURRENT - || grub_target_to_host32 (e->e_version) != EV_CURRENT) -- grub_util_error ("invalid arch-independent ELF magic"); -+ grub_util_error ("%s: invalid arch-independent ELF magic", filename); - - if (e->e_ident[EI_CLASS] != ELFCLASSXX - || e->e_ident[EI_DATA] != (arch->bigendian ? ELFDATA2MSB : ELFDATA2LSB) - || grub_target_to_host16 (e->e_machine) != arch->machine) -- grub_util_error ("invalid arch-dependent ELF magic"); -+ grub_util_error ("%s: invalid arch-dependent ELF magic", filename); - - if (grub_target_to_host16 (e->e_type) != ET_REL) - { -- grub_util_error ("this ELF file is not of the right type"); -+ grub_util_error ("%s: this ELF file is not of the right type", filename); - } - - /* Make sure that every section is within the core. */ - if (size < grub_target_to_host (e->e_shoff) - + (grub_uint32_t) grub_target_to_host16 (e->e_shentsize) * grub_target_to_host16(e->e_shnum)) - { -- grub_util_error ("ELF sections outside core"); -+ grub_util_error ("%s: ELF sections outside core", filename); - } - -- check_license (arch, e); -+ check_license (filename, arch, e); - - Elf_Shdr *s; - const char *modname; - - s = find_section (arch, e, ".modname"); - if (!s) -- grub_util_error ("no module name found"); -+ grub_util_error ("%s: no module name found", filename); - - modname = (const char *) e + grub_target_to_host (s->sh_offset); - - check_symbols(arch, e, modname, whitelist_empty); -- check_relocations(arch, e); -+ check_relocations(modname, arch, e); - } -diff --git a/include/grub/module_verifier.h b/include/grub/module_verifier.h -index f4870cb9c2d..ba21c75e2eb 100644 ---- a/include/grub/module_verifier.h -+++ b/include/grub/module_verifier.h -@@ -16,5 +16,5 @@ struct grub_module_verifier_arch { - const int *short_relocations; - }; - --void grub_module_verify64(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch, const char **whitelist_empty); --void grub_module_verify32(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch, const char **whitelist_empty); -+void grub_module_verify64(const char * const filename, void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch, const char **whitelist_empty); -+void grub_module_verify32(const char * const filename, void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch, const char **whitelist_empty); diff --git a/0225-Make-efi_netfs-not-duplicate-symbols-from-efinet.patch b/0225-Make-efi_netfs-not-duplicate-symbols-from-efinet.patch deleted file mode 100644 index e1b9bb4447b9009117eea288d5f1a0200dc2804c..0000000000000000000000000000000000000000 --- a/0225-Make-efi_netfs-not-duplicate-symbols-from-efinet.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Wed, 11 Jul 2018 13:50:00 -0400 -Subject: [PATCH] Make efi_netfs not duplicate symbols from efinet - -Signed-off-by: Peter Jones ---- - grub-core/Makefile.core.def | 6 ------ - 1 file changed, 6 deletions(-) - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index d3e3bfd4d7a..715d3a3ec02 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -2186,12 +2186,6 @@ module = { - module = { - name = efi_netfs; - common = net/efi/efi_netfs.c; -- common = net/efi/net.c; -- common = net/efi/http.c; -- common = net/efi/pxe.c; -- common = net/efi/ip4_config.c; -- common = net/efi/ip6_config.c; -- common = net/efi/dhcp.c; - enable = efi; - }; - diff --git a/0225-malloc-Use-overflow-checking-primitives-where-we-do-.patch b/0225-malloc-Use-overflow-checking-primitives-where-we-do-.patch new file mode 100644 index 0000000000000000000000000000000000000000..3f6f47f3eba87ff7b8fd6cbc331a3ed1658869de --- /dev/null +++ b/0225-malloc-Use-overflow-checking-primitives-where-we-do-.patch @@ -0,0 +1,1322 @@ +From 3f05d693d1274965ffbe4ba99080dc2c570944c6 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 15 Jun 2020 12:28:27 -0400 +Subject: [PATCH 05/27] malloc: Use overflow checking primitives where we do + complex allocations + +This attempts to fix the places where we do the following where +arithmetic_expr may include unvalidated data: + + X = grub_malloc(arithmetic_expr); + +It accomplishes this by doing the arithmetic ahead of time using grub_add(), +grub_sub(), grub_mul() and testing for overflow before proceeding. + +Among other issues, this fixes: + - allocation of integer overflow in grub_video_bitmap_create() + reported by Chris Coulson, + - allocation of integer overflow in grub_png_decode_image_header() + reported by Chris Coulson, + - allocation of integer overflow in grub_squash_read_symlink() + reported by Chris Coulson, + - allocation of integer overflow in grub_ext2_read_symlink() + reported by Chris Coulson, + - allocation of integer overflow in read_section_as_string() + reported by Chris Coulson. + +Fixes: CVE-2020-14309, CVE-2020-14310, CVE-2020-14311 + +Signed-off-by: Peter Jones +Reviewed-by: Daniel Kiper +--- + grub-core/commands/legacycfg.c | 29 +++++++++++++++---- + grub-core/commands/wildcard.c | 36 ++++++++++++++++++++---- + grub-core/disk/ldm.c | 32 +++++++++++++++------ + grub-core/font/font.c | 7 ++++- + grub-core/fs/btrfs.c | 28 +++++++++++++------ + grub-core/fs/ext2.c | 10 ++++++- + grub-core/fs/iso9660.c | 51 ++++++++++++++++++++++++---------- + grub-core/fs/sfs.c | 27 ++++++++++++++---- + grub-core/fs/squash4.c | 45 ++++++++++++++++++++++-------- + grub-core/fs/udf.c | 41 +++++++++++++++++---------- + grub-core/fs/xfs.c | 11 +++++--- + grub-core/fs/zfs/zfs.c | 22 ++++++++++----- + grub-core/fs/zfs/zfscrypt.c | 7 ++++- + grub-core/lib/arg.c | 20 +++++++++++-- + grub-core/loader/i386/bsd.c | 8 +++++- + grub-core/net/dns.c | 9 +++++- + grub-core/normal/charset.c | 10 +++++-- + grub-core/normal/cmdline.c | 14 ++++++++-- + grub-core/normal/menu_entry.c | 13 +++++++-- + grub-core/script/argv.c | 16 +++++++++-- + grub-core/script/lexer.c | 21 ++++++++++++-- + grub-core/video/bitmap.c | 25 +++++++++++------ + grub-core/video/readers/png.c | 13 +++++++-- + 23 files changed, 382 insertions(+), 113 deletions(-) + +diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c +index da5143d..782761c 100644 +--- a/grub-core/commands/legacycfg.c ++++ b/grub-core/commands/legacycfg.c +@@ -32,6 +32,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -104,13 +105,22 @@ legacy_file (const char *filename) + if (newsuffix) + { + char *t; +- ++ grub_size_t sz; ++ ++ if (grub_add (grub_strlen (suffix), grub_strlen (newsuffix), &sz) || ++ grub_add (sz, 1, &sz)) ++ { ++ grub_errno = GRUB_ERR_OUT_OF_RANGE; ++ goto fail_0; ++ } ++ + t = suffix; +- suffix = grub_realloc (suffix, grub_strlen (suffix) +- + grub_strlen (newsuffix) + 1); ++ suffix = grub_realloc (suffix, sz); + if (!suffix) + { + grub_free (t); ++ ++ fail_0: + grub_free (entrysrc); + grub_free (parsed); + grub_free (newsuffix); +@@ -154,13 +164,22 @@ legacy_file (const char *filename) + else + { + char *t; ++ grub_size_t sz; ++ ++ if (grub_add (grub_strlen (entrysrc), grub_strlen (parsed), &sz) || ++ grub_add (sz, 1, &sz)) ++ { ++ grub_errno = GRUB_ERR_OUT_OF_RANGE; ++ goto fail_1; ++ } + + t = entrysrc; +- entrysrc = grub_realloc (entrysrc, grub_strlen (entrysrc) +- + grub_strlen (parsed) + 1); ++ entrysrc = grub_realloc (entrysrc, sz); + if (!entrysrc) + { + grub_free (t); ++ ++ fail_1: + grub_free (parsed); + grub_free (suffix); + return grub_errno; +diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c +index 560d437..8f67a4b 100644 +--- a/grub-core/commands/wildcard.c ++++ b/grub-core/commands/wildcard.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + + #include + +@@ -48,6 +49,7 @@ merge (char **dest, char **ps) + int i; + int j; + char **p; ++ grub_size_t sz; + + if (! dest) + return ps; +@@ -60,7 +62,12 @@ merge (char **dest, char **ps) + for (j = 0; ps[j]; j++) + ; + +- p = grub_realloc (dest, sizeof (char*) * (i + j + 1)); ++ if (grub_add (i, j, &sz) || ++ grub_add (sz, 1, &sz) || ++ grub_mul (sz, sizeof (char *), &sz)) ++ return dest; ++ ++ p = grub_realloc (dest, sz); + if (! p) + { + grub_free (dest); +@@ -115,8 +122,15 @@ make_regex (const char *start, const char *end, regex_t *regexp) + char ch; + int i = 0; + unsigned len = end - start; +- char *buffer = grub_malloc (len * 2 + 2 + 1); /* worst case size. */ ++ char *buffer; ++ grub_size_t sz; + ++ /* Worst case size is (len * 2 + 2 + 1). */ ++ if (grub_mul (len, 2, &sz) || ++ grub_add (sz, 3, &sz)) ++ return 1; ++ ++ buffer = grub_malloc (sz); + if (! buffer) + return 1; + +@@ -226,6 +240,7 @@ match_devices_iter (const char *name, void *data) + struct match_devices_ctx *ctx = data; + char **t; + char *buffer; ++ grub_size_t sz; + + /* skip partitions if asked to. */ + if (ctx->noparts && grub_strchr (name, ',')) +@@ -239,11 +254,16 @@ match_devices_iter (const char *name, void *data) + if (regexec (ctx->regexp, buffer, 0, 0, 0)) + { + grub_dprintf ("expand", "not matched\n"); ++ fail: + grub_free (buffer); + return 0; + } + +- t = grub_realloc (ctx->devs, sizeof (char*) * (ctx->ndev + 2)); ++ if (grub_add (ctx->ndev, 2, &sz) || ++ grub_mul (sz, sizeof (char *), &sz)) ++ goto fail; ++ ++ t = grub_realloc (ctx->devs, sz); + if (! t) + { + grub_free (buffer); +@@ -300,6 +320,7 @@ match_files_iter (const char *name, + struct match_files_ctx *ctx = data; + char **t; + char *buffer; ++ grub_size_t sz; + + /* skip . and .. names */ + if (grub_strcmp(".", name) == 0 || grub_strcmp("..", name) == 0) +@@ -315,9 +336,14 @@ match_files_iter (const char *name, + if (! buffer) + return 1; + +- t = grub_realloc (ctx->files, sizeof (char*) * (ctx->nfile + 2)); +- if (! t) ++ if (grub_add (ctx->nfile, 2, &sz) || ++ grub_mul (sz, sizeof (char *), &sz)) ++ goto fail; ++ ++ t = grub_realloc (ctx->files, sz); ++ if (!t) + { ++ fail: + grub_free (buffer); + return 1; + } +diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c +index e632370..58f8a53 100644 +--- a/grub-core/disk/ldm.c ++++ b/grub-core/disk/ldm.c +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + + #ifdef GRUB_UTIL + #include +@@ -289,6 +290,7 @@ make_vg (grub_disk_t disk, + struct grub_ldm_vblk vblk[GRUB_DISK_SECTOR_SIZE + / sizeof (struct grub_ldm_vblk)]; + unsigned i; ++ grub_size_t sz; + err = grub_disk_read (disk, cursec, 0, + sizeof(vblk), &vblk); + if (err) +@@ -350,7 +352,13 @@ make_vg (grub_disk_t disk, + grub_free (lv); + goto fail2; + } +- lv->name = grub_malloc (*ptr + 1); ++ if (grub_add (*ptr, 1, &sz)) ++ { ++ grub_free (lv->internal_id); ++ grub_free (lv); ++ goto fail2; ++ } ++ lv->name = grub_malloc (sz); + if (!lv->name) + { + grub_free (lv->internal_id); +@@ -599,10 +607,13 @@ make_vg (grub_disk_t disk, + if (lv->segments->node_alloc == lv->segments->node_count) + { + void *t; +- lv->segments->node_alloc *= 2; +- t = grub_realloc (lv->segments->nodes, +- sizeof (*lv->segments->nodes) +- * lv->segments->node_alloc); ++ grub_size_t sz; ++ ++ if (grub_mul (lv->segments->node_alloc, 2, &lv->segments->node_alloc) || ++ grub_mul (lv->segments->node_alloc, sizeof (*lv->segments->nodes), &sz)) ++ goto fail2; ++ ++ t = grub_realloc (lv->segments->nodes, sz); + if (!t) + goto fail2; + lv->segments->nodes = t; +@@ -723,10 +734,13 @@ make_vg (grub_disk_t disk, + if (comp->segment_alloc == comp->segment_count) + { + void *t; +- comp->segment_alloc *= 2; +- t = grub_realloc (comp->segments, +- comp->segment_alloc +- * sizeof (*comp->segments)); ++ grub_size_t sz; ++ ++ if (grub_mul (comp->segment_alloc, 2, &comp->segment_alloc) || ++ grub_mul (comp->segment_alloc, sizeof (*comp->segments), &sz)) ++ goto fail2; ++ ++ t = grub_realloc (comp->segments, sz); + if (!t) + goto fail2; + comp->segments = t; +diff --git a/grub-core/font/font.c b/grub-core/font/font.c +index 8e118b3..5edb477 100644 +--- a/grub-core/font/font.c ++++ b/grub-core/font/font.c +@@ -30,6 +30,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -360,9 +361,13 @@ static char * + read_section_as_string (struct font_file_section *section) + { + char *str; ++ grub_size_t sz; + grub_ssize_t ret; + +- str = grub_malloc (section->length + 1); ++ if (grub_add (section->length, 1, &sz)) ++ return NULL; ++ ++ str = grub_malloc (sz); + if (!str) + return 0; + +diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c +index ba080fd..0d8c666 100644 +--- a/grub-core/fs/btrfs.c ++++ b/grub-core/fs/btrfs.c +@@ -44,6 +44,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -358,9 +359,13 @@ save_ref (struct grub_btrfs_leaf_descriptor *desc, + if (desc->allocated < desc->depth) + { + void *newdata; +- desc->allocated *= 2; +- newdata = grub_realloc (desc->data, sizeof (desc->data[0]) +- * desc->allocated); ++ grub_size_t sz; ++ ++ if (grub_mul (desc->allocated, 2, &desc->allocated) || ++ grub_mul (desc->allocated, sizeof (desc->data[0]), &sz)) ++ return GRUB_ERR_OUT_OF_RANGE; ++ ++ newdata = grub_realloc (desc->data, sz); + if (!newdata) + return grub_errno; + desc->data = newdata; +@@ -651,16 +656,21 @@ find_device (struct grub_btrfs_data *data, grub_uint64_t id) + if (data->n_devices_attached > data->n_devices_allocated) + { + void *tmp; +- data->n_devices_allocated = 2 * data->n_devices_attached + 1; +- data->devices_attached +- = grub_realloc (tmp = data->devices_attached, +- data->n_devices_allocated +- * sizeof (data->devices_attached[0])); ++ grub_size_t sz; ++ ++ if (grub_mul (data->n_devices_attached, 2, &data->n_devices_allocated) || ++ grub_add (data->n_devices_allocated, 1, &data->n_devices_allocated) || ++ grub_mul (data->n_devices_allocated, sizeof (data->devices_attached[0]), &sz)) ++ goto fail; ++ ++ data->devices_attached = grub_realloc (tmp = data->devices_attached, sz); + if (!data->devices_attached) + { ++ data->devices_attached = tmp; ++ ++ fail: + if (ctx.dev_found) + grub_device_close (ctx.dev_found); +- data->devices_attached = tmp; + return NULL; + } + } +diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c +index 9b38980..ac33bcd 100644 +--- a/grub-core/fs/ext2.c ++++ b/grub-core/fs/ext2.c +@@ -46,6 +46,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -703,6 +704,7 @@ grub_ext2_read_symlink (grub_fshelp_node_t node) + { + char *symlink; + struct grub_fshelp_node *diro = node; ++ grub_size_t sz; + + if (! diro->inode_read) + { +@@ -717,7 +719,13 @@ grub_ext2_read_symlink (grub_fshelp_node_t node) + } + } + +- symlink = grub_malloc (grub_le_to_cpu32 (diro->inode.size) + 1); ++ if (grub_add (grub_le_to_cpu32 (diro->inode.size), 1, &sz)) ++ { ++ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); ++ return NULL; ++ } ++ ++ symlink = grub_malloc (sz); + if (! symlink) + return 0; + +diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c +index 4f1b52a..7ba5b30 100644 +--- a/grub-core/fs/iso9660.c ++++ b/grub-core/fs/iso9660.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -531,8 +532,13 @@ add_part (struct iterate_dir_ctx *ctx, + int len2) + { + int size = ctx->symlink ? grub_strlen (ctx->symlink) : 0; ++ grub_size_t sz; + +- ctx->symlink = grub_realloc (ctx->symlink, size + len2 + 1); ++ if (grub_add (size, len2, &sz) || ++ grub_add (sz, 1, &sz)) ++ return; ++ ++ ctx->symlink = grub_realloc (ctx->symlink, sz); + if (! ctx->symlink) + return; + +@@ -560,17 +566,24 @@ susp_iterate_dir (struct grub_iso9660_susp_entry *entry, + { + grub_size_t off = 0, csize = 1; + char *old; ++ grub_size_t sz; ++ + csize = entry->len - 5; + old = ctx->filename; + if (ctx->filename_alloc) + { + off = grub_strlen (ctx->filename); +- ctx->filename = grub_realloc (ctx->filename, csize + off + 1); ++ if (grub_add (csize, off, &sz) || ++ grub_add (sz, 1, &sz)) ++ return GRUB_ERR_OUT_OF_RANGE; ++ ctx->filename = grub_realloc (ctx->filename, sz); + } + else + { + off = 0; +- ctx->filename = grub_zalloc (csize + 1); ++ if (grub_add (csize, 1, &sz)) ++ return GRUB_ERR_OUT_OF_RANGE; ++ ctx->filename = grub_zalloc (sz); + } + if (!ctx->filename) + { +@@ -776,14 +789,18 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir, + if (node->have_dirents >= node->alloc_dirents) + { + struct grub_fshelp_node *new_node; +- node->alloc_dirents *= 2; +- new_node = grub_realloc (node, +- sizeof (struct grub_fshelp_node) +- + ((node->alloc_dirents +- - ARRAY_SIZE (node->dirents)) +- * sizeof (node->dirents[0]))); ++ grub_size_t sz; ++ ++ if (grub_mul (node->alloc_dirents, 2, &node->alloc_dirents) || ++ grub_sub (node->alloc_dirents, ARRAY_SIZE (node->dirents), &sz) || ++ grub_mul (sz, sizeof (node->dirents[0]), &sz) || ++ grub_add (sz, sizeof (struct grub_fshelp_node), &sz)) ++ goto fail_0; ++ ++ new_node = grub_realloc (node, sz); + if (!new_node) + { ++ fail_0: + if (ctx.filename_alloc) + grub_free (ctx.filename); + grub_free (node); +@@ -799,14 +816,18 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir, + * sizeof (node->dirents[0]) < grub_strlen (ctx.symlink) + 1) + { + struct grub_fshelp_node *new_node; +- new_node = grub_realloc (node, +- sizeof (struct grub_fshelp_node) +- + ((node->alloc_dirents +- - ARRAY_SIZE (node->dirents)) +- * sizeof (node->dirents[0])) +- + grub_strlen (ctx.symlink) + 1); ++ grub_size_t sz; ++ ++ if (grub_sub (node->alloc_dirents, ARRAY_SIZE (node->dirents), &sz) || ++ grub_mul (sz, sizeof (node->dirents[0]), &sz) || ++ grub_add (sz, sizeof (struct grub_fshelp_node) + 1, &sz) || ++ grub_add (sz, grub_strlen (ctx.symlink), &sz)) ++ goto fail_1; ++ ++ new_node = grub_realloc (node, sz); + if (!new_node) + { ++ fail_1: + if (ctx.filename_alloc) + grub_free (ctx.filename); + grub_free (node); +diff --git a/grub-core/fs/sfs.c b/grub-core/fs/sfs.c +index 90f7fb3..de2b107 100644 +--- a/grub-core/fs/sfs.c ++++ b/grub-core/fs/sfs.c +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -307,10 +308,15 @@ grub_sfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) + if (node->cache && node->cache_size >= node->cache_allocated) + { + struct cache_entry *e = node->cache; +- e = grub_realloc (node->cache,node->cache_allocated * 2 +- * sizeof (e[0])); ++ grub_size_t sz; ++ ++ if (grub_mul (node->cache_allocated, 2 * sizeof (e[0]), &sz)) ++ goto fail; ++ ++ e = grub_realloc (node->cache, sz); + if (!e) + { ++ fail: + grub_errno = 0; + grub_free (node->cache); + node->cache = 0; +@@ -477,10 +483,16 @@ grub_sfs_create_node (struct grub_fshelp_node **node, + grub_size_t len = grub_strlen (name); + grub_uint8_t *name_u8; + int ret; ++ grub_size_t sz; ++ ++ if (grub_mul (len, GRUB_MAX_UTF8_PER_LATIN1, &sz) || ++ grub_add (sz, 1, &sz)) ++ return 1; ++ + *node = grub_malloc (sizeof (**node)); + if (!*node) + return 1; +- name_u8 = grub_malloc (len * GRUB_MAX_UTF8_PER_LATIN1 + 1); ++ name_u8 = grub_malloc (sz); + if (!name_u8) + { + grub_free (*node); +@@ -724,8 +736,13 @@ grub_sfs_label (grub_device_t device, char **label) + data = grub_sfs_mount (disk); + if (data) + { +- grub_size_t len = grub_strlen (data->label); +- *label = grub_malloc (len * GRUB_MAX_UTF8_PER_LATIN1 + 1); ++ grub_size_t sz, len = grub_strlen (data->label); ++ ++ if (grub_mul (len, GRUB_MAX_UTF8_PER_LATIN1, &sz) || ++ grub_add (sz, 1, &sz)) ++ return GRUB_ERR_OUT_OF_RANGE; ++ ++ *label = grub_malloc (sz); + if (*label) + *grub_latin1_to_utf8 ((grub_uint8_t *) *label, + (const grub_uint8_t *) data->label, +diff --git a/grub-core/fs/squash4.c b/grub-core/fs/squash4.c +index 95d5c1e..7851238 100644 +--- a/grub-core/fs/squash4.c ++++ b/grub-core/fs/squash4.c +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + #include + + #include "xz.h" +@@ -459,7 +460,17 @@ grub_squash_read_symlink (grub_fshelp_node_t node) + { + char *ret; + grub_err_t err; +- ret = grub_malloc (grub_le_to_cpu32 (node->ino.symlink.namelen) + 1); ++ grub_size_t sz; ++ ++ if (grub_add (grub_le_to_cpu32 (node->ino.symlink.namelen), 1, &sz)) ++ { ++ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); ++ return NULL; ++ } ++ ++ ret = grub_malloc (sz); ++ if (!ret) ++ return NULL; + + err = read_chunk (node->data, ret, + grub_le_to_cpu32 (node->ino.symlink.namelen), +@@ -506,11 +517,16 @@ grub_squash_iterate_dir (grub_fshelp_node_t dir, + + { + grub_fshelp_node_t node; +- node = grub_malloc (sizeof (*node) + dir->stsize * sizeof (dir->stack[0])); ++ grub_size_t sz; ++ ++ if (grub_mul (dir->stsize, sizeof (dir->stack[0]), &sz) || ++ grub_add (sz, sizeof (*node), &sz)) ++ return 0; ++ ++ node = grub_malloc (sz); + if (!node) + return 0; +- grub_memcpy (node, dir, +- sizeof (*node) + dir->stsize * sizeof (dir->stack[0])); ++ grub_memcpy (node, dir, sz); + if (hook (".", GRUB_FSHELP_DIR, node, hook_data)) + return 1; + +@@ -518,12 +534,15 @@ grub_squash_iterate_dir (grub_fshelp_node_t dir, + { + grub_err_t err; + +- node = grub_malloc (sizeof (*node) + dir->stsize * sizeof (dir->stack[0])); ++ if (grub_mul (dir->stsize, sizeof (dir->stack[0]), &sz) || ++ grub_add (sz, sizeof (*node), &sz)) ++ return 0; ++ ++ node = grub_malloc (sz); + if (!node) + return 0; + +- grub_memcpy (node, dir, +- sizeof (*node) + dir->stsize * sizeof (dir->stack[0])); ++ grub_memcpy (node, dir, sz); + + node->stsize--; + err = read_chunk (dir->data, &node->ino, sizeof (node->ino), +@@ -557,6 +576,7 @@ grub_squash_iterate_dir (grub_fshelp_node_t dir, + enum grub_fshelp_filetype filetype = GRUB_FSHELP_REG; + struct grub_squash_dirent di; + struct grub_squash_inode ino; ++ grub_size_t sz; + + err = read_chunk (dir->data, &di, sizeof (di), + grub_le_to_cpu64 (dir->data->sb.diroffset) +@@ -589,13 +609,16 @@ grub_squash_iterate_dir (grub_fshelp_node_t dir, + if (grub_le_to_cpu16 (di.type) == SQUASH_TYPE_SYMLINK) + filetype = GRUB_FSHELP_SYMLINK; + +- node = grub_malloc (sizeof (*node) +- + (dir->stsize + 1) * sizeof (dir->stack[0])); ++ if (grub_add (dir->stsize, 1, &sz) || ++ grub_mul (sz, sizeof (dir->stack[0]), &sz) || ++ grub_add (sz, sizeof (*node), &sz)) ++ return 0; ++ ++ node = grub_malloc (sz); + if (! node) + return 0; + +- grub_memcpy (node, dir, +- sizeof (*node) + dir->stsize * sizeof (dir->stack[0])); ++ grub_memcpy (node, dir, sz - sizeof(dir->stack[0])); + + node->ino = ino; + node->stack[node->stsize].ino_chunk = grub_le_to_cpu32 (dh.ino_chunk); +diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c +index a837616..21ac7f4 100644 +--- a/grub-core/fs/udf.c ++++ b/grub-core/fs/udf.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -890,9 +891,19 @@ read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf) + utf16[i] = (raw[2 * i + 1] << 8) | raw[2*i + 2]; + } + if (!outbuf) +- outbuf = grub_malloc (utf16len * GRUB_MAX_UTF8_PER_UTF16 + 1); ++ { ++ grub_size_t size; ++ ++ if (grub_mul (utf16len, GRUB_MAX_UTF8_PER_UTF16, &size) || ++ grub_add (size, 1, &size)) ++ goto fail; ++ ++ outbuf = grub_malloc (size); ++ } + if (outbuf) + *grub_utf16_to_utf8 ((grub_uint8_t *) outbuf, utf16, utf16len) = '\0'; ++ ++ fail: + grub_free (utf16); + return outbuf; + } +@@ -1005,7 +1016,7 @@ grub_udf_read_symlink (grub_fshelp_node_t node) + grub_size_t sz = U64 (node->block.fe.file_size); + grub_uint8_t *raw; + const grub_uint8_t *ptr; +- char *out, *optr; ++ char *out = NULL, *optr; + + if (sz < 4) + return NULL; +@@ -1013,14 +1024,16 @@ grub_udf_read_symlink (grub_fshelp_node_t node) + if (!raw) + return NULL; + if (grub_udf_read_file (node, NULL, NULL, 0, sz, (char *) raw) < 0) +- { +- grub_free (raw); +- return NULL; +- } ++ goto fail_1; + +- out = grub_malloc (sz * 2 + 1); ++ if (grub_mul (sz, 2, &sz) || ++ grub_add (sz, 1, &sz)) ++ goto fail_0; ++ ++ out = grub_malloc (sz); + if (!out) + { ++ fail_0: + grub_free (raw); + return NULL; + } +@@ -1031,17 +1044,17 @@ grub_udf_read_symlink (grub_fshelp_node_t node) + { + grub_size_t s; + if ((grub_size_t) (ptr - raw + 4) > sz) +- goto fail; ++ goto fail_1; + if (!(ptr[2] == 0 && ptr[3] == 0)) +- goto fail; ++ goto fail_1; + s = 4 + ptr[1]; + if ((grub_size_t) (ptr - raw + s) > sz) +- goto fail; ++ goto fail_1; + switch (*ptr) + { + case 1: + if (ptr[1]) +- goto fail; ++ goto fail_1; + /* Fallthrough. */ + case 2: + /* in 4 bytes. out: 1 byte. */ +@@ -1066,11 +1079,11 @@ grub_udf_read_symlink (grub_fshelp_node_t node) + if (optr != out) + *optr++ = '/'; + if (!read_string (ptr + 4, s - 4, optr)) +- goto fail; ++ goto fail_1; + optr += grub_strlen (optr); + break; + default: +- goto fail; ++ goto fail_1; + } + ptr += s; + } +@@ -1078,7 +1091,7 @@ grub_udf_read_symlink (grub_fshelp_node_t node) + grub_free (raw); + return out; + +- fail: ++ fail_1: + grub_free (raw); + grub_free (out); + grub_error (GRUB_ERR_BAD_FS, "invalid symlink"); +diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c +index 96ffecb..ea65902 100644 +--- a/grub-core/fs/xfs.c ++++ b/grub-core/fs/xfs.c +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -899,6 +900,7 @@ static struct grub_xfs_data * + grub_xfs_mount (grub_disk_t disk) + { + struct grub_xfs_data *data = 0; ++ grub_size_t sz; + + data = grub_zalloc (sizeof (struct grub_xfs_data)); + if (!data) +@@ -913,10 +915,11 @@ grub_xfs_mount (grub_disk_t disk) + if (!grub_xfs_sb_valid(data)) + goto fail; + +- data = grub_realloc (data, +- sizeof (struct grub_xfs_data) +- - sizeof (struct grub_xfs_inode) +- + grub_xfs_inode_size(data) + 1); ++ if (grub_add (grub_xfs_inode_size (data), ++ sizeof (struct grub_xfs_data) - sizeof (struct grub_xfs_inode) + 1, &sz)) ++ goto fail; ++ ++ data = grub_realloc (data, sz); + + if (! data) + goto fail; +diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c +index 381dde5..36d0373 100644 +--- a/grub-core/fs/zfs/zfs.c ++++ b/grub-core/fs/zfs/zfs.c +@@ -55,6 +55,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -773,11 +774,14 @@ fill_vdev_info (struct grub_zfs_data *data, + if (data->n_devices_attached > data->n_devices_allocated) + { + void *tmp; +- data->n_devices_allocated = 2 * data->n_devices_attached + 1; +- data->devices_attached +- = grub_realloc (tmp = data->devices_attached, +- data->n_devices_allocated +- * sizeof (data->devices_attached[0])); ++ grub_size_t sz; ++ ++ if (grub_mul (data->n_devices_attached, 2, &data->n_devices_allocated) || ++ grub_add (data->n_devices_allocated, 1, &data->n_devices_allocated) || ++ grub_mul (data->n_devices_allocated, sizeof (data->devices_attached[0]), &sz)) ++ return GRUB_ERR_OUT_OF_RANGE; ++ ++ data->devices_attached = grub_realloc (tmp = data->devices_attached, sz); + if (!data->devices_attached) + { + data->devices_attached = tmp; +@@ -3468,14 +3472,18 @@ grub_zfs_nvlist_lookup_nvlist (const char *nvlist, const char *name) + { + char *nvpair; + char *ret; +- grub_size_t size; ++ grub_size_t size, sz; + int found; + + found = nvlist_find_value (nvlist, name, DATA_TYPE_NVLIST, &nvpair, + &size, 0); + if (!found) + return 0; +- ret = grub_zalloc (size + 3 * sizeof (grub_uint32_t)); ++ ++ if (grub_add (size, 3 * sizeof (grub_uint32_t), &sz)) ++ return 0; ++ ++ ret = grub_zalloc (sz); + if (!ret) + return 0; + grub_memcpy (ret, nvlist, sizeof (grub_uint32_t)); +diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c +index 1402e0b..de3b015 100644 +--- a/grub-core/fs/zfs/zfscrypt.c ++++ b/grub-core/fs/zfs/zfscrypt.c +@@ -22,6 +22,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -82,9 +83,13 @@ grub_zfs_add_key (grub_uint8_t *key_in, + int passphrase) + { + struct grub_zfs_wrap_key *key; ++ grub_size_t sz; ++ + if (!passphrase && keylen > 32) + keylen = 32; +- key = grub_malloc (sizeof (*key) + keylen); ++ if (grub_add (sizeof (*key), keylen, &sz)) ++ return GRUB_ERR_OUT_OF_RANGE; ++ key = grub_malloc (sz); + if (!key) + return grub_errno; + key->is_passphrase = passphrase; +diff --git a/grub-core/lib/arg.c b/grub-core/lib/arg.c +index ccc1850..8439a00 100644 +--- a/grub-core/lib/arg.c ++++ b/grub-core/lib/arg.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + + /* Built-in parser for default options. */ + static const struct grub_arg_option help_options[] = +@@ -216,7 +217,13 @@ static inline grub_err_t + add_arg (char ***argl, int *num, char *s) + { + char **p = *argl; +- *argl = grub_realloc (*argl, (++(*num) + 1) * sizeof (char *)); ++ grub_size_t sz; ++ ++ if (grub_add (++(*num), 1, &sz) || ++ grub_mul (sz, sizeof (char *), &sz)) ++ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); ++ ++ *argl = grub_realloc (*argl, sz); + if (! *argl) + { + grub_free (p); +@@ -431,6 +438,7 @@ grub_arg_list_alloc(grub_extcmd_t extcmd, int argc, + grub_size_t argcnt; + struct grub_arg_list *list; + const struct grub_arg_option *options; ++ grub_size_t sz0, sz1; + + options = extcmd->options; + if (! options) +@@ -443,7 +451,15 @@ grub_arg_list_alloc(grub_extcmd_t extcmd, int argc, + argcnt += ((grub_size_t) argc + 1) / 2 + 1; /* max possible for any option */ + } + +- list = grub_zalloc (sizeof (*list) * i + sizeof (char*) * argcnt); ++ if (grub_mul (sizeof (*list), i, &sz0) || ++ grub_mul (sizeof (char *), argcnt, &sz1) || ++ grub_add (sz0, sz1, &sz0)) ++ { ++ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); ++ return 0; ++ } ++ ++ list = grub_zalloc (sz0); + if (! list) + return 0; + +diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c +index 50cca30..ff98fb7 100644 +--- a/grub-core/loader/i386/bsd.c ++++ b/grub-core/loader/i386/bsd.c +@@ -35,6 +35,7 @@ + #include + #include + #include ++#include + #include + #ifdef GRUB_MACHINE_PCBIOS + #include +@@ -1013,11 +1014,16 @@ grub_netbsd_add_modules (void) + struct grub_netbsd_btinfo_modules *mods; + unsigned i; + grub_err_t err; ++ grub_size_t sz; + + for (mod = netbsd_mods; mod; mod = mod->next) + modcnt++; + +- mods = grub_malloc (sizeof (*mods) + sizeof (mods->mods[0]) * modcnt); ++ if (grub_mul (modcnt, sizeof (mods->mods[0]), &sz) || ++ grub_add (sz, sizeof (*mods), &sz)) ++ return GRUB_ERR_OUT_OF_RANGE; ++ ++ mods = grub_malloc (sz); + if (!mods) + return grub_errno; + +diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c +index e332d5e..906ec7d 100644 +--- a/grub-core/net/dns.c ++++ b/grub-core/net/dns.c +@@ -22,6 +22,7 @@ + #include + #include + #include ++#include + + struct dns_cache_element + { +@@ -51,9 +52,15 @@ grub_net_add_dns_server (const struct grub_net_network_level_address *s) + { + int na = dns_servers_alloc * 2; + struct grub_net_network_level_address *ns; ++ grub_size_t sz; ++ + if (na < 8) + na = 8; +- ns = grub_realloc (dns_servers, na * sizeof (ns[0])); ++ ++ if (grub_mul (na, sizeof (ns[0]), &sz)) ++ return GRUB_ERR_OUT_OF_RANGE; ++ ++ ns = grub_realloc (dns_servers, sz); + if (!ns) + return grub_errno; + dns_servers_alloc = na; +diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c +index d57fb72..4dfcc31 100644 +--- a/grub-core/normal/charset.c ++++ b/grub-core/normal/charset.c +@@ -48,6 +48,7 @@ + #include + #include + #include ++#include + + #if HAVE_FONT_SOURCE + #include "widthspec.h" +@@ -464,6 +465,7 @@ grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen, + { + struct grub_unicode_combining *n; + unsigned j; ++ grub_size_t sz; + + if (!haveout) + continue; +@@ -477,10 +479,14 @@ grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen, + n = out->combining_inline; + else if (out->ncomb > (int) ARRAY_SIZE (out->combining_inline)) + { +- n = grub_realloc (out->combining_ptr, +- sizeof (n[0]) * (out->ncomb + 1)); ++ if (grub_add (out->ncomb, 1, &sz) || ++ grub_mul (sz, sizeof (n[0]), &sz)) ++ goto fail; ++ ++ n = grub_realloc (out->combining_ptr, sz); + if (!n) + { ++ fail: + grub_errno = GRUB_ERR_NONE; + continue; + } +diff --git a/grub-core/normal/cmdline.c b/grub-core/normal/cmdline.c +index c57242e..de03fe6 100644 +--- a/grub-core/normal/cmdline.c ++++ b/grub-core/normal/cmdline.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + + static grub_uint32_t *kill_buf; + +@@ -307,12 +308,21 @@ cl_insert (struct cmdline_term *cl_terms, unsigned nterms, + if (len + (*llen) >= (*max_len)) + { + grub_uint32_t *nbuf; +- (*max_len) *= 2; +- nbuf = grub_realloc ((*buf), sizeof (grub_uint32_t) * (*max_len)); ++ grub_size_t sz; ++ ++ if (grub_mul (*max_len, 2, max_len) || ++ grub_mul (*max_len, sizeof (grub_uint32_t), &sz)) ++ { ++ grub_errno = GRUB_ERR_OUT_OF_RANGE; ++ goto fail; ++ } ++ ++ nbuf = grub_realloc ((*buf), sz); + if (nbuf) + (*buf) = nbuf; + else + { ++ fail: + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + (*max_len) /= 2; +diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c +index f31487c..de64a36 100644 +--- a/grub-core/normal/menu_entry.c ++++ b/grub-core/normal/menu_entry.c +@@ -27,6 +27,7 @@ + #include + #include + #include ++#include + + enum update_mode + { +@@ -113,10 +114,18 @@ ensure_space (struct line *linep, int extra) + { + if (linep->max_len < linep->len + extra) + { +- linep->max_len = 2 * (linep->len + extra); +- linep->buf = grub_realloc (linep->buf, (linep->max_len + 1) * sizeof (linep->buf[0])); ++ grub_size_t sz0, sz1; ++ ++ if (grub_add (linep->len, extra, &sz0) || ++ grub_mul (sz0, 2, &sz0) || ++ grub_add (sz0, 1, &sz1) || ++ grub_mul (sz1, sizeof (linep->buf[0]), &sz1)) ++ return 0; ++ ++ linep->buf = grub_realloc (linep->buf, sz1); + if (! linep->buf) + return 0; ++ linep->max_len = sz0; + } + + return 1; +diff --git a/grub-core/script/argv.c b/grub-core/script/argv.c +index 217ec5d..5751fdd 100644 +--- a/grub-core/script/argv.c ++++ b/grub-core/script/argv.c +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + + /* Return nearest power of two that is >= v. */ + static unsigned +@@ -81,11 +82,16 @@ int + grub_script_argv_next (struct grub_script_argv *argv) + { + char **p = argv->args; ++ grub_size_t sz; + + if (argv->args && argv->argc && argv->args[argv->argc - 1] == 0) + return 0; + +- p = grub_realloc (p, round_up_exp ((argv->argc + 2) * sizeof (char *))); ++ if (grub_add (argv->argc, 2, &sz) || ++ grub_mul (sz, sizeof (char *), &sz)) ++ return 1; ++ ++ p = grub_realloc (p, round_up_exp (sz)); + if (! p) + return 1; + +@@ -105,13 +111,19 @@ grub_script_argv_append (struct grub_script_argv *argv, const char *s, + { + grub_size_t a; + char *p = argv->args[argv->argc - 1]; ++ grub_size_t sz; + + if (! s) + return 0; + + a = p ? grub_strlen (p) : 0; + +- p = grub_realloc (p, round_up_exp ((a + slen + 1) * sizeof (char))); ++ if (grub_add (a, slen, &sz) || ++ grub_add (sz, 1, &sz) || ++ grub_mul (sz, sizeof (char), &sz)) ++ return 1; ++ ++ p = grub_realloc (p, round_up_exp (sz)); + if (! p) + return 1; + +diff --git a/grub-core/script/lexer.c b/grub-core/script/lexer.c +index c6bd317..5fb0cbd 100644 +--- a/grub-core/script/lexer.c ++++ b/grub-core/script/lexer.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + #define yytext_ptr char * + #include "grub_script.tab.h" +@@ -110,10 +111,14 @@ grub_script_lexer_record (struct grub_parser_param *parser, char *str) + old = lexer->recording; + if (lexer->recordlen < len) + lexer->recordlen = len; +- lexer->recordlen *= 2; ++ ++ if (grub_mul (lexer->recordlen, 2, &lexer->recordlen)) ++ goto fail; ++ + lexer->recording = grub_realloc (lexer->recording, lexer->recordlen); + if (!lexer->recording) + { ++ fail: + grub_free (old); + lexer->recordpos = 0; + lexer->recordlen = 0; +@@ -130,7 +135,7 @@ int + grub_script_lexer_yywrap (struct grub_parser_param *parserstate, + const char *input) + { +- grub_size_t len = 0; ++ grub_size_t len = 0, sz; + char *p = 0; + char *line = 0; + YY_BUFFER_STATE buffer; +@@ -168,12 +173,22 @@ grub_script_lexer_yywrap (struct grub_parser_param *parserstate, + } + else if (len && line[len - 1] != '\n') + { +- p = grub_realloc (line, len + 2); ++ if (grub_add (len, 2, &sz)) ++ { ++ grub_free (line); ++ grub_script_yyerror (parserstate, N_("overflow is detected")); ++ return 1; ++ } ++ ++ p = grub_realloc (line, sz); + if (p) + { + p[len++] = '\n'; + p[len] = '\0'; + } ++ else ++ grub_free (line); ++ + line = p; + } + +diff --git a/grub-core/video/bitmap.c b/grub-core/video/bitmap.c +index b2e0315..6256e20 100644 +--- a/grub-core/video/bitmap.c ++++ b/grub-core/video/bitmap.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -58,7 +59,7 @@ grub_video_bitmap_create (struct grub_video_bitmap **bitmap, + enum grub_video_blit_format blit_format) + { + struct grub_video_mode_info *mode_info; +- unsigned int size; ++ grub_size_t size; + + if (!bitmap) + return grub_error (GRUB_ERR_BUG, "invalid argument"); +@@ -137,19 +138,25 @@ grub_video_bitmap_create (struct grub_video_bitmap **bitmap, + + mode_info->pitch = width * mode_info->bytes_per_pixel; + +- /* Calculate size needed for the data. */ +- size = (width * mode_info->bytes_per_pixel) * height; ++ /* Calculate size needed for the data. */ ++ if (grub_mul (width, mode_info->bytes_per_pixel, &size) || ++ grub_mul (size, height, &size)) ++ { ++ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); ++ goto fail; ++ } + + (*bitmap)->data = grub_zalloc (size); + if (! (*bitmap)->data) +- { +- grub_free (*bitmap); +- *bitmap = 0; +- +- return grub_errno; +- } ++ goto fail; + + return GRUB_ERR_NONE; ++ ++ fail: ++ grub_free (*bitmap); ++ *bitmap = NULL; ++ ++ return grub_errno; + } + + /* Frees all resources allocated by bitmap. */ +diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c +index 61bd645..0157ff7 100644 +--- a/grub-core/video/readers/png.c ++++ b/grub-core/video/readers/png.c +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -301,9 +302,17 @@ grub_png_decode_image_header (struct grub_png_data *data) + data->bpp <<= 1; + + data->color_bits = color_bits; +- data->row_bytes = data->image_width * data->bpp; ++ ++ if (grub_mul (data->image_width, data->bpp, &data->row_bytes)) ++ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); ++ + if (data->color_bits <= 4) +- data->row_bytes = (data->image_width * data->color_bits + 7) / 8; ++ { ++ if (grub_mul (data->image_width, data->color_bits + 7, &data->row_bytes)) ++ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); ++ ++ data->row_bytes >>= 3; ++ } + + #ifndef GRUB_CPU_WORDS_BIGENDIAN + if (data->is_16bit || data->is_gray || data->is_palette) +-- +2.23.0 + diff --git a/0226-iso9660-Don-t-leak-memory-on-realloc-failures.patch b/0226-iso9660-Don-t-leak-memory-on-realloc-failures.patch new file mode 100644 index 0000000000000000000000000000000000000000..93dc15ec5b8404bf8be158c11828b59fbab58ef8 --- /dev/null +++ b/0226-iso9660-Don-t-leak-memory-on-realloc-failures.patch @@ -0,0 +1,68 @@ +From f14380cfa955a2fb502ba148d045f68ac1250f2d Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Sat, 4 Jul 2020 12:25:09 -0400 +Subject: [PATCH 06/27] iso9660: Don't leak memory on realloc() failures + +Signed-off-by: Peter Jones +Reviewed-by: Daniel Kiper +--- + grub-core/fs/iso9660.c | 24 ++++++++++++++++++++---- + 1 file changed, 20 insertions(+), 4 deletions(-) + +diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c +index 7ba5b30..5ec4433 100644 +--- a/grub-core/fs/iso9660.c ++++ b/grub-core/fs/iso9660.c +@@ -533,14 +533,20 @@ add_part (struct iterate_dir_ctx *ctx, + { + int size = ctx->symlink ? grub_strlen (ctx->symlink) : 0; + grub_size_t sz; ++ char *new; + + if (grub_add (size, len2, &sz) || + grub_add (sz, 1, &sz)) + return; + +- ctx->symlink = grub_realloc (ctx->symlink, sz); +- if (! ctx->symlink) +- return; ++ new = grub_realloc (ctx->symlink, sz); ++ if (!new) ++ { ++ grub_free (ctx->symlink); ++ ctx->symlink = NULL; ++ return; ++ } ++ ctx->symlink = new; + + grub_memcpy (ctx->symlink + size, part, len2); + ctx->symlink[size + len2] = 0; +@@ -634,7 +640,12 @@ susp_iterate_dir (struct grub_iso9660_susp_entry *entry, + is the length. Both are part of the `Component + Record'. */ + if (ctx->symlink && !ctx->was_continue) +- add_part (ctx, "/", 1); ++ { ++ add_part (ctx, "/", 1); ++ if (grub_errno) ++ return grub_errno; ++ } ++ + add_part (ctx, (char *) &entry->data[pos + 2], + entry->data[pos + 1]); + ctx->was_continue = (entry->data[pos] & 1); +@@ -653,6 +664,11 @@ susp_iterate_dir (struct grub_iso9660_susp_entry *entry, + add_part (ctx, "/", 1); + break; + } ++ ++ /* Check if grub_realloc() failed in add_part(). */ ++ if (grub_errno) ++ return grub_errno; ++ + /* In pos + 1 the length of the `Component Record' is + stored. */ + pos += entry->data[pos + 1] + 2; +-- +2.23.0 + diff --git a/0227-font-Do-not-load-more-than-one-NAME-section.patch b/0227-font-Do-not-load-more-than-one-NAME-section.patch new file mode 100644 index 0000000000000000000000000000000000000000..c80d43b5baf9b570d95c64c39dfc848c6bea57c3 --- /dev/null +++ b/0227-font-Do-not-load-more-than-one-NAME-section.patch @@ -0,0 +1,37 @@ +From 7c1e10c986d1c4b50146f03f58c1aece2aa0bdbe Mon Sep 17 00:00:00 2001 +From: Daniel Kiper +Date: Tue, 7 Jul 2020 15:36:26 +0200 +Subject: [PATCH 07/27] font: Do not load more than one NAME section + +The GRUB font file can have one NAME section only. Though if somebody +crafts a broken font file with many NAME sections and loads it then the +GRUB leaks memory. So, prevent against that by loading first NAME +section and failing in controlled way on following one. + +Reported-by: Chris Coulson +Signed-off-by: Daniel Kiper +Reviewed-by: Jan Setje-Eilers +--- + grub-core/font/font.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/grub-core/font/font.c b/grub-core/font/font.c +index 5edb477..d09bb38 100644 +--- a/grub-core/font/font.c ++++ b/grub-core/font/font.c +@@ -532,6 +532,12 @@ grub_font_load (const char *filename) + if (grub_memcmp (section.name, FONT_FORMAT_SECTION_NAMES_FONT_NAME, + sizeof (FONT_FORMAT_SECTION_NAMES_FONT_NAME) - 1) == 0) + { ++ if (font->name != NULL) ++ { ++ grub_error (GRUB_ERR_BAD_FONT, "invalid font file: too many NAME sections"); ++ goto fail; ++ } ++ + font->name = read_section_as_string (§ion); + if (!font->name) + goto fail; +-- +2.23.0 + diff --git a/0228-gfxmenu-Fix-double-free-in-load_image.patch b/0228-gfxmenu-Fix-double-free-in-load_image.patch new file mode 100644 index 0000000000000000000000000000000000000000..7170aca842ca83645f551938f76ecdd2aecd3a50 --- /dev/null +++ b/0228-gfxmenu-Fix-double-free-in-load_image.patch @@ -0,0 +1,35 @@ +From a2e9386cbca0aeb951badd992a1fc3634c348877 Mon Sep 17 00:00:00 2001 +From: Alexey Makhalov +Date: Wed, 8 Jul 2020 20:41:56 +0000 +Subject: [PATCH 08/27] gfxmenu: Fix double free in load_image() + +self->bitmap should be zeroed after free. Otherwise, there is a chance +to double free (USE_AFTER_FREE) it later in rescale_image(). + +Fixes: CID 292472 + +Signed-off-by: Alexey Makhalov +Reviewed-by: Daniel Kiper +--- + grub-core/gfxmenu/gui_image.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/grub-core/gfxmenu/gui_image.c b/grub-core/gfxmenu/gui_image.c +index 29784ed..6b2e976 100644 +--- a/grub-core/gfxmenu/gui_image.c ++++ b/grub-core/gfxmenu/gui_image.c +@@ -195,7 +195,10 @@ load_image (grub_gui_image_t self, const char *path) + return grub_errno; + + if (self->bitmap && (self->bitmap != self->raw_bitmap)) +- grub_video_bitmap_destroy (self->bitmap); ++ { ++ grub_video_bitmap_destroy (self->bitmap); ++ self->bitmap = 0; ++ } + if (self->raw_bitmap) + grub_video_bitmap_destroy (self->raw_bitmap); + +-- +2.23.0 + diff --git a/0229-xnu-Fix-double-free-in-grub_xnu_devprop_add_property.patch b/0229-xnu-Fix-double-free-in-grub_xnu_devprop_add_property.patch new file mode 100644 index 0000000000000000000000000000000000000000..6a80f6e326883645c90e78f60b437a0beb9cc1af --- /dev/null +++ b/0229-xnu-Fix-double-free-in-grub_xnu_devprop_add_property.patch @@ -0,0 +1,54 @@ +From d7bdee0e38c93b4c49281f5ca79d416bab6eb3ce Mon Sep 17 00:00:00 2001 +From: Alexey Makhalov +Date: Wed, 8 Jul 2020 21:30:43 +0000 +Subject: [PATCH 09/27] xnu: Fix double free in grub_xnu_devprop_add_property() + +grub_xnu_devprop_add_property() should not free utf8 and utf16 as it get +allocated and freed in the caller. + +Minor improvement: do prop fields initialization after memory allocations. + +Fixes: CID 292442, CID 292457, CID 292460, CID 292466 + +Signed-off-by: Alexey Makhalov +Reviewed-by: Daniel Kiper +--- + grub-core/loader/i386/xnu.c | 17 ++++++++--------- + 1 file changed, 8 insertions(+), 9 deletions(-) + +diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c +index b7d176b..e9e1192 100644 +--- a/grub-core/loader/i386/xnu.c ++++ b/grub-core/loader/i386/xnu.c +@@ -262,20 +262,19 @@ grub_xnu_devprop_add_property (struct grub_xnu_devprop_device_descriptor *dev, + if (!prop) + return grub_errno; + +- prop->name = utf8; +- prop->name16 = utf16; +- prop->name16len = utf16len; +- +- prop->length = datalen; +- prop->data = grub_malloc (prop->length); ++ prop->data = grub_malloc (datalen); + if (!prop->data) + { +- grub_free (prop->name); +- grub_free (prop->name16); + grub_free (prop); + return grub_errno; + } +- grub_memcpy (prop->data, data, prop->length); ++ grub_memcpy (prop->data, data, datalen); ++ ++ prop->name = utf8; ++ prop->name16 = utf16; ++ prop->name16len = utf16len; ++ prop->length = datalen; ++ + grub_list_push (GRUB_AS_LIST_P (&dev->properties), + GRUB_AS_LIST (prop)); + return GRUB_ERR_NONE; +-- +2.23.0 + diff --git a/0230-lzma-Make-sure-we-don-t-dereference-past-array.patch b/0230-lzma-Make-sure-we-don-t-dereference-past-array.patch new file mode 100644 index 0000000000000000000000000000000000000000..74f4f2a366b6ab1e93d656a76e255d99ff56a32a --- /dev/null +++ b/0230-lzma-Make-sure-we-don-t-dereference-past-array.patch @@ -0,0 +1,51 @@ +From a2fd8fe73250d5a6ebe7e1b9dc31df6ecbcdfc8f Mon Sep 17 00:00:00 2001 +From: Konrad Rzeszutek Wilk +Date: Thu, 9 Jul 2020 03:05:23 +0000 +Subject: [PATCH 10/27] lzma: Make sure we don't dereference past array + +The two dimensional array p->posSlotEncoder[4][64] is being dereferenced +using the GetLenToPosState() macro which checks if len is less than 5, +and if so subtracts 2 from it. If len = 0, that is 0 - 2 = 4294967294. +Obviously we don't want to dereference that far out so we check if the +position found is greater or equal kNumLenToPosStates (4) and bail out. + +N.B.: Upstream LZMA 18.05 and later has this function completely rewritten +without any history. + +Fixes: CID 51526 + +Signed-off-by: Konrad Rzeszutek Wilk +Reviewed-by: Daniel Kiper +--- + grub-core/lib/LzmaEnc.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/grub-core/lib/LzmaEnc.c b/grub-core/lib/LzmaEnc.c +index f2ec04a..753e56a 100644 +--- a/grub-core/lib/LzmaEnc.c ++++ b/grub-core/lib/LzmaEnc.c +@@ -1877,13 +1877,19 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize + } + else + { +- UInt32 posSlot; ++ UInt32 posSlot, lenToPosState; + RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0); + p->state = kMatchNextStates[p->state]; + LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices); + pos -= LZMA_NUM_REPS; + GetPosSlot(pos, posSlot); +- RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot); ++ lenToPosState = GetLenToPosState(len); ++ if (lenToPosState >= kNumLenToPosStates) ++ { ++ p->result = SZ_ERROR_DATA; ++ return CheckErrors(p); ++ } ++ RcTree_Encode(&p->rc, p->posSlotEncoder[lenToPosState], kNumPosSlotBits, posSlot); + + if (posSlot >= kStartPosModelIndex) + { +-- +2.23.0 + diff --git a/0231-Mark-some-unused-stuff-unused.patch b/0231-Mark-some-unused-stuff-unused.patch deleted file mode 100644 index 2561754531dd04da47f1b672e8e2cfab7e8453a4..0000000000000000000000000000000000000000 --- a/0231-Mark-some-unused-stuff-unused.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Mon, 27 Aug 2018 13:10:08 -0400 -Subject: [PATCH] Mark some unused stuff unused - -Signed-off-by: Peter Jones ---- - grub-core/commands/blscfg.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index bdb1c5a95aa..abd6f00d0de 100644 ---- a/grub-core/commands/blscfg.c -+++ b/grub-core/commands/blscfg.c -@@ -434,7 +434,7 @@ finish: - - static grub_envblk_t saved_env = NULL; - --static int -+static int UNUSED - save_var (const char *name, const char *value, void *whitelist UNUSED) - { - const char *val = grub_env_get (name); -@@ -446,7 +446,7 @@ save_var (const char *name, const char *value, void *whitelist UNUSED) - return 0; - } - --static int -+static int UNUSED - unset_var (const char *name, const char *value UNUSED, void *whitelist) - { - grub_dprintf("blscfg", "restoring \"%s\"\n", name); diff --git a/0231-term-Fix-overflow-on-user-inputs.patch b/0231-term-Fix-overflow-on-user-inputs.patch new file mode 100644 index 0000000000000000000000000000000000000000..90def3496da9021c8a2354827c1cf7c5991563af --- /dev/null +++ b/0231-term-Fix-overflow-on-user-inputs.patch @@ -0,0 +1,65 @@ +From 8054c31c62c4caf5a8767c0e4c8ce09219b8ec6e Mon Sep 17 00:00:00 2001 +From: Konrad Rzeszutek Wilk +Date: Tue, 7 Jul 2020 15:12:25 -0400 +Subject: [PATCH 11/27] term: Fix overflow on user inputs + +This requires a very weird input from the serial interface but can cause +an overflow in input_buf (keys) overwriting the next variable (npending) +with the user choice: + +(pahole output) + +struct grub_terminfo_input_state { + int input_buf[6]; /* 0 24 */ + int npending; /* 24 4 */ <- CORRUPT + ...snip... + +The magic string requires causing this is "ESC,O,],0,1,2,q" and we overflow +npending with "q" (aka increase npending to 161). The simplest fix is to +just to disallow overwrites input_buf, which exactly what this patch does. + +Fixes: CID 292449 + +Signed-off-by: Konrad Rzeszutek Wilk +Reviewed-by: Daniel Kiper +--- + grub-core/term/terminfo.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c +index 537a5c0..44d0b3b 100644 +--- a/grub-core/term/terminfo.c ++++ b/grub-core/term/terminfo.c +@@ -398,7 +398,7 @@ grub_terminfo_getwh (struct grub_term_output *term) + } + + static void +-grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, ++grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, int max_len, + int (*readkey) (struct grub_term_input *term)) + { + int c; +@@ -414,6 +414,9 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, + if (c == -1) \ + return; \ + \ ++ if (*len >= max_len) \ ++ return; \ ++ \ + keys[*len] = c; \ + (*len)++; \ + } +@@ -602,8 +605,8 @@ grub_terminfo_getkey (struct grub_term_input *termi) + return ret; + } + +- grub_terminfo_readkey (termi, data->input_buf, +- &data->npending, data->readkey); ++ grub_terminfo_readkey (termi, data->input_buf, &data->npending, ++ GRUB_TERMINFO_READKEY_MAX_LEN, data->readkey); + + #if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275) + if (data->npending == 1 && data->input_buf[0] == GRUB_TERM_ESC +-- +2.23.0 + diff --git a/0232-udf-Fix-memory-leak.patch b/0232-udf-Fix-memory-leak.patch new file mode 100644 index 0000000000000000000000000000000000000000..2a743697aa3b1a3c8c8cfc0e051bd0c086a2dd57 --- /dev/null +++ b/0232-udf-Fix-memory-leak.patch @@ -0,0 +1,55 @@ +From ba6a43c85d73196ed00ba662a4d310c310540864 Mon Sep 17 00:00:00 2001 +From: Konrad Rzeszutek Wilk +Date: Tue, 7 Jul 2020 22:02:31 -0400 +Subject: [PATCH 12/27] udf: Fix memory leak + +Fixes: CID 73796 + +Signed-off-by: Konrad Rzeszutek Wilk +Reviewed-by: Daniel Kiper +Reviewed-by: Jan Setje-Eilers +--- + grub-core/fs/udf.c | 17 +++++++++++++---- + 1 file changed, 13 insertions(+), 4 deletions(-) + +diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c +index 21ac7f4..2ac5c1d 100644 +--- a/grub-core/fs/udf.c ++++ b/grub-core/fs/udf.c +@@ -965,8 +965,10 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir, + return 0; + + if (grub_udf_read_icb (dir->data, &dirent.icb, child)) +- return 0; +- ++ { ++ grub_free (child); ++ return 0; ++ } + if (dirent.characteristics & GRUB_UDF_FID_CHAR_PARENT) + { + /* This is the parent directory. */ +@@ -988,11 +990,18 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir, + dirent.file_ident_length, + (char *) raw)) + != dirent.file_ident_length) +- return 0; ++ { ++ grub_free (child); ++ return 0; ++ } + + filename = read_string (raw, dirent.file_ident_length, 0); + if (!filename) +- grub_print_error (); ++ { ++ /* As the hook won't get called. */ ++ grub_free (child); ++ grub_print_error (); ++ } + + if (filename && hook (filename, type, child, hook_data)) + { +-- +2.23.0 + diff --git a/0233-multiboot2-Fix-memory-leak-if-grub_create_loader_cmd.patch b/0233-multiboot2-Fix-memory-leak-if-grub_create_loader_cmd.patch new file mode 100644 index 0000000000000000000000000000000000000000..c53f98100aefe8413ef15fcab8bcaad4bd62254d --- /dev/null +++ b/0233-multiboot2-Fix-memory-leak-if-grub_create_loader_cmd.patch @@ -0,0 +1,34 @@ +From 1eebc205991aeb48f5d88acaac3833ad527b1fb1 Mon Sep 17 00:00:00 2001 +From: Konrad Rzeszutek Wilk +Date: Fri, 26 Jun 2020 10:51:43 -0400 +Subject: [PATCH 13/27] multiboot2: Fix memory leak if + grub_create_loader_cmdline() fails + +Fixes: CID 292468 + +Signed-off-by: Konrad Rzeszutek Wilk +Reviewed-by: Daniel Kiper +--- + grub-core/loader/multiboot_mbi2.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c +index 53da786..0efc660 100644 +--- a/grub-core/loader/multiboot_mbi2.c ++++ b/grub-core/loader/multiboot_mbi2.c +@@ -1070,7 +1070,11 @@ grub_multiboot2_add_module (grub_addr_t start, grub_size_t size, + err = grub_create_loader_cmdline (argc, argv, newmod->cmdline, + newmod->cmdline_size, GRUB_VERIFY_MODULE_CMDLINE); + if (err) +- return err; ++ { ++ grub_free (newmod->cmdline); ++ grub_free (newmod); ++ return err; ++ } + + if (modules_last) + modules_last->next = newmod; +-- +2.23.0 + diff --git a/0234-tftp-Do-not-use-priority-queue.patch b/0234-tftp-Do-not-use-priority-queue.patch new file mode 100644 index 0000000000000000000000000000000000000000..da00b103323458a705f8fda2c7a248f8acd69b4f --- /dev/null +++ b/0234-tftp-Do-not-use-priority-queue.patch @@ -0,0 +1,284 @@ +From 781b3e5efc35c17cbce95393aafd63a5b429f9e6 Mon Sep 17 00:00:00 2001 +From: Alexey Makhalov +Date: Thu, 9 Jul 2020 08:10:40 +0000 +Subject: [PATCH 14/27] tftp: Do not use priority queue + +There is not need to reassemble the order of blocks. Per RFC 1350, +server must wait for the ACK, before sending next block. Data packets +can be served immediately without putting them to priority queue. + +Logic to handle incoming packet is this: + - if packet block id equal to expected block id, then + process the packet, + - if packet block id is less than expected - this is retransmit + of old packet, then ACK it and drop the packet, + - if packet block id is more than expected - that shouldn't + happen, just drop the packet. + +It makes the tftp receive path code simpler, smaller and faster. +As a benefit, this change fixes CID# 73624 and CID# 96690, caused +by following while loop: + + while (cmp_block (grub_be_to_cpu16 (tftph->u.data.block), data->block + 1) == 0) + +where tftph pointer is not moving from one iteration to another, causing +to serve same packet again. Luckily, double serving didn't happen due to +data->block++ during the first iteration. + +Fixes: CID 73624, CID 96690 + +Signed-off-by: Alexey Makhalov +Reviewed-by: Daniel Kiper +--- +--- + grub-core/net/tftp.c | 168 ++++++++++++++----------------------------- + 1 file changed, 53 insertions(+), 115 deletions(-) + +diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c +index e267af3..c2df3d7 100644 +--- a/grub-core/net/tftp.c ++++ b/grub-core/net/tftp.c +@@ -25,7 +25,6 @@ + #include + #include + #include +-#include + #include + + GRUB_MOD_LICENSE ("GPLv3+"); +@@ -106,31 +105,8 @@ typedef struct tftp_data + int have_oack; + struct grub_error_saved save_err; + grub_net_udp_socket_t sock; +- grub_priority_queue_t pq; + } *tftp_data_t; + +-static int +-cmp_block (grub_uint16_t a, grub_uint16_t b) +-{ +- grub_int16_t i = (grub_int16_t) (a - b); +- if (i > 0) +- return +1; +- if (i < 0) +- return -1; +- return 0; +-} +- +-static int +-cmp (const void *a__, const void *b__) +-{ +- struct grub_net_buff *a_ = *(struct grub_net_buff **) a__; +- struct grub_net_buff *b_ = *(struct grub_net_buff **) b__; +- struct tftphdr *a = (struct tftphdr *) a_->data; +- struct tftphdr *b = (struct tftphdr *) b_->data; +- /* We want the first elements to be on top. */ +- return -cmp_block (grub_be_to_cpu16 (a->u.data.block), grub_be_to_cpu16 (b->u.data.block)); +-} +- + static grub_err_t + ack (tftp_data_t data, grub_uint64_t block) + { +@@ -207,73 +183,60 @@ tftp_receive (grub_net_udp_socket_t sock __attribute__ ((unused)), + return GRUB_ERR_NONE; + } + +- err = grub_priority_queue_push (data->pq, &nb); +- if (err) +- return err; +- +- { +- struct grub_net_buff **nb_top_p, *nb_top; +- while (1) +- { +- nb_top_p = grub_priority_queue_top (data->pq); +- if (!nb_top_p) +- return GRUB_ERR_NONE; +- nb_top = *nb_top_p; +- tftph = (struct tftphdr *) nb_top->data; +- if (cmp_block (grub_be_to_cpu16 (tftph->u.data.block), data->block + 1) >= 0) +- break; +- ack (data, grub_be_to_cpu16 (tftph->u.data.block)); +- grub_netbuff_free (nb_top); +- grub_priority_queue_pop (data->pq); +- } +- while (cmp_block (grub_be_to_cpu16 (tftph->u.data.block), data->block + 1) == 0) +- { +- unsigned size; +- +- grub_priority_queue_pop (data->pq); +- +- if (file->device->net->packs.count < 50) ++ /* Ack old/retransmitted block. */ ++ if (grub_be_to_cpu16 (tftph->u.data.block) < data->block + 1) ++ ack (data, grub_be_to_cpu16 (tftph->u.data.block)); ++ /* Ignore unexpected block. */ ++ else if (grub_be_to_cpu16 (tftph->u.data.block) > data->block + 1) ++ grub_dprintf ("tftp", "TFTP unexpected block # %d\n", tftph->u.data.block); ++ else ++ { ++ unsigned size; ++ ++ if (file->device->net->packs.count < 50) ++ { + err = ack (data, data->block + 1); +- else +- { +- file->device->net->stall = 1; +- err = 0; +- } +- if (err) +- return err; +- +- err = grub_netbuff_pull (nb_top, sizeof (tftph->opcode) + +- sizeof (tftph->u.data.block)); +- if (err) +- return err; +- size = nb_top->tail - nb_top->data; +- +- data->block++; +- if (size < data->block_size) +- { +- if (data->ack_sent < data->block) +- ack (data, data->block); +- file->device->net->eof = 1; +- file->device->net->stall = 1; +- grub_net_udp_close (data->sock); +- data->sock = NULL; +- } +- /* Prevent garbage in broken cards. Is it still necessary +- given that IP implementation has been fixed? +- */ +- if (size > data->block_size) +- { +- err = grub_netbuff_unput (nb_top, size - data->block_size); +- if (err) +- return err; +- } +- /* If there is data, puts packet in socket list. */ +- if ((nb_top->tail - nb_top->data) > 0) +- grub_net_put_packet (&file->device->net->packs, nb_top); +- else +- grub_netbuff_free (nb_top); +- } +- } ++ if (err) ++ return err; ++ } ++ else ++ file->device->net->stall = 1; ++ ++ err = grub_netbuff_pull (nb, sizeof (tftph->opcode) + ++ sizeof (tftph->u.data.block)); ++ if (err) ++ return err; ++ size = nb->tail - nb->data; ++ ++ data->block++; ++ if (size < data->block_size) ++ { ++ if (data->ack_sent < data->block) ++ ack (data, data->block); ++ file->device->net->eof = 1; ++ file->device->net->stall = 1; ++ grub_net_udp_close (data->sock); ++ data->sock = NULL; ++ } ++ /* ++ * Prevent garbage in broken cards. Is it still necessary ++ * given that IP implementation has been fixed? ++ */ ++ if (size > data->block_size) ++ { ++ err = grub_netbuff_unput (nb, size - data->block_size); ++ if (err) ++ return err; ++ } ++ /* If there is data, puts packet in socket list. */ ++ if ((nb->tail - nb->data) > 0) ++ { ++ grub_net_put_packet (&file->device->net->packs, nb); ++ /* Do not free nb. */ ++ return GRUB_ERR_NONE; ++ } ++ } ++ grub_netbuff_free (nb); + return GRUB_ERR_NONE; + case TFTP_ERROR: + data->have_oack = 1; +@@ -287,19 +250,6 @@ tftp_receive (grub_net_udp_socket_t sock __attribute__ ((unused)), + } + } + +-static void +-destroy_pq (tftp_data_t data) +-{ +- struct grub_net_buff **nb_p; +- while ((nb_p = grub_priority_queue_top (data->pq))) +- { +- grub_netbuff_free (*nb_p); +- grub_priority_queue_pop (data->pq); +- } +- +- grub_priority_queue_destroy (data->pq); +-} +- + /* Create a normalized copy of the filename. + Compress any string of consecutive forward slashes to a single forward + slash. */ +@@ -395,13 +345,6 @@ tftp_open (struct grub_file *file, const char *filename) + file->not_easily_seekable = 1; + file->data = data; + +- data->pq = grub_priority_queue_new (sizeof (struct grub_net_buff *), cmp); +- if (!data->pq) +- { +- grub_free (data); +- return grub_errno; +- } +- + grub_dprintf("tftp", "resolving address for %s\n", file->device->net->server); + err = grub_net_resolve_address (file->device->net->server, &addr); + if (err) +@@ -410,7 +353,6 @@ tftp_open (struct grub_file *file, const char *filename) + grub_dprintf ("tftp", "file_size is %llu, block_size is %llu\n", + (unsigned long long)data->file_size, + (unsigned long long)data->block_size); +- destroy_pq (data); + grub_free (data); + return err; + } +@@ -422,7 +364,6 @@ tftp_open (struct grub_file *file, const char *filename) + if (!data->sock) + { + grub_dprintf("tftp", "connection failed\n"); +- destroy_pq (data); + grub_free (data); + return grub_errno; + } +@@ -436,7 +377,6 @@ tftp_open (struct grub_file *file, const char *filename) + if (err) + { + grub_net_udp_close (data->sock); +- destroy_pq (data); + grub_free (data); + return err; + } +@@ -453,7 +393,6 @@ tftp_open (struct grub_file *file, const char *filename) + if (grub_errno) + { + grub_net_udp_close (data->sock); +- destroy_pq (data); + grub_free (data); + return grub_errno; + } +@@ -496,7 +435,6 @@ tftp_close (struct grub_file *file) + grub_print_error (); + grub_net_udp_close (data->sock); + } +- destroy_pq (data); + grub_free (data); + return GRUB_ERR_NONE; + } +-- +2.23.0 + diff --git a/0235-relocator-Protect-grub_relocator_alloc_chunk_addr-in.patch b/0235-relocator-Protect-grub_relocator_alloc_chunk_addr-in.patch new file mode 100644 index 0000000000000000000000000000000000000000..a1a42cfe951c5e2b5e3f3d38606c3995e58b0e95 --- /dev/null +++ b/0235-relocator-Protect-grub_relocator_alloc_chunk_addr-in.patch @@ -0,0 +1,149 @@ +From caea56d1f8fa1ae298936f8d75b220e7f12b73d3 Mon Sep 17 00:00:00 2001 +From: Alexey Makhalov +Date: Wed, 15 Jul 2020 06:42:37 +0000 +Subject: [PATCH 15/27] relocator: Protect grub_relocator_alloc_chunk_addr() + input args against integer underflow/overflow + +Use arithmetic macros from safemath.h to accomplish it. In this commit, +I didn't want to be too paranoid to check every possible math equation +for overflow/underflow. Only obvious places (with non zero chance of +overflow/underflow) were refactored. + +Signed-off-by: Alexey Makhalov +Reviewed-by: Daniel Kiper +--- + grub-core/loader/i386/linux.c | 9 +++++++-- + grub-core/loader/i386/pc/linux.c | 9 +++++++-- + grub-core/loader/i386/xen.c | 12 ++++++++++-- + grub-core/loader/xnu.c | 11 +++++++---- + 4 files changed, 31 insertions(+), 10 deletions(-) + +diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c +index 201e659..90f2315 100644 +--- a/grub-core/loader/i386/linux.c ++++ b/grub-core/loader/i386/linux.c +@@ -37,6 +37,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -548,9 +549,13 @@ grub_linux_boot (void) + + { + grub_relocator_chunk_t ch; ++ grub_size_t sz; ++ ++ if (grub_add (ctx.real_size, efi_mmap_size, &sz)) ++ return GRUB_ERR_OUT_OF_RANGE; ++ + err = grub_relocator_alloc_chunk_addr (relocator, &ch, +- ctx.real_mode_target, +- (ctx.real_size + efi_mmap_size)); ++ ctx.real_mode_target, sz); + if (err) + return err; + real_mode_mem = get_virtual_current_address (ch); +diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c +index 0bf0e13..33d1196 100644 +--- a/grub-core/loader/i386/pc/linux.c ++++ b/grub-core/loader/i386/pc/linux.c +@@ -36,6 +36,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -231,8 +232,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + setup_sects = GRUB_LINUX_DEFAULT_SETUP_SECTS; + + real_size = setup_sects << GRUB_DISK_SECTOR_BITS; +- grub_linux16_prot_size = grub_file_size (file) +- - real_size - GRUB_DISK_SECTOR_SIZE; ++ if (grub_sub (grub_file_size (file), real_size, &grub_linux16_prot_size) || ++ grub_sub (grub_linux16_prot_size, GRUB_DISK_SECTOR_SIZE, &grub_linux16_prot_size)) ++ { ++ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); ++ goto fail; ++ } + + if (! grub_linux_is_bzimage + && GRUB_LINUX_ZIMAGE_ADDR + grub_linux16_prot_size +diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c +index 8f662c8..cd24874 100644 +--- a/grub-core/loader/i386/xen.c ++++ b/grub-core/loader/i386/xen.c +@@ -41,6 +41,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -636,6 +637,7 @@ grub_cmd_xen (grub_command_t cmd __attribute__ ((unused)), + grub_relocator_chunk_t ch; + grub_addr_t kern_start; + grub_addr_t kern_end; ++ grub_size_t sz; + + if (argc == 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); +@@ -703,8 +705,14 @@ grub_cmd_xen (grub_command_t cmd __attribute__ ((unused)), + + xen_state.max_addr = ALIGN_UP (kern_end, PAGE_SIZE); + +- err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, kern_start, +- kern_end - kern_start); ++ ++ if (grub_sub (kern_end, kern_start, &sz)) ++ { ++ err = GRUB_ERR_OUT_OF_RANGE; ++ goto fail; ++ } ++ ++ err = grub_relocator_alloc_chunk_addr (xen_state.relocator, &ch, kern_start, sz); + if (err) + goto fail; + kern_chunk_src = get_virtual_current_address (ch); +diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c +index 2f0ebd0..3fd6539 100644 +--- a/grub-core/loader/xnu.c ++++ b/grub-core/loader/xnu.c +@@ -35,6 +35,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -60,15 +61,17 @@ grub_xnu_heap_malloc (int size, void **src, grub_addr_t *target) + { + grub_err_t err; + grub_relocator_chunk_t ch; ++ grub_addr_t tgt; ++ ++ if (grub_add (grub_xnu_heap_target_start, grub_xnu_heap_size, &tgt)) ++ return GRUB_ERR_OUT_OF_RANGE; + +- err = grub_relocator_alloc_chunk_addr (grub_xnu_relocator, &ch, +- grub_xnu_heap_target_start +- + grub_xnu_heap_size, size); ++ err = grub_relocator_alloc_chunk_addr (grub_xnu_relocator, &ch, tgt, size); + if (err) + return err; + + *src = get_virtual_current_address (ch); +- *target = grub_xnu_heap_target_start + grub_xnu_heap_size; ++ *target = tgt; + grub_xnu_heap_size += size; + grub_dprintf ("xnu", "val=%p\n", *src); + return GRUB_ERR_NONE; +-- +2.23.0 + diff --git a/0236-multiboot2-Set-min-address-for-mbi-allocation-to-0x1.patch b/0236-multiboot2-Set-min-address-for-mbi-allocation-to-0x1.patch new file mode 100644 index 0000000000000000000000000000000000000000..ba498f86c99fb8e258295b0fd70dcc998baadbee --- /dev/null +++ b/0236-multiboot2-Set-min-address-for-mbi-allocation-to-0x1.patch @@ -0,0 +1,49 @@ +From 0f3f5b7c13fa9b677a64cf11f20eca0f850a2b20 Mon Sep 17 00:00:00 2001 +From: Lukasz Hawrylko +Date: Mon, 16 Dec 2019 11:15:55 +0100 +Subject: [PATCH] multiboot2: Set min address for mbi allocation to 0x1000 + +Subject: [PATCH 16/27] multiboot2: Set min address for mbi allocation to + 0x1000 + +In some cases GRUB2 allocates multiboot2 structure at 0 address, that is +a confusing behavior. Consumers of that structure can have internal NULL-checks +that will throw an error when get a pointer to data allocated at address 0. +To prevent that, define min address for mbi allocation on x86 and x86_64 +platforms. + +Signed-off-by: Lukasz Hawrylko +Reviewed-by: Daniel Kiper +--- + grub-core/loader/multiboot_mbi2.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c +index 0efc660..e88c9f4 100644 +--- a/grub-core/loader/multiboot_mbi2.c ++++ b/grub-core/loader/multiboot_mbi2.c +@@ -48,6 +48,12 @@ + #define HAS_VGA_TEXT 0 + #endif + ++#if defined (__i386__) || defined (__x86_64__) ++#define MBI_MIN_ADDR 0x1000 ++#else ++#define MBI_MIN_ADDR 0 ++#endif ++ + struct module + { + struct module *next; +@@ -708,7 +714,7 @@ grub_multiboot2_make_mbi (grub_uint32_t *target) + COMPILE_TIME_ASSERT (MULTIBOOT_TAG_ALIGN % sizeof (grub_properly_aligned_t) == 0); + + err = grub_relocator_alloc_chunk_align (grub_multiboot2_relocator, &ch, +- 0, 0xffffffff - bufsize, ++ MBI_MIN_ADDR, 0xffffffff - bufsize, + bufsize, MULTIBOOT_TAG_ALIGN, + GRUB_RELOCATOR_PREFERENCE_NONE, 1); + if (err) +-- +2.23.0 + diff --git a/0237-relocator-Protect-grub_relocator_alloc_chunk_align-m.patch b/0237-relocator-Protect-grub_relocator_alloc_chunk_align-m.patch new file mode 100644 index 0000000000000000000000000000000000000000..21065756b1f8c7a1bb7bae9fababd526946ede3d --- /dev/null +++ b/0237-relocator-Protect-grub_relocator_alloc_chunk_align-m.patch @@ -0,0 +1,334 @@ +From 61ff5602fe8f2a3446346795daebe4ec3b82c20f Mon Sep 17 00:00:00 2001 +From: Alexey Makhalov +Date: Wed, 8 Jul 2020 01:44:38 +0000 +Subject: [PATCH 17/27] relocator: Protect grub_relocator_alloc_chunk_align() + max_addr against integer underflow + +This commit introduces integer underflow mitigation in max_addr calculation +in grub_relocator_alloc_chunk_align() invocation. + +It consists of 2 fixes: + 1. Introduced grub_relocator_alloc_chunk_align_safe() wrapper function to perform + sanity check for min/max and size values, and to make safe invocation of + grub_relocator_alloc_chunk_align() with validated max_addr value. Replace all + invocations such as grub_relocator_alloc_chunk_align(..., min_addr, max_addr - size, size, ...) + by grub_relocator_alloc_chunk_align_safe(..., min_addr, max_addr, size, ...). + 2. Introduced UP_TO_TOP32(s) macro for the cases where max_addr is 32-bit top + address (0xffffffff - size + 1) or similar. +--- + grub-core/lib/i386/relocator.c | 28 ++++++++++---------------- + grub-core/lib/mips/relocator.c | 6 ++---- + grub-core/lib/powerpc/relocator.c | 6 ++---- + grub-core/lib/x86_64/efi/relocator.c | 7 +++---- + grub-core/loader/i386/linux.c | 5 ++--- + grub-core/loader/i386/multiboot_mbi.c | 7 +++---- + grub-core/loader/i386/pc/linux.c | 6 ++---- + grub-core/loader/mips/linux.c | 9 +++------ + grub-core/loader/multiboot.c | 2 +- + grub-core/loader/multiboot_elfxx.c | 10 ++++----- + grub-core/loader/multiboot_mbi2.c | 10 ++++----- + grub-core/loader/xnu_resume.c | 2 +- + include/grub/relocator.h | 29 +++++++++++++++++++++++++++ + 13 files changed, 69 insertions(+), 58 deletions(-) + +diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c +index 71dd4f0..34cbe83 100644 +--- a/grub-core/lib/i386/relocator.c ++++ b/grub-core/lib/i386/relocator.c +@@ -83,11 +83,10 @@ grub_relocator32_boot (struct grub_relocator *rel, + /* Specific memory range due to Global Descriptor Table for use by payload + that we will store in returned chunk. The address range and preference + are based on "THE LINUX/x86 BOOT PROTOCOL" specification. */ +- err = grub_relocator_alloc_chunk_align (rel, &ch, 0x1000, +- 0x9a000 - RELOCATOR_SIZEOF (32), +- RELOCATOR_SIZEOF (32), 16, +- GRUB_RELOCATOR_PREFERENCE_LOW, +- avoid_efi_bootservices); ++ err = grub_relocator_alloc_chunk_align_safe (rel, &ch, 0x1000, 0x9a000, ++ RELOCATOR_SIZEOF (32), 16, ++ GRUB_RELOCATOR_PREFERENCE_LOW, ++ avoid_efi_bootservices); + if (err) + return err; + +@@ -125,13 +124,10 @@ grub_relocator16_boot (struct grub_relocator *rel, + grub_relocator_chunk_t ch; + + /* Put it higher than the byte it checks for A20 check. */ +- err = grub_relocator_alloc_chunk_align (rel, &ch, 0x8010, +- 0xa0000 - RELOCATOR_SIZEOF (16) +- - GRUB_RELOCATOR16_STACK_SIZE, +- RELOCATOR_SIZEOF (16) +- + GRUB_RELOCATOR16_STACK_SIZE, 16, +- GRUB_RELOCATOR_PREFERENCE_NONE, +- 0); ++ err = grub_relocator_alloc_chunk_align_safe (rel, &ch, 0x8010, 0xa0000, ++ RELOCATOR_SIZEOF (16) + ++ GRUB_RELOCATOR16_STACK_SIZE, 16, ++ GRUB_RELOCATOR_PREFERENCE_NONE, 0); + if (err) + return err; + +@@ -183,11 +179,9 @@ grub_relocator64_boot (struct grub_relocator *rel, + void *relst; + grub_relocator_chunk_t ch; + +- err = grub_relocator_alloc_chunk_align (rel, &ch, min_addr, +- max_addr - RELOCATOR_SIZEOF (64), +- RELOCATOR_SIZEOF (64), 16, +- GRUB_RELOCATOR_PREFERENCE_NONE, +- 0); ++ err = grub_relocator_alloc_chunk_align_safe (rel, &ch, min_addr, max_addr, ++ RELOCATOR_SIZEOF (64), 16, ++ GRUB_RELOCATOR_PREFERENCE_NONE, 0); + if (err) + return err; + +diff --git a/grub-core/lib/mips/relocator.c b/grub-core/lib/mips/relocator.c +index 9d5f49c..743b213 100644 +--- a/grub-core/lib/mips/relocator.c ++++ b/grub-core/lib/mips/relocator.c +@@ -120,10 +120,8 @@ grub_relocator32_boot (struct grub_relocator *rel, + unsigned i; + grub_addr_t vtarget; + +- err = grub_relocator_alloc_chunk_align (rel, &ch, 0, +- (0xffffffff - stateset_size) +- + 1, stateset_size, +- sizeof (grub_uint32_t), ++ err = grub_relocator_alloc_chunk_align (rel, &ch, 0, UP_TO_TOP32 (stateset_size), ++ stateset_size, sizeof (grub_uint32_t), + GRUB_RELOCATOR_PREFERENCE_NONE, 0); + if (err) + return err; +diff --git a/grub-core/lib/powerpc/relocator.c b/grub-core/lib/powerpc/relocator.c +index bdf2b11..8ffb8b6 100644 +--- a/grub-core/lib/powerpc/relocator.c ++++ b/grub-core/lib/powerpc/relocator.c +@@ -115,10 +115,8 @@ grub_relocator32_boot (struct grub_relocator *rel, + unsigned i; + grub_relocator_chunk_t ch; + +- err = grub_relocator_alloc_chunk_align (rel, &ch, 0, +- (0xffffffff - stateset_size) +- + 1, stateset_size, +- sizeof (grub_uint32_t), ++ err = grub_relocator_alloc_chunk_align (rel, &ch, 0, UP_TO_TOP32 (stateset_size), ++ stateset_size, sizeof (grub_uint32_t), + GRUB_RELOCATOR_PREFERENCE_NONE, 0); + if (err) + return err; +diff --git a/grub-core/lib/x86_64/efi/relocator.c b/grub-core/lib/x86_64/efi/relocator.c +index 3caef7a..7d200a1 100644 +--- a/grub-core/lib/x86_64/efi/relocator.c ++++ b/grub-core/lib/x86_64/efi/relocator.c +@@ -50,10 +50,9 @@ grub_relocator64_efi_boot (struct grub_relocator *rel, + * 64-bit relocator code may live above 4 GiB quite well. + * However, I do not want ask for problems. Just in case. + */ +- err = grub_relocator_alloc_chunk_align (rel, &ch, 0, +- 0x100000000 - RELOCATOR_SIZEOF (64_efi), +- RELOCATOR_SIZEOF (64_efi), 16, +- GRUB_RELOCATOR_PREFERENCE_NONE, 1); ++ err = grub_relocator_alloc_chunk_align_safe (rel, &ch, 0, 0x100000000, ++ RELOCATOR_SIZEOF (64_efi), 16, ++ GRUB_RELOCATOR_PREFERENCE_NONE, 1); + if (err) + return err; + +diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c +index 90f2315..7d0c987 100644 +--- a/grub-core/loader/i386/linux.c ++++ b/grub-core/loader/i386/linux.c +@@ -182,9 +182,8 @@ allocate_pages (grub_size_t prot_size, grub_size_t *align, + for (; err && *align + 1 > min_align; (*align)--) + { + grub_errno = GRUB_ERR_NONE; +- err = grub_relocator_alloc_chunk_align (relocator, &ch, +- 0x1000000, +- 0xffffffff & ~prot_size, ++ err = grub_relocator_alloc_chunk_align (relocator, &ch, 0x1000000, ++ UP_TO_TOP32 (prot_size), + prot_size, 1 << *align, + GRUB_RELOCATOR_PREFERENCE_LOW, + 1); +diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c +index ad3cc29..a67d9d0 100644 +--- a/grub-core/loader/i386/multiboot_mbi.c ++++ b/grub-core/loader/i386/multiboot_mbi.c +@@ -466,10 +466,9 @@ grub_multiboot_make_mbi (grub_uint32_t *target) + + bufsize = grub_multiboot_get_mbi_size (); + +- err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, +- 0x10000, 0xa0000 - bufsize, +- bufsize, 4, +- GRUB_RELOCATOR_PREFERENCE_NONE, 0); ++ err = grub_relocator_alloc_chunk_align_safe (grub_multiboot_relocator, &ch, ++ 0x10000, 0xa0000, bufsize, 4, ++ GRUB_RELOCATOR_PREFERENCE_NONE, 0); + if (err) + return err; + ptrorig = get_virtual_current_address (ch); +diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c +index 33d1196..f1ad185 100644 +--- a/grub-core/loader/i386/pc/linux.c ++++ b/grub-core/loader/i386/pc/linux.c +@@ -463,10 +463,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + + { + grub_relocator_chunk_t ch; +- err = grub_relocator_alloc_chunk_align (relocator, &ch, +- addr_min, addr_max - size, +- size, 0x1000, +- GRUB_RELOCATOR_PREFERENCE_HIGH, 0); ++ err = grub_relocator_alloc_chunk_align_safe (relocator, &ch, addr_min, addr_max, size, ++ 0x1000, GRUB_RELOCATOR_PREFERENCE_HIGH, 0); + if (err) + return err; + initrd_chunk = get_virtual_current_address (ch); +diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c +index 7b723bf..e4ed959 100644 +--- a/grub-core/loader/mips/linux.c ++++ b/grub-core/loader/mips/linux.c +@@ -442,12 +442,9 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + { + grub_relocator_chunk_t ch; + +- err = grub_relocator_alloc_chunk_align (relocator, &ch, +- (target_addr & 0x1fffffff) +- + linux_size + 0x10000, +- (0x10000000 - size), +- size, 0x10000, +- GRUB_RELOCATOR_PREFERENCE_NONE, 0); ++ err = grub_relocator_alloc_chunk_align_safe (relocator, &ch, (target_addr & 0x1fffffff) + ++ linux_size + 0x10000, 0x10000000, size, ++ 0x10000, GRUB_RELOCATOR_PREFERENCE_NONE, 0); + + if (err) + goto fail; +diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c +index 3e6ad16..3e28690 100644 +--- a/grub-core/loader/multiboot.c ++++ b/grub-core/loader/multiboot.c +@@ -404,7 +404,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), + { + grub_relocator_chunk_t ch; + err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch, +- lowest_addr, (0xffffffff - size) + 1, ++ lowest_addr, UP_TO_TOP32 (size), + size, MULTIBOOT_MOD_ALIGN, + GRUB_RELOCATOR_PREFERENCE_NONE, 1); + if (err) +diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c +index cc68536..f2318e0 100644 +--- a/grub-core/loader/multiboot_elfxx.c ++++ b/grub-core/loader/multiboot_elfxx.c +@@ -109,10 +109,10 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) + if (load_size > mld->max_addr || mld->min_addr > mld->max_addr - load_size) + return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load size"); + +- err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch, +- mld->min_addr, mld->max_addr - load_size, +- load_size, mld->align ? mld->align : 1, +- mld->preference, mld->avoid_efi_boot_services); ++ err = grub_relocator_alloc_chunk_align_safe (GRUB_MULTIBOOT (relocator), &ch, ++ mld->min_addr, mld->max_addr, ++ load_size, mld->align ? mld->align : 1, ++ mld->preference, mld->avoid_efi_boot_services); + + if (err) + { +@@ -256,7 +256,7 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) + continue; + + err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch, 0, +- (0xffffffff - sh->sh_size) + 1, ++ UP_TO_TOP32 (sh->sh_size), + sh->sh_size, sh->sh_addralign, + GRUB_RELOCATOR_PREFERENCE_NONE, + mld->avoid_efi_boot_services); +diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c +index e88c9f4..9a943d7 100644 +--- a/grub-core/loader/multiboot_mbi2.c ++++ b/grub-core/loader/multiboot_mbi2.c +@@ -301,10 +301,10 @@ grub_multiboot2_load (grub_file_t file, const char *filename) + return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load size"); + } + +- err = grub_relocator_alloc_chunk_align (grub_multiboot2_relocator, &ch, +- mld.min_addr, mld.max_addr - code_size, +- code_size, mld.align ? mld.align : 1, +- mld.preference, keep_bs); ++ err = grub_relocator_alloc_chunk_align_safe (grub_multiboot2_relocator, &ch, ++ mld.min_addr, mld.max_addr, ++ code_size, mld.align ? mld.align : 1, ++ mld.preference, keep_bs); + } + else + err = grub_relocator_alloc_chunk_addr (grub_multiboot2_relocator, +@@ -714,7 +714,7 @@ grub_multiboot2_make_mbi (grub_uint32_t *target) + COMPILE_TIME_ASSERT (MULTIBOOT_TAG_ALIGN % sizeof (grub_properly_aligned_t) == 0); + + err = grub_relocator_alloc_chunk_align (grub_multiboot2_relocator, &ch, +- MBI_MIN_ADDR, 0xffffffff - bufsize, ++ MBI_MIN_ADDR, UP_TO_TOP32 (bufsize), + bufsize, MULTIBOOT_TAG_ALIGN, + GRUB_RELOCATOR_PREFERENCE_NONE, 1); + if (err) +diff --git a/grub-core/loader/xnu_resume.c b/grub-core/loader/xnu_resume.c +index 8089804..d648ef0 100644 +--- a/grub-core/loader/xnu_resume.c ++++ b/grub-core/loader/xnu_resume.c +@@ -129,7 +129,7 @@ grub_xnu_resume (char *imagename) + { + grub_relocator_chunk_t ch; + err = grub_relocator_alloc_chunk_align (grub_xnu_relocator, &ch, 0, +- (0xffffffff - hibhead.image_size) + 1, ++ UP_TO_TOP32 (hibhead.image_size), + hibhead.image_size, + GRUB_XNU_PAGESIZE, + GRUB_RELOCATOR_PREFERENCE_NONE, 0); +diff --git a/include/grub/relocator.h b/include/grub/relocator.h +index 24d8672..1b3bdd9 100644 +--- a/include/grub/relocator.h ++++ b/include/grub/relocator.h +@@ -49,6 +49,35 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel, + int preference, + int avoid_efi_boot_services); + ++/* ++ * Wrapper for grub_relocator_alloc_chunk_align() with purpose of ++ * protecting against integer underflow. ++ * ++ * Compare to its callee, max_addr has different meaning here. ++ * It covers entire chunk and not just start address of the chunk. ++ */ ++static inline grub_err_t ++grub_relocator_alloc_chunk_align_safe (struct grub_relocator *rel, ++ grub_relocator_chunk_t *out, ++ grub_phys_addr_t min_addr, ++ grub_phys_addr_t max_addr, ++ grub_size_t size, grub_size_t align, ++ int preference, ++ int avoid_efi_boot_services) ++{ ++ /* Sanity check and ensure following equation (max_addr - size) is safe. */ ++ if (max_addr < size || (max_addr - size) < min_addr) ++ return GRUB_ERR_OUT_OF_RANGE; ++ ++ return grub_relocator_alloc_chunk_align (rel, out, min_addr, ++ max_addr - size, ++ size, align, preference, ++ avoid_efi_boot_services); ++} ++ ++/* Top 32-bit address minus s bytes and plus 1 byte. */ ++#define UP_TO_TOP32(s) ((~(s) & 0xffffffff) + 1) ++ + #define GRUB_RELOCATOR_PREFERENCE_NONE 0 + #define GRUB_RELOCATOR_PREFERENCE_LOW 1 + #define GRUB_RELOCATOR_PREFERENCE_HIGH 2 +-- +2.23.0 + diff --git a/0238-script-Remove-unused-fields-from-grub_script_functio.patch b/0238-script-Remove-unused-fields-from-grub_script_functio.patch new file mode 100644 index 0000000000000000000000000000000000000000..3567b6f64594372cf8feac11731011f53928a6dd --- /dev/null +++ b/0238-script-Remove-unused-fields-from-grub_script_functio.patch @@ -0,0 +1,33 @@ +From 78dc80eec01a56866a0732bf2f808ec26ae45a59 Mon Sep 17 00:00:00 2001 +From: Chris Coulson +Date: Fri, 10 Jul 2020 11:21:14 +0100 +Subject: [PATCH 18/27] script: Remove unused fields from grub_script_function + struct + +Signed-off-by: Chris Coulson +Reviewed-by: Daniel Kiper +--- + include/grub/script_sh.h | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h +index 360c2be..b382bcf 100644 +--- a/include/grub/script_sh.h ++++ b/include/grub/script_sh.h +@@ -359,13 +359,8 @@ struct grub_script_function + /* The script function. */ + struct grub_script *func; + +- /* The flags. */ +- unsigned flags; +- + /* The next element. */ + struct grub_script_function *next; +- +- int references; + }; + typedef struct grub_script_function *grub_script_function_t; + +-- +2.23.0 + diff --git a/0239-grub-boot-success.timer-Add-a-few-Conditions-for-run.patch b/0239-grub-boot-success.timer-Add-a-few-Conditions-for-run.patch deleted file mode 100644 index 4f82ba2e8fb25a84b563e82cfcbffdfa0f9e0b1e..0000000000000000000000000000000000000000 --- a/0239-grub-boot-success.timer-Add-a-few-Conditions-for-run.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Mon, 3 Sep 2018 13:01:58 +0200 -Subject: [PATCH] grub-boot-success.timer: Add a few Conditions for running the - timer - -Add 2 Conditions for running the boot-success timer / service: - -1) Do not run it for system users, this fixes errors about gdm not being -allowed to use pkexec when the greeter session lasts for more then 2 minutes: -https://bugzilla.redhat.com/show_bug.cgi?id=1592201#c6 - -2) Do not run the timer when pkexec is not available (on minimal installs) -since then it will just lead to a bunch of errors without doing anything: -https://bugzilla.redhat.com/show_bug.cgi?id=1619445 - -Signed-off-by: Hans de Goede ---- - docs/grub-boot-success.timer | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/docs/grub-boot-success.timer b/docs/grub-boot-success.timer -index 221b532781b..67bd829b795 100644 ---- a/docs/grub-boot-success.timer -+++ b/docs/grub-boot-success.timer -@@ -1,5 +1,7 @@ - [Unit] - Description=Mark boot as successful after the user session has run 2 minutes -+ConditionUser=!@system -+ConditionPathExists=/usr/bin/pkexec - - [Timer] - OnActiveSec=2min diff --git a/0239-script-Avoid-a-use-after-free-when-redefining-a-func.patch b/0239-script-Avoid-a-use-after-free-when-redefining-a-func.patch new file mode 100644 index 0000000000000000000000000000000000000000..a48426ee927c4962d93f6fe7cd25febda57144a8 --- /dev/null +++ b/0239-script-Avoid-a-use-after-free-when-redefining-a-func.patch @@ -0,0 +1,109 @@ +From 0b86881d32d66a0d21b71fdb148ec2accba1be6e Mon Sep 17 00:00:00 2001 +From: Chris Coulson +Date: Fri, 10 Jul 2020 14:41:45 +0100 +Subject: [PATCH 19/27] script: Avoid a use-after-free when redefining a + function during execution + +Defining a new function with the same name as a previously defined +function causes the grub_script and associated resources for the +previous function to be freed. If the previous function is currently +executing when a function with the same name is defined, this results +in use-after-frees when processing subsequent commands in the original +function. + +Instead, reject a new function definition if it has the same name as +a previously defined function, and that function is currently being +executed. Although a behavioural change, this should be backwards +compatible with existing configurations because they can't be +dependent on the current behaviour without being broken. + +Fixes: CVE-2020-15706 + +Signed-off-by: Chris Coulson +Reviewed-by: Daniel Kiper +--- + grub-core/script/execute.c | 2 ++ + grub-core/script/function.c | 16 +++++++++++++--- + grub-core/script/parser.y | 3 ++- + include/grub/script_sh.h | 2 ++ + 4 files changed, 19 insertions(+), 4 deletions(-) + +diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c +index b55e171..d2f02cc 100644 +--- a/grub-core/script/execute.c ++++ b/grub-core/script/execute.c +@@ -872,7 +872,9 @@ grub_script_function_call (grub_script_function_t func, int argc, char **args) + old_scope = scope; + scope = &new_scope; + ++ func->executing++; + ret = grub_script_execute (func->func); ++ func->executing--; + + function_return = 0; + active_loops = loops; +diff --git a/grub-core/script/function.c b/grub-core/script/function.c +index d36655e..3aad04b 100644 +--- a/grub-core/script/function.c ++++ b/grub-core/script/function.c +@@ -34,6 +34,7 @@ grub_script_function_create (struct grub_script_arg *functionname_arg, + func = (grub_script_function_t) grub_malloc (sizeof (*func)); + if (! func) + return 0; ++ func->executing = 0; + + func->name = grub_strdup (functionname_arg->str); + if (! func->name) +@@ -60,10 +61,19 @@ grub_script_function_create (struct grub_script_arg *functionname_arg, + grub_script_function_t q; + + q = *p; +- grub_script_free (q->func); +- q->func = cmd; + grub_free (func); +- func = q; ++ if (q->executing > 0) ++ { ++ grub_error (GRUB_ERR_BAD_ARGUMENT, ++ N_("attempt to redefine a function being executed")); ++ func = NULL; ++ } ++ else ++ { ++ grub_script_free (q->func); ++ q->func = cmd; ++ func = q; ++ } + } + else + { +diff --git a/grub-core/script/parser.y b/grub-core/script/parser.y +index 4f0ab83..f80b86b 100644 +--- a/grub-core/script/parser.y ++++ b/grub-core/script/parser.y +@@ -289,7 +289,8 @@ function: "function" "name" + grub_script_mem_free (state->func_mem); + else { + script->children = state->scripts; +- grub_script_function_create ($2, script); ++ if (!grub_script_function_create ($2, script)) ++ grub_script_free (script); + } + + state->scripts = $3; +diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h +index b382bcf..6c48e07 100644 +--- a/include/grub/script_sh.h ++++ b/include/grub/script_sh.h +@@ -361,6 +361,8 @@ struct grub_script_function + + /* The next element. */ + struct grub_script_function *next; ++ ++ unsigned executing; + }; + typedef struct grub_script_function *grub_script_function_t; + +-- +2.23.0 + diff --git a/0240-docs-Stop-using-polkit-pkexec-for-grub-boot-success..patch b/0240-docs-Stop-using-polkit-pkexec-for-grub-boot-success..patch deleted file mode 100644 index bf4ad27fa890c66fbce09d49a6d1724b3174d2f1..0000000000000000000000000000000000000000 --- a/0240-docs-Stop-using-polkit-pkexec-for-grub-boot-success..patch +++ /dev/null @@ -1,69 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Fri, 14 Sep 2018 16:39:40 +0200 -Subject: [PATCH] docs: Stop using polkit / pkexec for grub-boot-success.timer - / service - -We also want to call grub2-set-bootflag under gdm and pkexec does not -work under gdm because the gdm user has /sbin/nologin as shell. - -So instead we are going to install grub2-set-bootflag as suid root, -grub2-set-bootflag was written with this usage in mind, so is safe -to be made suid root. - -Signed-off-by: Hans de Goede ---- - docs/grub-boot-success.service | 2 +- - docs/grub-boot-success.timer | 1 - - docs/org.gnu.grub.policy | 20 -------------------- - 3 files changed, 1 insertion(+), 22 deletions(-) - delete mode 100644 docs/org.gnu.grub.policy - -diff --git a/docs/grub-boot-success.service b/docs/grub-boot-success.service -index c8c91c34d49..80e79584c91 100644 ---- a/docs/grub-boot-success.service -+++ b/docs/grub-boot-success.service -@@ -3,4 +3,4 @@ Description=Mark boot as successful - - [Service] - Type=oneshot --ExecStart=/usr/bin/pkexec /usr/sbin/grub2-set-bootflag boot_success -+ExecStart=/usr/sbin/grub2-set-bootflag boot_success -diff --git a/docs/grub-boot-success.timer b/docs/grub-boot-success.timer -index 67bd829b795..5d8fcba21aa 100644 ---- a/docs/grub-boot-success.timer -+++ b/docs/grub-boot-success.timer -@@ -1,7 +1,6 @@ - [Unit] - Description=Mark boot as successful after the user session has run 2 minutes - ConditionUser=!@system --ConditionPathExists=/usr/bin/pkexec - - [Timer] - OnActiveSec=2min -diff --git a/docs/org.gnu.grub.policy b/docs/org.gnu.grub.policy -deleted file mode 100644 -index 18391efc8e7..00000000000 ---- a/docs/org.gnu.grub.policy -+++ /dev/null -@@ -1,20 +0,0 @@ -- -- -- -- GNU GRUB -- https://www.gnu.org/software/grub/ -- -- -- Set GRUB bootflags -- Authentication is required to modify the bootloaders bootflags -- -- no -- no -- yes -- -- /usr/sbin/grub2-set-bootflag -- -- diff --git a/0240-relocator-Fix-grub_relocator_alloc_chunk_align-top-m.patch b/0240-relocator-Fix-grub_relocator_alloc_chunk_align-top-m.patch new file mode 100644 index 0000000000000000000000000000000000000000..9df944f5263c2b172405d8edb63969cf34902cb5 --- /dev/null +++ b/0240-relocator-Fix-grub_relocator_alloc_chunk_align-top-m.patch @@ -0,0 +1,45 @@ +From 93ec7ea234ae82499034313df0f63c01cb382520 Mon Sep 17 00:00:00 2001 +From: Alexey Makhalov +Date: Fri, 17 Jul 2020 05:17:26 +0000 +Subject: [PATCH 20/27] relocator: Fix grub_relocator_alloc_chunk_align() top + memory allocation + +Current implementation of grub_relocator_alloc_chunk_align() +does not allow allocation of the top byte. + +Assuming input args are: + max_addr = 0xfffff000; + size = 0x1000; + +And this is valid. But following overflow protection will +unnecessarily move max_addr one byte down (to 0xffffefff): + if (max_addr > ~size) + max_addr = ~size; + +~size + 1 will fix the situation. In addition, check size +for non zero to do not zero max_addr. + +Signed-off-by: Alexey Makhalov +Reviewed-by: Daniel Kiper +--- + grub-core/lib/relocator.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c +index 5847aac..f2c1944 100644 +--- a/grub-core/lib/relocator.c ++++ b/grub-core/lib/relocator.c +@@ -1386,8 +1386,8 @@ grub_relocator_alloc_chunk_align (struct grub_relocator *rel, + }; + grub_addr_t min_addr2 = 0, max_addr2; + +- if (max_addr > ~size) +- max_addr = ~size; ++ if (size && (max_addr > ~size)) ++ max_addr = ~size + 1; + + #ifdef GRUB_MACHINE_PCBIOS + if (min_addr < 0x1000) +-- +2.23.0 + diff --git a/0241-hfsplus-Fix-two-more-overflows.patch b/0241-hfsplus-Fix-two-more-overflows.patch new file mode 100644 index 0000000000000000000000000000000000000000..1dbbd029f534bf3c007ba5659ce381ad16dbbffd --- /dev/null +++ b/0241-hfsplus-Fix-two-more-overflows.patch @@ -0,0 +1,57 @@ +From 0c0c7f7de657dde6994c58e29133a7356f6f672f Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Sun, 19 Jul 2020 14:43:31 -0400 +Subject: [PATCH 21/27] hfsplus: Fix two more overflows + +Both node->size and node->namelen come from the supplied filesystem, +which may be user-supplied. We can't trust them for the math unless we +know they don't overflow. Making sure they go through grub_add() or +grub_calloc() first will give us that. + +Signed-off-by: Peter Jones +Reviewed-by: Darren Kenny +Reviewed-by: Daniel Kiper +--- + grub-core/fs/hfsplus.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c +index dae43be..9c4e4c8 100644 +--- a/grub-core/fs/hfsplus.c ++++ b/grub-core/fs/hfsplus.c +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + + GRUB_MOD_LICENSE ("GPLv3+"); + +@@ -475,8 +476,12 @@ grub_hfsplus_read_symlink (grub_fshelp_node_t node) + { + char *symlink; + grub_ssize_t numread; ++ grub_size_t sz = node->size; + +- symlink = grub_malloc (node->size + 1); ++ if (grub_add (sz, 1, &sz)) ++ return NULL; ++ ++ symlink = grub_malloc (sz); + if (!symlink) + return 0; + +@@ -715,8 +720,8 @@ list_nodes (void *record, void *hook_arg) + if (type == GRUB_FSHELP_UNKNOWN) + return 0; + +- filename = grub_malloc (grub_be_to_cpu16 (catkey->namelen) +- * GRUB_MAX_UTF8_PER_UTF16 + 1); ++ filename = grub_calloc (grub_be_to_cpu16 (catkey->namelen), ++ GRUB_MAX_UTF8_PER_UTF16 + 1); + if (! filename) + return 0; + +-- +2.23.0 + diff --git a/0242-lvm-Fix-two-more-potential-data-dependent-alloc-over.patch b/0242-lvm-Fix-two-more-potential-data-dependent-alloc-over.patch new file mode 100644 index 0000000000000000000000000000000000000000..3f3cad234181d02f06377d228d781d124128cf61 --- /dev/null +++ b/0242-lvm-Fix-two-more-potential-data-dependent-alloc-over.patch @@ -0,0 +1,112 @@ +From 4a56a951ae3cc8ff25f94a291051b5246f1b828a Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Sun, 19 Jul 2020 15:48:20 -0400 +Subject: [PATCH 22/27] lvm: Fix two more potential data-dependent alloc + overflows + +It appears to be possible to make a (possibly invalid) lvm PV with +a metadata size field that overflows our type when adding it to the +address we've allocated. Even if it doesn't, it may be possible to do so +with the math using the outcome of that as an operand. Check them both. + +Signed-off-by: Peter Jones +Signed-off-by: Darren Kenny +Reviewed-by: Daniel Kiper +--- + grub-core/disk/lvm.c | 48 ++++++++++++++++++++++++++++++++++++-------- + 1 file changed, 40 insertions(+), 8 deletions(-) + +diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c +index 8e76d1a..9f5630c 100644 +--- a/grub-core/disk/lvm.c ++++ b/grub-core/disk/lvm.c +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + + #ifdef GRUB_UTIL + #include +@@ -102,10 +103,11 @@ grub_lvm_detect (grub_disk_t disk, + { + grub_err_t err; + grub_uint64_t mda_offset, mda_size; ++ grub_size_t ptr; + char buf[GRUB_LVM_LABEL_SIZE]; + char vg_id[GRUB_LVM_ID_STRLEN+1]; + char pv_id[GRUB_LVM_ID_STRLEN+1]; +- char *metadatabuf, *vgname; ++ char *metadatabuf, *mda_end, *vgname; + const char *p, *q; + struct grub_lvm_label_header *lh = (struct grub_lvm_label_header *) buf; + struct grub_lvm_pv_header *pvh; +@@ -206,19 +208,31 @@ grub_lvm_detect (grub_disk_t disk, + grub_le_to_cpu64 (rlocn->size) - + grub_le_to_cpu64 (mdah->size)); + } +- p = q = metadatabuf + grub_le_to_cpu64 (rlocn->offset); + +- while (*q != ' ' && q < metadatabuf + mda_size) +- q++; +- +- if (q == metadatabuf + mda_size) ++ if (grub_add ((grub_size_t)metadatabuf, ++ (grub_size_t)grub_le_to_cpu64 (rlocn->offset), ++ &ptr)) + { ++ error_parsing_metadata: + #ifdef GRUB_UTIL + grub_util_info ("error parsing metadata"); + #endif + goto fail2; + } + ++ p = q = (char *)ptr; ++ ++ if (grub_add ((grub_size_t)metadatabuf, (grub_size_t)mda_size, &ptr)) ++ goto error_parsing_metadata; ++ ++ mda_end = (char *)ptr; ++ ++ while (*q != ' ' && q < mda_end) ++ q++; ++ ++ if (q == mda_end) ++ goto error_parsing_metadata; ++ + vgname_len = q - p; + vgname = grub_malloc (vgname_len + 1); + if (!vgname) +@@ -368,8 +382,26 @@ grub_lvm_detect (grub_disk_t disk, + { + const char *iptr; + char *optr; +- lv->fullname = grub_malloc (sizeof ("lvm/") - 1 + 2 * vgname_len +- + 1 + 2 * s + 1); ++ ++ /* ++ * This is kind of hard to read with our safe (but rather ++ * baroque) math primatives, but it boils down to: ++ * ++ * sz0 = vgname_len * 2 + 1 + ++ * s * 2 + 1 + ++ * sizeof ("lvm/") - 1; ++ */ ++ grub_size_t sz0 = vgname_len, sz1 = s; ++ ++ if (grub_mul (sz0, 2, &sz0) || ++ grub_add (sz0, 1, &sz0) || ++ grub_mul (sz1, 2, &sz1) || ++ grub_add (sz1, 1, &sz1) || ++ grub_add (sz0, sz1, &sz0) || ++ grub_add (sz0, sizeof ("lvm/") - 1, &sz0)) ++ goto lvs_fail; ++ ++ lv->fullname = grub_malloc (sz0); + if (!lv->fullname) + goto lvs_fail; + +-- +2.23.0 + diff --git a/0243-efi-Fix-some-malformed-device-path-arithmetic-errors.patch b/0243-efi-Fix-some-malformed-device-path-arithmetic-errors.patch new file mode 100644 index 0000000000000000000000000000000000000000..4453d63d0562fe0bc626dd49283f7fd0782f2792 --- /dev/null +++ b/0243-efi-Fix-some-malformed-device-path-arithmetic-errors.patch @@ -0,0 +1,235 @@ +From 8088b8c61e7b45dd8d6115eac72bc718e261e6fe Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Sun, 19 Jul 2020 16:53:27 -0400 +Subject: [PATCH 23/27] efi: Fix some malformed device path arithmetic errors + +Several places we take the length of a device path and subtract 4 from +it, without ever checking that it's >= 4. There are also cases where +this kind of malformation will result in unpredictable iteration, +including treating the length from one dp node as the type in the next +node. These are all errors, no matter where the data comes from. + +This patch adds a checking macro, GRUB_EFI_DEVICE_PATH_VALID(), which +can be used in several places, and makes GRUB_EFI_NEXT_DEVICE_PATH() +return NULL and GRUB_EFI_END_ENTIRE_DEVICE_PATH() evaluate as true when +the length is too small. Additionally, it makes several places in the +code check for and return errors in these cases. + +Signed-off-by: Peter Jones +Reviewed-by: Daniel Kiper +--- + grub-core/kern/efi/efi.c | 64 +++++++++++++++++++++++++----- + grub-core/loader/efi/chainloader.c | 13 +++++- + grub-core/loader/i386/xnu.c | 9 +++-- + include/grub/efi/api.h | 14 ++++--- + 4 files changed, 79 insertions(+), 21 deletions(-) + +diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c +index ab133fe..d6f7bf0 100644 +--- a/grub-core/kern/efi/efi.c ++++ b/grub-core/kern/efi/efi.c +@@ -350,7 +350,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) + + dp = dp0; + +- while (1) ++ while (dp) + { + grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp); + grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp); +@@ -360,9 +360,15 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) + if (type == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE + && subtype == GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE) + { +- grub_efi_uint16_t len; +- len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4) +- / sizeof (grub_efi_char16_t)); ++ grub_efi_uint16_t len = GRUB_EFI_DEVICE_PATH_LENGTH (dp); ++ ++ if (len < 4) ++ { ++ grub_error (GRUB_ERR_OUT_OF_RANGE, ++ "malformed EFI Device Path node has length=%d", len); ++ return NULL; ++ } ++ len = (len - 4) / sizeof (grub_efi_char16_t); + filesize += GRUB_MAX_UTF8_PER_UTF16 * len + 2; + } + +@@ -378,7 +384,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) + if (!name) + return NULL; + +- while (1) ++ while (dp) + { + grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp); + grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp); +@@ -394,8 +400,15 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) + + *p++ = '/'; + +- len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4) +- / sizeof (grub_efi_char16_t)); ++ len = GRUB_EFI_DEVICE_PATH_LENGTH (dp); ++ if (len < 4) ++ { ++ grub_error (GRUB_ERR_OUT_OF_RANGE, ++ "malformed EFI Device Path node has length=%d", len); ++ return NULL; ++ } ++ ++ len = (len - 4) / sizeof (grub_efi_char16_t); + fp = (grub_efi_file_path_device_path_t *) dp; + /* According to EFI spec Path Name is NULL terminated */ + while (len > 0 && fp->path_name[len - 1] == 0) +@@ -470,7 +483,26 @@ grub_efi_duplicate_device_path (const grub_efi_device_path_t *dp) + ; + p = GRUB_EFI_NEXT_DEVICE_PATH (p)) + { +- total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p); ++ grub_size_t len = GRUB_EFI_DEVICE_PATH_LENGTH (p); ++ ++ /* ++ * In the event that we find a node that's completely garbage, for ++ * example if we get to 0x7f 0x01 0x02 0x00 ... (EndInstance with a size ++ * of 2), GRUB_EFI_END_ENTIRE_DEVICE_PATH() will be true and ++ * GRUB_EFI_NEXT_DEVICE_PATH() will return NULL, so we won't continue, ++ * and neither should our consumers, but there won't be any error raised ++ * even though the device path is junk. ++ * ++ * This keeps us from passing junk down back to our caller. ++ */ ++ if (len < 4) ++ { ++ grub_error (GRUB_ERR_OUT_OF_RANGE, ++ "malformed EFI Device Path node has length=%d", len); ++ return NULL; ++ } ++ ++ total_size += len; + if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p)) + break; + } +@@ -515,7 +547,7 @@ dump_vendor_path (const char *type, grub_efi_vendor_device_path_t *vendor) + void + grub_efi_print_device_path (grub_efi_device_path_t *dp) + { +- while (1) ++ while (GRUB_EFI_DEVICE_PATH_VALID (dp)) + { + grub_efi_uint8_t type = GRUB_EFI_DEVICE_PATH_TYPE (dp); + grub_efi_uint8_t subtype = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp); +@@ -987,7 +1019,10 @@ grub_efi_compare_device_paths (const grub_efi_device_path_t *dp1, + /* Return non-zero. */ + return 1; + +- while (1) ++ if (dp1 == dp2) ++ return 0; ++ ++ while (GRUB_EFI_DEVICE_PATH_VALID (dp1) && GRUB_EFI_DEVICE_PATH_VALID (dp2)) + { + grub_efi_uint8_t type1, type2; + grub_efi_uint8_t subtype1, subtype2; +@@ -1023,5 +1058,14 @@ grub_efi_compare_device_paths (const grub_efi_device_path_t *dp1, + dp2 = (grub_efi_device_path_t *) ((char *) dp2 + len2); + } + ++ /* ++ * There's no "right" answer here, but we probably don't want to call a valid ++ * dp and an invalid dp equal, so pick one way or the other. ++ */ ++ if (GRUB_EFI_DEVICE_PATH_VALID (dp1) && !GRUB_EFI_DEVICE_PATH_VALID (dp2)) ++ return 1; ++ else if (!GRUB_EFI_DEVICE_PATH_VALID (dp1) && GRUB_EFI_DEVICE_PATH_VALID (dp2)) ++ return -1; ++ + return 0; + } +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index 7365051..9a99f04 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -165,9 +165,18 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) + + size = 0; + d = dp; +- while (1) ++ while (d) + { +- size += GRUB_EFI_DEVICE_PATH_LENGTH (d); ++ grub_size_t len = GRUB_EFI_DEVICE_PATH_LENGTH (d); ++ ++ if (len < 4) ++ { ++ grub_error (GRUB_ERR_OUT_OF_RANGE, ++ "malformed EFI Device Path node has length=%d", len); ++ return NULL; ++ } ++ ++ size += len; + if ((GRUB_EFI_END_ENTIRE_DEVICE_PATH (d))) + break; + d = GRUB_EFI_NEXT_DEVICE_PATH (d); +diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c +index e9e1192..a700936 100644 +--- a/grub-core/loader/i386/xnu.c ++++ b/grub-core/loader/i386/xnu.c +@@ -515,14 +515,15 @@ grub_cmd_devprop_load (grub_command_t cmd __attribute__ ((unused)), + + devhead = buf; + buf = devhead + 1; +- dpstart = buf; ++ dp = dpstart = buf; + +- do ++ while (GRUB_EFI_DEVICE_PATH_VALID (dp) && buf < bufend) + { +- dp = buf; + buf = (char *) buf + GRUB_EFI_DEVICE_PATH_LENGTH (dp); ++ if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp)) ++ break; ++ dp = buf; + } +- while (!GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp) && buf < bufend); + + dev = grub_xnu_devprop_add_device (dpstart, (char *) buf + - (char *) dpstart); +diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h +index dec7b06..fc8a564 100644 +--- a/include/grub/efi/api.h ++++ b/include/grub/efi/api.h +@@ -666,6 +666,7 @@ typedef struct grub_efi_device_path grub_efi_device_path_protocol_t; + #define GRUB_EFI_DEVICE_PATH_TYPE(dp) ((dp)->type & 0x7f) + #define GRUB_EFI_DEVICE_PATH_SUBTYPE(dp) ((dp)->subtype) + #define GRUB_EFI_DEVICE_PATH_LENGTH(dp) ((dp)->length) ++#define GRUB_EFI_DEVICE_PATH_VALID(dp) ((dp) != NULL && GRUB_EFI_DEVICE_PATH_LENGTH (dp) >= 4) + + /* The End of Device Path nodes. */ + #define GRUB_EFI_END_DEVICE_PATH_TYPE (0xff & 0x7f) +@@ -674,13 +675,16 @@ typedef struct grub_efi_device_path grub_efi_device_path_protocol_t; + #define GRUB_EFI_END_THIS_DEVICE_PATH_SUBTYPE 0x01 + + #define GRUB_EFI_END_ENTIRE_DEVICE_PATH(dp) \ +- (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_END_DEVICE_PATH_TYPE \ +- && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp) \ +- == GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)) ++ (!GRUB_EFI_DEVICE_PATH_VALID (dp) || \ ++ (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_END_DEVICE_PATH_TYPE \ ++ && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp) \ ++ == GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE))) + + #define GRUB_EFI_NEXT_DEVICE_PATH(dp) \ +- ((grub_efi_device_path_t *) ((char *) (dp) \ +- + GRUB_EFI_DEVICE_PATH_LENGTH (dp))) ++ (GRUB_EFI_DEVICE_PATH_VALID (dp) \ ++ ? ((grub_efi_device_path_t *) \ ++ ((char *) (dp) + GRUB_EFI_DEVICE_PATH_LENGTH (dp))) \ ++ : NULL) + + /* Hardware Device Path. */ + #define GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE 1 +-- +2.23.0 + diff --git a/0244-efi-chainloader-Propagate-errors-from-copy_file_path.patch b/0244-efi-chainloader-Propagate-errors-from-copy_file_path.patch new file mode 100644 index 0000000000000000000000000000000000000000..df0d20c3a99b86038548b2c15f2b79f03649e990 --- /dev/null +++ b/0244-efi-chainloader-Propagate-errors-from-copy_file_path.patch @@ -0,0 +1,74 @@ +From 098058752e1cee7b457ff45562a81e756ab0b532 Mon Sep 17 00:00:00 2001 +From: Daniel Kiper +Date: Wed, 29 Jul 2020 13:38:31 +0200 +Subject: [PATCH 24/27] efi/chainloader: Propagate errors from copy_file_path() + +Without any error propagated to the caller, make_file_path() +would then try to advance the invalid device path node with +GRUB_EFI_NEXT_DEVICE_PATH(), which would fail, returning a NULL +pointer that would subsequently be dereferenced. Hence, propagate +errors from copy_file_path(). + +Signed-off-by: Chris Coulson +Reviewed-by: Daniel Kiper +--- + grub-core/loader/efi/chainloader.c | 19 +++++++++++++------ + 1 file changed, 13 insertions(+), 6 deletions(-) + +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index 9a99f04..813dc0e 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -115,7 +115,7 @@ grub_chainloader_boot (void) + return grub_errno; + } + +-static void ++static grub_err_t + copy_file_path (grub_efi_file_path_device_path_t *fp, + const char *str, grub_efi_uint16_t len) + { +@@ -127,7 +127,7 @@ copy_file_path (grub_efi_file_path_device_path_t *fp, + + path_name = grub_calloc (len, GRUB_MAX_UTF16_PER_UTF8 * sizeof (*path_name)); + if (!path_name) +- return; ++ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "failed to allocate path buffer"); + + size = grub_utf8_to_utf16 (path_name, len * GRUB_MAX_UTF16_PER_UTF8, + (const grub_uint8_t *) str, len, 0); +@@ -140,6 +140,7 @@ copy_file_path (grub_efi_file_path_device_path_t *fp, + fp->path_name[size++] = '\0'; + fp->header.length = size * sizeof (grub_efi_char16_t) + sizeof (*fp); + grub_free (path_name); ++ return GRUB_ERR_NONE; + } + + static grub_efi_device_path_t * +@@ -197,13 +198,19 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) + /* Fill the file path for the directory. */ + d = (grub_efi_device_path_t *) ((char *) file_path + + ((char *) d - (char *) dp)); +- copy_file_path ((grub_efi_file_path_device_path_t *) d, +- dir_start, dir_end - dir_start); ++ if (copy_file_path ((grub_efi_file_path_device_path_t *) d, ++ dir_start, dir_end - dir_start) != GRUB_ERR_NONE) ++ { ++fail: ++ grub_free(file_path); ++ return 0; ++ } + + /* Fill the file path for the file. */ + d = GRUB_EFI_NEXT_DEVICE_PATH (d); +- copy_file_path ((grub_efi_file_path_device_path_t *) d, +- dir_end + 1, grub_strlen (dir_end + 1)); ++ if (copy_file_path ((grub_efi_file_path_device_path_t *) d, ++ dir_end + 1, grub_strlen (dir_end + 1)) != GRUB_ERR_NONE) ++ goto fail; + + /* Fill the end of device path nodes. */ + d = GRUB_EFI_NEXT_DEVICE_PATH (d); +-- +2.23.0 + diff --git a/0245-efi-Fix-use-after-free-in-halt-reboot-path.patch b/0245-efi-Fix-use-after-free-in-halt-reboot-path.patch new file mode 100644 index 0000000000000000000000000000000000000000..cfc13ab057508f41ccd361bf6b34fd049ba4d5ea --- /dev/null +++ b/0245-efi-Fix-use-after-free-in-halt-reboot-path.patch @@ -0,0 +1,179 @@ +From f7bd9986f607a924bf23b813900a8595f2815f0c Mon Sep 17 00:00:00 2001 +From: Alexey Makhalov +Date: Mon, 20 Jul 2020 23:03:05 +0000 +Subject: [PATCH 25/27] efi: Fix use-after-free in halt/reboot path + +commit 92bfc33db984 ("efi: Free malloc regions on exit") +introduced memory freeing in grub_efi_fini(), which is +used not only by exit path but by halt/reboot one as well. +As result of memory freeing, code and data regions used by +modules, such as halt, reboot, acpi (used by halt) also got +freed. After return to module code, CPU executes, filled +by UEFI firmware (tested with edk2), 0xAFAFAFAF pattern as +a code. Which leads to #UD exception later. + +grub> halt +!!!! X64 Exception Type - 06(#UD - Invalid Opcode) CPU Apic ID - 00000000 !!!! +RIP - 0000000003F4EC28, CS - 0000000000000038, RFLAGS - 0000000000200246 +RAX - 0000000000000000, RCX - 00000000061DA188, RDX - 0A74C0854DC35D41 +RBX - 0000000003E10E08, RSP - 0000000007F0F860, RBP - 0000000000000000 +RSI - 00000000064DB768, RDI - 000000000832C5C3 +R8 - 0000000000000002, R9 - 0000000000000000, R10 - 00000000061E2E52 +R11 - 0000000000000020, R12 - 0000000003EE5C1F, R13 - 00000000061E0FF4 +R14 - 0000000003E10D80, R15 - 00000000061E2F60 +DS - 0000000000000030, ES - 0000000000000030, FS - 0000000000000030 +GS - 0000000000000030, SS - 0000000000000030 +CR0 - 0000000080010033, CR2 - 0000000000000000, CR3 - 0000000007C01000 +CR4 - 0000000000000668, CR8 - 0000000000000000 +DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000 +DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400 +GDTR - 00000000079EEA98 0000000000000047, LDTR - 0000000000000000 +IDTR - 0000000007598018 0000000000000FFF, TR - 0000000000000000 +FXSAVE_STATE - 0000000007F0F4C0 + +Proposal here is to continue to free allocated memory for +exit boot services path but keep it for halt/reboot path +as it won't be much security concern here. +Introduced GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY +loader flag to be used by efi halt/reboot path. + +Signed-off-by: Alexey Makhalov +Reviewed-by: Darren Kenny +Reviewed-by: Daniel Kiper +--- + grub-core/kern/arm/efi/init.c | 3 +++ + grub-core/kern/arm64/efi/init.c | 3 +++ + grub-core/kern/efi/efi.c | 3 ++- + grub-core/kern/efi/init.c | 1 - + grub-core/kern/i386/efi/init.c | 9 +++++++-- + grub-core/kern/ia64/efi/init.c | 9 +++++++-- + grub-core/kern/riscv/efi/init.c | 3 +++ + grub-core/lib/efi/halt.c | 3 ++- + include/grub/loader.h | 1 + + 9 files changed, 28 insertions(+), 7 deletions(-) + +diff --git a/grub-core/kern/arm/efi/init.c b/grub-core/kern/arm/efi/init.c +index 06df60e..40c3b46 100644 +--- a/grub-core/kern/arm/efi/init.c ++++ b/grub-core/kern/arm/efi/init.c +@@ -71,4 +71,7 @@ grub_machine_fini (int flags) + efi_call_1 (b->close_event, tmr_evt); + + grub_efi_fini (); ++ ++ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY)) ++ grub_efi_memory_fini (); + } +diff --git a/grub-core/kern/arm64/efi/init.c b/grub-core/kern/arm64/efi/init.c +index 6224999..5010cae 100644 +--- a/grub-core/kern/arm64/efi/init.c ++++ b/grub-core/kern/arm64/efi/init.c +@@ -57,4 +57,7 @@ grub_machine_fini (int flags) + return; + + grub_efi_fini (); ++ ++ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY)) ++ grub_efi_memory_fini (); + } +diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c +index d6f7bf0..c45c8f4 100644 +--- a/grub-core/kern/efi/efi.c ++++ b/grub-core/kern/efi/efi.c +@@ -157,7 +157,8 @@ grub_efi_get_loaded_image (grub_efi_handle_t image_handle) + void + grub_reboot (void) + { +- grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); ++ grub_machine_fini (GRUB_LOADER_FLAG_NORETURN | ++ GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY); + efi_call_4 (grub_efi_system_table->runtime_services->reset_system, + GRUB_EFI_RESET_COLD, GRUB_EFI_SUCCESS, 0, NULL); + for (;;) ; +diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c +index d1afa3a..2ffb520 100644 +--- a/grub-core/kern/efi/init.c ++++ b/grub-core/kern/efi/init.c +@@ -131,5 +131,4 @@ grub_efi_fini (void) + { + grub_efidisk_fini (); + grub_console_fini (); +- grub_efi_memory_fini (); + } +diff --git a/grub-core/kern/i386/efi/init.c b/grub-core/kern/i386/efi/init.c +index da499ab..deb2eac 100644 +--- a/grub-core/kern/i386/efi/init.c ++++ b/grub-core/kern/i386/efi/init.c +@@ -39,6 +39,11 @@ grub_machine_init (void) + void + grub_machine_fini (int flags) + { +- if (flags & GRUB_LOADER_FLAG_NORETURN) +- grub_efi_fini (); ++ if (!(flags & GRUB_LOADER_FLAG_NORETURN)) ++ return; ++ ++ grub_efi_fini (); ++ ++ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY)) ++ grub_efi_memory_fini (); + } +diff --git a/grub-core/kern/ia64/efi/init.c b/grub-core/kern/ia64/efi/init.c +index b5ecbd0..f196557 100644 +--- a/grub-core/kern/ia64/efi/init.c ++++ b/grub-core/kern/ia64/efi/init.c +@@ -70,6 +70,11 @@ grub_machine_init (void) + void + grub_machine_fini (int flags) + { +- if (flags & GRUB_LOADER_FLAG_NORETURN) +- grub_efi_fini (); ++ if (!(flags & GRUB_LOADER_FLAG_NORETURN)) ++ return; ++ ++ grub_efi_fini (); ++ ++ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY)) ++ grub_efi_memory_fini (); + } +diff --git a/grub-core/kern/riscv/efi/init.c b/grub-core/kern/riscv/efi/init.c +index 7eb1969..38795fe 100644 +--- a/grub-core/kern/riscv/efi/init.c ++++ b/grub-core/kern/riscv/efi/init.c +@@ -73,4 +73,7 @@ grub_machine_fini (int flags) + return; + + grub_efi_fini (); ++ ++ if (!(flags & GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY)) ++ grub_efi_memory_fini (); + } +diff --git a/grub-core/lib/efi/halt.c b/grub-core/lib/efi/halt.c +index 5859f04..29d4136 100644 +--- a/grub-core/lib/efi/halt.c ++++ b/grub-core/lib/efi/halt.c +@@ -28,7 +28,8 @@ + void + grub_halt (void) + { +- grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); ++ grub_machine_fini (GRUB_LOADER_FLAG_NORETURN | ++ GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY); + #if !defined(__ia64__) && !defined(__arm__) && !defined(__aarch64__) && \ + !defined(__riscv) + grub_acpi_halt (); +diff --git a/include/grub/loader.h b/include/grub/loader.h +index 7f82a49..b208642 100644 +--- a/include/grub/loader.h ++++ b/include/grub/loader.h +@@ -33,6 +33,7 @@ enum + { + GRUB_LOADER_FLAG_NORETURN = 1, + GRUB_LOADER_FLAG_PXE_NOT_UNLOAD = 2, ++ GRUB_LOADER_FLAG_EFI_KEEP_ALLOCATED_MEMORY = 4, + }; + + void EXPORT_FUNC (grub_loader_set) (grub_err_t (*boot) (void), +-- +2.23.0 + diff --git a/0246-loader-linux-Avoid-overflow-on-initrd-size-calculati.patch b/0246-loader-linux-Avoid-overflow-on-initrd-size-calculati.patch new file mode 100644 index 0000000000000000000000000000000000000000..fdfc666ed1d03c5dae85656891119e12f916f5a8 --- /dev/null +++ b/0246-loader-linux-Avoid-overflow-on-initrd-size-calculati.patch @@ -0,0 +1,28 @@ +From cb79f0455946270ddaf6b098d8cd71b39f840edc Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Fri, 24 Jul 2020 13:57:27 -0400 +Subject: [PATCH 26/27] loader/linux: Avoid overflow on initrd size calculation + +Signed-off-by: Peter Jones +Reviewed-by: Daniel Kiper +--- + grub-core/loader/linux.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c +index 471b214..4cd8c20 100644 +--- a/grub-core/loader/linux.c ++++ b/grub-core/loader/linux.c +@@ -151,8 +151,7 @@ grub_initrd_init (int argc, char *argv[], + initrd_ctx->nfiles = 0; + initrd_ctx->components = 0; + +- initrd_ctx->components = grub_zalloc (argc +- * sizeof (initrd_ctx->components[0])); ++ initrd_ctx->components = grub_calloc (argc, sizeof (initrd_ctx->components[0])); + if (!initrd_ctx->components) + return grub_errno; + +-- +2.23.0 + diff --git a/0247-linux-Fix-integer-overflows-in-initrd-size-handling.patch b/0247-linux-Fix-integer-overflows-in-initrd-size-handling.patch new file mode 100644 index 0000000000000000000000000000000000000000..6deb52d12205a4b0721043d1165bb540a2e803d7 --- /dev/null +++ b/0247-linux-Fix-integer-overflows-in-initrd-size-handling.patch @@ -0,0 +1,169 @@ +From 4edf7dc1bf561beb36fe245348a91d3bde699f15 Mon Sep 17 00:00:00 2001 +From: Colin Watson +Date: Sat, 25 Jul 2020 12:15:37 +0100 +Subject: [PATCH 27/27] linux: Fix integer overflows in initrd size handling + +These could be triggered by a crafted filesystem with very large files. + +Fixes: CVE-2020-15707 + +Signed-off-by: Colin Watson +Reviewed-by: Jan Setje-Eilers +Reviewed-by: Daniel Kiper +--- + grub-core/loader/linux.c | 74 +++++++++++++++++++++++++++++----------- + 1 file changed, 54 insertions(+), 20 deletions(-) + +diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c +index 4cd8c20..3fe390f 100644 +--- a/grub-core/loader/linux.c ++++ b/grub-core/loader/linux.c +@@ -4,6 +4,7 @@ + #include + #include + #include ++#include + + struct newc_head + { +@@ -98,13 +99,13 @@ free_dir (struct dir *root) + grub_free (root); + } + +-static grub_size_t ++static grub_err_t + insert_dir (const char *name, struct dir **root, +- grub_uint8_t *ptr) ++ grub_uint8_t *ptr, grub_size_t *size) + { + struct dir *cur, **head = root; + const char *cb, *ce = name; +- grub_size_t size = 0; ++ *size = 0; + while (1) + { + for (cb = ce; *cb == '/'; cb++); +@@ -130,14 +131,22 @@ insert_dir (const char *name, struct dir **root, + ptr = make_header (ptr, name, ce - name, + 040777, 0); + } +- size += ALIGN_UP ((ce - (char *) name) +- + sizeof (struct newc_head), 4); ++ if (grub_add (*size, ++ ALIGN_UP ((ce - (char *) name) ++ + sizeof (struct newc_head), 4), ++ size)) ++ { ++ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); ++ grub_free (n->name); ++ grub_free (n); ++ return grub_errno; ++ } + *head = n; + cur = n; + } + root = &cur->next; + } +- return size; ++ return GRUB_ERR_NONE; + } + + grub_err_t +@@ -172,26 +181,33 @@ grub_initrd_init (int argc, char *argv[], + eptr = grub_strchr (ptr, ':'); + if (eptr) + { ++ grub_size_t dir_size, name_len; ++ + initrd_ctx->components[i].newc_name = grub_strndup (ptr, eptr - ptr); +- if (!initrd_ctx->components[i].newc_name) ++ if (!initrd_ctx->components[i].newc_name || ++ insert_dir (initrd_ctx->components[i].newc_name, &root, 0, ++ &dir_size)) + { + grub_initrd_close (initrd_ctx); + return grub_errno; + } +- initrd_ctx->size +- += ALIGN_UP (sizeof (struct newc_head) +- + grub_strlen (initrd_ctx->components[i].newc_name), +- 4); +- initrd_ctx->size += insert_dir (initrd_ctx->components[i].newc_name, +- &root, 0); ++ name_len = grub_strlen (initrd_ctx->components[i].newc_name); ++ if (grub_add (initrd_ctx->size, ++ ALIGN_UP (sizeof (struct newc_head) + name_len, 4), ++ &initrd_ctx->size) || ++ grub_add (initrd_ctx->size, dir_size, &initrd_ctx->size)) ++ goto overflow; + newc = 1; + fname = eptr + 1; + } + } + else if (newc) + { +- initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head) +- + sizeof ("TRAILER!!!") - 1, 4); ++ if (grub_add (initrd_ctx->size, ++ ALIGN_UP (sizeof (struct newc_head) ++ + sizeof ("TRAILER!!!") - 1, 4), ++ &initrd_ctx->size)) ++ goto overflow; + free_dir (root); + root = 0; + newc = 0; +@@ -207,19 +223,29 @@ grub_initrd_init (int argc, char *argv[], + initrd_ctx->nfiles++; + initrd_ctx->components[i].size + = grub_file_size (initrd_ctx->components[i].file); +- initrd_ctx->size += initrd_ctx->components[i].size; ++ if (grub_add (initrd_ctx->size, initrd_ctx->components[i].size, ++ &initrd_ctx->size)) ++ goto overflow; + } + + if (newc) + { + initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4); +- initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head) +- + sizeof ("TRAILER!!!") - 1, 4); ++ if (grub_add (initrd_ctx->size, ++ ALIGN_UP (sizeof (struct newc_head) ++ + sizeof ("TRAILER!!!") - 1, 4), ++ &initrd_ctx->size)) ++ goto overflow; + free_dir (root); + root = 0; + } + + return GRUB_ERR_NONE; ++ ++ overflow: ++ free_dir (root); ++ grub_initrd_close (initrd_ctx); ++ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected")); + } + + grub_size_t +@@ -260,8 +286,16 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, + + if (initrd_ctx->components[i].newc_name) + { +- ptr += insert_dir (initrd_ctx->components[i].newc_name, +- &root, ptr); ++ grub_size_t dir_size; ++ ++ if (insert_dir (initrd_ctx->components[i].newc_name, &root, ptr, ++ &dir_size)) ++ { ++ free_dir (root); ++ grub_initrd_close (initrd_ctx); ++ return grub_errno; ++ } ++ ptr += dir_size; + ptr = make_header (ptr, initrd_ctx->components[i].newc_name, + grub_strlen (initrd_ctx->components[i].newc_name), + 0100777, +-- +2.23.0 + diff --git a/0248-linuxefi-fail-kernel-validation-without-shim-protoco.patch b/0248-linuxefi-fail-kernel-validation-without-shim-protoco.patch new file mode 100644 index 0000000000000000000000000000000000000000..66fbfd94ac4e70d94964a36d4e166e48c3c831a1 --- /dev/null +++ b/0248-linuxefi-fail-kernel-validation-without-shim-protoco.patch @@ -0,0 +1,88 @@ +From b01dc9aaedb5a5e91e2ca10748fce65406d657c0 Mon Sep 17 00:00:00 2001 +From: Fedora Ninjas +Date: Mon, 10 Aug 2020 14:54:34 +0800 +Subject: [PATCH 7/7] linuxefi: fail kernel validation without shim protocol. + +If certificates that signed grub are installed into db, grub can be +booted directly. It will then boot any kernel without signature +validation. The booted kernel will think it was booted in secureboot +mode and will implement lockdown, yet it could have been tampered. + +This version of the patch skips calling verification, when booted +without secureboot. And is indented with gnu ident. + +CVE-2020-15705 + +Reported-by: Mathieu Trudel-Lapierre +Signed-off-by: Dimitri John Ledkov +Signed-off-by: Baogen Shang +--- + grub-core/loader/arm64/linux.c | 12 ++++++++---- + grub-core/loader/efi/linux.c | 1 + + grub-core/loader/i386/efi/linux.c | 13 ++++++++----- + 3 files changed, 17 insertions(+), 9 deletions(-) + +diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c +index 8791b35..a18c487 100644 +--- a/grub-core/loader/arm64/linux.c ++++ b/grub-core/loader/arm64/linux.c +@@ -383,11 +383,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + + grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); + +- rc = grub_linuxefi_secure_validate (kernel_addr, kernel_size); +- if (rc < 0) ++ if (grub_efi_secure_boot ()) + { +- grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), argv[0]); +- goto fail; ++ rc = grub_linuxefi_secure_validate (kernel_addr, kernel_size); ++ if (rc <= 0) ++ { ++ grub_error (GRUB_ERR_INVALID_COMMAND, ++ N_("%s has invalid signature"), argv[0]); ++ goto fail; ++ } + } + + pe = (void *)((unsigned long)kernel_addr + lh.hdr_offset); +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index e09f824..927d89a 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -33,6 +33,7 @@ struct grub_efi_shim_lock + }; + typedef struct grub_efi_shim_lock grub_efi_shim_lock_t; + ++// Returns 1 on success, -1 on error, 0 when not available + int + grub_linuxefi_secure_validate (void *data, grub_uint32_t size) + { +diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c +index e5b2736..e613115 100644 +--- a/grub-core/loader/i386/efi/linux.c ++++ b/grub-core/loader/i386/efi/linux.c +@@ -301,12 +301,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + +- rc = grub_linuxefi_secure_validate (kernel, filelen); +- if (rc < 0) ++ if (grub_efi_secure_boot ()) + { +- grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), +- argv[0]); +- goto fail; ++ rc = grub_linuxefi_secure_validate (kernel, filelen); ++ if (rc <= 0) ++ { ++ grub_error (GRUB_ERR_INVALID_COMMAND, ++ N_("%s has invalid signature"), argv[0]); ++ goto fail; ++ } + } + + lh = (struct linux_i386_kernel_header *)kernel; +-- +1.8.3.1 + diff --git a/20-grub.install b/20-grub.install index eda11d881a786b97cfb38879582a6d0bdb306d3a..8ae388530da12974996958e87554f00024152805 100644 --- a/20-grub.install +++ b/20-grub.install @@ -16,14 +16,15 @@ KERNEL_DIR="${KERNEL_IMAGE%/*}" MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID -# Remove it, since for grub2 the images are always installed in /boot -rm -rf "${BOOT_DIR_ABS%/*}" +# If ${BOOT_DIR_ABS} exists, some other boot loader is active. +[[ -d "${BOOT_DIR_ABS}" ]] && exit 0 BLS_DIR="/boot/loader/entries" mkbls() { local kernelver=$1 && shift local datetime=$1 && shift + local kernelopts=$1 && shift local debugname="" local debugid="" @@ -42,8 +43,7 @@ title ${NAME} (${kernelver}) ${VERSION}${debugname} version ${kernelver}${debugid} linux /vmlinuz-${kernelver} initrd /initramfs-${kernelver}.img -options \$kernelopts -id ${ID}-${datetime}-${kernelver} +options ${kernelopts} grub_users \$grub_users grub_arg --unrestricted grub_class kernel${flavor} @@ -62,6 +62,7 @@ case "$COMMAND" in "$KERNEL_DIR"/dtb do [[ -e "$i" ]] || continue + rm -f "/boot/${i##*/}-${KERNEL_VERSION}" cp -aT "$i" "/boot/${i##*/}-${KERNEL_VERSION}" command -v restorecon &>/dev/null && \ restorecon -R "/boot/${i##*/}-${KERNEL_VERSION}" @@ -69,6 +70,7 @@ case "$COMMAND" in # hmac is .vmlinuz-.hmac so needs a special treatment i="$KERNEL_DIR/.${KERNEL_IMAGE##*/}.hmac" if [[ -e "$i" ]]; then + rm -f "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac" cp -a "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac" command -v restorecon &>/dev/null && \ restorecon "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac" @@ -76,38 +78,70 @@ case "$COMMAND" in fi if [[ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]] || [[ ! -f /sbin/new-kernel-pkg ]]; then - [[ -d "$BLS_DIR" ]] || mkdir -m 0700 -p "$BLS_DIR" - BLS_TARGET="${BLS_DIR}/${MACHINE_ID}-${KERNEL_VERSION}.conf" - if [[ -f "${KERNEL_DIR}/bls.conf" ]]; then - cp -aT "${KERNEL_DIR}/bls.conf" "${BLS_TARGET}" || exit $? + if [[ -f /etc/kernel/cmdline ]]; then + read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline + elif [[ -f /usr/lib/kernel/cmdline ]]; then + read -r -d '' -a BOOT_OPTIONS < /usr/lib/kernel/cmdline else - mkbls "${KERNEL_VERSION}" \ - "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${KERNEL_DIR}")")" \ - >"${BLS_TARGET}" + declare -a BOOT_OPTIONS + + read -r -d '' -a line < /proc/cmdline + for i in "${line[@]}"; do + [[ "${i#initrd=*}" != "$i" ]] && continue + [[ "${i#BOOT_IMAGE=*}" != "$i" ]] && continue + BOOT_OPTIONS+=("$i") + done fi + eval "$(grub2-get-kernel-settings)" || true + [[ -d "$BLS_DIR" ]] || mkdir -m 0700 -p "$BLS_DIR" + BLS_ID="${MACHINE_ID}-${KERNEL_VERSION}" + BLS_TARGET="${BLS_DIR}/${BLS_ID}.conf" + mkbls "${KERNEL_VERSION}" \ + "$(date -u +%Y%m%d%H%M%S -d "$(stat -c '%y' "${KERNEL_DIR}")")" \ + "${BOOT_OPTIONS[*]}" >"${BLS_TARGET}" + command -v restorecon &>/dev/null && restorecon -R "${BLS_TARGET}" + LINUX="$(grep '^linux[ \t]' "${BLS_TARGET}" | sed -e 's,^linux[ \t]*,,')" INITRD="$(grep '^initrd[ \t]' "${BLS_TARGET}" | sed -e 's,^initrd[ \t]*,,')" LINUX_RELPATH="$(grub2-mkrelpath /boot${LINUX})" BOOTPREFIX="$(dirname ${LINUX_RELPATH})" + ROOTPREFIX="$(dirname "/boot${LINUX}")" if [[ $LINUX != $LINUX_RELPATH ]]; then sed -i -e "s,^linux.*,linux ${BOOTPREFIX}${LINUX},g" "${BLS_TARGET}" sed -i -e "s,^initrd.*,initrd ${BOOTPREFIX}${INITRD},g" "${BLS_TARGET}" fi - eval "$(grub2-get-kernel-settings)" || true + if [[ "$KERNEL_VERSION" == *\+* ]] && [ "x$GRUB_DEFAULT_TO_DEBUG" != "xtrue" ]; then + GRUB_UPDATE_DEFAULT_KERNEL=false + fi + + if [ "x$GRUB_UPDATE_DEFAULT_KERNEL" = "xtrue" ]; then + NEWDEFAULT="${BLS_ID}" + fi + if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then - ARCH="$(uname -m)" - BLS_DEBUG="$(echo ${BLS_TARGET} | sed -e "s/\.${ARCH}/-debug.${ARCH}/")" + BLS_DEBUG="$(echo ${BLS_TARGET} | sed -e "s/${KERNEL_VERSION}/${KERNEL_VERSION}~debug/")" cp -aT "${BLS_TARGET}" "${BLS_DEBUG}" TITLE="$(grep '^title[ \t]' "${BLS_DEBUG}" | sed -e 's/^title[ \t]*//')" - BLSID="$(grep '^id[ \t]' "${BLS_DEBUG}" | sed -e "s/\.${ARCH}/-debug.${ARCH}/")" + OPTIONS="$(echo "${BOOT_OPTIONS[*]} ${GRUB_CMDLINE_LINUX_DEBUG}" | sed -e 's/\//\\\//g')" sed -i -e "s/^title.*/title ${TITLE}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${BLS_DEBUG}" - sed -i -e "s/^id.*/${BLSID}/" "${BLS_DEBUG}" - sed -i -e "s/^options.*/options \$kernelopts ${GRUB_CMDLINE_LINUX_DEBUG}/" "${BLS_DEBUG}" - fi + sed -i -e "s/^options.*/options ${OPTIONS}/" "${BLS_DEBUG}" + if [ -n "$NEWDEFAULT" -a "x$GRUB_DEFAULT_TO_DEBUG" = "xtrue" ]; then + NEWDEFAULT="${BLS_DEBUG_ID}" + fi + fi + if [ -n "$NEWDEFAULT" ]; then + grub2-editenv - set "saved_entry=${NEWDEFAULT}" + fi + # this probably isn't the best place to do this, but it will do for now. + if [ -e "${ROOTPREFIX}${INITRD}" -a -e "${ROOTPREFIX}${LINUX}" -a \ + "${ROOTPREFIX}${INITRD}" -ot "${ROOTPREFIX}${LINUX}" -a \ + -x /usr/lib/kernel/install.d/50-dracut.install ]; then + rm -f "${ROOTPREFIX}${INITRD}" + fi exit 0 fi @@ -120,9 +154,8 @@ case "$COMMAND" in remove) if [[ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]] || [[ ! -f /sbin/new-kernel-pkg ]]; then - ARCH="$(uname -m)" BLS_TARGET="${BLS_DIR}/${MACHINE_ID}-${KERNEL_VERSION}.conf" - BLS_DEBUG="$(echo ${BLS_TARGET} | sed -e "s/\.${ARCH}/-debug.${ARCH}/")" + BLS_DEBUG="$(echo ${BLS_TARGET} | sed -e "s/${KERNEL_VERSION}/${KERNEL_VERSION}~debug/")" rm -f "${BLS_TARGET}" "${BLS_DEBUG}" for i in vmlinuz System.map config zImage.stub dtb; do diff --git a/99-grub-mkconfig.install b/99-grub-mkconfig.install new file mode 100755 index 0000000000000000000000000000000000000000..d9686b51a22f01e8d2a3133e33373771d890543c --- /dev/null +++ b/99-grub-mkconfig.install @@ -0,0 +1,59 @@ +#!/bin/bash + +if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then + exit 0 +fi + +# PV and PVH Xen DomU guests boot with pygrub that doesn't have BLS support, +# also Xen Dom0 use the menuentries from 20_linux_xen and not the ones from +# 10_linux. So BLS support needs to be disabled for both Xen Dom0 and DomU. +if [[ -e /sys/hypervisor/type ]] && grep -q "^xen$" /sys/hypervisor/type; then + RUN_MKCONFIG=true + DISABLE_BLS=true +fi + +ARCH=$(uname -m) +# Older ppc64le OPAL firmware (petitboot version < 1.8.0) don't have BLS support +# so grub2-mkconfig has to be run to generate a config with menuentry commands. +if [[ $ARCH = "ppc64le" ]] && [ -d /sys/firmware/opal ]; then + + petitboot_path="/sys/firmware/devicetree/base/ibm,firmware-versions/petitboot" + + if test -e ${petitboot_path}; then + read -r -d '' petitboot_version < ${petitboot_path} + petitboot_version="$(echo ${petitboot_version//v})" + major_version="$(echo ${petitboot_version} | cut -d . -f1)" + minor_version="$(echo ${petitboot_version} | cut -d . -f2)" + + if test -z ${petitboot_version} || test ${major_version} -lt 1 || \ + test ${major_version} -eq 1 -a ${minor_version} -lt 8; then + RUN_MKCONFIG=true + fi + else + RUN_MKCONFIG=true + fi +fi + +if [[ $DISABLE_BLS = "true" ]]; then + if grep -q '^GRUB_ENABLE_BLSCFG="*true"*\s*$' /etc/default/grub; then + sed -i 's/^GRUB_ENABLE_BLSCFG=.*/GRUB_ENABLE_BLSCFG=false/' /etc/default/grub + fi +fi + +# A traditional grub configuration file needs to be generated only in the case when +# the bootloaders are not capable of populating a menu entry from the BLS fragments. +if [[ $RUN_MKCONFIG != "true" ]]; then + exit 0 +fi + +[[ -f /etc/default/grub ]] && . /etc/default/grub + +COMMAND="$1" + +case "$COMMAND" in + add|remove) + grub2-mkconfig --no-grubenv-update -o /boot/grub2/grub.cfg >& /dev/null + ;; + *) + ;; +esac diff --git a/Cope-with-being-on-a-ZFS-root-dataset.patch b/Cope-with-being-on-a-ZFS-root-dataset.patch deleted file mode 100644 index e249f81eeca4e88e5d006435bc9eed17677d258d..0000000000000000000000000000000000000000 --- a/Cope-with-being-on-a-ZFS-root-dataset.patch +++ /dev/null @@ -1,52 +0,0 @@ -From e720eef6a69bc4acc767d9a4cf8bc939b8b98e11 Mon Sep 17 00:00:00 2001 -From: Colin Watson -Date: Mon, 29 Oct 2018 12:33:37 +0000 -Subject: [PATCH 201/270] Cope with / being on a ZFS root dataset -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -If / is on the root dataset in a ZFS pool, then ${bootfs} will be set to -"/" (whereas if it is on a non-root dataset, there will be no trailing -slash). Passing "root=ZFS=${rpool}/" will fail to boot, but -"root=ZFS=${rpool}" works fine, so strip the trailing slash. - -Fixes: https://savannah.gnu.org/bugs/?52746 - -Signed-off-by: Colin Watson -Tested-by: Fejes József -Reviewed-by: Daniel Kiper ---- - util/grub.d/10_linux.in | 2 +- - util/grub.d/20_linux_xen.in | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 61ebd7d..4532266 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -73,7 +73,7 @@ case x"$GRUB_FS" in - xzfs) - rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` - bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`" -- LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}" -+ LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}" - ;; - esac - -diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in -index e8143b0..d22626e 100644 ---- a/util/grub.d/20_linux_xen.in -+++ b/util/grub.d/20_linux_xen.in -@@ -81,7 +81,7 @@ case x"$GRUB_FS" in - xzfs) - rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` - bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`" -- LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}" -+ LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}" - ;; - esac - --- -1.8.3.1 - diff --git a/ahci-Increase-time-out-from-10-s-to-32-s.patch b/ahci-Increase-time-out-from-10-s-to-32-s.patch deleted file mode 100644 index 55a4ccf052c1b4384b463d58c0f2cabfefce95be..0000000000000000000000000000000000000000 --- a/ahci-Increase-time-out-from-10-s-to-32-s.patch +++ /dev/null @@ -1,61 +0,0 @@ -From d62cafcf357f9103d9aea6eb4702b862dc67659a Mon Sep 17 00:00:00 2001 -From: Paul Menzel -Date: Thu, 9 Aug 2018 18:10:51 +0200 -Subject: [PATCH 173/270] ahci: Increase time-out from 10 s to 32 s - -This is a cryptographically signed message in MIME format. - -Date: Thu, 9 Aug 2018 07:27:35 +0200 - -Currently, the GRUB payload for coreboot does not detect the Western -Digital hard disk WDC WD20EARS-60M AB51 connected to the ASRock E350M1, -as that takes over ten seconds to spin up. - -``` -disk/ahci.c:533: port 0, err: 0 -disk/ahci.c:539: port 0, err: 0 -disk/ahci.c:543: port 0, err: 0 -disk/ahci.c:549: port 0, offset: 120, tfd:80, CMD: 6016 -disk/ahci.c:552: port 0, err: 0 -disk/ahci.c:563: port 0, offset: 120, tfd:80, CMD: 6016 -disk/ahci.c:566: port: 0, err: 0 -disk/ahci.c:593: port 0 is busy -disk/ahci.c:621: cleaning up failed devs -``` - -GRUB detects the drive, when either unloading the module *ahci*, and -then loading it again, or when doing a warm reset. - -As the ten second time-out is too short, increase it to 32 seconds, -used by SeaBIOS. which detects the drive successfully. - -The AHCI driver in libpayload uses 30 seconds, and that time-out was -added in commit 354066e1 (libpayload: ahci: Increase timeout for -signature reading) with the description below. - -> We can't read the drives signature before it's ready, i.e. spun up. -> So set the timeout to the standard 30s. Also put a notice on the -> console, so the user knows why the signature reading failed. - -Signed-off-by: Paul Menzel -Reviewed-by: Daniel Kiper ---- - grub-core/disk/ahci.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c -index f2f6064..0e6d56c 100644 ---- a/grub-core/disk/ahci.c -+++ b/grub-core/disk/ahci.c -@@ -576,7 +576,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, - grub_ahci_readwrite_real (dev, &parms2, 1, 1);*/ - } - -- endtime = grub_get_time_ms () + 10000; -+ endtime = grub_get_time_ms () + 32000; - - while (grub_get_time_ms () < endtime) - { --- -1.8.3.1 - diff --git a/arm-Move-initrd-upper-to-leave-more-space-for-kernel.patch b/arm-Move-initrd-upper-to-leave-more-space-for-kernel.patch deleted file mode 100644 index a0bcfb57dfd0c3297d5ba28b595ee677f4efca0b..0000000000000000000000000000000000000000 --- a/arm-Move-initrd-upper-to-leave-more-space-for-kernel.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 748e544fd0eb5fb618c4613f69612bc8c2eb65b6 Mon Sep 17 00:00:00 2001 -From: Guillaume GARDET -Date: Tue, 29 Jan 2019 09:09:45 +0100 -Subject: [PATCH 245/270] arm: Move initrd upper to leave more space for kernel - -This patch allows to have bigger kernels. If the kernel grows, then it will -overwrite the initrd when it is extracted. - -Signed-off-by: Guillaume GARDET -Acked-by: Alexander Graf -Reviewed-by: Daniel Kiper ---- - grub-core/loader/arm/linux.c | 2 +- - include/grub/arm/linux.h | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c -index 67ed793..5168491 100644 ---- a/grub-core/loader/arm/linux.c -+++ b/grub-core/loader/arm/linux.c -@@ -48,7 +48,7 @@ static const void *current_fdt; - typedef void (*kernel_entry_t) (int, unsigned long, void *); - - #define LINUX_PHYS_OFFSET (0x00008000) --#define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000) -+#define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x03000000) - #define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000) - - static grub_size_t -diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h -index 712ba17..d0b24d4 100644 ---- a/include/grub/arm/linux.h -+++ b/include/grub/arm/linux.h -@@ -42,7 +42,7 @@ struct linux_arm_kernel_header { - #if defined GRUB_MACHINE_UBOOT - # include - # define LINUX_ADDRESS (start_of_ram + 0x8000) --# define LINUX_INITRD_ADDRESS (start_of_ram + 0x02000000) -+# define LINUX_INITRD_ADDRESS (start_of_ram + 0x03000000) - # define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000) - # define grub_arm_firmware_get_boot_data grub_uboot_get_boot_data - # define grub_arm_firmware_get_machine_type grub_uboot_get_machine_type -@@ -50,7 +50,7 @@ struct linux_arm_kernel_header { - #include - #include - # define LINUX_ADDRESS (start_of_ram + 0x8000) --# define LINUX_INITRD_ADDRESS (start_of_ram + 0x02000000) -+# define LINUX_INITRD_ADDRESS (start_of_ram + 0x03000000) - # define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000) - static inline const void * - grub_arm_firmware_get_boot_data (void) --- -1.8.3.1 - diff --git a/gitignore b/gitignore index eca17bec9b82d69139241bc28faa7116d57dc8bc..819cd185d44b620d05eadad504ec0c171bbbf3df 100644 --- a/gitignore +++ b/gitignore @@ -1,3 +1,4 @@ +*~ 00_header 10_* 20_linux_xen @@ -6,11 +7,13 @@ 41_custom *.1 *.8 +ABOUT-NLS aclocal.m4 ahci_test ascii.bitmaps ascii.h autom4te.cache +build-aux build-grub-gen-asciih build-grub-gen-widthspec build-grub-mkfont @@ -42,6 +45,7 @@ gensymlist.sh gentrigtables gentrigtables.exe gettext_strings_test +/gnulib grub-bin2h /grub-bios-setup /grub-bios-setup.exe @@ -134,6 +138,7 @@ help_test *.image.exe include/grub/cpu include/grub/machine +INSTALL.grub install-sh lib/libgcrypt-grub libgrub_a_init.c @@ -142,6 +147,7 @@ libgrub_a_init.c lzocompress_test *.marker Makefile +/m4 *.mod mod-*.c missing @@ -155,7 +161,11 @@ pata_test *.pp po/*.mo po/grub.pot +po/Makefile.in.in +po/Makevars +po/Makevars.template po/POTFILES +po/Rules-quot po/stamp-po printf_test priority_queue_unit_test @@ -202,25 +212,7 @@ grub-core/*.module.exe grub-core/*.pp grub-core/kernel.img.bin util/bash-completion.d/grub -grub-core/gnulib/alloca.h -grub-core/gnulib/arg-nonnull.h -grub-core/gnulib/c++defs.h -grub-core/gnulib/charset.alias -grub-core/gnulib/configmake.h -grub-core/gnulib/float.h -grub-core/gnulib/getopt.h -grub-core/gnulib/langinfo.h -grub-core/gnulib/ref-add.sed -grub-core/gnulib/ref-del.sed -grub-core/gnulib/stdio.h -grub-core/gnulib/stdlib.h -grub-core/gnulib/string.h -grub-core/gnulib/strings.h -grub-core/gnulib/sys -grub-core/gnulib/unistd.h -grub-core/gnulib/warn-on-use.h -grub-core/gnulib/wchar.h -grub-core/gnulib/wctype.h +grub-core/lib/gnulib grub-core/rs_decoder.h widthspec.bin widthspec.h @@ -239,10 +231,6 @@ po/POTFILES-shell.in /grub-render-label /grub-glue-efi.exe /grub-render-label.exe -grub-core/gnulib/locale.h -grub-core/gnulib/unitypes.h -grub-core/gnulib/uniwidth.h -build-aux/test-driver /garbage-gen /garbage-gen.exe /grub-fs-tester diff --git a/grub-2.02.tar.xz b/grub-2.04.tar.xz similarity index 45% rename from grub-2.02.tar.xz rename to grub-2.04.tar.xz index 9ce84c1e2698594687d24a8ec8f7ff0af55deae5..88872047855a9de4bd93f3e3912ea4301137f49c 100644 Binary files a/grub-2.02.tar.xz and b/grub-2.04.tar.xz differ diff --git a/grub-core-loader-efi-fdt.c-Do-not-copy-random-memory.patch b/grub-core-loader-efi-fdt.c-Do-not-copy-random-memory.patch deleted file mode 100644 index 4ac6fe41344d329cb98c0c0bfa2b2ea392556fa8..0000000000000000000000000000000000000000 --- a/grub-core-loader-efi-fdt.c-Do-not-copy-random-memory.patch +++ /dev/null @@ -1,32 +0,0 @@ -From ad0ea7c444234ca519a3b528ddc70fff45810e25 Mon Sep 17 00:00:00 2001 -From: Heinrich Schuchardt -Date: Mon, 17 Dec 2018 22:00:24 +0100 -Subject: [PATCH 239/270] grub-core/loader/efi/fdt.c: Do not copy random memory - -We should not try to copy any memory area which is outside of the original -fdt. If this extra memory is controlled by a hypervisor this might end -with a crash. - -Signed-off-by: Heinrich Schuchardt -Reviewed-by: Leif Lindholm -Reviewed-by: Daniel Kiper ---- - grub-core/loader/efi/fdt.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c -index a18ca8c..ee9c559 100644 ---- a/grub-core/loader/efi/fdt.c -+++ b/grub-core/loader/efi/fdt.c -@@ -66,7 +66,7 @@ grub_fdt_load (grub_size_t additional_size) - - if (raw_fdt) - { -- grub_memmove (fdt, raw_fdt, size); -+ grub_memmove (fdt, raw_fdt, size - additional_size); - grub_fdt_set_totalsize (fdt, size); - } - else --- -1.8.3.1 - diff --git a/grub.macros b/grub.macros index d2163a35740fdadb2cbaa93ad584b19155bca5ba..aa6bfc0953ac1828ec3d1b55dff713b01a839bcf 100644 --- a/grub.macros +++ b/grub.macros @@ -29,28 +29,48 @@ -e 's/^/ -fno-strict-aliasing /' \\\ %{nil} -%global host_cflags %{expand:%%(echo %{optflags} | %{cflags_sed})} -%global target_cflags %{expand:%%(echo %{optflags} | %{cflags_sed})} - -%global legacy_target_cflags \\\ - %{expand:%%(echo %{target_cflags} | \\\ +%global host_cflags %{expand:%%(echo %{build_cflags} %{?_hardening_cflags} | %{cflags_sed})} +%global legacy_host_cflags \\\ + %{expand:%%(echo %{host_cflags} | \\\ %{cflags_sed} \\\ -e 's/-m64//g' \\\ -e 's/-mcpu=power[[:alnum:]]\\+/-mcpu=power6/g' \\\ )} -%global legacy_host_cflags \\\ - %{expand:%%(echo %{host_cflags} | \\\ +%global efi_host_cflags %{expand:%%(echo %{host_cflags})} + +%global target_cflags %{expand:%%(echo %{build_cflags} | %{cflags_sed})} +%global legacy_target_cflags \\\ + %{expand:%%(echo %{target_cflags} | \\\ %{cflags_sed} \\\ -e 's/-m64//g' \\\ -e 's/-mcpu=power[[:alnum:]]\\+/-mcpu=power6/g' \\\ )} - -%global efi_host_cflags %{expand:%%(echo %{host_cflags})} %global efi_target_cflags %{expand:%%(echo %{target_cflags})} +%global ldflags_sed \\\ + sed \\\ + -e 's/^$//' \\\ + %{nil} + +%global host_ldflags %{expand:%%(echo %{build_ldflags} %{?_hardening_ldflags} | %{ldflags_sed})} +%global legacy_host_ldflags \\\ + %{expand:%%(echo %{host_ldflags} | \\\ + %{ldflags_sed} \\\ + )} +%global efi_host_ldflags %{expand:%%(echo %{host_ldflags})} + +%global target_ldflags %{expand:%%(echo %{build_ldflags} -static | %{ldflags_sed})} +%global legacy_target_ldflags \\\ + %{expand:%%(echo %{target_ldflags} | \\\ + %{ldflags_sed} \\\ + )} +%global efi_target_ldflags %{expand:%%(echo %{target_ldflags})} + %global with_efi_arch 0 %global with_alt_efi_arch 0 %global with_legacy_arch 0 +%global with_emu_arch 0 +%global emuarch %{_arch} %global grubefiarch %{nil} %global grublegacyarch %{nil} @@ -64,6 +84,8 @@ %endif # ppc is always compiled 64 bit %ifarch ppc ppc64 ppc64le +# GRUB emu fails to build on ppc64le +%global with_emu_arch 0 %global target_cpu_name %{_arch} %global legacy_target_cpu_name powerpc %global legacy_package_arch %{_arch} @@ -74,7 +96,7 @@ %global efi_only aarch64 %{arm} -%global efi_arch x86_64 %{ix86} ia64 %{efi_only} +%global efi_arch x86_64 ia64 %{efi_only} %ifarch %{efi_arch} %global with_efi_arch 1 %else @@ -137,6 +159,7 @@ %endif %ifarch aarch64 +%global emuarch arm64 %global efiarch aa64 %global target_cpu_name aarch64 %global grub_target_name arm64-efi @@ -215,7 +238,7 @@ Requires(pre): dracut \ Requires(post): dracut \ %{expand:%%description %%{1}} \ %{desc} \ -This subpackage provides support for %%{1} systems. \ +This subpackage provides support for %{1} systems. \ \ %{expand:%%{?!buildsubdir:%%define buildsubdir grub-%%{1}-%{tarversion}}}\ %{expand:%%if 0%%{with_legacy_modules} \ @@ -290,7 +313,7 @@ This subpackage provides optional components of grub used with removeable media %setup -q -n grub-%{tarversion} \ rm -fv docs/*.info \ cp %{SOURCE6} .gitignore \ -cp %{SOURCE8} ./grub-core/tests/strtoull_test.c \ +cp %{SOURCE9} ./grub-core/tests/strtoull_test.c \ git init \ echo '![[:digit:]][[:digit:]]_*.in' > util/grub.d/.gitignore \ echo '!*.[[:digit:]]' > util/.gitignore \ @@ -301,31 +324,29 @@ git config gc.auto 0 \ rm -f configure \ git add . \ git commit -a -q -m "%{tarversion} baseline." \ -git apply --index --whitespace=nowarn %{SOURCE3} \ -git commit -a -q -m "%{tarversion} master." \ git am --whitespace=nowarn %%{patches} = 0.99-8 @@ -38,7 +38,7 @@ BuildRequires: pesign >= 0.99-8 BuildRequires: ccache %endif -Obsoletes: grub2 <= %{evr} grub < 1:0.98 +Obsoletes: grub2 <= %{evr} grub < 1:0.98 %if 0%{with_legacy_arch} Requires: %{name}-%{legacy_package_arch} = %{evr} @@ -49,16 +49,16 @@ Requires: %{name}-%{package_arch} = %{evr} %{nil} %description -GNU GRUB is a Multiboot boot loader. It was derived from GRUB, the GRand -Unified Bootloader, which was originally designed and implemented by +GNU GRUB is a Multiboot boot loader. It was derived from GRUB, the GRand +Unified Bootloader, which was originally designed and implemented by Erich Stefan Boleyn. -Briefly, a boot loader is the first software program that runs when a -computer starts. It is responsible for loading and transferring control -to the operating system kernel software (such as the Hurd or Linux). The +Briefly, a boot loader is the first software program that runs when a +computer starts. It is responsible for loading and transferring control +to the operating system kernel software (such as the Hurd or Linux). The kernel, in turn, initializes the rest of the operating system (e.g. GNU). -%package common +%package common Summary: common package for grub2 BuildArch: noarch Conflicts: grubby < 8.40-18 @@ -67,11 +67,11 @@ Conflicts: grubby < 8.40-18 Common package for grub2. %package tools -Summary: tools package for grub2 -Requires: grub2-common = %{epoch}:%{version}-%{release} -Requires: gettext os-prober which file -Requires(pre): dracut -Requires(post): dracut +Summary: tools package for grub2 +Requires: grub2-common = %{epoch}:%{version}-%{release} +Requires: gettext os-prober which file +Requires(pre): dracut +Requires(post): dracut Provides: grub2-tools-minimal grub2-tools-extra Obsoletes: grub2-tools-minimal grub2-tools-extra @@ -81,9 +81,9 @@ tools package for grub2. %ifarch x86_64 %package tools-efi Summary: efi packages for grub2-tools -Requires: grub2-common = %{epoch}:%{version}-%{release} -Requires: gettext os-prober which file -Obsoletes: grub2-tools < %{evr} +Requires: grub2-common = %{epoch}:%{version}-%{release} +Requires: gettext os-prober which file +Obsoletes: grub2-tools < %{evr} %description tools-efi Efi packages for grub2-tools. @@ -99,17 +99,31 @@ Efi packages for grub2-tools. %{expand:%define_legacy_variant %%{legacy_package_arch}} %endif -%package_help +%if 0%{with_emu_arch} +%package emu +Summary: GRUB user-space emulation. +Requires: %{name}-tools-minimal = %{epoch}:%{version}-%{release} + +%description emu +This subpackage provides the GRUB user-space emulation support of all platforms. + +%package emu-modules +Summary: GRUB user-space emulation modules. +Requires: %{name}-tools-minimal = %{epoch}:%{version}-%{release} + +%description emu-modules +This subpackage provides the GRUB user-space emulation modules. +%endif + +%package_help %prep %do_common_setup - %if 0%{with_efi_arch} mkdir grub-%{grubefiarch}-%{tarversion} grep -A100000 '# stuff "make" creates' .gitignore > grub-%{grubefiarch}-%{tarversion}/.gitignore cp %{SOURCE4} grub-%{grubefiarch}-%{tarversion}/unifont.pcf.gz git add grub-%{grubefiarch}-%{tarversion} - %endif %if 0%{with_alt_efi_arch} mkdir grub-%{grubaltefiarch}-%{tarversion} @@ -117,14 +131,18 @@ grep -A100000 '# stuff "make" creates' .gitignore > grub-%{grubaltefiarch}-%{tar cp %{SOURCE4} grub-%{grubaltefiarch}-%{tarversion}/unifont.pcf.gz git add grub-%{grubaltefiarch}-%{tarversion} %endif - %if 0%{with_legacy_arch} mkdir grub-%{grublegacyarch}-%{tarversion} grep -A100000 '# stuff "make" creates' .gitignore > grub-%{grublegacyarch}-%{tarversion}/.gitignore cp %{SOURCE4} grub-%{grublegacyarch}-%{tarversion}/unifont.pcf.gz git add grub-%{grublegacyarch}-%{tarversion} %endif - +%if 0%{with_emu_arch} +mkdir grub-emu-%{tarversion} +grep -A100000 '# stuff "make" creates' .gitignore > grub-emu-%{tarversion}/.gitignore +cp %{SOURCE4} grub-emu-%{tarversion}/unifont.pcf.gz +git add grub-emu-%{tarversion} +%endif git commit -m "After making subdirs" %build @@ -137,6 +155,9 @@ git commit -m "After making subdirs" %if 0%{with_legacy_arch} %{expand:%do_legacy_build %%{grublegacyarch}} %endif +%if 0%{with_emu_arch} +%{expand:%do_emu_build} +%endif makeinfo --info --no-split -I docs -o docs/grub-dev.info docs/grub-dev.texi makeinfo --info --no-split -I docs -o docs/grub.info docs/grub.texi makeinfo --html --no-split -I docs -o docs/grub-dev.html docs/grub-dev.texi @@ -160,17 +181,21 @@ set -e %if 0%{with_legacy_arch} %{expand:%do_legacy_install %%{grublegacyarch} %%{alt_grub_target_name} 0%{with_efi_arch}} %endif - -rm -rf %{buildroot}%{_infodir}/dir -ln -s grub2-set-password %{buildroot}%{_sbindir}/grub2-setpassword -echo '.so man8/grub2-set-password.8' > %{buildroot}%{_datadir}/man/man8/%{name}-setpassword.8 +%if 0%{with_emu_arch} +%{expand:%do_emu_install %%{package_arch}} +%endif +rm -f $RPM_BUILD_ROOT%{_infodir}/dir +ln -s %{name}-set-password ${RPM_BUILD_ROOT}/%{_sbindir}/%{name}-setpassword +echo '.so man8/%{name}-set-password.8' > ${RPM_BUILD_ROOT}/%{_datadir}/man/man8/%{name}-setpassword.8 %ifnarch x86_64 -rm -vf %{buildroot}%{_bindir}/grub2-render-label -rm -vf %{buildroot}%{_sbindir}/grub2-bios-setup -rm -vf %{buildroot}%{_sbindir}/grub2-macbless +rm -vf ${RPM_BUILD_ROOT}/%{_bindir}/%{name}-render-label +rm -vf ${RPM_BUILD_ROOT}/%{_sbindir}/%{name}-bios-setup +rm -vf ${RPM_BUILD_ROOT}/%{_sbindir}/%{name}-macbless %endif +%find_lang grub + install -d %{buildroot}%{_sysconfdir}/prelink.conf.d/ pushd %{buildroot}%{_sysconfdir}/prelink.conf.d/ @@ -188,10 +213,11 @@ popd mkdir -p %{buildroot}%{_datadir}/grub/themes -install -d -m 0755 %{buildroot}%{_prefix}/lib/kernel/install.d -install -m 0755 %{SOURCE9} %{buildroot}%{_prefix}/lib/kernel/install.d +install -d -m 0755 %{buildroot}%{_prefix}/lib/kernel/install.d/ +install -m 0755 %{SOURCE10} %{buildroot}%{_prefix}/lib/kernel/install.d +install -m 0755 %{SOURCE7} %{buildroot}%{_prefix}/lib/kernel/install.d -install -d -m 0755 %{buildroot}%{_sysconfdir}/kernel/install.d +install -d -m 0755 %{buildroot}%{_sysconfdir}/kernel/install.d/ install -m 0644 /dev/null %{buildroot}%{_sysconfdir}/kernel/install.d/20-grubby.install install -m 0644 /dev/null %{buildroot}%{_sysconfdir}/kernel/install.d/90-loaderentry.install @@ -206,30 +232,28 @@ ln -s ../grub-boot-indeterminate.service %{buildroot}%{_unitdir}/system-update.t install -d -m 0755 %{buildroot}%{_libexecdir}/installkernel cp -v %{SOURCE11} %{buildroot}%{_libexecdir}/installkernel -sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/installkernel,g" %{SOURCE12} \ - > %{buildroot}%{_sbindir}/installkernel - +sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/installkernel,g" %{SOURCE12} > %{buildroot}%{_sbindir}/installkernel %global finddebugroot "%{_builddir}/%{?buildsubdir}/debug" %global dip RPM_BUILD_ROOT=%{finddebugroot} %{__debug_install_post} -%define __debug_install_post ( \ - install -m 0755 -d %{finddebugroot}/usr \ - mv %{buildroot}%{_bindir} %{finddebugroot}%{_bindir} \ - mv %{buildroot}%{_sbindir} %{finddebugroot}%{_sbindir} \ - %{dip} \ - install -m 0755 -d %{buildroot}/usr/lib/ %{buildroot}/usr/src/ \ - cp -al %{finddebugroot}/usr/lib/debug/ \\\ - %{buildroot}/usr/lib/debug/ \ - cp -al %{finddebugroot}/usr/src/debug/ \\\ - %{buildroot}/usr/src/debug/ ) \ - mv %{finddebugroot}%{_bindir} %{buildroot}%{_bindir} \ - mv %{finddebugroot}%{_sbindir} %{buildroot}%{_sbindir} \ - %{nil} +%define __debug_install_post ( \ + install -m 0755 -d %{finddebugroot}/usr \ + mv %{buildroot}%{_bindir} %{finddebugroot}%{_bindir} \ + mv %{buildroot}%{_sbindir} %{finddebugroot}%{_sbindir} \ + %{dip} \ + install -m 0755 -d %{buildroot}/usr/lib/ %{buildroot}/usr/src/ \ + cp -al %{finddebugroot}/usr/lib/debug/ \\\ + %{buildroot}/usr/lib/debug/ \ + cp -al %{finddebugroot}/usr/src/debug/ \\\ + %{buildroot}/usr/src/debug/ ) \ + mv %{finddebugroot}%{_bindir} %{buildroot}%{_bindir} \ + mv %{finddebugroot}%{_sbindir} %{buildroot}%{_sbindir} \ + %{nil} %undefine buildsubdir -%pre tools +%pre tools if [ -f /boot/grub2/user.cfg ]; then if grep -q '^GRUB_PASSWORD=' /boot/grub2/user.cfg ; then sed -i 's/^GRUB_PASSWORD=/GRUB2_PASSWORD=/' /boot/grub2/user.cfg @@ -257,10 +281,11 @@ elif [ -f /etc/grub.d/01_users ] && \ fi fi -%post tools -if [ "$1" = 1 ]; then - /sbin/install-info --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz || : - /sbin/install-info --info-dir=%{_infodir} %{_infodir}/%{name}-dev.info.gz || : +%posttrans tools + +if [ -f /etc/default/grub ]; then + ! grep -q '^GRUB_ENABLE_BLSCFG=.*' /etc/default/grub && \ + /sbin/grub2-switch-to-blscfg --backup-suffix=.rpmsave &>/dev/null || : fi %triggerun -- grub2 < 1:1.99-4 @@ -281,13 +306,7 @@ mv -f /boot/grub2.tmp/*.mod \ /boot/grub2/ && rm -r /boot/grub2.tmp/ || : -%preun tools -if [ "$1" = 0 ]; then - /sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz || : - /sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/%{name}-dev.info.gz || : -fi - -%files common +%files common -f grub.lang %defattr(-,root,root) %license COPYING %dir /boot/grub2/themes/system @@ -299,17 +318,20 @@ fi %{_datarootdir}/grub/themes/ %attr(0700,root,root) %dir %{_sysconfdir}/grub.d %{_prefix}/lib/kernel/install.d/20-grub.install +%{_prefix}/lib/kernel/install.d/99-grub-mkconfig.install %{_sysconfdir}/kernel/install.d/*.install %{_libexecdir}/installkernel/installkernel-bls %dir %attr(0700,root,root) %{efi_esp_dir} %{_datadir}/locale/* -%files tools +%files tools %defattr(-,root,root) %{_sbindir}/grub2-* %exclude %{_sbindir}/grub2-set-bootflag %attr(4755, root, root) %{_sbindir}/grub2-set-bootflag %{_bindir}/grub2-* +%exclude %{_sbindir}/%{name}-macbless +%exclude %{_bindir}/%{name}-render-label %config %{_sysconfdir}/grub.d/??_* %exclude %{_sysconfdir}/grub.d/01_fallback_counting %attr(0644,root,root) %ghost %config(noreplace) %{_sysconfdir}/default/grub @@ -339,12 +361,12 @@ fi %endif %ifarch x86_64 -%files tools-efi -%defattr(-,root,root) +%files tools-efi %{_sbindir}/%{name}-macbless %{_bindir}/%{name}-render-label %endif + %if 0%{with_efi_arch} %{expand:%define_efi_variant_files %%{package_arch} %%{grubefiname} %%{grubeficdname} %%{grubefiarch} %%{target_cpu_name} %%{grub_target_name}} %endif @@ -355,31 +377,40 @@ fi %{expand:%define_legacy_variant_files %%{legacy_package_arch} %%{grublegacyarch}} %endif +%if 0%{with_emu_arch} +%files emu +%{_bindir}/%{name}-emu* + +%files emu-modules +%{_libdir}/grub/%{emuarch}-emu/* +%exclude %{_libdir}/grub/%{emuarch}-emu/*.module +%endif + %files help %defattr(-,root,root) %doc INSTALL NEWS README THANKS TODO docs/grub.html docs/grub-dev.html docs/font_char_metrics.png %{_datadir}/man/man* %changelog -* Mon Aug 10 2020 hanzhijun - 2.02-77 +* Fri Aug 7 2020 hanzhijun - 2.04-3 - Type:cves -- Id:CVE-2020-14308 CVE-2020-14309 CVE-2020-14310 CVE-2020-14311 CVE-2020-15706 CVE-2020-15707 +- Id:CVE-2020-10713 CVE-2020-14308 CVE-2020-14309 CVE-2020-14310 CVE-2020-14311 CVE-2020-15705 CVE-2020-15706 CVE-2020-15707 - SUG:NA -- DESC:fix CVE-2020-14308 CVE-2020-14309 CVE-2020-14310 CVE-2020-14311 CVE-2020-15706 CVE-2020-15707 +- DESC:fix CVE-2020-10713 CVE-2020-14308 CVE-2020-14309 CVE-2020-14310 CVE-2020-14311 CVE-2020-15705 CVE-2020-15706 CVE-2020-15707 -* Fri Jul 31 2020 openEuler Buildteam - 2.02-76 -- Type:cves -- Id:CVE-2020-10713 -- SUG:NA -- DESC:fix CVE-2020-10713 +* Mon Aug 3 2020 hanzhijun - 2.04-2 +- add CPPFLAGS -* Fri Jun 5 2020 fengtao - 2.02-75 -- remove sign for grub efi +* Sat Aug 1 2020 hanzhijun - 2.04-1 +- update to 2.0.4 + +* Fri Jul 17 2020 chenyaqiang - 2.02-75 +- remove repeated buildrequest packge “rpm-devel” in grub2.spec -* Mon May 25 2020 songnannan - 2.02-74 -- rebuild for the update packages +* Fri Apr 24 2020 fengtao - 2.02-74 +- exclude two cmd in grub2-tools -* Wed May 3 2020 songnannan - 2.02-73 +* Wed Mar 3 2020 songnannan - 2.02-73 - delete java-1.8.0-openjdk in buildrequires * Thu Feb 20 2020 openEuler Buildteam - 2.02-72 @@ -400,8 +431,7 @@ fi - SUG:NA - DESC:add the path for themes -* Tue Dec 3 2019 openEuler Buildteam - 2.02-69 -- Type:bugfix +* Tue Dec 3 2019 openEuler Buildteam - 2.02-69- Type:bugfix - Id:NA - SUG:NA - DESC:add config_for_secure file for gcc_secure diff --git a/grub2.yaml b/grub2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a35e29a5211a8cad4e1bf066bf8e9ee46ad9eaf4 --- /dev/null +++ b/grub2.yaml @@ -0,0 +1,4 @@ +version_control: git +src_repo: https://git.savannah.gnu.org/git/grub.git +tag_prefix: grub- +seperator: . diff --git a/normal-menu-Do-not-treat-error-values-as-key-presses.patch b/normal-menu-Do-not-treat-error-values-as-key-presses.patch deleted file mode 100644 index 731c7e65496a8d58e6b5c6b96b28ef0afb8d1f99..0000000000000000000000000000000000000000 --- a/normal-menu-Do-not-treat-error-values-as-key-presses.patch +++ /dev/null @@ -1,79 +0,0 @@ -From d3a3543a5666c1dd180ae6027948ca753dcffc18 Mon Sep 17 00:00:00 2001 -From: Paul Menzel -Date: Tue, 5 Feb 2019 17:29:13 +0100 -Subject: [PATCH 260/270] normal/menu: Do not treat error values as key presses -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Some terminals, like `grub-core/term/at_keyboard.c`, return `-1` in case -they are not ready yet. - - if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS))) - return -1; - -Currently, that is treated as a key press, and the menu time-out is -cancelled/cleared. This is unwanted, as the boot is stopped and the user -manually has to select a menu entry. Therefore, adapt the condition to -require the key value also to be greater than 0. - -`GRUB_TERM_NO_KEY` is defined as 0, so the condition could be collapsed -to greater or equal than (≥) 0, but the compiler will probably do that -for us anyway, so keep the cases separate for clarity. - -This is tested with coreboot, the GRUB default payload, and the -configuration file `grub.cfg` below. - -For GRUB: - - $ ./autogen.sh - $ ./configure --with-platform=coreboot - $ make -j`nproc` - $ make default_payload.elf - -For coreboot: - - $ more grub.cfg - serial --unit 0 --speed 115200 - set timeout=5 - - menuentry 'halt' { - halt - } - $ build/cbfstool build/coreboot.rom add-payload \ - -f /dev/shm/grub/default_payload.elf -n fallback/payload -c lzma - $ build/cbfstool build/coreboot.rom add -f grub.cfg -n etc/grub.cfg -t raw - $ qemu-system-x86_64 --version - QEMU emulator version 3.1.0 (Debian 1:3.1+dfsg-2+b1) - Copyright (c) 2003-2018 Fabrice Bellard and the QEMU Project developers - $ qemu-system-x86_64 -M pc -bios build/coreboot.rom -serial stdio -nic none - -Currently, the time-out is cancelled/cleared. With the commit, it is not. -With a small GRUB payload, this the problem is also reproducible on the -ASRock E350M1. - -Link: http://lists.gnu.org/archive/html/grub-devel/2019-01/msg00037.html - -Signed-off-by: Paul Menzel -Reviewed-by: Daniel Kiper ---- - grub-core/normal/menu.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index e7a83c2..d5e0c79 100644 ---- a/grub-core/normal/menu.c -+++ b/grub-core/normal/menu.c -@@ -698,7 +698,8 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) - - c = grub_getkey_noblock (); - -- if (c != GRUB_TERM_NO_KEY) -+ /* Negative values are returned on error. */ -+ if ((c != GRUB_TERM_NO_KEY) && (c > 0)) - { - if (timeout >= 0) - { --- -1.8.3.1 - diff --git a/ofnet-Fix-build-regression-in-grub_ieee1275_parse_bo.patch b/ofnet-Fix-build-regression-in-grub_ieee1275_parse_bo.patch deleted file mode 100644 index e345b07e0dbc2c7d1455ee0364a96687d2ba7f7e..0000000000000000000000000000000000000000 --- a/ofnet-Fix-build-regression-in-grub_ieee1275_parse_bo.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 29157553b7fb581fe81b9916f968127f19ef64f3 Mon Sep 17 00:00:00 2001 -From: Eric Snowberg -Date: Tue, 27 Nov 2018 15:17:26 -0800 -Subject: [PATCH 213/270] ofnet: Fix build regression in - grub_ieee1275_parse_bootpath() - -The grub_ieee1275_parse_bootpath() function (commit a661a32, ofnet: Initialize -structs in bootpath parser) introduces a build regression on SPARC: - -cc1: warnings being treated as errors -net/drivers/ieee1275/ofnet.c: In function 'grub_ieee1275_parse_bootpath': -net/drivers/ieee1275/ofnet.c:156: error: missing initializer -net/drivers/ieee1275/ofnet.c:156: error: (near initialization for 'client_addr.type') -net/drivers/ieee1275/ofnet.c:156: error: missing initializer -net/drivers/ieee1275/ofnet.c:156: error: (near initialization for 'gateway_addr.type') -net/drivers/ieee1275/ofnet.c:156: error: missing initializer -net/drivers/ieee1275/ofnet.c:156: error: (near initialization for 'subnet_mask.type') -net/drivers/ieee1275/ofnet.c:157: error: missing initializer -net/drivers/ieee1275/ofnet.c:157: error: (near initialization for 'hw_addr.type') -make[3]: *** [net/drivers/ieee1275/ofnet_module-ofnet.o] Error 1 - -Initialize the entire structure. - -More info can be found here: - http://lists.gnu.org/archive/html/grub-devel/2018-03/msg00034.html - -Signed-off-by: Eric Snowberg -Reviewed-by: Daniel Kiper ---- - grub-core/net/drivers/ieee1275/ofnet.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c -index 00abc64..ac4e62a 100644 ---- a/grub-core/net/drivers/ieee1275/ofnet.c -+++ b/grub-core/net/drivers/ieee1275/ofnet.c -@@ -153,8 +153,8 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, - char *comma_char = 0; - char *equal_char = 0; - grub_size_t field_counter = 0; -- grub_net_network_level_address_t client_addr = {}, gateway_addr = {}, subnet_mask = {}; -- grub_net_link_level_address_t hw_addr = {}; -+ grub_net_network_level_address_t client_addr = {0, {0}, 0}, gateway_addr = {0, {0}, 0}, subnet_mask = {0, {0}, 0}; -+ grub_net_link_level_address_t hw_addr = {0, {{0, 0, 0, 0, 0, 0}}}; - grub_net_interface_flags_t flags = 0; - struct grub_net_network_level_interface *inter = NULL; - grub_uint16_t vlantag = 0; --- -1.8.3.1 - diff --git a/ofnet-Initialize-structs-in-bootpath-parser.patch b/ofnet-Initialize-structs-in-bootpath-parser.patch deleted file mode 100644 index 062bb977a6413180df4d3ad0e3e9b8360428112c..0000000000000000000000000000000000000000 --- a/ofnet-Initialize-structs-in-bootpath-parser.patch +++ /dev/null @@ -1,41 +0,0 @@ -From a661a321c314d23cd2666c82cbb38d356c7956ba Mon Sep 17 00:00:00 2001 -From: Julian Andres Klode -Date: Mon, 3 Sep 2018 10:09:15 +0200 -Subject: [PATCH 176/270] ofnet: Initialize structs in bootpath parser - -Code later on checks if variables inside the struct are -0 to see if they have been set, like if there were addresses -in the bootpath. - -The variables were not initialized however, so the check -might succeed with uninitialized data, and a new interface -with random addresses and the same name is added. This causes -$net_default_mac to point to the random one, so, for example, -using that variable to load per-mac config files fails. - -Bug-Ubuntu: https://bugs.launchpad.net/bugs/1785859 - -Signed-off-by: Julian Andres Klode -Reviewed-by: Daniel Kiper ---- - grub-core/net/drivers/ieee1275/ofnet.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c -index 002446b..00abc64 100644 ---- a/grub-core/net/drivers/ieee1275/ofnet.c -+++ b/grub-core/net/drivers/ieee1275/ofnet.c -@@ -153,8 +153,8 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, - char *comma_char = 0; - char *equal_char = 0; - grub_size_t field_counter = 0; -- grub_net_network_level_address_t client_addr, gateway_addr, subnet_mask; -- grub_net_link_level_address_t hw_addr; -+ grub_net_network_level_address_t client_addr = {}, gateway_addr = {}, subnet_mask = {}; -+ grub_net_link_level_address_t hw_addr = {}; - grub_net_interface_flags_t flags = 0; - struct grub_net_network_level_interface *inter = NULL; - grub_uint16_t vlantag = 0; --- -1.8.3.1 - diff --git a/osdep-freebsd-Fix-partition-calculation-for-EBR-entr.patch b/osdep-freebsd-Fix-partition-calculation-for-EBR-entr.patch deleted file mode 100644 index 9dbf881a1c07ccd5aff3298aafff36a354591834..0000000000000000000000000000000000000000 --- a/osdep-freebsd-Fix-partition-calculation-for-EBR-entr.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 222cb8f6df4f0e5964a5dfcdc9a4eb9ad2e631a6 Mon Sep 17 00:00:00 2001 -From: James Clarke -Date: Tue, 26 Feb 2019 18:40:14 +0000 -Subject: [PATCH 266/270] osdep/freebsd: Fix partition calculation for EBR - entries - -For EBR partitions, "start" is the relative starting sector of the EBR -header itself, whereas "offset" is the relative starting byte of the -partition's contents, excluding the EBR header and any padding. Thus we -must use "offset", and divide by the sector size to convert to sectors. - -Fixes Debian bug #923253. - -Signed-off-by: James Clarke -Reviewed-by: Colin Watson -Reviewed-by: Daniel Kiper ---- - grub-core/osdep/freebsd/getroot.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/osdep/freebsd/getroot.c b/grub-core/osdep/freebsd/getroot.c -index ccc1d70..b1e8244 100644 ---- a/grub-core/osdep/freebsd/getroot.c -+++ b/grub-core/osdep/freebsd/getroot.c -@@ -338,8 +338,8 @@ grub_util_follow_gpart_up (const char *name, grub_disk_addr_t *off_out, char **n - grub_util_follow_gpart_up (name_tmp, &off, name_out); - free (name_tmp); - LIST_FOREACH (config, &provider->lg_config, lg_config) -- if (strcasecmp (config->lg_name, "start") == 0) -- off += strtoull (config->lg_val, 0, 10); -+ if (strcasecmp (config->lg_name, "offset") == 0) -+ off += strtoull (config->lg_val, 0, 10) / provider->lg_sectorsize; - if (off_out) - *off_out = off; - return; --- -1.8.3.1 - diff --git a/release-to-master.patch b/release-to-master.patch deleted file mode 100644 index a1b6e6a09f5929cc473bae9c68c67b76af104ff1..0000000000000000000000000000000000000000 --- a/release-to-master.patch +++ /dev/null @@ -1,16760 +0,0 @@ -diff --git a/configure.ac b/configure.ac -index edd184154f7e9aad556b6437b8ec22bc79d5a057..c7888e40f6695ee23a43fb98420d6cbcd3d86622 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -31,7 +31,7 @@ dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables - dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are - dnl used for the target type. See INSTALL for full list of variables. - --AC_INIT([GRUB],[2.02],[bug-grub@gnu.org]) -+AC_INIT([GRUB],[2.03],[bug-grub@gnu.org]) - - AC_CONFIG_AUX_DIR([build-aux]) - -@@ -167,6 +167,7 @@ case "$target_cpu"-"$platform" in - mipsel-fuloong) platform=loongson ;; - mipsel-loongson) ;; - arm-uboot) ;; -+ arm-coreboot) ;; - arm-efi) ;; - arm64-efi) ;; - *-emu) ;; -@@ -203,7 +204,8 @@ case "$host_os" in - esac - - case "$host_os" in -- cygwin | windows* | mingw32*) have_exec=n ;; -+ cygwin) have_exec=y ;; -+ windows* | mingw32*) have_exec=n ;; - aros*) have_exec=n ;; - *) have_exec=y;; - esac -@@ -373,7 +375,10 @@ case "$host_os" in - ;; - *) - AC_CHECK_SIZEOF(off_t) -- test x"$ac_cv_sizeof_off_t" = x8 || AC_MSG_ERROR([Large file support is required]);; -+ if test x"$ac_cv_sizeof_off_t" != x8 ; then -+ AC_CHECK_SIZEOF(off64_t) -+ test x"$ac_cv_sizeof_off64_t" = x8 || AC_MSG_ERROR([Large file support is required]) -+ fi;; - esac - - if test x$USE_NLS = xno; then -@@ -456,6 +461,16 @@ case "$build_os" in - esac - AC_SUBST(BUILD_EXEEXT) - -+# In some build environments like termux /bin/sh is not a valid -+# shebang. Use $SHELL instead if it's executable and /bin/sh isn't -+BUILD_SHEBANG=/bin/sh -+for she in /bin/sh "$SHELL"; do -+ if test -x "$she" ; then -+ BUILD_SHEBANG="$she" -+ fi -+done -+AC_SUBST(BUILD_SHEBANG) -+ - # For gnulib. - gl_INIT - -@@ -1905,6 +1920,7 @@ AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel]) - AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips]) - AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ]) - AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot]) -+AM_CONDITIONAL([COND_arm_coreboot], [test x$target_cpu = xarm -a x$platform = xcoreboot]) - AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi]) - AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ]) - AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi]) -diff --git a/Makefile.util.def b/Makefile.util.def -index f9caccb9780ffe8d4b31c8a19399ba7bbd308e56..3180ac880a9aa86e94fb47a7386bfa324425bff0 100644 ---- a/Makefile.util.def -+++ b/Makefile.util.def -@@ -99,6 +99,7 @@ library = { - common = grub-core/fs/ext2.c; - common = grub-core/fs/fat.c; - common = grub-core/fs/exfat.c; -+ common = grub-core/fs/f2fs.c; - common = grub-core/fs/fshelp.c; - common = grub-core/fs/hfs.c; - common = grub-core/fs/hfsplus.c; -@@ -774,6 +775,12 @@ script = { - common = tests/xfs_test.in; - }; - -+script = { -+ testcase; -+ name = f2fs_test; -+ common = tests/f2fs_test.in; -+}; -+ - script = { - testcase; - name = nilfs2_test; -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 2dfa22a9271bd6624fad9b91ce051ac12202dfbd..9590e87d9c080d6675a9521d91ef6a47d39f2751 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -68,11 +68,11 @@ kernel = { - i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)'; - i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000'; - i386_qemu_ldflags = '$(TARGET_IMG_LDFLAGS)'; -- i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8200'; -+ i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000'; - i386_coreboot_ldflags = '$(TARGET_IMG_LDFLAGS)'; -- i386_coreboot_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8200'; -+ i386_coreboot_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000'; - i386_multiboot_ldflags = '$(TARGET_IMG_LDFLAGS)'; -- i386_multiboot_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8200'; -+ i386_multiboot_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000'; - i386_ieee1275_ldflags = '$(TARGET_IMG_LDFLAGS)'; - i386_ieee1275_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x10000'; - i386_xen_ldflags = '$(TARGET_IMG_LDFLAGS)'; -@@ -92,6 +92,8 @@ kernel = { - emu_cppflags = '$(CPPFLAGS_GNULIB)'; - arm_uboot_ldflags = '-Wl,-r,-d'; - arm_uboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; -+ arm_coreboot_ldflags = '-Wl,-r,-d'; -+ arm_coreboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; - - i386_pc_startup = kern/i386/pc/startup.S; - i386_efi_startup = kern/i386/efi/startup.S; -@@ -105,7 +107,8 @@ kernel = { - mips_startup = kern/mips/startup.S; - sparc64_ieee1275_startup = kern/sparc64/ieee1275/crt0.S; - powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S; -- arm_uboot_startup = kern/arm/uboot/startup.S; -+ arm_uboot_startup = kern/arm/startup.S; -+ arm_coreboot_startup = kern/arm/startup.S; - arm_efi_startup = kern/arm/efi/startup.S; - arm64_efi_startup = kern/arm64/efi/startup.S; - -@@ -149,6 +152,21 @@ kernel = { - uboot = kern/uboot/init.c; - uboot = kern/uboot/hw.c; - uboot = term/uboot/console.c; -+ arm_uboot = kern/arm/uboot/init.c; -+ arm_uboot = kern/arm/uboot/uboot.S; -+ -+ arm_coreboot = kern/arm/coreboot/init.c; -+ arm_coreboot = kern/arm/coreboot/timer.c; -+ arm_coreboot = kern/arm/coreboot/coreboot.S; -+ arm_coreboot = lib/fdt.c; -+ arm_coreboot = bus/fdt.c; -+ arm_coreboot = term/ps2.c; -+ arm_coreboot = term/arm/pl050.c; -+ arm_coreboot = term/arm/cros.c; -+ arm_coreboot = term/arm/cros_ec.c; -+ arm_coreboot = bus/spi/rk3288_spi.c; -+ arm_coreboot = commands/keylayouts.c; -+ arm_coreboot = kern/arm/coreboot/dma.c; - - terminfoinkernel = term/terminfo.c; - terminfoinkernel = term/tparm.c; -@@ -164,7 +182,7 @@ kernel = { - i386_multiboot = kern/i386/coreboot/init.c; - i386_qemu = kern/i386/qemu/init.c; - i386_coreboot_multiboot_qemu = term/i386/pc/vga_text.c; -- i386_coreboot = video/i386/coreboot/cbfb.c; -+ coreboot = video/coreboot/cbfb.c; - - efi = disk/efi/efidisk.c; - efi = kern/efi/efi.c; -@@ -211,7 +229,6 @@ kernel = { - ia64_efi = kern/ia64/cache.c; - - arm_efi = kern/arm/efi/init.c; -- arm_efi = kern/arm/efi/misc.c; - arm_efi = kern/efi/fdt.c; - - arm64_efi = kern/arm64/efi/init.c; -@@ -225,8 +242,10 @@ kernel = { - i386_qemu = kern/vga_init.c; - i386_qemu = kern/i386/qemu/mmap.c; - -- i386_coreboot = kern/i386/coreboot/mmap.c; -+ coreboot = kern/coreboot/mmap.c; - i386_coreboot = kern/i386/coreboot/cbtable.c; -+ coreboot = kern/coreboot/cbtable.c; -+ arm_coreboot = kern/arm/coreboot/cbtable.c; - - i386_multiboot = kern/i386/multiboot_mmap.c; - -@@ -238,6 +257,7 @@ kernel = { - mips_qemu_mips = term/ns8250.c; - mips_qemu_mips = term/serial.c; - mips_qemu_mips = term/at_keyboard.c; -+ mips_qemu_mips = term/ps2.c; - mips_qemu_mips = commands/boot.c; - mips_qemu_mips = commands/keylayouts.c; - mips_qemu_mips = term/i386/pc/vga_text.c; -@@ -253,6 +273,7 @@ kernel = { - mips_loongson = bus/pci.c; - mips_loongson = kern/mips/loongson/init.c; - mips_loongson = term/at_keyboard.c; -+ mips_loongson = term/ps2.c; - mips_loongson = commands/boot.c; - mips_loongson = term/serial.c; - mips_loongson = video/sm712.c; -@@ -574,7 +595,10 @@ module = { - module = { - name = ehci; - common = bus/usb/ehci.c; -+ arm_coreboot = bus/usb/ehci-fdt.c; -+ pci = bus/usb/ehci-pci.c; - enable = pci; -+ enable = arm_coreboot; - }; - - module = { -@@ -641,6 +665,7 @@ module = { - module = { - name = cbtable; - common = kern/i386/coreboot/cbtable.c; -+ common = kern/coreboot/cbtable.c; - enable = i386_pc; - enable = i386_efi; - enable = i386_qemu; -@@ -754,6 +779,7 @@ module = { - enable = arm_efi; - enable = arm64_efi; - enable = arm_uboot; -+ enable = arm_coreboot; - }; - - module = { -@@ -837,17 +863,14 @@ module = { - efi = lib/efi/halt.c; - ieee1275 = lib/ieee1275/halt.c; - emu = lib/emu/halt.c; -- uboot = lib/uboot/halt.c; -+ uboot = lib/dummy/halt.c; -+ arm_coreboot = lib/dummy/halt.c; - }; - - module = { - name = reboot; - i386 = lib/i386/reboot.c; - i386 = lib/i386/reboot_trampoline.S; -- ia64_efi = lib/efi/reboot.c; -- x86_64_efi = lib/efi/reboot.c; -- arm_efi = lib/efi/reboot.c; -- arm64_efi = lib/efi/reboot.c; - powerpc_ieee1275 = lib/ieee1275/reboot.c; - sparc64_ieee1275 = lib/ieee1275/reboot.c; - mips_arc = lib/mips/arc/reboot.c; -@@ -855,6 +878,7 @@ module = { - mips_qemu_mips = lib/mips/qemu_mips/reboot.c; - xen = lib/xen/reboot.c; - uboot = lib/uboot/reboot.c; -+ arm_coreboot = lib/dummy/reboot.c; - common = commands/reboot.c; - }; - -@@ -873,7 +897,6 @@ module = { - module = { - name = hdparm; - common = commands/hdparm.c; -- common = lib/hexdump.c; - enable = pci; - enable = mips_qemu_mips; - }; -@@ -1290,6 +1313,11 @@ module = { - common = fs/exfat.c; - }; - -+module = { -+ name = f2fs; -+ common = fs/f2fs.c; -+}; -+ - module = { - name = fshelp; - common = fs/fshelp.c; -@@ -1548,7 +1576,8 @@ module = { - name = datetime; - cmos = lib/cmos_datetime.c; - efi = lib/efi/datetime.c; -- uboot = lib/uboot/datetime.c; -+ uboot = lib/dummy/datetime.c; -+ arm_coreboot = lib/dummy/datetime.c; - sparc64_ieee1275 = lib/ieee1275/datetime.c; - powerpc_ieee1275 = lib/ieee1275/datetime.c; - sparc64_ieee1275 = lib/ieee1275/cmos.c; -@@ -1601,8 +1630,6 @@ module = { - module = { - name = linux16; - common = loader/i386/pc/linux.c; -- common = loader/linux.c; -- common = lib/cmdline.c; - enable = x86; - }; - -@@ -1637,7 +1664,6 @@ module = { - cppflags = "-DGRUB_USE_MULTIBOOT2"; - - common = loader/multiboot.c; -- common = lib/cmdline.c; - common = loader/multiboot_mbi2.c; - enable = x86; - enable = mips; -@@ -1646,7 +1672,6 @@ module = { - module = { - name = multiboot; - common = loader/multiboot.c; -- common = lib/cmdline.c; - x86 = loader/i386/multiboot_mbi.c; - extra_dist = loader/multiboot_elfxx.c; - enable = x86; -@@ -1654,7 +1679,6 @@ module = { - - module = { - name = xen_boot; -- common = lib/cmdline.c; - arm64 = loader/arm64/xen_boot.c; - enable = arm64; - }; -@@ -1668,7 +1692,9 @@ module = { - powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c; - sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c; - ia64_efi = loader/ia64/efi/linux.c; -- arm = loader/arm/linux.c; -+ arm_coreboot = loader/arm/linux.c; -+ arm_efi = loader/arm64/linux.c; -+ arm_uboot = loader/arm/linux.c; - arm64 = loader/arm64/linux.c; - common = loader/linux.c; - common = lib/cmdline.c; -@@ -1677,7 +1703,7 @@ module = { - - module = { - name = fdt; -- arm64 = loader/arm64/fdt.c; -+ efi = loader/efi/fdt.c; - common = lib/fdt.c; - enable = fdt; - }; -@@ -1869,6 +1895,7 @@ module = { - module = { - name = at_keyboard; - common = term/at_keyboard.c; -+ common = term/ps2.c; - enable = x86; - }; - -@@ -1961,6 +1988,11 @@ module = { - common = tests/example_functional_test.c; - }; - -+module = { -+ name = strtoull_test; -+ common = tests/strtoull_test.c; -+}; -+ - module = { - name = setjmp_test; - common = tests/setjmp_test.c; -diff --git a/grub-core/bus/fdt.c b/grub-core/bus/fdt.c -new file mode 100644 -index 0000000000000000000000000000000000000000..135da497ba67e7545490e0e73ee3a1fa676a6069 ---- /dev/null -+++ b/grub-core/bus/fdt.c -@@ -0,0 +1,256 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2016 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+ -+static const void *dtb; -+static grub_size_t root_address_cells, root_size_cells; -+/* Pointer to this symbol signals invalid mapping. */ -+char grub_fdtbus_invalid_mapping[1]; -+ -+struct grub_fdtbus_dev *devs; -+struct grub_fdtbus_driver *drivers; -+ -+int -+grub_fdtbus_is_compatible (const char *compat_string, -+ const struct grub_fdtbus_dev *dev) -+{ -+ grub_size_t compatible_size; -+ const char *compatible = grub_fdt_get_prop (dtb, dev->node, "compatible", -+ &compatible_size); -+ if (!compatible) -+ return 0; -+ const char *compatible_end = compatible + compatible_size; -+ while (compatible < compatible_end) -+ { -+ if (grub_strcmp (compat_string, compatible) == 0) -+ return 1; -+ compatible += grub_strlen (compatible) + 1; -+ } -+ return 0; -+} -+ -+static void -+fdtbus_scan (struct grub_fdtbus_dev *parent) -+{ -+ int node; -+ for (node = grub_fdt_first_node (dtb, parent ? parent->node : 0); node >= 0; -+ node = grub_fdt_next_node (dtb, node)) -+ { -+ struct grub_fdtbus_dev *dev; -+ struct grub_fdtbus_driver *driver; -+ dev = grub_zalloc (sizeof (*dev)); -+ if (!dev) -+ { -+ grub_print_error (); -+ return; -+ } -+ dev->node = node; -+ dev->next = devs; -+ dev->parent = parent; -+ devs = dev; -+ FOR_LIST_ELEMENTS(driver, drivers) -+ if (!dev->driver && grub_fdtbus_is_compatible (driver->compatible, dev)) -+ { -+ grub_dprintf ("fdtbus", "Attaching %s\n", driver->compatible); -+ if (driver->attach (dev) == GRUB_ERR_NONE) -+ { -+ grub_dprintf ("fdtbus", "Attached %s\n", driver->compatible); -+ dev->driver = driver; -+ break; -+ } -+ grub_print_error (); -+ } -+ fdtbus_scan (dev); -+ } -+} -+ -+void -+grub_fdtbus_register (struct grub_fdtbus_driver *driver) -+{ -+ struct grub_fdtbus_dev *dev; -+ grub_dprintf ("fdtbus", "Registering %s\n", driver->compatible); -+ grub_list_push (GRUB_AS_LIST_P (&drivers), -+ GRUB_AS_LIST (driver)); -+ for (dev = devs; dev; dev = dev->next) -+ if (!dev->driver && grub_fdtbus_is_compatible (driver->compatible, dev)) -+ { -+ grub_dprintf ("fdtbus", "Attaching %s (%p)\n", driver->compatible, dev); -+ if (driver->attach (dev) == GRUB_ERR_NONE) -+ { -+ grub_dprintf ("fdtbus", "Attached %s\n", driver->compatible); -+ dev->driver = driver; -+ } -+ grub_print_error (); -+ } -+} -+ -+void -+grub_fdtbus_unregister (struct grub_fdtbus_driver *driver) -+{ -+ grub_list_remove (GRUB_AS_LIST (driver)); -+ struct grub_fdtbus_dev *dev; -+ for (dev = devs; dev; dev = dev->next) -+ if (dev->driver == driver) -+ { -+ if (driver->detach) -+ driver->detach(dev); -+ dev->driver = 0; -+ } -+} -+ -+void -+grub_fdtbus_init (const void *dtb_in, grub_size_t size) -+{ -+ if (!dtb_in || grub_fdt_check_header (dtb_in, size) < 0) -+ grub_fatal ("invalid FDT"); -+ dtb = dtb_in; -+ const grub_uint32_t *prop = grub_fdt_get_prop (dtb, 0, "#address-cells", 0); -+ if (prop) -+ root_address_cells = grub_be_to_cpu32 (*prop); -+ else -+ root_address_cells = 1; -+ -+ prop = grub_fdt_get_prop (dtb, 0, "#size-cells", 0); -+ if (prop) -+ root_size_cells = grub_be_to_cpu32 (*prop); -+ else -+ root_size_cells = 1; -+ -+ fdtbus_scan (0); -+} -+ -+static int -+get_address_cells (const struct grub_fdtbus_dev *dev) -+{ -+ const grub_uint32_t *prop; -+ if (!dev) -+ return root_address_cells; -+ prop = grub_fdt_get_prop (dtb, dev->node, "#address-cells", 0); -+ if (prop) -+ return grub_be_to_cpu32 (*prop); -+ return 1; -+} -+ -+static int -+get_size_cells (const struct grub_fdtbus_dev *dev) -+{ -+ const grub_uint32_t *prop; -+ if (!dev) -+ return root_size_cells; -+ prop = grub_fdt_get_prop (dtb, dev->node, "#size-cells", 0); -+ if (prop) -+ return grub_be_to_cpu32 (*prop); -+ return 1; -+} -+ -+static grub_uint64_t -+get64 (const grub_uint32_t *reg, grub_size_t cells) -+{ -+ grub_uint64_t val = 0; -+ if (cells >= 1) -+ val = grub_be_to_cpu32 (reg[cells - 1]); -+ if (cells >= 2) -+ val |= ((grub_uint64_t) grub_be_to_cpu32 (reg[cells - 2])) << 32; -+ return val; -+} -+ -+static volatile void * -+translate (const struct grub_fdtbus_dev *dev, const grub_uint32_t *reg) -+{ -+ volatile void *ret; -+ const grub_uint32_t *ranges; -+ grub_size_t ranges_size, cells_per_mapping; -+ grub_size_t parent_address_cells, child_address_cells, child_size_cells; -+ grub_size_t nmappings, i; -+ if (dev == 0) -+ { -+ grub_uint64_t val; -+ val = get64 (reg, root_address_cells); -+ if (sizeof (void *) == 4 && (val >> 32)) -+ return grub_fdtbus_invalid_mapping; -+ return (void *) (grub_addr_t) val; -+ } -+ ranges = grub_fdt_get_prop (dtb, dev->node, "ranges", &ranges_size); -+ if (!ranges) -+ return grub_fdtbus_invalid_mapping; -+ if (ranges_size == 0) -+ return translate (dev->parent, reg); -+ parent_address_cells = get_address_cells (dev->parent); -+ child_address_cells = get_address_cells (dev); -+ child_size_cells = get_size_cells (dev); -+ cells_per_mapping = parent_address_cells + child_address_cells + child_size_cells; -+ nmappings = ranges_size / 4 / cells_per_mapping; -+ for (i = 0; i < nmappings; i++) -+ { -+ const grub_uint32_t *child_addr = &ranges[i * cells_per_mapping]; -+ const grub_uint32_t *parent_addr = child_addr + child_address_cells; -+ grub_uint64_t child_size = get64 (parent_addr + parent_address_cells, child_size_cells); -+ -+ if (child_address_cells > 2 && grub_memcmp (reg, child_addr, (child_address_cells - 2) * 4) != 0) -+ continue; -+ if (get64 (reg, child_address_cells) < get64 (child_addr, child_address_cells)) -+ continue; -+ -+ grub_uint64_t offset = get64 (reg, child_address_cells) - get64 (child_addr, child_address_cells); -+ if (offset >= child_size) -+ continue; -+ -+ ret = translate (dev->parent, parent_addr); -+ if (grub_fdtbus_is_mapping_valid (ret)) -+ ret = (volatile char *) ret + offset; -+ return ret; -+ } -+ return grub_fdtbus_invalid_mapping; -+} -+ -+volatile void * -+grub_fdtbus_map_reg (const struct grub_fdtbus_dev *dev, int regno, grub_size_t *size) -+{ -+ grub_size_t address_cells, size_cells; -+ address_cells = get_address_cells (dev->parent); -+ size_cells = get_size_cells (dev->parent); -+ const grub_uint32_t *reg = grub_fdt_get_prop (dtb, dev->node, "reg", 0); -+ if (size && size_cells) -+ *size = reg[(address_cells + size_cells) * regno + address_cells]; -+ if (size && !size_cells) -+ *size = 0; -+ return translate (dev->parent, reg + (address_cells + size_cells) * regno); -+} -+ -+const char * -+grub_fdtbus_get_name (const struct grub_fdtbus_dev *dev) -+{ -+ return grub_fdt_get_nodename (dtb, dev->node); -+} -+ -+const void * -+grub_fdtbus_get_prop (const struct grub_fdtbus_dev *dev, -+ const char *name, -+ grub_uint32_t *len) -+{ -+ return grub_fdt_get_prop (dtb, dev->node, name, len); -+} -+ -+const void * -+grub_fdtbus_get_fdt (void) -+{ -+ return dtb; -+} -diff --git a/grub-core/bus/spi/rk3288_spi.c b/grub-core/bus/spi/rk3288_spi.c -new file mode 100644 -index 0000000000000000000000000000000000000000..aacb79ffef103bdbff1bb66dd70229b85b1e8030 ---- /dev/null -+++ b/grub-core/bus/spi/rk3288_spi.c -@@ -0,0 +1,103 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * -+ * Copyright (C) 2012 Google Inc. -+ * Copyright (C) 2016 Free Software Foundation, Inc. -+ * -+ * This is based on depthcharge code. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+static grub_err_t -+spi_send (const struct grub_fdtbus_dev *dev, const void *data, grub_size_t sz) -+{ -+ const grub_uint8_t *ptr = data, *end = ptr + sz; -+ volatile grub_uint32_t *spi = grub_fdtbus_map_reg (dev, 0, 0); -+ spi[2] = 0; -+ spi[1] = sz - 1; -+ spi[0] = ((1 << 18) | spi[0]) & ~(1 << 19); -+ spi[2] = 1; -+ while (ptr < end) -+ { -+ while (spi[9] & 2); -+ spi[256] = *ptr++; -+ } -+ while (spi[9] & 1); -+ return GRUB_ERR_NONE; -+} -+ -+static grub_err_t -+spi_receive (const struct grub_fdtbus_dev *dev, void *data, grub_size_t sz) -+{ -+ grub_uint8_t *ptr = data, *end = ptr + sz; -+ volatile grub_uint32_t *spi = grub_fdtbus_map_reg (dev, 0, 0); -+ spi[2] = 0; -+ spi[1] = sz - 1; -+ spi[0] = ((1 << 19) | spi[0]) & ~(1 << 18); -+ spi[2] = 1; -+ while (ptr < end) -+ { -+ while (spi[9] & 8); -+ *ptr++ = spi[512]; -+ } -+ while (spi[9] & 1); -+ return GRUB_ERR_NONE; -+} -+ -+static grub_err_t -+spi_start (const struct grub_fdtbus_dev *dev) -+{ -+ volatile grub_uint32_t *spi = grub_fdtbus_map_reg (dev, 0, 0); -+ spi[3] = 1; -+ return GRUB_ERR_NONE; -+} -+ -+static void -+spi_stop (const struct grub_fdtbus_dev *dev) -+{ -+ volatile grub_uint32_t *spi = grub_fdtbus_map_reg (dev, 0, 0); -+ spi[3] = 0; -+} -+ -+static grub_err_t -+spi_attach(const struct grub_fdtbus_dev *dev) -+{ -+ if (!grub_fdtbus_is_mapping_valid (grub_fdtbus_map_reg (dev, 0, 0))) -+ return GRUB_ERR_IO; -+ -+ return GRUB_ERR_NONE; -+} -+ -+static struct grub_fdtbus_driver spi = -+{ -+ .compatible = "rockchip,rk3288-spi", -+ .attach = spi_attach, -+ .send = spi_send, -+ .receive = spi_receive, -+ .start = spi_start, -+ .stop = spi_stop, -+}; -+ -+void -+grub_rk3288_spi_init (void) -+{ -+ grub_fdtbus_register (&spi); -+} -diff --git a/grub-core/bus/usb/ehci-fdt.c b/grub-core/bus/usb/ehci-fdt.c -new file mode 100644 -index 0000000000000000000000000000000000000000..29b50bdd5c30d192cc3cba1d7f466a9bcf321d92 ---- /dev/null -+++ b/grub-core/bus/usb/ehci-fdt.c -@@ -0,0 +1,45 @@ -+/* ehci.c - EHCI Support. */ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2011 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+static grub_err_t -+ehci_attach(const struct grub_fdtbus_dev *dev) -+{ -+ grub_dprintf ("ehci", "Found generic-ehci\n"); -+ -+ grub_ehci_init_device (grub_fdtbus_map_reg (dev, 0, 0)); -+ return 0; -+} -+ -+struct grub_fdtbus_driver ehci = -+{ -+ .compatible = "generic-ehci", -+ .attach = ehci_attach -+}; -+ -+void -+grub_ehci_pci_scan (void) -+{ -+ grub_fdtbus_register (&ehci); -+} -diff --git a/grub-core/bus/usb/ehci-pci.c b/grub-core/bus/usb/ehci-pci.c -new file mode 100644 -index 0000000000000000000000000000000000000000..65e6cb57438b7dfa35b80bbbe36a1e50629f025f ---- /dev/null -+++ b/grub-core/bus/usb/ehci-pci.c -@@ -0,0 +1,208 @@ -+/* ehci.c - EHCI Support. */ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2011 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define GRUB_EHCI_PCI_SBRN_REG 0x60 -+#define GRUB_EHCI_ADDR_MEM_MASK (~0xff) -+ -+/* USBLEGSUP bits and related OS OWNED byte offset */ -+enum -+{ -+ GRUB_EHCI_BIOS_OWNED = (1 << 16), -+ GRUB_EHCI_OS_OWNED = (1 << 24) -+}; -+ -+/* PCI iteration function... */ -+static int -+grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, -+ void *data __attribute__ ((unused))) -+{ -+ volatile grub_uint32_t *regs; -+ grub_uint32_t base, base_h; -+ grub_uint32_t eecp_offset; -+ grub_uint32_t usblegsup = 0; -+ grub_uint64_t maxtime; -+ grub_uint32_t interf; -+ grub_uint32_t subclass; -+ grub_uint32_t class; -+ grub_uint8_t release; -+ grub_uint32_t class_code; -+ -+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: begin\n"); -+ -+ if (pciid == GRUB_CS5536_PCIID) -+ { -+ grub_uint64_t basereg; -+ -+ basereg = grub_cs5536_read_msr (dev, GRUB_CS5536_MSR_USB_EHCI_BASE); -+ if (!(basereg & GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE)) -+ { -+ /* Shouldn't happen. */ -+ grub_dprintf ("ehci", "No EHCI address is assigned\n"); -+ return 0; -+ } -+ base = (basereg & GRUB_CS5536_MSR_USB_BASE_ADDR_MASK); -+ basereg |= GRUB_CS5536_MSR_USB_BASE_BUS_MASTER; -+ basereg &= ~GRUB_CS5536_MSR_USB_BASE_PME_ENABLED; -+ basereg &= ~GRUB_CS5536_MSR_USB_BASE_PME_STATUS; -+ basereg &= ~GRUB_CS5536_MSR_USB_BASE_SMI_ENABLE; -+ grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_USB_EHCI_BASE, basereg); -+ } -+ else -+ { -+ grub_pci_address_t addr; -+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS); -+ class_code = grub_pci_read (addr) >> 8; -+ interf = class_code & 0xFF; -+ subclass = (class_code >> 8) & 0xFF; -+ class = class_code >> 16; -+ -+ /* If this is not an EHCI controller, just return. */ -+ if (class != 0x0c || subclass != 0x03 || interf != 0x20) -+ return 0; -+ -+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: class OK\n"); -+ -+ /* Check Serial Bus Release Number */ -+ addr = grub_pci_make_address (dev, GRUB_EHCI_PCI_SBRN_REG); -+ release = grub_pci_read_byte (addr); -+ if (release != 0x20) -+ { -+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: Wrong SBRN: %0x\n", -+ release); -+ return 0; -+ } -+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: bus rev. num. OK\n"); -+ -+ /* Determine EHCI EHCC registers base address. */ -+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0); -+ base = grub_pci_read (addr); -+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG1); -+ base_h = grub_pci_read (addr); -+ /* Stop if registers are mapped above 4G - GRUB does not currently -+ * work with registers mapped above 4G */ -+ if (((base & GRUB_PCI_ADDR_MEM_TYPE_MASK) != GRUB_PCI_ADDR_MEM_TYPE_32) -+ && (base_h != 0)) -+ { -+ grub_dprintf ("ehci", -+ "EHCI grub_ehci_pci_iter: registers above 4G are not supported\n"); -+ return 0; -+ } -+ base &= GRUB_PCI_ADDR_MEM_MASK; -+ if (!base) -+ { -+ grub_dprintf ("ehci", -+ "EHCI: EHCI is not mapped\n"); -+ return 0; -+ } -+ -+ /* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */ -+ addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND); -+ grub_pci_write_word(addr, -+ GRUB_PCI_COMMAND_MEM_ENABLED -+ | GRUB_PCI_COMMAND_BUS_MASTER -+ | grub_pci_read_word(addr)); -+ -+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: 32-bit EHCI OK\n"); -+ } -+ -+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: iobase of EHCC: %08x\n", -+ (base & GRUB_EHCI_ADDR_MEM_MASK)); -+ -+ regs = grub_pci_device_map_range (dev, -+ (base & GRUB_EHCI_ADDR_MEM_MASK), -+ 0x100); -+ -+ /* Is there EECP ? */ -+ eecp_offset = (grub_le_to_cpu32 (regs[2]) >> 8) & 0xff; -+ -+ /* Determine and change ownership. */ -+ /* EECP offset valid in HCCPARAMS */ -+ /* Ownership can be changed via EECP only */ -+ if (pciid != GRUB_CS5536_PCIID && eecp_offset >= 0x40) -+ { -+ grub_pci_address_t pciaddr_eecp; -+ pciaddr_eecp = grub_pci_make_address (dev, eecp_offset); -+ -+ usblegsup = grub_pci_read (pciaddr_eecp); -+ if (usblegsup & GRUB_EHCI_BIOS_OWNED) -+ { -+ grub_boot_time ("Taking ownership of EHCI controller"); -+ grub_dprintf ("ehci", -+ "EHCI grub_ehci_pci_iter: EHCI owned by: BIOS\n"); -+ /* Ownership change - set OS_OWNED bit */ -+ grub_pci_write (pciaddr_eecp, usblegsup | GRUB_EHCI_OS_OWNED); -+ /* Ensure PCI register is written */ -+ grub_pci_read (pciaddr_eecp); -+ -+ /* Wait for finish of ownership change, EHCI specification -+ * doesn't say how long it can take... */ -+ maxtime = grub_get_time_ms () + 1000; -+ while ((grub_pci_read (pciaddr_eecp) & GRUB_EHCI_BIOS_OWNED) -+ && (grub_get_time_ms () < maxtime)); -+ if (grub_pci_read (pciaddr_eecp) & GRUB_EHCI_BIOS_OWNED) -+ { -+ grub_dprintf ("ehci", -+ "EHCI grub_ehci_pci_iter: EHCI change ownership timeout"); -+ /* Change ownership in "hard way" - reset BIOS ownership */ -+ grub_pci_write (pciaddr_eecp, GRUB_EHCI_OS_OWNED); -+ /* Ensure PCI register is written */ -+ grub_pci_read (pciaddr_eecp); -+ } -+ } -+ else if (usblegsup & GRUB_EHCI_OS_OWNED) -+ /* XXX: What to do in this case - nothing ? Can it happen ? */ -+ grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: EHCI owned by: OS\n"); -+ else -+ { -+ grub_dprintf ("ehci", -+ "EHCI grub_ehci_pci_iter: EHCI owned by: NONE\n"); -+ /* XXX: What to do in this case ? Can it happen ? -+ * Is code below correct ? */ -+ /* Ownership change - set OS_OWNED bit */ -+ grub_pci_write (pciaddr_eecp, GRUB_EHCI_OS_OWNED); -+ /* Ensure PCI register is written */ -+ grub_pci_read (pciaddr_eecp); -+ } -+ -+ /* Disable SMI, just to be sure. */ -+ pciaddr_eecp = grub_pci_make_address (dev, eecp_offset + 4); -+ grub_pci_write (pciaddr_eecp, 0); -+ /* Ensure PCI register is written */ -+ grub_pci_read (pciaddr_eecp); -+ } -+ -+ grub_dprintf ("ehci", "inithw: EHCI grub_ehci_pci_iter: ownership OK\n"); -+ -+ grub_ehci_init_device (regs); -+ return 0; -+} -+ -+void -+grub_ehci_pci_scan (void) -+{ -+ grub_pci_iterate (grub_ehci_pci_iter, NULL); -+} -diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c -index 5f4297bb21ec4c28824abb0c442a87a3dd4a872e..d966fc21002602fab3f1b68668ddcb5bfa639442 100644 ---- a/grub-core/bus/usb/ehci.c -+++ b/grub-core/bus/usb/ehci.c -@@ -22,13 +22,10 @@ - #include - #include - #include --#include --#include --#include - #include - #include --#include - #include -+#include - #include - - GRUB_MOD_LICENSE ("GPLv3+"); -@@ -39,8 +36,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); - * - is not supporting interrupt transfers - */ - --#define GRUB_EHCI_PCI_SBRN_REG 0x60 -- - /* Capability registers offsets */ - enum - { -@@ -54,7 +49,6 @@ enum - #define GRUB_EHCI_EECP_MASK (0xff << 8) - #define GRUB_EHCI_EECP_SHIFT 8 - --#define GRUB_EHCI_ADDR_MEM_MASK (~0xff) - #define GRUB_EHCI_POINTER_MASK (~0x1f) - - /* Capability register SPARAMS bits */ -@@ -85,13 +79,6 @@ enum - - #define GRUB_EHCI_QH_EMPTY 1 - --/* USBLEGSUP bits and related OS OWNED byte offset */ --enum --{ -- GRUB_EHCI_BIOS_OWNED = (1 << 16), -- GRUB_EHCI_OS_OWNED = (1 << 24) --}; -- - /* Operational registers offsets */ - enum - { -@@ -455,9 +442,10 @@ grub_ehci_reset (struct grub_ehci *e) - - sync_all_caches (e); - -+ grub_dprintf ("ehci", "reset\n"); -+ - grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND, -- GRUB_EHCI_CMD_HC_RESET -- | grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)); -+ GRUB_EHCI_CMD_HC_RESET); - /* Ensure command is written */ - grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND); - /* XXX: How long time could take reset of HC ? */ -@@ -473,116 +461,24 @@ grub_ehci_reset (struct grub_ehci *e) - } - - /* PCI iteration function... */ --static int --grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, -- void *data __attribute__ ((unused))) -+void -+grub_ehci_init_device (volatile void *regs) - { -- grub_uint8_t release; -- grub_uint32_t class_code; -- grub_uint32_t interf; -- grub_uint32_t subclass; -- grub_uint32_t class; -- grub_uint32_t base, base_h; - struct grub_ehci *e; -- grub_uint32_t eecp_offset; - grub_uint32_t fp; - int i; -- grub_uint32_t usblegsup = 0; -- grub_uint64_t maxtime; - grub_uint32_t n_ports; - grub_uint8_t caplen; - -- grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: begin\n"); -- -- if (pciid == GRUB_CS5536_PCIID) -- { -- grub_uint64_t basereg; -- -- basereg = grub_cs5536_read_msr (dev, GRUB_CS5536_MSR_USB_EHCI_BASE); -- if (!(basereg & GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE)) -- { -- /* Shouldn't happen. */ -- grub_dprintf ("ehci", "No EHCI address is assigned\n"); -- return 0; -- } -- base = (basereg & GRUB_CS5536_MSR_USB_BASE_ADDR_MASK); -- basereg |= GRUB_CS5536_MSR_USB_BASE_BUS_MASTER; -- basereg &= ~GRUB_CS5536_MSR_USB_BASE_PME_ENABLED; -- basereg &= ~GRUB_CS5536_MSR_USB_BASE_PME_STATUS; -- basereg &= ~GRUB_CS5536_MSR_USB_BASE_SMI_ENABLE; -- grub_cs5536_write_msr (dev, GRUB_CS5536_MSR_USB_EHCI_BASE, basereg); -- } -- else -- { -- grub_pci_address_t addr; -- addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS); -- class_code = grub_pci_read (addr) >> 8; -- interf = class_code & 0xFF; -- subclass = (class_code >> 8) & 0xFF; -- class = class_code >> 16; -- -- /* If this is not an EHCI controller, just return. */ -- if (class != 0x0c || subclass != 0x03 || interf != 0x20) -- return 0; -- -- grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: class OK\n"); -- -- /* Check Serial Bus Release Number */ -- addr = grub_pci_make_address (dev, GRUB_EHCI_PCI_SBRN_REG); -- release = grub_pci_read_byte (addr); -- if (release != 0x20) -- { -- grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: Wrong SBRN: %0x\n", -- release); -- return 0; -- } -- grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: bus rev. num. OK\n"); -- -- /* Determine EHCI EHCC registers base address. */ -- addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0); -- base = grub_pci_read (addr); -- addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG1); -- base_h = grub_pci_read (addr); -- /* Stop if registers are mapped above 4G - GRUB does not currently -- * work with registers mapped above 4G */ -- if (((base & GRUB_PCI_ADDR_MEM_TYPE_MASK) != GRUB_PCI_ADDR_MEM_TYPE_32) -- && (base_h != 0)) -- { -- grub_dprintf ("ehci", -- "EHCI grub_ehci_pci_iter: registers above 4G are not supported\n"); -- return 0; -- } -- base &= GRUB_PCI_ADDR_MEM_MASK; -- if (!base) -- { -- grub_dprintf ("ehci", -- "EHCI: EHCI is not mapped\n"); -- return 0; -- } -- -- /* Set bus master - needed for coreboot, VMware, broken BIOSes etc. */ -- addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND); -- grub_pci_write_word(addr, -- GRUB_PCI_COMMAND_MEM_ENABLED -- | GRUB_PCI_COMMAND_BUS_MASTER -- | grub_pci_read_word(addr)); -- -- grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: 32-bit EHCI OK\n"); -- } -- - /* Allocate memory for the controller and fill basic values. */ - e = grub_zalloc (sizeof (*e)); - if (!e) -- return 1; -+ return; - e->framelist_chunk = NULL; - e->td_chunk = NULL; - e->qh_chunk = NULL; -- e->iobase_ehcc = grub_pci_device_map_range (dev, -- (base & GRUB_EHCI_ADDR_MEM_MASK), -- 0x100); -+ e->iobase_ehcc = regs; - -- grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: iobase of EHCC: %08x\n", -- (base & GRUB_EHCI_ADDR_MEM_MASK)); - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: CAPLEN: %02x\n", - grub_ehci_ehcc_read8 (e, GRUB_EHCI_EHCC_CAPLEN)); - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: VERSION: %04x\n", -@@ -598,7 +494,7 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, - if (caplen & (sizeof (grub_uint32_t) - 1)) - { - grub_dprintf ("ehci", "Unaligned caplen\n"); -- return 0; -+ return; - } - e->iobase = ((volatile grub_uint32_t *) e->iobase_ehcc - + (caplen / sizeof (grub_uint32_t))); -@@ -608,8 +504,8 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, - #endif - - grub_dprintf ("ehci", -- "EHCI grub_ehci_pci_iter: iobase of oper. regs: %08x\n", -- (base & GRUB_EHCI_ADDR_MEM_MASK) + caplen); -+ "EHCI grub_ehci_pci_iter: iobase of oper. regs: %08llxx\n", -+ (unsigned long long) (grub_addr_t) e->iobase_ehcc + caplen); - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: COMMAND: %08x\n", - grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)); - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: STATUS: %08x\n", -@@ -625,10 +521,6 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: CONFIG_FLAG: %08x\n", - grub_ehci_oper_read32 (e, GRUB_EHCI_CONFIG_FLAG)); - -- /* Is there EECP ? */ -- eecp_offset = (grub_ehci_ehcc_read32 (e, GRUB_EHCI_EHCC_CPARAMS) -- & GRUB_EHCI_EECP_MASK) >> GRUB_EHCI_EECP_SHIFT; -- - /* Check format of data structures requested by EHCI */ - /* XXX: In fact it is not used at any place, it is prepared for future - * This implementation uses 32-bits pointers only */ -@@ -732,65 +624,6 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, - - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: QH/TD init. OK\n"); - -- /* Determine and change ownership. */ -- /* EECP offset valid in HCCPARAMS */ -- /* Ownership can be changed via EECP only */ -- if (pciid != GRUB_CS5536_PCIID && eecp_offset >= 0x40) -- { -- grub_pci_address_t pciaddr_eecp; -- pciaddr_eecp = grub_pci_make_address (dev, eecp_offset); -- -- usblegsup = grub_pci_read (pciaddr_eecp); -- if (usblegsup & GRUB_EHCI_BIOS_OWNED) -- { -- grub_boot_time ("Taking ownership of EHCI controller"); -- grub_dprintf ("ehci", -- "EHCI grub_ehci_pci_iter: EHCI owned by: BIOS\n"); -- /* Ownership change - set OS_OWNED bit */ -- grub_pci_write (pciaddr_eecp, usblegsup | GRUB_EHCI_OS_OWNED); -- /* Ensure PCI register is written */ -- grub_pci_read (pciaddr_eecp); -- -- /* Wait for finish of ownership change, EHCI specification -- * doesn't say how long it can take... */ -- maxtime = grub_get_time_ms () + 1000; -- while ((grub_pci_read (pciaddr_eecp) & GRUB_EHCI_BIOS_OWNED) -- && (grub_get_time_ms () < maxtime)); -- if (grub_pci_read (pciaddr_eecp) & GRUB_EHCI_BIOS_OWNED) -- { -- grub_dprintf ("ehci", -- "EHCI grub_ehci_pci_iter: EHCI change ownership timeout"); -- /* Change ownership in "hard way" - reset BIOS ownership */ -- grub_pci_write (pciaddr_eecp, GRUB_EHCI_OS_OWNED); -- /* Ensure PCI register is written */ -- grub_pci_read (pciaddr_eecp); -- } -- } -- else if (usblegsup & GRUB_EHCI_OS_OWNED) -- /* XXX: What to do in this case - nothing ? Can it happen ? */ -- grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: EHCI owned by: OS\n"); -- else -- { -- grub_dprintf ("ehci", -- "EHCI grub_ehci_pci_iter: EHCI owned by: NONE\n"); -- /* XXX: What to do in this case ? Can it happen ? -- * Is code below correct ? */ -- /* Ownership change - set OS_OWNED bit */ -- grub_pci_write (pciaddr_eecp, GRUB_EHCI_OS_OWNED); -- /* Ensure PCI register is written */ -- grub_pci_read (pciaddr_eecp); -- } -- -- /* Disable SMI, just to be sure. */ -- pciaddr_eecp = grub_pci_make_address (dev, eecp_offset + 4); -- grub_pci_write (pciaddr_eecp, 0); -- /* Ensure PCI register is written */ -- grub_pci_read (pciaddr_eecp); -- -- } -- -- grub_dprintf ("ehci", "inithw: EHCI grub_ehci_pci_iter: ownership OK\n"); -- - /* Now we can setup EHCI (maybe...) */ - - /* Check if EHCI is halted and halt it if not */ -@@ -863,8 +696,8 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: OK at all\n"); - - grub_dprintf ("ehci", -- "EHCI grub_ehci_pci_iter: iobase of oper. regs: %08x\n", -- (base & GRUB_EHCI_ADDR_MEM_MASK)); -+ "EHCI grub_ehci_pci_iter: iobase of oper. regs: %08llx\n", -+ (unsigned long long) (grub_addr_t) regs); - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: COMMAND: %08x\n", - grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)); - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: STATUS: %08x\n", -@@ -880,7 +713,7 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, - grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: CONFIG_FLAG: %08x\n", - grub_ehci_oper_read32 (e, GRUB_EHCI_CONFIG_FLAG)); - -- return 0; -+ return; - - fail: - if (e) -@@ -894,7 +727,7 @@ fail: - } - grub_free (e); - -- return 0; -+ return; - } - - static int -@@ -1891,12 +1724,6 @@ grub_ehci_detect_dev (grub_usb_controller_t dev, int port, int *changed) - } - } - --static void --grub_ehci_inithw (void) --{ -- grub_pci_iterate (grub_ehci_pci_iter, NULL); --} -- - static grub_err_t - grub_ehci_restore_hw (void) - { -@@ -1997,7 +1824,7 @@ GRUB_MOD_INIT (ehci) - grub_stop_disk_firmware (); - - grub_boot_time ("Initing EHCI hardware"); -- grub_ehci_inithw (); -+ grub_ehci_pci_scan (); - grub_boot_time ("Registering EHCI driver"); - grub_usb_controller_dev_register (&usb_controller); - grub_boot_time ("EHCI driver registered"); -diff --git a/grub-core/bus/usb/usbtrans.c b/grub-core/bus/usb/usbtrans.c -index 9266e49311c4471d0915aebf9fae05509d0fa5c7..85f081fffb3a2aa7354816c79977ae45a79b1c80 100644 ---- a/grub-core/bus/usb/usbtrans.c -+++ b/grub-core/bus/usb/usbtrans.c -@@ -18,7 +18,7 @@ - */ - - #include --#include -+#include - #include - #include - #include -diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c -index d901c3892630f2500eda9822c712aae278017907..d1ce99af438914692d1b71b0017050689dd73db9 100644 ---- a/grub-core/commands/efi/lsefi.c -+++ b/grub-core/commands/efi/lsefi.c -@@ -109,8 +109,10 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)), - - status = efi_call_3 (grub_efi_system_table->boot_services->protocols_per_handle, - handle, &protocols, &num_protocols); -- if (status != GRUB_EFI_SUCCESS) -+ if (status != GRUB_EFI_SUCCESS) { - grub_printf ("Unable to retrieve protocols\n"); -+ continue; -+ } - for (j = 0; j < num_protocols; j++) - { - for (k = 0; k < ARRAY_SIZE (known_protocols); k++) -diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c -index 12fba99e06a23cb72af67fc4bfb758d97bfa0e67..3ff6d5522d2d572c2af16fec371faeb8e4b28f9d 100644 ---- a/grub-core/commands/file.c -+++ b/grub-core/commands/file.c -@@ -27,6 +27,8 @@ - #include - #include - #include -+#include -+#include - #include - #include - #include -@@ -383,21 +385,19 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) - } - case IS_ARM_LINUX: - { -- grub_uint32_t sig, sig_pi; -- if (grub_file_read (file, &sig_pi, 4) != 4) -+ struct linux_arm_kernel_header lh; -+ -+ if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) - break; -- /* Raspberry pi. */ -- if (sig_pi == grub_cpu_to_le32_compile_time (0xea000006)) -+ /* Short forward branch in A32 state (for Raspberry pi kernels). */ -+ if (lh.code0 == grub_cpu_to_le32_compile_time (0xea000006)) - { - ret = 1; - break; - } - -- if (grub_file_seek (file, 0x24) == (grub_size_t) -1) -- break; -- if (grub_file_read (file, &sig, 4) != 4) -- break; -- if (sig == grub_cpu_to_le32_compile_time (0x016f2818)) -+ if (lh.magic == -+ grub_cpu_to_le32_compile_time (GRUB_LINUX_ARM_MAGIC_SIGNATURE)) - { - ret = 1; - break; -@@ -406,13 +406,13 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) - } - case IS_ARM64_LINUX: - { -- grub_uint32_t sig; -+ struct linux_arm64_kernel_header lh; - -- if (grub_file_seek (file, 0x38) == (grub_size_t) -1) -+ if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) - break; -- if (grub_file_read (file, &sig, 4) != 4) -- break; -- if (sig == grub_cpu_to_le32_compile_time (0x644d5241)) -+ -+ if (lh.magic == -+ grub_cpu_to_le32_compile_time (GRUB_LINUX_ARM64_MAGIC_SIGNATURE)) - { - ret = 1; - break; -@@ -497,7 +497,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) - case IS_X86_LINUX32: - case IS_X86_LINUX: - { -- struct linux_kernel_header lh; -+ struct linux_i386_kernel_header lh; - if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) - break; - if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) -@@ -508,7 +508,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) - - /* FIXME: some really old kernels (< 1.3.73) will fail this. */ - if (lh.header != -- grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) -+ grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) - || grub_le_to_cpu16 (lh.version) < 0x0200) - break; - -@@ -521,7 +521,7 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) - /* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and - still not support 32-bit boot. */ - if (lh.header != -- grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) -+ grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) - || grub_le_to_cpu16 (lh.version) < 0x0203) - break; - -diff --git a/grub-core/commands/i386/coreboot/cb_timestamps.c b/grub-core/commands/i386/coreboot/cb_timestamps.c -index e72f38d6e057dccfb981d6bbc483d2bdd8a06c98..e97ea6bed98b42d4f03f06ab5bc076fadbfee67f 100644 ---- a/grub-core/commands/i386/coreboot/cb_timestamps.c -+++ b/grub-core/commands/i386/coreboot/cb_timestamps.c -@@ -20,7 +20,7 @@ - #include - #include - #include --#include -+#include - #include - - GRUB_MOD_LICENSE ("GPLv3+"); -diff --git a/grub-core/commands/i386/coreboot/cbls.c b/grub-core/commands/i386/coreboot/cbls.c -index e0a10596fe279331cca94172e1f452fdfe18394f..102291f424ab782c6cd3bcd4ae1effd836cd832e 100644 ---- a/grub-core/commands/i386/coreboot/cbls.c -+++ b/grub-core/commands/i386/coreboot/cbls.c -@@ -20,7 +20,7 @@ - #include - #include - #include --#include -+#include - #include - - GRUB_MOD_LICENSE ("GPLv3+"); -diff --git a/grub-core/commands/keylayouts.c b/grub-core/commands/keylayouts.c -index f4b7730208ab8ffafb1b0283294a140248839d7a..f35d3a369bad7125cb04e25f0e32c01c00c673b0 100644 ---- a/grub-core/commands/keylayouts.c -+++ b/grub-core/commands/keylayouts.c -@@ -40,7 +40,7 @@ static struct grub_keyboard_layout layout_us = { - /* 0x10 */ 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', - /* 0x18 */ 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', - /* 0x20 */ '3', '4', '5', '6', '7', '8', '9', '0', -- /* 0x28 */ '\n', '\e', '\b', '\t', ' ', '-', '=', '[', -+ /* 0x28 */ '\n', GRUB_TERM_ESC, GRUB_TERM_BACKSPACE, GRUB_TERM_TAB, ' ', '-', '=', '[', - /* According to usage table 0x31 should be mapped to '/' - but testing with real keyboard shows that 0x32 is remapped to '/'. - Map 0x31 to 0. -@@ -82,8 +82,8 @@ static struct grub_keyboard_layout layout_us = { - /* 0x10 */ 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', - /* 0x18 */ 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '@', - /* 0x20 */ '#', '$', '%', '^', '&', '*', '(', ')', -- /* 0x28 */ '\n' | GRUB_TERM_SHIFT, '\e' | GRUB_TERM_SHIFT, -- /* 0x2a */ '\b' | GRUB_TERM_SHIFT, '\t' | GRUB_TERM_SHIFT, -+ /* 0x28 */ '\n' | GRUB_TERM_SHIFT, GRUB_TERM_ESC | GRUB_TERM_SHIFT, -+ /* 0x2a */ GRUB_TERM_BACKSPACE | GRUB_TERM_SHIFT, GRUB_TERM_TAB | GRUB_TERM_SHIFT, - /* 0x2c */ ' ' | GRUB_TERM_SHIFT, '_', '+', '{', - /* According to usage table 0x31 should be mapped to '/' - but testing with real keyboard shows that 0x32 is remapped to '/'. -diff --git a/grub-core/commands/ls.c b/grub-core/commands/ls.c -index 0eaf836527944ba69d499050ad080f919d3e57ef..c25161cc4f2c6d4fce6781bfac9bf7796fceb0c7 100644 ---- a/grub-core/commands/ls.c -+++ b/grub-core/commands/ls.c -@@ -201,6 +201,15 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human) - if (grub_errno == GRUB_ERR_UNKNOWN_FS) - grub_errno = GRUB_ERR_NONE; - -+#ifdef GRUB_MACHINE_IEEE1275 -+ /* -+ * Close device to prevent a double open in grub_normal_print_device_info(). -+ * Otherwise it may lead to hangs on some IEEE 1275 platforms. -+ */ -+ grub_device_close (dev); -+ dev = NULL; -+#endif -+ - grub_normal_print_device_info (device_name); - } - else if (fs) -diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c -index 58d4dadf6ee4ec392a09d433802803520704cd7b..2c5363da7f549b85ae04d1d88a78db0b85504c51 100644 ---- a/grub-core/commands/menuentry.c -+++ b/grub-core/commands/menuentry.c -@@ -52,8 +52,8 @@ static struct - int key; - } hotkey_aliases[] = - { -- {"backspace", '\b'}, -- {"tab", '\t'}, -+ {"backspace", GRUB_TERM_BACKSPACE}, -+ {"tab", GRUB_TERM_TAB}, - {"delete", GRUB_TERM_KEY_DC}, - {"insert", GRUB_TERM_KEY_INSERT}, - {"f1", GRUB_TERM_KEY_F1}, -diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c -index 494a1b7734ef44fef6e887f62b6eb30d0a494284..f2f606423aca4f842f5b16b797a1084cc5791cbb 100644 ---- a/grub-core/disk/ahci.c -+++ b/grub-core/disk/ahci.c -@@ -82,6 +82,20 @@ enum grub_ahci_hba_port_command - GRUB_AHCI_HBA_PORT_CMD_FR = 0x4000, - }; - -+enum grub_ahci_hba_port_int_status -+ { -+ GRUB_AHCI_HBA_PORT_IS_IFS = (1UL << 27), -+ GRUB_AHCI_HBA_PORT_IS_HBDS = (1UL << 28), -+ GRUB_AHCI_HBA_PORT_IS_HBFS = (1UL << 29), -+ GRUB_AHCI_HBA_PORT_IS_TFES = (1UL << 30), -+ }; -+ -+#define GRUB_AHCI_HBA_PORT_IS_FATAL_MASK ( \ -+ GRUB_AHCI_HBA_PORT_IS_IFS | \ -+ GRUB_AHCI_HBA_PORT_IS_HBDS | \ -+ GRUB_AHCI_HBA_PORT_IS_HBFS | \ -+ GRUB_AHCI_HBA_PORT_IS_TFES) -+ - struct grub_ahci_hba - { - grub_uint32_t cap; -@@ -1026,7 +1040,8 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev, - - endtime = grub_get_time_ms () + (spinup ? 20000 : 20000); - while ((dev->hba->ports[dev->port].command_issue & 1)) -- if (grub_get_time_ms () > endtime) -+ if (grub_get_time_ms () > endtime || -+ (dev->hba->ports[dev->port].intstatus & GRUB_AHCI_HBA_PORT_IS_FATAL_MASK)) - { - grub_dprintf ("ahci", "AHCI status <%x %x %x %x>\n", - dev->hba->ports[dev->port].command_issue, -@@ -1034,7 +1049,10 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev, - dev->hba->ports[dev->port].intstatus, - dev->hba->ports[dev->port].task_file_data); - dev->hba->ports[dev->port].command_issue = 0; -- err = grub_error (GRUB_ERR_IO, "AHCI transfer timed out"); -+ if (dev->hba->ports[dev->port].intstatus & GRUB_AHCI_HBA_PORT_IS_FATAL_MASK) -+ err = grub_error (GRUB_ERR_IO, "AHCI transfer error"); -+ else -+ err = grub_error (GRUB_ERR_IO, "AHCI transfer timed out"); - if (!reset) - grub_ahci_reset_port (dev, 1); - break; -diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c -index 0f978ad05079c9535d7ef9bb16462c7d7adeb80e..2a22d2d6c1c3121ec889f33f2aaaf3077723a6c1 100644 ---- a/grub-core/disk/ldm.c -+++ b/grub-core/disk/ldm.c -@@ -135,7 +135,7 @@ msdos_has_ldm_partition (grub_disk_t dsk) - return has_ldm; - } - --static const grub_gpt_part_type_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM; -+static const grub_gpt_part_guid_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM; - - /* Helper for gpt_ldm_sector. */ - static int -diff --git a/grub-core/efiemu/i386/loadcore64.c b/grub-core/efiemu/i386/loadcore64.c -index e49d0b6ff17e02e22e09b306d0a6a32a3b083b78..18facf47fd7678007deb730fb71256edff6292ad 100644 ---- a/grub-core/efiemu/i386/loadcore64.c -+++ b/grub-core/efiemu/i386/loadcore64.c -@@ -98,6 +98,7 @@ grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs, - break; - - case R_X86_64_PC32: -+ case R_X86_64_PLT32: - err = grub_efiemu_write_value (addr, - *addr32 + rel->r_addend - + sym.off -diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 4849c1ceb6533c1b19eb64d754d45d44282b5acb..be195448dbeb55abcfb117723cd2fc6d75e6e344 100644 ---- a/grub-core/fs/btrfs.c -+++ b/grub-core/fs/btrfs.c -@@ -175,7 +175,7 @@ struct grub_btrfs_time - { - grub_int64_t sec; - grub_uint32_t nanosec; --} __attribute__ ((aligned (4))); -+} GRUB_PACKED; - - struct grub_btrfs_inode - { -diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c -index cdce63bcc9d57e82b7a4f6a644803a1d8320935d..b8ad75a0ff7c4f72b67bef123510d99231531daf 100644 ---- a/grub-core/fs/ext2.c -+++ b/grub-core/fs/ext2.c -@@ -102,6 +102,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 - #define EXT4_FEATURE_INCOMPAT_MMP 0x0100 - #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 -+#define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000 - - /* The set of back-incompatible features this driver DOES support. Add (OR) - * flags here as the related features are implemented into the driver. */ -@@ -109,7 +110,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); - | EXT4_FEATURE_INCOMPAT_EXTENTS \ - | EXT4_FEATURE_INCOMPAT_FLEX_BG \ - | EXT2_FEATURE_INCOMPAT_META_BG \ -- | EXT4_FEATURE_INCOMPAT_64BIT) -+ | EXT4_FEATURE_INCOMPAT_64BIT \ -+ | EXT4_FEATURE_INCOMPAT_ENCRYPT) - /* List of rationales for the ignored "incompatible" features: - * needs_recovery: Not really back-incompatible - was added as such to forbid - * ext2 drivers from mounting an ext3 volume with a dirty -@@ -138,6 +140,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #define EXT3_JOURNAL_FLAG_DELETED 4 - #define EXT3_JOURNAL_FLAG_LAST_TAG 8 - -+#define EXT4_ENCRYPT_FLAG 0x800 - #define EXT4_EXTENTS_FLAG 0x80000 - - /* The ext2 superblock. */ -@@ -706,6 +709,12 @@ grub_ext2_read_symlink (grub_fshelp_node_t node) - grub_ext2_read_inode (diro->data, diro->ino, &diro->inode); - if (grub_errno) - return 0; -+ -+ if (diro->inode.flags & grub_cpu_to_le32_compile_time (EXT4_ENCRYPT_FLAG)) -+ { -+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "symlink is encrypted"); -+ return 0; -+ } - } - - symlink = grub_malloc (grub_le_to_cpu32 (diro->inode.size) + 1); -@@ -749,6 +758,12 @@ grub_ext2_iterate_dir (grub_fshelp_node_t dir, - return 0; - } - -+ if (diro->inode.flags & grub_cpu_to_le32_compile_time (EXT4_ENCRYPT_FLAG)) -+ { -+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "directory is encrypted"); -+ return 0; -+ } -+ - /* Search the file. */ - while (fpos < grub_le_to_cpu32 (diro->inode.size)) - { -@@ -859,6 +874,12 @@ grub_ext2_open (struct grub_file *file, const char *name) - goto fail; - } - -+ if (fdiro->inode.flags & grub_cpu_to_le32_compile_time (EXT4_ENCRYPT_FLAG)) -+ { -+ err = grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "file is encrypted"); -+ goto fail; -+ } -+ - grub_memcpy (data->inode, &fdiro->inode, sizeof (struct grub_ext2_inode)); - grub_free (fdiro); - -diff --git a/grub-core/fs/f2fs.c b/grub-core/fs/f2fs.c -new file mode 100644 -index 0000000000000000000000000000000000000000..1cad2615f3c9e65e57a12d18b76f4ecc1caa31d8 ---- /dev/null -+++ b/grub-core/fs/f2fs.c -@@ -0,0 +1,1314 @@ -+/* -+ * f2fs.c - Flash-Friendly File System -+ * -+ * Written by Jaegeuk Kim -+ * -+ * Copyright (C) 2015 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+GRUB_MOD_LICENSE ("GPLv3+"); -+ -+/* F2FS Magic Number. */ -+#define F2FS_SUPER_MAGIC 0xf2f52010 -+ -+#define CHECKSUM_OFFSET 4092 /* Must be aligned 4 bytes. */ -+#define U32_CHECKSUM_OFFSET (CHECKSUM_OFFSET >> 2) -+#define CRCPOLY_LE 0xedb88320 -+ -+/* Byte-size offset. */ -+#define F2FS_SUPER_OFFSET ((grub_disk_addr_t)1024) -+#define F2FS_SUPER_OFFSET0 (F2FS_SUPER_OFFSET >> GRUB_DISK_SECTOR_BITS) -+#define F2FS_SUPER_OFFSET1 ((F2FS_SUPER_OFFSET + F2FS_BLKSIZE) >> \ -+ GRUB_DISK_SECTOR_BITS) -+ -+/* 9 bits for 512 bytes. */ -+#define F2FS_MIN_LOG_SECTOR_SIZE 9 -+ -+/* Support only 4KB block. */ -+#define F2FS_BLK_BITS 12 -+#define F2FS_BLKSIZE (1 << F2FS_BLK_BITS) -+#define F2FS_BLK_SEC_BITS (F2FS_BLK_BITS - GRUB_DISK_SECTOR_BITS) -+ -+#define VERSION_LEN 256 -+#define F2FS_MAX_EXTENSION 64 -+ -+#define CP_COMPACT_SUM_FLAG 0x00000004 -+#define CP_UMOUNT_FLAG 0x00000001 -+ -+#define MAX_ACTIVE_LOGS 16 -+#define MAX_ACTIVE_NODE_LOGS 8 -+#define MAX_ACTIVE_DATA_LOGS 8 -+#define NR_CURSEG_DATA_TYPE 3 -+#define NR_CURSEG_NODE_TYPE 3 -+#define NR_CURSEG_TYPE (NR_CURSEG_DATA_TYPE + NR_CURSEG_NODE_TYPE) -+ -+#define ENTRIES_IN_SUM 512 -+#define SUMMARY_SIZE 7 -+#define SUM_FOOTER_SIZE 5 -+#define JENTRY_SIZE (sizeof(struct grub_f2fs_nat_jent)) -+#define SUM_ENTRIES_SIZE (SUMMARY_SIZE * ENTRIES_IN_SUM) -+#define SUM_JOURNAL_SIZE (F2FS_BLKSIZE - SUM_FOOTER_SIZE - SUM_ENTRIES_SIZE) -+#define NAT_JOURNAL_ENTRIES ((SUM_JOURNAL_SIZE - 2) / JENTRY_SIZE) -+#define NAT_JOURNAL_RESERVED ((SUM_JOURNAL_SIZE - 2) % JENTRY_SIZE) -+ -+#define NAT_ENTRY_SIZE (sizeof(struct grub_f2fs_nat_entry)) -+#define NAT_ENTRY_PER_BLOCK (F2FS_BLKSIZE / NAT_ENTRY_SIZE) -+ -+#define F2FS_NAME_LEN 255 -+#define F2FS_SLOT_LEN 8 -+#define NR_DENTRY_IN_BLOCK 214 -+#define SIZE_OF_DIR_ENTRY 11 /* By byte. */ -+#define BITS_PER_BYTE 8 -+#define SIZE_OF_DENTRY_BITMAP ((NR_DENTRY_IN_BLOCK + BITS_PER_BYTE - 1) / \ -+ BITS_PER_BYTE) -+#define SIZE_OF_RESERVED (F2FS_BLKSIZE - \ -+ ((SIZE_OF_DIR_ENTRY + F2FS_SLOT_LEN) * \ -+ NR_DENTRY_IN_BLOCK + SIZE_OF_DENTRY_BITMAP)) -+ -+#define F2FS_INLINE_XATTR_ADDRS 50 /* 200 bytes for inline xattrs. */ -+#define DEF_ADDRS_PER_INODE 923 /* Address Pointers in an Inode. */ -+ -+#define ADDRS_PER_BLOCK 1018 /* Address Pointers in a Direct Block. */ -+#define NIDS_PER_BLOCK 1018 /* Node IDs in an Indirect Block. */ -+#define NODE_DIR1_BLOCK (DEF_ADDRS_PER_INODE + 1) -+#define NODE_DIR2_BLOCK (DEF_ADDRS_PER_INODE + 2) -+#define NODE_IND1_BLOCK (DEF_ADDRS_PER_INODE + 3) -+#define NODE_IND2_BLOCK (DEF_ADDRS_PER_INODE + 4) -+#define NODE_DIND_BLOCK (DEF_ADDRS_PER_INODE + 5) -+ -+#define MAX_INLINE_DATA (4 * (DEF_ADDRS_PER_INODE - \ -+ F2FS_INLINE_XATTR_ADDRS - 1)) -+#define NR_INLINE_DENTRY (MAX_INLINE_DATA * BITS_PER_BYTE / \ -+ ((SIZE_OF_DIR_ENTRY + F2FS_SLOT_LEN) * \ -+ BITS_PER_BYTE + 1)) -+#define INLINE_DENTRY_BITMAP_SIZE ((NR_INLINE_DENTRY + BITS_PER_BYTE - 1) / \ -+ BITS_PER_BYTE) -+#define INLINE_RESERVED_SIZE (MAX_INLINE_DATA - \ -+ ((SIZE_OF_DIR_ENTRY + F2FS_SLOT_LEN) * \ -+ NR_INLINE_DENTRY + \ -+ INLINE_DENTRY_BITMAP_SIZE)) -+#define CURSEG_HOT_DATA 0 -+ -+#define CKPT_FLAG_SET(ckpt, f) (ckpt)->ckpt_flags & \ -+ grub_cpu_to_le32_compile_time (f) -+ -+#define F2FS_INLINE_XATTR 0x01 /* File inline xattr flag. */ -+#define F2FS_INLINE_DATA 0x02 /* File inline data flag. */ -+#define F2FS_INLINE_DENTRY 0x04 /* File inline dentry flag. */ -+#define F2FS_DATA_EXIST 0x08 /* File inline data exist flag. */ -+#define F2FS_INLINE_DOTS 0x10 /* File having implicit dot dentries. */ -+ -+#define MAX_VOLUME_NAME 512 -+ -+enum FILE_TYPE -+{ -+ F2FS_FT_UNKNOWN, -+ F2FS_FT_REG_FILE = 1, -+ F2FS_FT_DIR = 2, -+ F2FS_FT_SYMLINK = 7 -+}; -+ -+struct grub_f2fs_superblock -+{ -+ grub_uint32_t magic; -+ grub_uint16_t dummy1[2]; -+ grub_uint32_t log_sectorsize; -+ grub_uint32_t log_sectors_per_block; -+ grub_uint32_t log_blocksize; -+ grub_uint32_t log_blocks_per_seg; -+ grub_uint32_t segs_per_sec; -+ grub_uint32_t secs_per_zone; -+ grub_uint32_t checksum_offset; -+ grub_uint8_t dummy2[40]; -+ grub_uint32_t cp_blkaddr; -+ grub_uint32_t sit_blkaddr; -+ grub_uint32_t nat_blkaddr; -+ grub_uint32_t ssa_blkaddr; -+ grub_uint32_t main_blkaddr; -+ grub_uint32_t root_ino; -+ grub_uint32_t node_ino; -+ grub_uint32_t meta_ino; -+ grub_uint8_t uuid[16]; -+ grub_uint16_t volume_name[MAX_VOLUME_NAME]; -+ grub_uint32_t extension_count; -+ grub_uint8_t extension_list[F2FS_MAX_EXTENSION][8]; -+ grub_uint32_t cp_payload; -+ grub_uint8_t version[VERSION_LEN]; -+ grub_uint8_t init_version[VERSION_LEN]; -+} GRUB_PACKED; -+ -+struct grub_f2fs_checkpoint -+{ -+ grub_uint64_t checkpoint_ver; -+ grub_uint64_t user_block_count; -+ grub_uint64_t valid_block_count; -+ grub_uint32_t rsvd_segment_count; -+ grub_uint32_t overprov_segment_count; -+ grub_uint32_t free_segment_count; -+ grub_uint32_t cur_node_segno[MAX_ACTIVE_NODE_LOGS]; -+ grub_uint16_t cur_node_blkoff[MAX_ACTIVE_NODE_LOGS]; -+ grub_uint32_t cur_data_segno[MAX_ACTIVE_DATA_LOGS]; -+ grub_uint16_t cur_data_blkoff[MAX_ACTIVE_DATA_LOGS]; -+ grub_uint32_t ckpt_flags; -+ grub_uint32_t cp_pack_total_block_count; -+ grub_uint32_t cp_pack_start_sum; -+ grub_uint32_t valid_node_count; -+ grub_uint32_t valid_inode_count; -+ grub_uint32_t next_free_nid; -+ grub_uint32_t sit_ver_bitmap_bytesize; -+ grub_uint32_t nat_ver_bitmap_bytesize; -+ grub_uint32_t checksum_offset; -+ grub_uint64_t elapsed_time; -+ grub_uint8_t alloc_type[MAX_ACTIVE_LOGS]; -+ grub_uint8_t sit_nat_version_bitmap[3900]; -+ grub_uint32_t checksum; -+} GRUB_PACKED; -+ -+struct grub_f2fs_nat_entry { -+ grub_uint8_t version; -+ grub_uint32_t ino; -+ grub_uint32_t block_addr; -+} GRUB_PACKED; -+ -+struct grub_f2fs_nat_jent -+{ -+ grub_uint32_t nid; -+ struct grub_f2fs_nat_entry ne; -+} GRUB_PACKED; -+ -+struct grub_f2fs_nat_journal { -+ grub_uint16_t n_nats; -+ struct grub_f2fs_nat_jent entries[NAT_JOURNAL_ENTRIES]; -+ grub_uint8_t reserved[NAT_JOURNAL_RESERVED]; -+} GRUB_PACKED; -+ -+struct grub_f2fs_nat_block { -+ struct grub_f2fs_nat_entry ne[NAT_ENTRY_PER_BLOCK]; -+} GRUB_PACKED; -+ -+struct grub_f2fs_dir_entry -+{ -+ grub_uint32_t hash_code; -+ grub_uint32_t ino; -+ grub_uint16_t name_len; -+ grub_uint8_t file_type; -+} GRUB_PACKED; -+ -+struct grub_f2fs_inline_dentry -+{ -+ grub_uint8_t dentry_bitmap[INLINE_DENTRY_BITMAP_SIZE]; -+ grub_uint8_t reserved[INLINE_RESERVED_SIZE]; -+ struct grub_f2fs_dir_entry dentry[NR_INLINE_DENTRY]; -+ grub_uint8_t filename[NR_INLINE_DENTRY][F2FS_SLOT_LEN]; -+} GRUB_PACKED; -+ -+struct grub_f2fs_dentry_block { -+ grub_uint8_t dentry_bitmap[SIZE_OF_DENTRY_BITMAP]; -+ grub_uint8_t reserved[SIZE_OF_RESERVED]; -+ struct grub_f2fs_dir_entry dentry[NR_DENTRY_IN_BLOCK]; -+ grub_uint8_t filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN]; -+} GRUB_PACKED; -+ -+struct grub_f2fs_inode -+{ -+ grub_uint16_t i_mode; -+ grub_uint8_t i_advise; -+ grub_uint8_t i_inline; -+ grub_uint32_t i_uid; -+ grub_uint32_t i_gid; -+ grub_uint32_t i_links; -+ grub_uint64_t i_size; -+ grub_uint64_t i_blocks; -+ grub_uint64_t i_atime; -+ grub_uint64_t i_ctime; -+ grub_uint64_t i_mtime; -+ grub_uint32_t i_atime_nsec; -+ grub_uint32_t i_ctime_nsec; -+ grub_uint32_t i_mtime_nsec; -+ grub_uint32_t i_generation; -+ grub_uint32_t i_current_depth; -+ grub_uint32_t i_xattr_nid; -+ grub_uint32_t i_flags; -+ grub_uint32_t i_pino; -+ grub_uint32_t i_namelen; -+ grub_uint8_t i_name[F2FS_NAME_LEN]; -+ grub_uint8_t i_dir_level; -+ grub_uint8_t i_ext[12]; -+ grub_uint32_t i_addr[DEF_ADDRS_PER_INODE]; -+ grub_uint32_t i_nid[5]; -+} GRUB_PACKED; -+ -+struct grub_direct_node { -+ grub_uint32_t addr[ADDRS_PER_BLOCK]; -+} GRUB_PACKED; -+ -+struct grub_indirect_node { -+ grub_uint32_t nid[NIDS_PER_BLOCK]; -+} GRUB_PACKED; -+ -+struct grub_f2fs_node -+{ -+ union -+ { -+ struct grub_f2fs_inode i; -+ struct grub_direct_node dn; -+ struct grub_indirect_node in; -+ /* Should occupy F2FS_BLKSIZE totally. */ -+ char buf[F2FS_BLKSIZE - 40]; -+ }; -+ grub_uint8_t dummy[40]; -+} GRUB_PACKED; -+ -+struct grub_fshelp_node -+{ -+ struct grub_f2fs_data *data; -+ struct grub_f2fs_node inode; -+ grub_uint32_t ino; -+ int inode_read; -+}; -+ -+struct grub_f2fs_data -+{ -+ struct grub_f2fs_superblock sblock; -+ struct grub_f2fs_checkpoint ckpt; -+ -+ grub_uint32_t root_ino; -+ grub_uint32_t blocks_per_seg; -+ grub_uint32_t cp_blkaddr; -+ grub_uint32_t nat_blkaddr; -+ -+ struct grub_f2fs_nat_journal nat_j; -+ char *nat_bitmap; -+ -+ grub_disk_t disk; -+ struct grub_f2fs_node *inode; -+ struct grub_fshelp_node diropen; -+}; -+ -+struct grub_f2fs_dir_iter_ctx -+{ -+ struct grub_f2fs_data *data; -+ grub_fshelp_iterate_dir_hook_t hook; -+ void *hook_data; -+ grub_uint8_t *bitmap; -+ grub_uint8_t (*filename)[F2FS_SLOT_LEN]; -+ struct grub_f2fs_dir_entry *dentry; -+ int max; -+}; -+ -+struct grub_f2fs_dir_ctx -+{ -+ grub_fs_dir_hook_t hook; -+ void *hook_data; -+ struct grub_f2fs_data *data; -+}; -+ -+static grub_dl_t my_mod; -+ -+static int -+grub_f2fs_test_bit_le (int nr, const grub_uint8_t *addr) -+{ -+ return addr[nr >> 3] & (1 << (nr & 7)); -+} -+ -+static char * -+get_inline_addr (struct grub_f2fs_inode *inode) -+{ -+ return (char *) &inode->i_addr[1]; -+} -+ -+static grub_uint64_t -+grub_f2fs_file_size (struct grub_f2fs_inode *inode) -+{ -+ return grub_le_to_cpu64 (inode->i_size); -+} -+ -+static grub_uint32_t -+start_cp_addr (struct grub_f2fs_data *data) -+{ -+ struct grub_f2fs_checkpoint *ckpt = &data->ckpt; -+ grub_uint32_t start_addr = data->cp_blkaddr; -+ -+ if (!(ckpt->checkpoint_ver & grub_cpu_to_le64_compile_time(1))) -+ return start_addr + data->blocks_per_seg; -+ -+ return start_addr; -+} -+ -+static grub_uint32_t -+start_sum_block (struct grub_f2fs_data *data) -+{ -+ struct grub_f2fs_checkpoint *ckpt = &data->ckpt; -+ -+ return start_cp_addr (data) + grub_le_to_cpu32 (ckpt->cp_pack_start_sum); -+} -+ -+static grub_uint32_t -+sum_blk_addr (struct grub_f2fs_data *data, int base, int type) -+{ -+ struct grub_f2fs_checkpoint *ckpt = &data->ckpt; -+ -+ return start_cp_addr (data) + -+ grub_le_to_cpu32 (ckpt->cp_pack_total_block_count) - -+ (base + 1) + type; -+} -+ -+static void * -+nat_bitmap_ptr (struct grub_f2fs_data *data) -+{ -+ struct grub_f2fs_checkpoint *ckpt = &data->ckpt; -+ grub_uint32_t offset; -+ -+ if (grub_le_to_cpu32 (data->sblock.cp_payload) > 0) -+ return ckpt->sit_nat_version_bitmap; -+ -+ offset = grub_le_to_cpu32 (ckpt->sit_ver_bitmap_bytesize); -+ -+ return ckpt->sit_nat_version_bitmap + offset; -+} -+ -+static grub_uint32_t -+get_node_id (struct grub_f2fs_node *rn, int off, int inode_block) -+{ -+ if (inode_block) -+ return grub_le_to_cpu32 (rn->i.i_nid[off - NODE_DIR1_BLOCK]); -+ -+ return grub_le_to_cpu32 (rn->in.nid[off]); -+} -+ -+static grub_err_t -+grub_f2fs_block_read (struct grub_f2fs_data *data, grub_uint32_t blkaddr, -+ void *buf) -+{ -+ return grub_disk_read (data->disk, -+ ((grub_disk_addr_t)blkaddr) << F2FS_BLK_SEC_BITS, -+ 0, F2FS_BLKSIZE, buf); -+} -+ -+/* CRC32 */ -+static grub_uint32_t -+grub_f2fs_cal_crc32 (const void *buf, const grub_uint32_t len) -+{ -+ grub_uint32_t crc = F2FS_SUPER_MAGIC; -+ unsigned char *p = (unsigned char *)buf; -+ grub_uint32_t tmp = len; -+ int i; -+ -+ while (tmp--) -+ { -+ crc ^= *p++; -+ for (i = 0; i < 8; i++) -+ crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0); -+ } -+ -+ return crc; -+} -+ -+static int -+grub_f2fs_crc_valid (grub_uint32_t blk_crc, void *buf, const grub_uint32_t len) -+{ -+ grub_uint32_t cal_crc = 0; -+ -+ cal_crc = grub_f2fs_cal_crc32 (buf, len); -+ -+ return (cal_crc == blk_crc) ? 1 : 0; -+} -+ -+static int -+grub_f2fs_test_bit (grub_uint32_t nr, const char *p) -+{ -+ int mask; -+ -+ p += (nr >> 3); -+ mask = 1 << (7 - (nr & 0x07)); -+ -+ return mask & *p; -+} -+ -+static int -+grub_f2fs_sanity_check_sb (struct grub_f2fs_superblock *sb) -+{ -+ grub_uint32_t log_sectorsize, log_sectors_per_block; -+ -+ if (sb->magic != grub_cpu_to_le32_compile_time (F2FS_SUPER_MAGIC)) -+ return -1; -+ -+ if (sb->log_blocksize != grub_cpu_to_le32_compile_time (F2FS_BLK_BITS)) -+ return -1; -+ -+ log_sectorsize = grub_le_to_cpu32 (sb->log_sectorsize); -+ log_sectors_per_block = grub_le_to_cpu32 (sb->log_sectors_per_block); -+ -+ if (log_sectorsize > F2FS_BLK_BITS) -+ return -1; -+ -+ if (log_sectorsize < F2FS_MIN_LOG_SECTOR_SIZE) -+ return -1; -+ -+ if (log_sectors_per_block + log_sectorsize != F2FS_BLK_BITS) -+ return -1; -+ -+ return 0; -+} -+ -+static int -+grub_f2fs_read_sb (struct grub_f2fs_data *data, grub_disk_addr_t offset) -+{ -+ grub_disk_t disk = data->disk; -+ grub_err_t err; -+ -+ /* Read first super block. */ -+ err = grub_disk_read (disk, offset, 0, sizeof (data->sblock), &data->sblock); -+ if (err) -+ return -1; -+ -+ return grub_f2fs_sanity_check_sb (&data->sblock); -+} -+ -+static void * -+validate_checkpoint (struct grub_f2fs_data *data, grub_uint32_t cp_addr, -+ grub_uint64_t *version) -+{ -+ grub_uint32_t *cp_page_1, *cp_page_2; -+ struct grub_f2fs_checkpoint *cp_block; -+ grub_uint64_t cur_version = 0, pre_version = 0; -+ grub_uint32_t crc = 0; -+ grub_uint32_t crc_offset; -+ grub_err_t err; -+ -+ /* Read the 1st cp block in this CP pack. */ -+ cp_page_1 = grub_malloc (F2FS_BLKSIZE); -+ if (!cp_page_1) -+ return NULL; -+ -+ err = grub_f2fs_block_read (data, cp_addr, cp_page_1); -+ if (err) -+ goto invalid_cp1; -+ -+ cp_block = (struct grub_f2fs_checkpoint *)cp_page_1; -+ crc_offset = grub_le_to_cpu32 (cp_block->checksum_offset); -+ if (crc_offset != CHECKSUM_OFFSET) -+ goto invalid_cp1; -+ -+ crc = grub_le_to_cpu32 (*(cp_page_1 + U32_CHECKSUM_OFFSET)); -+ if (!grub_f2fs_crc_valid (crc, cp_block, crc_offset)) -+ goto invalid_cp1; -+ -+ pre_version = grub_le_to_cpu64 (cp_block->checkpoint_ver); -+ -+ /* Read the 2nd cp block in this CP pack. */ -+ cp_page_2 = grub_malloc (F2FS_BLKSIZE); -+ if (!cp_page_2) -+ goto invalid_cp1; -+ -+ cp_addr += grub_le_to_cpu32 (cp_block->cp_pack_total_block_count) - 1; -+ -+ err = grub_f2fs_block_read (data, cp_addr, cp_page_2); -+ if (err) -+ goto invalid_cp2; -+ -+ cp_block = (struct grub_f2fs_checkpoint *)cp_page_2; -+ crc_offset = grub_le_to_cpu32 (cp_block->checksum_offset); -+ if (crc_offset != CHECKSUM_OFFSET) -+ goto invalid_cp2; -+ -+ crc = grub_le_to_cpu32 (*(cp_page_2 + U32_CHECKSUM_OFFSET)); -+ if (!grub_f2fs_crc_valid (crc, cp_block, crc_offset)) -+ goto invalid_cp2; -+ -+ cur_version = grub_le_to_cpu64 (cp_block->checkpoint_ver); -+ if (cur_version == pre_version) -+ { -+ *version = cur_version; -+ grub_free (cp_page_2); -+ -+ return cp_page_1; -+ } -+ -+ invalid_cp2: -+ grub_free (cp_page_2); -+ -+ invalid_cp1: -+ grub_free (cp_page_1); -+ -+ return NULL; -+} -+ -+static grub_err_t -+grub_f2fs_read_cp (struct grub_f2fs_data *data) -+{ -+ void *cp1, *cp2, *cur_page; -+ grub_uint64_t cp1_version = 0, cp2_version = 0; -+ grub_uint64_t cp_start_blk_no; -+ -+ /* -+ * Finding out valid cp block involves read both -+ * sets (cp pack1 and cp pack 2). -+ */ -+ cp_start_blk_no = data->cp_blkaddr; -+ cp1 = validate_checkpoint (data, cp_start_blk_no, &cp1_version); -+ if (!cp1 && grub_errno) -+ return grub_errno; -+ -+ /* The second checkpoint pack should start at the next segment. */ -+ cp_start_blk_no += data->blocks_per_seg; -+ cp2 = validate_checkpoint (data, cp_start_blk_no, &cp2_version); -+ if (!cp2 && grub_errno) -+ { -+ grub_free (cp1); -+ return grub_errno; -+ } -+ -+ if (cp1 && cp2) -+ cur_page = (cp2_version > cp1_version) ? cp2 : cp1; -+ else if (cp1) -+ cur_page = cp1; -+ else if (cp2) -+ cur_page = cp2; -+ else -+ return grub_error (GRUB_ERR_BAD_FS, "no checkpoints"); -+ -+ grub_memcpy (&data->ckpt, cur_page, F2FS_BLKSIZE); -+ -+ grub_free (cp1); -+ grub_free (cp2); -+ -+ return 0; -+} -+ -+static grub_err_t -+get_nat_journal (struct grub_f2fs_data *data) -+{ -+ grub_uint32_t block; -+ char *buf; -+ grub_err_t err; -+ -+ buf = grub_malloc (F2FS_BLKSIZE); -+ if (!buf) -+ return grub_errno; -+ -+ if (CKPT_FLAG_SET(&data->ckpt, CP_COMPACT_SUM_FLAG)) -+ block = start_sum_block (data); -+ else if (CKPT_FLAG_SET (&data->ckpt, CP_UMOUNT_FLAG)) -+ block = sum_blk_addr (data, NR_CURSEG_TYPE, CURSEG_HOT_DATA); -+ else -+ block = sum_blk_addr (data, NR_CURSEG_DATA_TYPE, CURSEG_HOT_DATA); -+ -+ err = grub_f2fs_block_read (data, block, buf); -+ if (err) -+ goto fail; -+ -+ if (CKPT_FLAG_SET (&data->ckpt, CP_COMPACT_SUM_FLAG)) -+ grub_memcpy (&data->nat_j, buf, SUM_JOURNAL_SIZE); -+ else -+ grub_memcpy (&data->nat_j, buf + SUM_ENTRIES_SIZE, SUM_JOURNAL_SIZE); -+ -+ fail: -+ grub_free (buf); -+ -+ return err; -+} -+ -+static grub_uint32_t -+get_blkaddr_from_nat_journal (struct grub_f2fs_data *data, grub_uint32_t nid) -+{ -+ grub_uint16_t n = grub_le_to_cpu16 (data->nat_j.n_nats); -+ grub_uint32_t blkaddr = 0; -+ grub_uint16_t i; -+ -+ for (i = 0; i < n; i++) -+ { -+ if (grub_le_to_cpu32 (data->nat_j.entries[i].nid) == nid) -+ { -+ blkaddr = grub_le_to_cpu32 (data->nat_j.entries[i].ne.block_addr); -+ break; -+ } -+ } -+ -+ return blkaddr; -+} -+ -+static grub_uint32_t -+get_node_blkaddr (struct grub_f2fs_data *data, grub_uint32_t nid) -+{ -+ struct grub_f2fs_nat_block *nat_block; -+ grub_uint32_t seg_off, block_off, entry_off, block_addr; -+ grub_uint32_t blkaddr; -+ grub_err_t err; -+ -+ blkaddr = get_blkaddr_from_nat_journal (data, nid); -+ if (blkaddr) -+ return blkaddr; -+ -+ nat_block = grub_malloc (F2FS_BLKSIZE); -+ if (!nat_block) -+ return 0; -+ -+ block_off = nid / NAT_ENTRY_PER_BLOCK; -+ entry_off = nid % NAT_ENTRY_PER_BLOCK; -+ -+ seg_off = block_off / data->blocks_per_seg; -+ block_addr = data->nat_blkaddr + -+ ((seg_off * data->blocks_per_seg) << 1) + -+ (block_off & (data->blocks_per_seg - 1)); -+ -+ if (grub_f2fs_test_bit (block_off, data->nat_bitmap)) -+ block_addr += data->blocks_per_seg; -+ -+ err = grub_f2fs_block_read (data, block_addr, nat_block); -+ if (err) -+ { -+ grub_free (nat_block); -+ return 0; -+ } -+ -+ blkaddr = grub_le_to_cpu32 (nat_block->ne[entry_off].block_addr); -+ -+ grub_free (nat_block); -+ -+ return blkaddr; -+} -+ -+static int -+grub_get_node_path (struct grub_f2fs_inode *inode, grub_uint32_t block, -+ grub_uint32_t offset[4], grub_uint32_t noffset[4]) -+{ -+ grub_uint32_t direct_blks = ADDRS_PER_BLOCK; -+ grub_uint32_t dptrs_per_blk = NIDS_PER_BLOCK; -+ grub_uint32_t indirect_blks = ADDRS_PER_BLOCK * NIDS_PER_BLOCK; -+ grub_uint32_t dindirect_blks = indirect_blks * NIDS_PER_BLOCK; -+ grub_uint32_t direct_index = DEF_ADDRS_PER_INODE; -+ int n = 0; -+ int level = 0; -+ -+ if (inode->i_inline & F2FS_INLINE_XATTR) -+ direct_index -= F2FS_INLINE_XATTR_ADDRS; -+ -+ noffset[0] = 0; -+ -+ if (block < direct_index) -+ { -+ offset[n] = block; -+ goto got; -+ } -+ -+ block -= direct_index; -+ if (block < direct_blks) -+ { -+ offset[n++] = NODE_DIR1_BLOCK; -+ noffset[n] = 1; -+ offset[n] = block; -+ level = 1; -+ goto got; -+ } -+ -+ block -= direct_blks; -+ if (block < direct_blks) -+ { -+ offset[n++] = NODE_DIR2_BLOCK; -+ noffset[n] = 2; -+ offset[n] = block; -+ level = 1; -+ goto got; -+ } -+ -+ block -= direct_blks; -+ if (block < indirect_blks) -+ { -+ offset[n++] = NODE_IND1_BLOCK; -+ noffset[n] = 3; -+ offset[n++] = block / direct_blks; -+ noffset[n] = 4 + offset[n - 1]; -+ offset[n] = block % direct_blks; -+ level = 2; -+ goto got; -+ } -+ -+ block -= indirect_blks; -+ if (block < indirect_blks) -+ { -+ offset[n++] = NODE_IND2_BLOCK; -+ noffset[n] = 4 + dptrs_per_blk; -+ offset[n++] = block / direct_blks; -+ noffset[n] = 5 + dptrs_per_blk + offset[n - 1]; -+ offset[n] = block % direct_blks; -+ level = 2; -+ goto got; -+ } -+ -+ block -= indirect_blks; -+ if (block < dindirect_blks) -+ { -+ offset[n++] = NODE_DIND_BLOCK; -+ noffset[n] = 5 + (dptrs_per_blk * 2); -+ offset[n++] = block / indirect_blks; -+ noffset[n] = 6 + (dptrs_per_blk * 2) + -+ offset[n - 1] * (dptrs_per_blk + 1); -+ offset[n++] = (block / direct_blks) % dptrs_per_blk; -+ noffset[n] = 7 + (dptrs_per_blk * 2) + -+ offset[n - 2] * (dptrs_per_blk + 1) + offset[n - 1]; -+ offset[n] = block % direct_blks; -+ level = 3; -+ goto got; -+ } -+ -+ got: -+ return level; -+} -+ -+static grub_err_t -+grub_f2fs_read_node (struct grub_f2fs_data *data, -+ grub_uint32_t nid, struct grub_f2fs_node *np) -+{ -+ grub_uint32_t blkaddr; -+ -+ blkaddr = get_node_blkaddr (data, nid); -+ if (!blkaddr) -+ return grub_errno; -+ -+ return grub_f2fs_block_read (data, blkaddr, np); -+} -+ -+static struct grub_f2fs_data * -+grub_f2fs_mount (grub_disk_t disk) -+{ -+ struct grub_f2fs_data *data; -+ grub_err_t err; -+ -+ data = grub_malloc (sizeof (*data)); -+ if (!data) -+ return NULL; -+ -+ data->disk = disk; -+ -+ if (grub_f2fs_read_sb (data, F2FS_SUPER_OFFSET0)) -+ { -+ if (grub_f2fs_read_sb (data, F2FS_SUPER_OFFSET1)) -+ { -+ if (grub_errno == GRUB_ERR_NONE) -+ grub_error (GRUB_ERR_BAD_FS, -+ "not a F2FS filesystem (no superblock)"); -+ goto fail; -+ } -+ } -+ -+ data->root_ino = grub_le_to_cpu32 (data->sblock.root_ino); -+ data->cp_blkaddr = grub_le_to_cpu32 (data->sblock.cp_blkaddr); -+ data->nat_blkaddr = grub_le_to_cpu32 (data->sblock.nat_blkaddr); -+ data->blocks_per_seg = 1 << -+ grub_le_to_cpu32 (data->sblock.log_blocks_per_seg); -+ -+ err = grub_f2fs_read_cp (data); -+ if (err) -+ goto fail; -+ -+ data->nat_bitmap = nat_bitmap_ptr (data); -+ -+ err = get_nat_journal (data); -+ if (err) -+ goto fail; -+ -+ data->diropen.data = data; -+ data->diropen.ino = data->root_ino; -+ data->diropen.inode_read = 1; -+ data->inode = &data->diropen.inode; -+ -+ err = grub_f2fs_read_node (data, data->root_ino, data->inode); -+ if (err) -+ goto fail; -+ -+ return data; -+ -+ fail: -+ grub_free (data); -+ -+ return NULL; -+} -+ -+/* Guarantee inline_data was handled by caller. */ -+static grub_disk_addr_t -+grub_f2fs_get_block (grub_fshelp_node_t node, grub_disk_addr_t block_ofs) -+{ -+ struct grub_f2fs_data *data = node->data; -+ struct grub_f2fs_inode *inode = &node->inode.i; -+ grub_uint32_t offset[4], noffset[4], nids[4]; -+ struct grub_f2fs_node *node_block; -+ grub_uint32_t block_addr = -1; -+ int level, i; -+ -+ level = grub_get_node_path (inode, block_ofs, offset, noffset); -+ if (level == 0) -+ return grub_le_to_cpu32 (inode->i_addr[offset[0]]); -+ -+ node_block = grub_malloc (F2FS_BLKSIZE); -+ if (!node_block) -+ return -1; -+ -+ nids[1] = get_node_id (&node->inode, offset[0], 1); -+ -+ /* Get indirect or direct nodes. */ -+ for (i = 1; i <= level; i++) -+ { -+ grub_f2fs_read_node (data, nids[i], node_block); -+ if (grub_errno) -+ goto fail; -+ -+ if (i < level) -+ nids[i + 1] = get_node_id (node_block, offset[i], 0); -+ } -+ -+ block_addr = grub_le_to_cpu32 (node_block->dn.addr[offset[level]]); -+ -+ fail: -+ grub_free (node_block); -+ -+ return block_addr; -+} -+ -+static grub_ssize_t -+grub_f2fs_read_file (grub_fshelp_node_t node, -+ grub_disk_read_hook_t read_hook, void *read_hook_data, -+ grub_off_t pos, grub_size_t len, char *buf) -+{ -+ struct grub_f2fs_inode *inode = &node->inode.i; -+ grub_off_t filesize = grub_f2fs_file_size (inode); -+ char *inline_addr = get_inline_addr (inode); -+ -+ if (inode->i_inline & F2FS_INLINE_DATA) -+ { -+ if (filesize > MAX_INLINE_DATA) -+ return -1; -+ -+ if (len > filesize - pos) -+ len = filesize - pos; -+ -+ grub_memcpy (buf, inline_addr + pos, len); -+ return len; -+ } -+ -+ return grub_fshelp_read_file (node->data->disk, node, -+ read_hook, read_hook_data, -+ pos, len, buf, grub_f2fs_get_block, -+ filesize, -+ F2FS_BLK_SEC_BITS, 0); -+} -+ -+static char * -+grub_f2fs_read_symlink (grub_fshelp_node_t node) -+{ -+ char *symlink; -+ struct grub_fshelp_node *diro = node; -+ grub_uint64_t filesize; -+ -+ if (!diro->inode_read) -+ { -+ grub_f2fs_read_node (diro->data, diro->ino, &diro->inode); -+ if (grub_errno) -+ return 0; -+ } -+ -+ filesize = grub_f2fs_file_size(&diro->inode.i); -+ -+ symlink = grub_malloc (filesize + 1); -+ if (!symlink) -+ return 0; -+ -+ grub_f2fs_read_file (diro, 0, 0, 0, filesize, symlink); -+ if (grub_errno) -+ { -+ grub_free (symlink); -+ return 0; -+ } -+ -+ symlink[filesize] = '\0'; -+ -+ return symlink; -+} -+ -+static int -+grub_f2fs_check_dentries (struct grub_f2fs_dir_iter_ctx *ctx) -+{ -+ struct grub_fshelp_node *fdiro; -+ int i; -+ -+ for (i = 0; i < ctx->max;) -+ { -+ char *filename; -+ enum grub_fshelp_filetype type = GRUB_FSHELP_UNKNOWN; -+ enum FILE_TYPE ftype; -+ int name_len; -+ int ret; -+ -+ if (grub_f2fs_test_bit_le (i, ctx->bitmap) == 0) -+ { -+ i++; -+ continue; -+ } -+ -+ ftype = ctx->dentry[i].file_type; -+ name_len = grub_le_to_cpu16 (ctx->dentry[i].name_len); -+ filename = grub_malloc (name_len + 1); -+ if (!filename) -+ return 0; -+ -+ grub_memcpy (filename, ctx->filename[i], name_len); -+ filename[name_len] = 0; -+ -+ fdiro = grub_malloc (sizeof (struct grub_fshelp_node)); -+ if (!fdiro) -+ { -+ grub_free(filename); -+ return 0; -+ } -+ -+ if (ftype == F2FS_FT_DIR) -+ type = GRUB_FSHELP_DIR; -+ else if (ftype == F2FS_FT_SYMLINK) -+ type = GRUB_FSHELP_SYMLINK; -+ else if (ftype == F2FS_FT_REG_FILE) -+ type = GRUB_FSHELP_REG; -+ -+ fdiro->data = ctx->data; -+ fdiro->ino = grub_le_to_cpu32 (ctx->dentry[i].ino); -+ fdiro->inode_read = 0; -+ -+ ret = ctx->hook (filename, type, fdiro, ctx->hook_data); -+ grub_free(filename); -+ if (ret) -+ return 1; -+ -+ i += (name_len + F2FS_SLOT_LEN - 1) / F2FS_SLOT_LEN; -+ } -+ -+ return 0; -+} -+ -+static int -+grub_f2fs_iterate_inline_dir (struct grub_f2fs_inode *dir, -+ struct grub_f2fs_dir_iter_ctx *ctx) -+{ -+ struct grub_f2fs_inline_dentry *de_blk; -+ -+ de_blk = (struct grub_f2fs_inline_dentry *) get_inline_addr (dir); -+ -+ ctx->bitmap = de_blk->dentry_bitmap; -+ ctx->dentry = de_blk->dentry; -+ ctx->filename = de_blk->filename; -+ ctx->max = NR_INLINE_DENTRY; -+ -+ return grub_f2fs_check_dentries (ctx); -+} -+ -+static int -+grub_f2fs_iterate_dir (grub_fshelp_node_t dir, -+ grub_fshelp_iterate_dir_hook_t hook, void *hook_data) -+{ -+ struct grub_fshelp_node *diro = (struct grub_fshelp_node *) dir; -+ struct grub_f2fs_inode *inode; -+ struct grub_f2fs_dir_iter_ctx ctx = { -+ .data = diro->data, -+ .hook = hook, -+ .hook_data = hook_data -+ }; -+ grub_off_t fpos = 0; -+ -+ if (!diro->inode_read) -+ { -+ grub_f2fs_read_node (diro->data, diro->ino, &diro->inode); -+ if (grub_errno) -+ return 0; -+ } -+ -+ inode = &diro->inode.i; -+ -+ if (inode->i_inline & F2FS_INLINE_DENTRY) -+ return grub_f2fs_iterate_inline_dir (inode, &ctx); -+ -+ while (fpos < grub_f2fs_file_size (inode)) -+ { -+ struct grub_f2fs_dentry_block *de_blk; -+ char *buf; -+ int ret; -+ -+ buf = grub_zalloc (F2FS_BLKSIZE); -+ if (!buf) -+ return 0; -+ -+ grub_f2fs_read_file (diro, 0, 0, fpos, F2FS_BLKSIZE, buf); -+ if (grub_errno) -+ { -+ grub_free (buf); -+ return 0; -+ } -+ -+ de_blk = (struct grub_f2fs_dentry_block *) buf; -+ -+ ctx.bitmap = de_blk->dentry_bitmap; -+ ctx.dentry = de_blk->dentry; -+ ctx.filename = de_blk->filename; -+ ctx.max = NR_DENTRY_IN_BLOCK; -+ -+ ret = grub_f2fs_check_dentries (&ctx); -+ grub_free (buf); -+ if (ret) -+ return 1; -+ -+ fpos += F2FS_BLKSIZE; -+ } -+ -+ return 0; -+} -+ -+static int -+grub_f2fs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype, -+ grub_fshelp_node_t node, void *data) -+{ -+ struct grub_f2fs_dir_ctx *ctx = data; -+ struct grub_dirhook_info info; -+ -+ grub_memset (&info, 0, sizeof (info)); -+ if (!node->inode_read) -+ { -+ grub_f2fs_read_node (ctx->data, node->ino, &node->inode); -+ if (!grub_errno) -+ node->inode_read = 1; -+ grub_errno = GRUB_ERR_NONE; -+ } -+ if (node->inode_read) -+ { -+ info.mtimeset = 1; -+ info.mtime = grub_le_to_cpu64 (node->inode.i.i_mtime); -+ } -+ -+ info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR); -+ grub_free (node); -+ -+ return ctx->hook (filename, &info, ctx->hook_data); -+} -+ -+static grub_err_t -+grub_f2fs_dir (grub_device_t device, const char *path, -+ grub_fs_dir_hook_t hook, void *hook_data) -+{ -+ struct grub_f2fs_dir_ctx ctx = { -+ .hook = hook, -+ .hook_data = hook_data -+ }; -+ struct grub_fshelp_node *fdiro = 0; -+ -+ grub_dl_ref (my_mod); -+ -+ ctx.data = grub_f2fs_mount (device->disk); -+ if (!ctx.data) -+ goto fail; -+ -+ grub_fshelp_find_file (path, &ctx.data->diropen, &fdiro, -+ grub_f2fs_iterate_dir, grub_f2fs_read_symlink, -+ GRUB_FSHELP_DIR); -+ if (grub_errno) -+ goto fail; -+ -+ grub_f2fs_iterate_dir (fdiro, grub_f2fs_dir_iter, &ctx); -+ -+ fail: -+ if (fdiro != &ctx.data->diropen) -+ grub_free (fdiro); -+ grub_free (ctx.data); -+ grub_dl_unref (my_mod); -+ -+ return grub_errno; -+} -+ -+/* Open a file named NAME and initialize FILE. */ -+static grub_err_t -+grub_f2fs_open (struct grub_file *file, const char *name) -+{ -+ struct grub_f2fs_data *data = NULL; -+ struct grub_fshelp_node *fdiro = 0; -+ struct grub_f2fs_inode *inode; -+ -+ grub_dl_ref (my_mod); -+ -+ data = grub_f2fs_mount (file->device->disk); -+ if (!data) -+ goto fail; -+ -+ grub_fshelp_find_file (name, &data->diropen, &fdiro, -+ grub_f2fs_iterate_dir, grub_f2fs_read_symlink, -+ GRUB_FSHELP_REG); -+ if (grub_errno) -+ goto fail; -+ -+ if (!fdiro->inode_read) -+ { -+ grub_f2fs_read_node (data, fdiro->ino, &fdiro->inode); -+ if (grub_errno) -+ goto fail; -+ } -+ -+ grub_memcpy (data->inode, &fdiro->inode, sizeof (*data->inode)); -+ grub_free (fdiro); -+ -+ inode = &(data->inode->i); -+ file->size = grub_f2fs_file_size (inode); -+ file->data = data; -+ file->offset = 0; -+ -+ if (inode->i_inline & F2FS_INLINE_DATA && file->size > MAX_INLINE_DATA) -+ grub_error (GRUB_ERR_BAD_FS, "corrupted inline_data: need fsck"); -+ -+ return 0; -+ -+ fail: -+ if (fdiro != &data->diropen) -+ grub_free (fdiro); -+ grub_free (data); -+ -+ grub_dl_unref (my_mod); -+ -+ return grub_errno; -+} -+ -+static grub_ssize_t -+grub_f2fs_read (grub_file_t file, char *buf, grub_size_t len) -+{ -+ struct grub_f2fs_data *data = (struct grub_f2fs_data *) file->data; -+ -+ return grub_f2fs_read_file (&data->diropen, -+ file->read_hook, file->read_hook_data, -+ file->offset, len, buf); -+} -+ -+static grub_err_t -+grub_f2fs_close (grub_file_t file) -+{ -+ struct grub_f2fs_data *data = (struct grub_f2fs_data *) file->data; -+ -+ grub_free (data); -+ -+ grub_dl_unref (my_mod); -+ -+ return GRUB_ERR_NONE; -+} -+ -+static grub_uint8_t * -+grub_f2fs_utf16_to_utf8 (grub_uint16_t *in_buf_le) -+{ -+ grub_uint16_t in_buf[MAX_VOLUME_NAME]; -+ grub_uint8_t *out_buf; -+ int len = 0; -+ -+ out_buf = grub_malloc (MAX_VOLUME_NAME * GRUB_MAX_UTF8_PER_UTF16 + 1); -+ if (!out_buf) -+ return NULL; -+ -+ while (*in_buf_le != 0 && len < MAX_VOLUME_NAME) { -+ in_buf[len] = grub_le_to_cpu16 (in_buf_le[len]); -+ len++; -+ } -+ -+ *grub_utf16_to_utf8 (out_buf, in_buf, len) = '\0'; -+ -+ return out_buf; -+} -+ -+static grub_err_t -+grub_f2fs_label (grub_device_t device, char **label) -+{ -+ struct grub_f2fs_data *data; -+ grub_disk_t disk = device->disk; -+ -+ grub_dl_ref (my_mod); -+ -+ data = grub_f2fs_mount (disk); -+ if (data) -+ *label = (char *) grub_f2fs_utf16_to_utf8 (data->sblock.volume_name); -+ else -+ *label = NULL; -+ -+ grub_free (data); -+ grub_dl_unref (my_mod); -+ -+ return grub_errno; -+} -+ -+static grub_err_t -+grub_f2fs_uuid (grub_device_t device, char **uuid) -+{ -+ struct grub_f2fs_data *data; -+ grub_disk_t disk = device->disk; -+ -+ grub_dl_ref (my_mod); -+ -+ data = grub_f2fs_mount (disk); -+ if (data) -+ { -+ *uuid = -+ grub_xasprintf -+ ("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", -+ data->sblock.uuid[0], data->sblock.uuid[1], -+ data->sblock.uuid[2], data->sblock.uuid[3], -+ data->sblock.uuid[4], data->sblock.uuid[5], -+ data->sblock.uuid[6], data->sblock.uuid[7], -+ data->sblock.uuid[8], data->sblock.uuid[9], -+ data->sblock.uuid[10], data->sblock.uuid[11], -+ data->sblock.uuid[12], data->sblock.uuid[13], -+ data->sblock.uuid[14], data->sblock.uuid[15]); -+ } -+ else -+ *uuid = NULL; -+ -+ grub_free (data); -+ grub_dl_unref (my_mod); -+ -+ return grub_errno; -+} -+ -+static struct grub_fs grub_f2fs_fs = { -+ .name = "f2fs", -+ .dir = grub_f2fs_dir, -+ .open = grub_f2fs_open, -+ .read = grub_f2fs_read, -+ .close = grub_f2fs_close, -+ .label = grub_f2fs_label, -+ .uuid = grub_f2fs_uuid, -+#ifdef GRUB_UTIL -+ .reserved_first_sector = 1, -+ .blocklist_install = 0, -+#endif -+ .next = 0 -+}; -+ -+GRUB_MOD_INIT (f2fs) -+{ -+ grub_fs_register (&grub_f2fs_fs); -+ my_mod = mod; -+} -+ -+GRUB_MOD_FINI (f2fs) -+{ -+ grub_fs_unregister (&grub_f2fs_fs); -+} -diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c -index 839bff88963baba7730d788869e1f50481a66a30..00a16098b47aff52a352fa9433e279beae261329 100644 ---- a/grub-core/fs/udf.c -+++ b/grub-core/fs/udf.c -@@ -321,6 +321,32 @@ struct grub_udf_partmap - }; - } GRUB_PACKED; - -+struct grub_udf_pvd -+{ -+ struct grub_udf_tag tag; -+ grub_uint32_t seq_num; -+ grub_uint32_t pvd_num; -+ grub_uint8_t ident[32]; -+ grub_uint16_t vol_seq_num; -+ grub_uint16_t max_vol_seq_num; -+ grub_uint16_t interchange_level; -+ grub_uint16_t max_interchange_level; -+ grub_uint32_t charset_list; -+ grub_uint32_t max_charset_list; -+ grub_uint8_t volset_ident[128]; -+ struct grub_udf_charspec desc_charset; -+ struct grub_udf_charspec expl_charset; -+ struct grub_udf_extent_ad vol_abstract; -+ struct grub_udf_extent_ad vol_copyright; -+ struct grub_udf_regid app_ident; -+ struct grub_udf_timestamp recording_time; -+ struct grub_udf_regid imp_ident; -+ grub_uint8_t imp_use[64]; -+ grub_uint32_t pred_vds_loc; -+ grub_uint16_t flags; -+ grub_uint8_t reserved[22]; -+} GRUB_PACKED; -+ - struct grub_udf_lvd - { - struct grub_udf_tag tag; -@@ -348,6 +374,7 @@ struct grub_udf_aed - struct grub_udf_data - { - grub_disk_t disk; -+ struct grub_udf_pvd pvd; - struct grub_udf_lvd lvd; - struct grub_udf_pd pds[GRUB_UDF_MAX_PDS]; - struct grub_udf_partmap *pms[GRUB_UDF_MAX_PMS]; -@@ -692,7 +719,17 @@ grub_udf_mount (grub_disk_t disk) - } - - tag.tag_ident = U16 (tag.tag_ident); -- if (tag.tag_ident == GRUB_UDF_TAG_IDENT_PD) -+ if (tag.tag_ident == GRUB_UDF_TAG_IDENT_PVD) -+ { -+ if (grub_disk_read (disk, block << lbshift, 0, -+ sizeof (struct grub_udf_pvd), -+ &data->pvd)) -+ { -+ grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem"); -+ goto fail; -+ } -+ } -+ else if (tag.tag_ident == GRUB_UDF_TAG_IDENT_PD) - { - if (data->npd >= GRUB_UDF_MAX_PDS) - { -@@ -860,6 +897,25 @@ read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf) - return outbuf; - } - -+static char * -+read_dstring (const grub_uint8_t *raw, grub_size_t sz) -+{ -+ grub_size_t len; -+ -+ if (raw[0] == 0) { -+ char *outbuf = grub_malloc (1); -+ if (!outbuf) -+ return NULL; -+ outbuf[0] = 0; -+ return outbuf; -+ } -+ -+ len = raw[sz - 1]; -+ if (len > sz - 1) -+ len = sz - 1; -+ return read_string (raw, len, NULL); -+} -+ - static int - grub_udf_iterate_dir (grub_fshelp_node_t dir, - grub_fshelp_iterate_dir_hook_t hook, void *hook_data) -@@ -1197,7 +1253,7 @@ grub_udf_label (grub_device_t device, char **label) - - if (data) - { -- *label = read_string (data->lvd.ident, sizeof (data->lvd.ident), 0); -+ *label = read_dstring (data->lvd.ident, sizeof (data->lvd.ident)); - grub_free (data); - } - else -@@ -1206,6 +1262,87 @@ grub_udf_label (grub_device_t device, char **label) - return grub_errno; - } - -+static char * -+gen_uuid_from_volset (char *volset_ident) -+{ -+ grub_size_t i; -+ grub_size_t len; -+ grub_size_t nonhexpos; -+ grub_uint8_t buf[17]; -+ char *uuid; -+ -+ len = grub_strlen (volset_ident); -+ if (len < 8) -+ return NULL; -+ -+ uuid = grub_malloc (17); -+ if (!uuid) -+ return NULL; -+ -+ if (len > 16) -+ len = 16; -+ -+ grub_memset (buf, 0, sizeof (buf)); -+ grub_memcpy (buf, volset_ident, len); -+ -+ nonhexpos = 16; -+ for (i = 0; i < 16; ++i) -+ { -+ if (!grub_isxdigit (buf[i])) -+ { -+ nonhexpos = i; -+ break; -+ } -+ } -+ -+ if (nonhexpos < 8) -+ { -+ grub_snprintf (uuid, 17, "%02x%02x%02x%02x%02x%02x%02x%02x", -+ buf[0], buf[1], buf[2], buf[3], -+ buf[4], buf[5], buf[6], buf[7]); -+ } -+ else if (nonhexpos < 16) -+ { -+ for (i = 0; i < 8; ++i) -+ uuid[i] = grub_tolower (buf[i]); -+ grub_snprintf (uuid+8, 9, "%02x%02x%02x%02x", -+ buf[8], buf[9], buf[10], buf[11]); -+ } -+ else -+ { -+ for (i = 0; i < 16; ++i) -+ uuid[i] = grub_tolower (buf[i]); -+ uuid[16] = 0; -+ } -+ -+ return uuid; -+} -+ -+static grub_err_t -+grub_udf_uuid (grub_device_t device, char **uuid) -+{ -+ char *volset_ident; -+ struct grub_udf_data *data; -+ data = grub_udf_mount (device->disk); -+ -+ if (data) -+ { -+ volset_ident = read_dstring (data->pvd.volset_ident, sizeof (data->pvd.volset_ident)); -+ if (volset_ident) -+ { -+ *uuid = gen_uuid_from_volset (volset_ident); -+ grub_free (volset_ident); -+ } -+ else -+ *uuid = 0; -+ grub_free (data); -+ } -+ else -+ *uuid = 0; -+ -+ return grub_errno; -+} -+ - static struct grub_fs grub_udf_fs = { - .name = "udf", - .dir = grub_udf_dir, -@@ -1213,6 +1350,7 @@ static struct grub_fs grub_udf_fs = { - .read = grub_udf_read, - .close = grub_udf_close, - .label = grub_udf_label, -+ .uuid = grub_udf_uuid, - #ifdef GRUB_UTIL - .reserved_first_sector = 1, - .blocklist_install = 1, -diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c -index 9f66dd6e4c6491e6b2cbfc7866335b432c824502..3b00c744e23c34243df781baa96e5b1b0d88417d 100644 ---- a/grub-core/fs/xfs.c -+++ b/grub-core/fs/xfs.c -@@ -79,9 +79,18 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */ - #define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */ - --/* We do not currently verify metadata UUID so it is safe to read such filesystem */ -+/* -+ * Directory entries with ftype are explicitly handled by GRUB code. -+ * -+ * We do not currently read the inode btrees, so it is safe to read filesystems -+ * with the XFS_SB_FEAT_INCOMPAT_SPINODES feature. -+ * -+ * We do not currently verify metadata UUID, so it is safe to read filesystems -+ * with the XFS_SB_FEAT_INCOMPAT_META_UUID feature. -+ */ - #define XFS_SB_FEAT_INCOMPAT_SUPPORTED \ - (XFS_SB_FEAT_INCOMPAT_FTYPE | \ -+ XFS_SB_FEAT_INCOMPAT_SPINODES | \ - XFS_SB_FEAT_INCOMPAT_META_UUID) - - struct grub_xfs_sblock -@@ -828,6 +837,9 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - entries = (grub_be_to_cpu32 (tail->leaf_count) - - grub_be_to_cpu32 (tail->leaf_stale)); - -+ if (!entries) -+ continue; -+ - /* Iterate over all entries within this block. */ - while ((char *)direntry < (char *)tail) - { -diff --git a/grub-core/fs/zfs/zfs_lz4.c b/grub-core/fs/zfs/zfs_lz4.c -index 2f73449f0d4c63cadc7b5b4388250a4d474594b6..5453822d0258527ba751e551cbb54753f0331043 100644 ---- a/grub-core/fs/zfs/zfs_lz4.c -+++ b/grub-core/fs/zfs/zfs_lz4.c -@@ -73,7 +73,6 @@ static int LZ4_uncompress_unknownOutputSize(const char *source, char *dest, - #define U32 grub_uint32_t - #define S32 grub_int32_t - #define U64 grub_uint64_t --typedef grub_size_t size_t; - - typedef struct _U16_S { - U16 v; -@@ -133,10 +132,10 @@ typedef struct _U64_S { - - /* Decompression functions */ - grub_err_t --lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len); -+lz4_decompress(void *s_start, void *d_start, grub_size_t s_len, grub_size_t d_len); - - grub_err_t --lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len) -+lz4_decompress(void *s_start, void *d_start, grub_size_t s_len, grub_size_t d_len) - { - const BYTE *src = s_start; - U32 bufsiz = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | -@@ -167,7 +166,7 @@ LZ4_uncompress_unknownOutputSize(const char *source, - BYTE *const oend = op + maxOutputSize; - BYTE *cpy; - -- size_t dec[] = { 0, 3, 2, 3, 0, 0, 0, 0 }; -+ grub_size_t dec[] = { 0, 3, 2, 3, 0, 0, 0, 0 }; - - /* Main Loop */ - while (ip < iend) { -@@ -237,8 +236,8 @@ LZ4_uncompress_unknownOutputSize(const char *source, - /* copy repeated sequence */ - if unlikely(op - ref < STEPSIZE) { - #if LZ4_ARCH64 -- size_t dec2table[] = { 0, 0, 0, -1, 0, 1, 2, 3 }; -- size_t dec2 = dec2table[op - ref]; -+ grub_size_t dec2table[] = { 0, 0, 0, -1, 0, 1, 2, 3 }; -+ grub_size_t dec2 = dec2table[op - ref]; - #else - const int dec2 = 0; - #endif -diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c -index 22438277d7456358dfc6bcbb51317fd704987738..dbed64744317c2f849fb2bda8fd5a6b142affe91 100644 ---- a/grub-core/io/bufio.c -+++ b/grub-core/io/bufio.c -@@ -61,6 +61,13 @@ grub_bufio_open (grub_file_t io, int size) - size = ((io->size > GRUB_BUFIO_MAX_SIZE) ? GRUB_BUFIO_MAX_SIZE : - io->size); - -+ /* -+ * Round up size to power of 2 which the binary math to -+ * calculate next_buf in grub_bufio_read() requires. -+ */ -+ while (size & (size - 1)) -+ size = (size | (size - 1)) + 1; -+ - bufio = grub_zalloc (sizeof (struct grub_bufio) + size); - if (! bufio) - { -diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c -index 0f2ea6bd845227265eef205c212e7c52ee03ebcf..86ea8cfdea2e0abd1f73c6df4dca58806c8f2d9b 100644 ---- a/grub-core/io/gzio.c -+++ b/grub-core/io/gzio.c -@@ -43,6 +43,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -94,6 +95,14 @@ struct grub_gzio - struct huft *tl; - /* The distance code table. */ - struct huft *td; -+ /* The checksum algorithm */ -+ const gcry_md_spec_t *hdesc; -+ /* The wanted checksum */ -+ grub_uint32_t orig_checksum; -+ /* The uncompressed length */ -+ grub_size_t orig_len; -+ /* Context for checksum calculation */ -+ grub_uint8_t *hcontext; - /* The lookup bits for the literal/length code table. */ - int bl; - /* The lookup bits for the distance code table. */ -@@ -140,24 +149,24 @@ eat_field (grub_file_t file, int len) - #define OLD_GZIP_MAGIC grub_le_to_cpu16 (0x9E1F) - - /* Compression methods (see algorithm.doc) */ --#define STORED 0 --#define COMPRESSED 1 --#define PACKED 2 --#define LZHED 3 -+#define GRUB_GZ_STORED 0 -+#define GRUB_GZ_COMPRESSED 1 -+#define GRUB_GZ_PACKED 2 -+#define GRUB_GZ_LZHED 3 - /* methods 4 to 7 reserved */ --#define DEFLATED 8 --#define MAX_METHODS 9 -+#define GRUB_GZ_DEFLATED 8 -+#define GRUB_GZ_MAX_METHODS 9 - - /* gzip flag byte */ --#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ --#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ --#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ --#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ --#define COMMENT 0x10 /* bit 4 set: file comment present */ --#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ --#define RESERVED 0xC0 /* bit 6,7: reserved */ -+#define GRUB_GZ_ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ -+#define GRUB_GZ_CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ -+#define GRUB_GZ_EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ -+#define GRUB_GZ_ORIG_NAME 0x08 /* bit 3 set: original file name present */ -+#define GRUB_GZ_COMMENT 0x10 /* bit 4 set: file comment present */ -+#define GRUB_GZ_ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ -+#define GRUB_GZ_RESERVED 0xC0 /* bit 6,7: reserved */ - --#define UNSUPPORTED_FLAGS (CONTINUATION | ENCRYPTED | RESERVED) -+#define GRUB_GZ_UNSUPPORTED_FLAGS (GRUB_GZ_CONTINUATION | GRUB_GZ_ENCRYPTED | GRUB_GZ_RESERVED) - - /* inflate block codes */ - #define INFLATE_STORED 0 -@@ -180,7 +189,7 @@ test_gzip_header (grub_file_t file) - grub_uint8_t os_type; - } hdr; - grub_uint16_t extra_len; -- grub_uint32_t orig_len; -+ grub_uint32_t crc32; - grub_gzio_t gzio = file->data; - - if (grub_file_tell (gzio->file) != 0) -@@ -201,26 +210,29 @@ test_gzip_header (grub_file_t file) - * problem occurs from here on, then we have corrupt or otherwise - * bad data, and the error should be reported to the user. - */ -- if (hdr.method != DEFLATED -- || (hdr.flags & UNSUPPORTED_FLAGS) -- || ((hdr.flags & EXTRA_FIELD) -+ if (hdr.method != GRUB_GZ_DEFLATED -+ || (hdr.flags & GRUB_GZ_UNSUPPORTED_FLAGS) -+ || ((hdr.flags & GRUB_GZ_EXTRA_FIELD) - && (grub_file_read (gzio->file, &extra_len, 2) != 2 - || eat_field (gzio->file, - grub_le_to_cpu16 (extra_len)))) -- || ((hdr.flags & ORIG_NAME) && eat_field (gzio->file, -1)) -- || ((hdr.flags & COMMENT) && eat_field (gzio->file, -1))) -+ || ((hdr.flags & GRUB_GZ_ORIG_NAME) && eat_field (gzio->file, -1)) -+ || ((hdr.flags & GRUB_GZ_COMMENT) && eat_field (gzio->file, -1))) - return 0; - - gzio->data_offset = grub_file_tell (gzio->file); - - /* FIXME: don't do this on not easily seekable files. */ - { -- grub_file_seek (gzio->file, grub_file_size (gzio->file) - 4); -- if (grub_file_read (gzio->file, &orig_len, 4) != 4) -+ grub_file_seek (gzio->file, grub_file_size (gzio->file) - 8); -+ if (grub_file_read (gzio->file, &crc32, 4) != 4) -+ return 0; -+ gzio->orig_checksum = grub_le_to_cpu32 (crc32); -+ if (grub_file_read (gzio->file, &gzio->orig_len, 4) != 4) - return 0; - /* FIXME: this does not handle files whose original size is over 4GB. - But how can we know the real original size? */ -- file->size = grub_le_to_cpu32 (orig_len); -+ file->size = grub_le_to_cpu32 (gzio->orig_len); - } - - initialize_tables (gzio); -@@ -1095,7 +1107,23 @@ inflate_window (grub_gzio_t gzio) - - gzio->saved_offset += gzio->wp; - -- /* XXX do CRC calculation here! */ -+ if (gzio->hcontext) -+ { -+ gzio->hdesc->write (gzio->hcontext, gzio->slide, gzio->wp); -+ -+ if (gzio->saved_offset == gzio->orig_len) -+ { -+ grub_uint32_t csum; -+ -+ gzio->hdesc->final (gzio->hcontext); -+ csum = grub_get_unaligned32 (gzio->hdesc->read (gzio->hcontext)); -+ csum = grub_be_to_cpu32 (csum); -+ if (csum != gzio->orig_checksum) -+ grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, -+ "checksum mismatch %08x/%08x", -+ gzio->orig_checksum, csum); -+ } -+ } - } - - -@@ -1118,6 +1146,9 @@ initialize_tables (grub_gzio_t gzio) - huft_free (gzio->td); - gzio->tl = NULL; - gzio->td = NULL; -+ -+ if (gzio->hcontext) -+ gzio->hdesc->init(gzio->hcontext); - } - - -@@ -1143,6 +1174,9 @@ grub_gzio_open (grub_file_t io, const char *name __attribute__ ((unused))) - - gzio->file = io; - -+ gzio->hdesc = GRUB_MD_CRC32; -+ gzio->hcontext = grub_malloc(gzio->hdesc->contextsize); -+ - file->device = io->device; - file->data = gzio; - file->fs = &grub_gzio_fs; -@@ -1151,6 +1185,7 @@ grub_gzio_open (grub_file_t io, const char *name __attribute__ ((unused))) - if (! test_gzip_header (file)) - { - grub_errno = GRUB_ERR_NONE; -+ grub_free (gzio->hcontext); - grub_free (gzio); - grub_free (file); - grub_file_seek (io, 0); -@@ -1183,7 +1218,7 @@ test_zlib_header (grub_gzio_t gzio) - flg = get_byte (gzio); - - /* Check that compression method is DEFLATE. */ -- if ((cmf & 0xf) != DEFLATED) -+ if ((cmf & 0xf) != GRUB_GZ_DEFLATED) - { - /* TRANSLATORS: It's about given file having some strange format, not - complete lack of gzip support. */ -@@ -1287,6 +1322,7 @@ grub_gzio_close (grub_file_t file) - grub_file_close (gzio->file); - huft_free (gzio->tl); - huft_free (gzio->td); -+ grub_free (gzio->hcontext); - grub_free (gzio); - - /* No need to close the same device twice. */ -diff --git a/grub-core/kern/arm/cache.c b/grub-core/kern/arm/cache.c -index 34154ccdb0e09d7d9fd91c4164fe8577ce449260..af1c4bbf544f0ebcca5c0f58c847c8dddc1f2e91 100644 ---- a/grub-core/kern/arm/cache.c -+++ b/grub-core/kern/arm/cache.c -@@ -29,6 +29,8 @@ void grub_arm_clean_dcache_range_armv6 (grub_addr_t start, grub_addr_t end, - grub_addr_t dlinesz); - void grub_arm_clean_dcache_range_armv7 (grub_addr_t start, grub_addr_t end, - grub_addr_t dlinesz); -+void grub_arm_clean_dcache_range_poc_armv7 (grub_addr_t start, grub_addr_t end, -+ grub_addr_t dlinesz); - void grub_arm_invalidate_icache_range_armv6 (grub_addr_t start, grub_addr_t end, - grub_addr_t dlinesz); - void grub_arm_invalidate_icache_range_armv7 (grub_addr_t start, grub_addr_t end, -@@ -252,6 +254,38 @@ grub_arch_sync_caches (void *address, grub_size_t len) - } - } - -+void -+grub_arch_sync_dma_caches (volatile void *address, grub_size_t len) -+{ -+ grub_addr_t start = (grub_addr_t) address; -+ grub_addr_t end = start + len; -+ -+ if (type == ARCH_UNKNOWN) -+ probe_caches (); -+ start = ALIGN_DOWN (start, grub_arch_cache_max_linesz); -+ end = ALIGN_UP (end, grub_arch_cache_max_linesz); -+ switch (type) -+ { -+ case ARCH_ARMV6: -+ grub_arm_clean_dcache_range_armv6 (start, end, grub_arch_cache_dlinesz); -+ grub_arm_invalidate_icache_range_armv6 (start, end, -+ grub_arch_cache_ilinesz); -+ break; -+ case ARCH_ARMV5_WRITE_THROUGH: -+ case ARCH_ARMV6_UNIFIED: -+ grub_arm_clean_dcache_range_armv6 (start, end, grub_arch_cache_dlinesz); -+ break; -+ case ARCH_ARMV7: -+ grub_arm_clean_dcache_range_poc_armv7 (start, end, grub_arch_cache_dlinesz); -+ grub_arm_invalidate_icache_range_armv7 (start, end, -+ grub_arch_cache_ilinesz); -+ break; -+ /* Pacify GCC. */ -+ case ARCH_UNKNOWN: -+ break; -+ } -+} -+ - void - grub_arm_disable_caches_mmu (void) - { -diff --git a/grub-core/kern/arm/coreboot/cbtable.c b/grub-core/kern/arm/coreboot/cbtable.c -new file mode 100644 -index 0000000000000000000000000000000000000000..8a655bb5cc28fb013674dc792531d8a9ba1c4b85 ---- /dev/null -+++ b/grub-core/kern/arm/coreboot/cbtable.c -@@ -0,0 +1,40 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2007,2008,2013 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+GRUB_MOD_LICENSE ("GPLv3+"); -+ -+#pragma GCC diagnostic ignored "-Wcast-align" -+ -+grub_linuxbios_table_header_t -+grub_linuxbios_get_tables (void) -+{ -+ grub_linuxbios_table_header_t table_header -+ = (grub_linuxbios_table_header_t) grub_arm_saved_registers.r[0]; -+ -+ if (!grub_linuxbios_check_signature (table_header)) -+ return 0; -+ -+ return table_header; -+} -diff --git a/grub-core/kern/arm/coreboot/dma.c b/grub-core/kern/arm/coreboot/dma.c -new file mode 100644 -index 0000000000000000000000000000000000000000..2c2a6278904631c91bd29b3c4338c606471672fe ---- /dev/null -+++ b/grub-core/kern/arm/coreboot/dma.c -@@ -0,0 +1,59 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2007,2009 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+struct grub_pci_dma_chunk * -+grub_memalign_dma32 (grub_size_t align, grub_size_t size) -+{ -+ void *ret; -+ if (align < 64) -+ align = 64; -+ size = ALIGN_UP (size, align); -+ ret = grub_memalign (align, size); -+ if (!ret) -+ return 0; -+ grub_arch_sync_dma_caches (ret, size); -+ return ret; -+} -+ -+void -+grub_dma_free (struct grub_pci_dma_chunk *ch) -+{ -+ grub_size_t size = (((struct grub_mm_header *) ch) - 1)->size * GRUB_MM_ALIGN; -+ grub_arch_sync_dma_caches (ch, size); -+ grub_free (ch); -+} -+ -+volatile void * -+grub_dma_get_virt (struct grub_pci_dma_chunk *ch) -+{ -+ return (void *) ch; -+} -+ -+grub_uint32_t -+grub_dma_get_phys (struct grub_pci_dma_chunk *ch) -+{ -+ return (grub_uint32_t) (grub_addr_t) ch; -+} -+ -diff --git a/grub-core/kern/arm/coreboot/init.c b/grub-core/kern/arm/coreboot/init.c -new file mode 100644 -index 0000000000000000000000000000000000000000..8d8c5b8291eff9743b0325b76f851d52509b1f4f ---- /dev/null -+++ b/grub-core/kern/arm/coreboot/init.c -@@ -0,0 +1,151 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2013 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+extern grub_uint8_t _start[]; -+extern grub_uint8_t _end[]; -+extern grub_uint8_t _edata[]; -+grub_addr_t start_of_ram = ~(grub_addr_t)0; -+ -+void __attribute__ ((noreturn)) -+grub_exit (void) -+{ -+ /* We can't use grub_fatal() in this function. This would create an infinite -+ loop, since grub_fatal() calls grub_abort() which in turn calls grub_exit(). */ -+ while (1) -+ grub_cpu_idle (); -+} -+ -+static grub_uint64_t modend; -+static int have_memory = 0; -+ -+/* Helper for grub_machine_init. */ -+static int -+heap_init (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, -+ void *data __attribute__ ((unused))) -+{ -+ grub_uint64_t begin = addr, end = addr + size; -+ -+#if GRUB_CPU_SIZEOF_VOID_P == 4 -+ /* Restrict ourselves to 32-bit memory space. */ -+ if (begin > GRUB_ULONG_MAX) -+ return 0; -+ if (end > GRUB_ULONG_MAX) -+ end = GRUB_ULONG_MAX; -+#endif -+ -+ if (start_of_ram > begin) -+ start_of_ram = begin; -+ -+ if (type != GRUB_MEMORY_AVAILABLE) -+ return 0; -+ -+ if (modend && begin < modend) -+ { -+ if (begin < (grub_addr_t)_start) -+ { -+ grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) ((grub_addr_t)_start - begin)); -+ have_memory = 1; -+ } -+ begin = modend; -+ } -+ -+ /* Avoid DMA problems. */ -+ if (end >= 0xfe000000) -+ end = 0xfe000000; -+ -+ if (end <= begin) -+ return 0; -+ -+ grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) (end - begin)); -+ -+ have_memory = 1; -+ -+ return 0; -+} -+ -+void -+grub_machine_init (void) -+{ -+ struct grub_module_header *header; -+ void *dtb = 0; -+ grub_size_t dtb_size = 0; -+ -+ modend = grub_modules_get_end (); -+ -+ grub_video_coreboot_fb_early_init (); -+ -+ grub_machine_mmap_iterate (heap_init, NULL); -+ if (!have_memory) -+ grub_fatal ("No memory found"); -+ -+ grub_video_coreboot_fb_late_init (); -+ -+ grub_font_init (); -+ grub_gfxterm_init (); -+ -+ FOR_MODULES (header) -+ if (header->type == OBJ_TYPE_DTB) -+ { -+ char *dtb_orig_addr, *dtb_copy; -+ dtb_orig_addr = (char *) header + sizeof (struct grub_module_header); -+ -+ dtb_size = header->size - sizeof (struct grub_module_header); -+ dtb = dtb_copy = grub_malloc (dtb_size); -+ grub_memmove (dtb_copy, dtb_orig_addr, dtb_size); -+ break; -+ } -+ if (!dtb) -+ grub_fatal ("No DTB found"); -+ grub_fdtbus_init (dtb, dtb_size); -+ -+ grub_rk3288_spi_init (); -+ -+ grub_machine_timer_init (); -+ grub_cros_init (); -+ grub_pl050_init (); -+} -+ -+void -+grub_machine_get_bootlocation (char **device __attribute__ ((unused)), -+ char **path __attribute__ ((unused))) -+{ -+} -+ -+void -+grub_machine_fini (int flags __attribute__ ((unused))) -+{ -+} -diff --git a/grub-core/kern/arm/coreboot/timer.c b/grub-core/kern/arm/coreboot/timer.c -new file mode 100644 -index 0000000000000000000000000000000000000000..d97b844f8487c064922a552a5ea4d5f220031dba ---- /dev/null -+++ b/grub-core/kern/arm/coreboot/timer.c -@@ -0,0 +1,101 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2016 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+grub_uint64_t -+grub_armv7_get_timer_value(void); -+ -+grub_uint32_t -+grub_armv7_get_timer_frequency(void); -+ -+grub_uint32_t -+grub_arm_pfr1(void); -+ -+static int have_timer = 0; -+static volatile grub_uint32_t *sp804_regs; -+ -+static grub_uint64_t -+sp804_get_time_ms (void) -+{ -+ static grub_uint32_t high, last_low; -+ grub_uint32_t low = ~sp804_regs[1]; -+ if (last_low > low) -+ high++; -+ last_low = low; -+ return grub_divmod64 ((((grub_uint64_t) high) << 32) | low, -+ 1000, 0); -+} -+ -+static grub_err_t -+sp804_attach(const struct grub_fdtbus_dev *dev) -+{ -+ if (have_timer) -+ return GRUB_ERR_NONE; -+ sp804_regs = grub_fdtbus_map_reg (dev, 0, 0); -+ if (!grub_fdtbus_is_mapping_valid (sp804_regs)) -+ return grub_error (GRUB_ERR_IO, "could not map sp804: %p", sp804_regs); -+ grub_install_get_time_ms (sp804_get_time_ms); -+ have_timer = 1; -+ return GRUB_ERR_NONE; -+} -+ -+struct grub_fdtbus_driver sp804 = -+{ -+ .compatible = "arm,sp804", -+ .attach = sp804_attach -+}; -+ -+static grub_uint32_t timer_frequency_in_khz; -+ -+static grub_uint64_t -+generic_get_time_ms (void) -+{ -+ return grub_divmod64 (grub_armv7_get_timer_value(), timer_frequency_in_khz, 0); -+} -+ -+static int -+try_generic_timer (void) -+{ -+ if (((grub_arm_pfr1 () >> 16) & 0xf) != 1) -+ return 0; -+ grub_printf ("freq = %x\n", grub_armv7_get_timer_frequency()); -+ timer_frequency_in_khz = 0x016e3600 / 1000; //grub_armv7_get_timer_frequency() / 1000; -+ if (timer_frequency_in_khz == 0) -+ return 0; -+ grub_install_get_time_ms (generic_get_time_ms); -+ have_timer = 1; -+ return 1; -+} -+ -+void -+grub_machine_timer_init (void) -+{ -+ grub_fdtbus_register (&sp804); -+ -+ if (!have_timer) -+ try_generic_timer (); -+ if (!have_timer) -+ grub_fatal ("No timer found"); -+} -diff --git a/grub-core/kern/arm/efi/misc.c b/grub-core/kern/arm/efi/misc.c -deleted file mode 100644 -index 7cd41842ae7662018c2ce5ff847aeb250572ec85..0000000000000000000000000000000000000000 ---- a/grub-core/kern/arm/efi/misc.c -+++ /dev/null -@@ -1,202 +0,0 @@ --/* misc.c - various system functions for an arm-based EFI system */ --/* -- * GRUB -- GRand Unified Bootloader -- * Copyright (C) 2013 Free Software Foundation, Inc. -- * -- * GRUB is free software: you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published by -- * the Free Software Foundation, either version 3 of the License, or -- * (at your option) any later version. -- * -- * GRUB is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- * GNU General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with GRUB. If not, see . -- */ -- --#include --#include --#include --#include --#include --#include -- --static inline grub_size_t --page_align (grub_size_t size) --{ -- return (size + (1 << 12) - 1) & (~((1 << 12) - 1)); --} -- --/* Find the optimal number of pages for the memory map. Is it better to -- move this code to efi/mm.c? */ --static grub_efi_uintn_t --find_mmap_size (void) --{ -- static grub_efi_uintn_t mmap_size = 0; -- -- if (mmap_size != 0) -- return mmap_size; -- -- mmap_size = (1 << 12); -- while (1) -- { -- int ret; -- grub_efi_memory_descriptor_t *mmap; -- grub_efi_uintn_t desc_size; -- -- mmap = grub_malloc (mmap_size); -- if (! mmap) -- return 0; -- -- ret = grub_efi_get_memory_map (&mmap_size, mmap, 0, &desc_size, 0); -- grub_free (mmap); -- -- if (ret < 0) -- { -- grub_error (GRUB_ERR_IO, "cannot get memory map"); -- return 0; -- } -- else if (ret > 0) -- break; -- -- mmap_size += (1 << 12); -- } -- -- /* Increase the size a bit for safety, because GRUB allocates more on -- later, and EFI itself may allocate more. */ -- mmap_size += (1 << 12); -- -- return page_align (mmap_size); --} -- --#define NEXT_MEMORY_DESCRIPTOR(desc, size) \ -- ((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size))) --#define PAGE_SHIFT 12 -- --void * --grub_efi_allocate_loader_memory (grub_uint32_t min_offset, grub_uint32_t size) --{ -- grub_efi_uintn_t desc_size; -- grub_efi_memory_descriptor_t *mmap, *mmap_end; -- grub_efi_uintn_t mmap_size, tmp_mmap_size; -- grub_efi_memory_descriptor_t *desc; -- void *mem = NULL; -- grub_addr_t min_start = 0; -- -- mmap_size = find_mmap_size(); -- if (!mmap_size) -- return NULL; -- -- mmap = grub_malloc(mmap_size); -- if (!mmap) -- return NULL; -- -- tmp_mmap_size = mmap_size; -- if (grub_efi_get_memory_map (&tmp_mmap_size, mmap, 0, &desc_size, 0) <= 0) -- { -- grub_error (GRUB_ERR_IO, "cannot get memory map"); -- goto fail; -- } -- -- mmap_end = NEXT_MEMORY_DESCRIPTOR (mmap, tmp_mmap_size); -- /* Find lowest accessible RAM location */ -- { -- int found = 0; -- for (desc = mmap ; !found && (desc < mmap_end) ; -- desc = NEXT_MEMORY_DESCRIPTOR(desc, desc_size)) -- { -- switch (desc->type) -- { -- case GRUB_EFI_CONVENTIONAL_MEMORY: -- case GRUB_EFI_LOADER_CODE: -- case GRUB_EFI_LOADER_DATA: -- min_start = desc->physical_start + min_offset; -- found = 1; -- break; -- default: -- break; -- } -- } -- } -- -- /* First, find free pages for the real mode code -- and the memory map buffer. */ -- for (desc = mmap ; desc < mmap_end ; -- desc = NEXT_MEMORY_DESCRIPTOR(desc, desc_size)) -- { -- grub_uint64_t start, end; -- -- grub_dprintf("mm", "%s: 0x%08x bytes @ 0x%08x\n", -- __FUNCTION__, -- (grub_uint32_t) (desc->num_pages << PAGE_SHIFT), -- (grub_uint32_t) (desc->physical_start)); -- -- if (desc->type != GRUB_EFI_CONVENTIONAL_MEMORY) -- continue; -- -- start = desc->physical_start; -- end = start + (desc->num_pages << PAGE_SHIFT); -- grub_dprintf("mm", "%s: start=0x%016llx, end=0x%016llx\n", -- __FUNCTION__, start, end); -- start = start < min_start ? min_start : start; -- if (start + size > end) -- continue; -- grub_dprintf("mm", "%s: let's allocate some (0x%x) pages @ 0x%08x...\n", -- __FUNCTION__, (size >> PAGE_SHIFT), (grub_addr_t) start); -- mem = grub_efi_allocate_pages (start, (size >> PAGE_SHIFT) + 1); -- grub_dprintf("mm", "%s: retval=0x%08x\n", -- __FUNCTION__, (grub_addr_t) mem); -- if (! mem) -- { -- grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory"); -- goto fail; -- } -- break; -- } -- -- if (! mem) -- { -- grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory"); -- goto fail; -- } -- -- grub_free (mmap); -- return mem; -- -- fail: -- grub_free (mmap); -- return NULL; --} -- --grub_err_t --grub_efi_prepare_platform (void) --{ -- grub_efi_uintn_t mmap_size; -- grub_efi_uintn_t map_key; -- grub_efi_uintn_t desc_size; -- grub_efi_uint32_t desc_version; -- grub_efi_memory_descriptor_t *mmap_buf; -- grub_err_t err; -- -- /* -- * Cloned from IA64 -- * Must be done after grub_machine_fini because map_key is used by -- *exit_boot_services. -- */ -- mmap_size = find_mmap_size (); -- if (! mmap_size) -- return GRUB_ERR_OUT_OF_MEMORY; -- mmap_buf = grub_efi_allocate_pages (0, page_align (mmap_size) >> 12); -- if (! mmap_buf) -- return GRUB_ERR_OUT_OF_MEMORY; -- -- err = grub_efi_finish_boot_services (&mmap_size, mmap_buf, &map_key, -- &desc_size, &desc_version); -- if (err != GRUB_ERR_NONE) -- return err; -- -- return GRUB_ERR_NONE; --} -diff --git a/grub-core/kern/arm/uboot/init.c b/grub-core/kern/arm/uboot/init.c -new file mode 100644 -index 0000000000000000000000000000000000000000..2a6aa3fdd3dd049848015f6c67dfc0f30a79a9c4 ---- /dev/null -+++ b/grub-core/kern/arm/uboot/init.c -@@ -0,0 +1,70 @@ -+/* init.c - generic U-Boot initialization and finalization */ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2016 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+ -+extern int (*grub_uboot_syscall_ptr) (int, int *, ...); -+ -+grub_uint32_t -+grub_uboot_get_machine_type (void) -+{ -+ return grub_arm_saved_registers.r[1]; -+} -+ -+grub_addr_t -+grub_uboot_get_boot_data (void) -+{ -+ return grub_arm_saved_registers.r[2]; -+} -+ -+int -+grub_uboot_api_init (void) -+{ -+ struct api_signature *start, *end; -+ struct api_signature *p; -+ grub_addr_t grub_uboot_search_hint = grub_arm_saved_registers.sp; -+ if (grub_uboot_search_hint) -+ { -+ /* Extended search range to work around Trim Slice U-Boot issue */ -+ start = (struct api_signature *) ((grub_uboot_search_hint & ~0x000fffff) -+ - 0x00500000); -+ end = -+ (struct api_signature *) ((grub_addr_t) start + UBOOT_API_SEARCH_LEN - -+ API_SIG_MAGLEN + 0x00500000); -+ } -+ else -+ { -+ start = 0; -+ end = (struct api_signature *) (256 * 1024 * 1024); -+ } -+ -+ /* Structure alignment is (at least) 8 bytes */ -+ for (p = start; p < end; p = (void *) ((grub_addr_t) p + 8)) -+ { -+ if (grub_memcmp (&(p->magic), API_SIG_MAGIC, API_SIG_MAGLEN) == 0) -+ { -+ grub_uboot_syscall_ptr = p->syscall; -+ return p->version; -+ } -+ } -+ -+ return 0; -+} -diff --git a/grub-core/kern/coreboot/cbtable.c b/grub-core/kern/coreboot/cbtable.c -new file mode 100644 -index 0000000000000000000000000000000000000000..aec63dbd1209e4c3cbbe165d54a78277ea72f361 ---- /dev/null -+++ b/grub-core/kern/coreboot/cbtable.c -@@ -0,0 +1,72 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2007,2008,2013 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#pragma GCC diagnostic ignored "-Wcast-align" -+ -+/* Helper for grub_linuxbios_table_iterate. */ -+int -+grub_linuxbios_check_signature (grub_linuxbios_table_header_t tbl_header) -+{ -+ if (! grub_memcmp (tbl_header->signature, "LBIO", 4)) -+ return 1; -+ -+ return 0; -+} -+ -+grub_err_t -+grub_linuxbios_table_iterate (int (*hook) (grub_linuxbios_table_item_t, -+ void *), -+ void *hook_data) -+{ -+ grub_linuxbios_table_header_t table_header = grub_linuxbios_get_tables (); -+ grub_linuxbios_table_item_t table_item; -+ -+ if (!table_header) -+ return 0; -+ -+signature_found: -+ -+ table_item = -+ (grub_linuxbios_table_item_t) ((char *) table_header + -+ table_header->header_size); -+ for (; table_item < (grub_linuxbios_table_item_t) ((char *) table_header -+ + table_header->header_size -+ + table_header->table_size); -+ table_item = (grub_linuxbios_table_item_t) ((char *) table_item + table_item->size)) -+ { -+ if (table_item->tag == GRUB_LINUXBIOS_MEMBER_LINK -+ && grub_linuxbios_check_signature ((grub_linuxbios_table_header_t) (grub_addr_t) -+ *(grub_uint64_t *) (table_item + 1))) -+ { -+ table_header = (grub_linuxbios_table_header_t) (grub_addr_t) -+ *(grub_uint64_t *) (table_item + 1); -+ goto signature_found; -+ } -+ if (hook (table_item, hook_data)) -+ return 1; -+ } -+ -+ return 0; -+} -diff --git a/grub-core/kern/i386/coreboot/mmap.c b/grub-core/kern/coreboot/mmap.c -similarity index 97% -rename from grub-core/kern/i386/coreboot/mmap.c -rename to grub-core/kern/coreboot/mmap.c -index 4d29f6b7d90591939cf5d837b39c5d259a55efb0..caf8f7cef1b4552c720eb3b7ca355eb6cec32955 100644 ---- a/grub-core/kern/i386/coreboot/mmap.c -+++ b/grub-core/kern/coreboot/mmap.c -@@ -16,8 +16,8 @@ - * along with GRUB. If not, see . - */ - --#include --#include -+#include -+#include - #include - #include - #include -@@ -49,6 +49,7 @@ iterate_linuxbios_table (grub_linuxbios_table_item_t table_item, void *data) - { - grub_uint64_t start = mem_region->addr; - grub_uint64_t end = mem_region->addr + mem_region->size; -+#ifdef __i386__ - /* Mark region 0xa0000 - 0x100000 as reserved. */ - if (start < 0x100000 && end >= 0xa0000 - && mem_region->type == GRUB_MACHINE_MEMORY_AVAILABLE) -@@ -75,6 +76,7 @@ iterate_linuxbios_table (grub_linuxbios_table_item_t table_item, void *data) - if (end <= start) - continue; - } -+#endif - if (ctx->hook (start, end - start, - /* Multiboot mmaps match with the coreboot mmap - definition. Therefore, we can just pass type -diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index d467785fc6ce0763ec1392a65d6b30f1747ab5c4..708581fcbde007fc0174be636771b401d5e69ea2 100644 ---- a/grub-core/kern/efi/efi.c -+++ b/grub-core/kern/efi/efi.c -@@ -154,6 +154,15 @@ grub_efi_get_loaded_image (grub_efi_handle_t image_handle) - GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); - } - -+void -+grub_reboot (void) -+{ -+ grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); -+ efi_call_4 (grub_efi_system_table->runtime_services->reset_system, -+ GRUB_EFI_RESET_COLD, GRUB_EFI_SUCCESS, 0, NULL); -+ for (;;) ; -+} -+ - void - grub_exit (void) - { -diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c -index 2c31847bf6db77fab377c90e7ed36897439d6027..3dfdf2d22b02ae8847a3e19a175517d2d71544fa 100644 ---- a/grub-core/kern/efi/init.c -+++ b/grub-core/kern/efi/init.c -@@ -80,4 +80,5 @@ grub_efi_fini (void) - { - grub_efidisk_fini (); - grub_console_fini (); -+ grub_efi_memory_fini (); - } -diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index 20a47aaf5d0df376090510ddb8337ecc8aa18e98..42ad7c570a5532c4f6a5bef9d1ff3295f413aa11 100644 ---- a/grub-core/kern/efi/mm.c -+++ b/grub-core/kern/efi/mm.c -@@ -49,38 +49,86 @@ static grub_efi_uintn_t finish_desc_size; - static grub_efi_uint32_t finish_desc_version; - int grub_efi_is_finished = 0; - -+/* -+ * We need to roll back EFI allocations on exit. Remember allocations that -+ * we'll free on exit. -+ */ -+struct efi_allocation; -+struct efi_allocation { -+ grub_efi_physical_address_t address; -+ grub_efi_uint64_t pages; -+ struct efi_allocation *next; -+}; -+static struct efi_allocation *efi_allocated_memory; -+ -+static void -+grub_efi_store_alloc (grub_efi_physical_address_t address, -+ grub_efi_uintn_t pages) -+{ -+ grub_efi_boot_services_t *b; -+ struct efi_allocation *alloc; -+ grub_efi_status_t status; -+ -+ b = grub_efi_system_table->boot_services; -+ status = efi_call_3 (b->allocate_pool, GRUB_EFI_LOADER_DATA, -+ sizeof(*alloc), (void**)&alloc); -+ -+ if (status == GRUB_EFI_SUCCESS) -+ { -+ alloc->next = efi_allocated_memory; -+ alloc->address = address; -+ alloc->pages = pages; -+ efi_allocated_memory = alloc; -+ } -+ else -+ grub_printf ("Could not malloc memory to remember EFI allocation. " -+ "Exiting GRUB won't free all memory.\n"); -+} -+ -+static void -+grub_efi_drop_alloc (grub_efi_physical_address_t address, -+ grub_efi_uintn_t pages) -+{ -+ struct efi_allocation *ea, *eap; -+ grub_efi_boot_services_t *b; -+ -+ b = grub_efi_system_table->boot_services; -+ -+ for (eap = NULL, ea = efi_allocated_memory; ea; eap = ea, ea = ea->next) -+ { -+ if (ea->address != address || ea->pages != pages) -+ continue; -+ -+ /* Remove the current entry from the list. */ -+ if (eap) -+ eap->next = ea->next; -+ else -+ efi_allocated_memory = ea->next; -+ -+ /* Then free the memory backing it. */ -+ efi_call_1 (b->free_pool, ea); -+ -+ /* And leave, we're done. */ -+ break; -+ } -+} -+ - /* Allocate pages. Return the pointer to the first of allocated pages. */ - void * --grub_efi_allocate_pages (grub_efi_physical_address_t address, -- grub_efi_uintn_t pages) -+grub_efi_allocate_pages_real (grub_efi_physical_address_t address, -+ grub_efi_uintn_t pages, -+ grub_efi_allocate_type_t alloctype, -+ grub_efi_memory_type_t memtype) - { -- grub_efi_allocate_type_t type; - grub_efi_status_t status; - grub_efi_boot_services_t *b; - --#if 1 - /* Limit the memory access to less than 4GB for 32-bit platforms. */ - if (address > GRUB_EFI_MAX_USABLE_ADDRESS) - return 0; --#endif -- --#if 1 -- if (address == 0) -- { -- type = GRUB_EFI_ALLOCATE_MAX_ADDRESS; -- address = GRUB_EFI_MAX_USABLE_ADDRESS; -- } -- else -- type = GRUB_EFI_ALLOCATE_ADDRESS; --#else -- if (address == 0) -- type = GRUB_EFI_ALLOCATE_ANY_PAGES; -- else -- type = GRUB_EFI_ALLOCATE_ADDRESS; --#endif - - b = grub_efi_system_table->boot_services; -- status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address); -+ status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address); - if (status != GRUB_EFI_SUCCESS) - return 0; - -@@ -89,15 +137,34 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address, - /* Uggh, the address 0 was allocated... This is too annoying, - so reallocate another one. */ - address = GRUB_EFI_MAX_USABLE_ADDRESS; -- status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address); -+ status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address); - grub_efi_free_pages (0, pages); - if (status != GRUB_EFI_SUCCESS) - return 0; - } - -+ grub_efi_store_alloc (address, pages); -+ - return (void *) ((grub_addr_t) address); - } - -+void * -+grub_efi_allocate_any_pages (grub_efi_uintn_t pages) -+{ -+ return grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS, -+ pages, GRUB_EFI_ALLOCATE_MAX_ADDRESS, -+ GRUB_EFI_LOADER_DATA); -+} -+ -+void * -+grub_efi_allocate_fixed (grub_efi_physical_address_t address, -+ grub_efi_uintn_t pages) -+{ -+ return grub_efi_allocate_pages_real (address, pages, -+ GRUB_EFI_ALLOCATE_ADDRESS, -+ GRUB_EFI_LOADER_DATA); -+} -+ - /* Free pages starting from ADDRESS. */ - void - grub_efi_free_pages (grub_efi_physical_address_t address, -@@ -107,6 +174,8 @@ grub_efi_free_pages (grub_efi_physical_address_t address, - - b = grub_efi_system_table->boot_services; - efi_call_2 (b->free_pages, address, pages); -+ -+ grub_efi_drop_alloc (address, pages); - } - - #if defined (__i386__) || defined (__x86_64__) -@@ -217,6 +286,30 @@ grub_efi_finish_boot_services (grub_efi_uintn_t *outbuf_size, void *outbuf, - return GRUB_ERR_NONE; - } - -+/* -+ * To obtain the UEFI memory map, we must pass a buffer of sufficient size -+ * to hold the entire map. This function returns a sane start value for -+ * buffer size. -+ */ -+grub_efi_uintn_t -+grub_efi_find_mmap_size (void) -+{ -+ grub_efi_uintn_t mmap_size = 0; -+ grub_efi_uintn_t desc_size; -+ -+ if (grub_efi_get_memory_map (&mmap_size, NULL, NULL, &desc_size, 0) < 0) -+ { -+ grub_error (GRUB_ERR_IO, "cannot get EFI memory map size"); -+ return 0; -+ } -+ -+ /* -+ * Add an extra page, since UEFI can alter the memory map itself on -+ * callbacks or explicit calls, including console output. -+ */ -+ return ALIGN_UP (mmap_size + GRUB_EFI_PAGE_SIZE, GRUB_EFI_PAGE_SIZE); -+} -+ - /* Get the memory map as defined in the EFI spec. Return 1 if successful, - return 0 if partial, or return -1 if an error occurs. */ - int -@@ -402,7 +495,9 @@ add_memory_regions (grub_efi_memory_descriptor_t *memory_map, - pages = required_pages; - } - -- addr = grub_efi_allocate_pages (start, pages); -+ addr = grub_efi_allocate_pages_real (start, pages, -+ GRUB_EFI_ALLOCATE_ADDRESS, -+ GRUB_EFI_LOADER_CODE); - if (! addr) - grub_fatal ("cannot allocate conventional memory %p with %u pages", - (void *) ((grub_addr_t) start), -@@ -419,6 +514,20 @@ add_memory_regions (grub_efi_memory_descriptor_t *memory_map, - grub_fatal ("too little memory"); - } - -+void -+grub_efi_memory_fini (void) -+{ -+ /* -+ * Free all stale allocations. grub_efi_free_pages() will remove -+ * the found entry from the list and it will always find the first -+ * list entry (efi_allocated_memory is the list start). Hence we -+ * remove all entries from the list until none is left altogether. -+ */ -+ while (efi_allocated_memory) -+ grub_efi_free_pages (efi_allocated_memory->address, -+ efi_allocated_memory->pages); -+} -+ - #if 0 - /* Print the memory map. */ - static void -@@ -454,8 +563,7 @@ grub_efi_mm_init (void) - int mm_status; - - /* Prepare a memory region to store two memory maps. */ -- memory_map = grub_efi_allocate_pages (0, -- 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); -+ memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); - if (! memory_map) - grub_fatal ("cannot allocate memory"); - -@@ -473,7 +581,7 @@ grub_efi_mm_init (void) - /* Freeing/allocating operations may increase memory map size. */ - map_size += desc_size * 32; - -- memory_map = grub_efi_allocate_pages (0, 2 * BYTES_TO_PAGES (map_size)); -+ memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (map_size)); - if (! memory_map) - grub_fatal ("cannot allocate memory"); - -@@ -525,3 +633,34 @@ grub_efi_mm_init (void) - grub_efi_free_pages ((grub_addr_t) memory_map, - 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); - } -+ -+#if defined (__aarch64__) || defined (__arm__) -+grub_err_t -+grub_efi_get_ram_base(grub_addr_t *base_addr) -+{ -+ grub_efi_memory_descriptor_t *memory_map, *desc; -+ grub_efi_uintn_t memory_map_size, desc_size; -+ int ret; -+ -+ memory_map_size = grub_efi_find_mmap_size(); -+ -+ memory_map = grub_malloc (memory_map_size); -+ if (! memory_map) -+ return GRUB_ERR_OUT_OF_MEMORY; -+ ret = grub_efi_get_memory_map (&memory_map_size, memory_map, NULL, -+ &desc_size, NULL); -+ -+ if (ret < 1) -+ return GRUB_ERR_BUG; -+ -+ for (desc = memory_map, *base_addr = GRUB_UINT_MAX; -+ (grub_addr_t) desc < ((grub_addr_t) memory_map + memory_map_size); -+ desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) -+ if (desc->attribute & GRUB_EFI_MEMORY_WB) -+ *base_addr = grub_min (*base_addr, desc->physical_start); -+ -+ grub_free(memory_map); -+ -+ return GRUB_ERR_NONE; -+} -+#endif -diff --git a/grub-core/kern/i386/coreboot/cbtable.c b/grub-core/kern/i386/coreboot/cbtable.c -index 1669bc0ca23a2fe5dcfb8e2b6c973ddb5e27e880..34a2b59be1ffa926e9dcc931140695cc82be223c 100644 ---- a/grub-core/kern/i386/coreboot/cbtable.c -+++ b/grub-core/kern/i386/coreboot/cbtable.c -@@ -17,7 +17,7 @@ - */ - - #include --#include -+#include - #include - #include - #include -@@ -25,59 +25,20 @@ - - GRUB_MOD_LICENSE ("GPLv3+"); - --/* Helper for grub_linuxbios_table_iterate. */ --static int --check_signature (grub_linuxbios_table_header_t tbl_header) --{ -- if (! grub_memcmp (tbl_header->signature, "LBIO", 4)) -- return 1; -- -- return 0; --} -- --grub_err_t --grub_linuxbios_table_iterate (int (*hook) (grub_linuxbios_table_item_t, -- void *), -- void *hook_data) -+grub_linuxbios_table_header_t -+grub_linuxbios_get_tables (void) - { - grub_linuxbios_table_header_t table_header; -- grub_linuxbios_table_item_t table_item; -- - /* Assuming table_header is aligned to its size (8 bytes). */ -- - for (table_header = (grub_linuxbios_table_header_t) 0x500; - table_header < (grub_linuxbios_table_header_t) 0x1000; table_header++) -- if (check_signature (table_header)) -- goto signature_found; -+ if (grub_linuxbios_check_signature (table_header)) -+ return table_header; - - for (table_header = (grub_linuxbios_table_header_t) 0xf0000; - table_header < (grub_linuxbios_table_header_t) 0x100000; table_header++) -- if (check_signature (table_header)) -- goto signature_found; -- -- return 0; -- --signature_found: -- -- table_item = -- (grub_linuxbios_table_item_t) ((char *) table_header + -- table_header->header_size); -- for (; table_item < (grub_linuxbios_table_item_t) ((char *) table_header -- + table_header->header_size -- + table_header->table_size); -- table_item = (grub_linuxbios_table_item_t) ((char *) table_item + table_item->size)) -- { -- if (table_item->tag == GRUB_LINUXBIOS_MEMBER_LINK -- && check_signature ((grub_linuxbios_table_header_t) (grub_addr_t) -- *(grub_uint64_t *) (table_item + 1))) -- { -- table_header = (grub_linuxbios_table_header_t) (grub_addr_t) -- *(grub_uint64_t *) (table_item + 1); -- goto signature_found; -- } -- if (hook (table_item, hook_data)) -- return 1; -- } -+ if (grub_linuxbios_check_signature (table_header)) -+ return table_header; - - return 0; - } -diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c -index 2e85289d848946da8260b826ed36114557299278..f266eb13185f20dd4c8f67fdffa9a4790d9e01da 100644 ---- a/grub-core/kern/i386/tsc.c -+++ b/grub-core/kern/i386/tsc.c -@@ -68,7 +68,7 @@ grub_tsc_init (void) - #ifdef GRUB_MACHINE_XEN - (void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode()); - #elif defined (GRUB_MACHINE_EFI) -- (void) (grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode()); -+ (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode()); - #elif defined (GRUB_MACHINE_COREBOOT) - (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode()); - #else -diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c -index 98217029f458dcef3a5b227b300762ff14cf8c52..86f81a3c4671be293d823cd3235a66dff9774faa 100644 ---- a/grub-core/kern/ieee1275/ieee1275.c -+++ b/grub-core/kern/ieee1275/ieee1275.c -@@ -19,6 +19,7 @@ - - #include - #include -+#include - - #define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_cell_t) -1) - #define IEEE1275_IHANDLE_INVALID ((grub_ieee1275_cell_t) 0) -@@ -482,6 +483,91 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle) - return 0; - } - -+int -+grub_ieee1275_decode_unit4 (grub_ieee1275_ihandle_t ihandle, -+ void *addr, grub_size_t size, -+ grub_uint32_t *phy_lo, grub_uint32_t *phy_hi, -+ grub_uint32_t *lun_lo, grub_uint32_t *lun_hi) -+{ -+ struct decode_args -+ { -+ struct grub_ieee1275_common_hdr common; -+ grub_ieee1275_cell_t method; -+ grub_ieee1275_cell_t ihandle; -+ grub_ieee1275_cell_t size; -+ grub_ieee1275_cell_t addr; -+ grub_ieee1275_cell_t catch_result; -+ grub_ieee1275_cell_t tgt_h; -+ grub_ieee1275_cell_t tgt_l; -+ grub_ieee1275_cell_t lun_h; -+ grub_ieee1275_cell_t lun_l; -+ } -+ args; -+ -+ INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 5); -+ args.method = (grub_ieee1275_cell_t) "decode-unit"; -+ args.ihandle = ihandle; -+ args.size = size; -+ args.addr = (grub_ieee1275_cell_t) addr; -+ args.catch_result = 1; -+ -+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result)) -+ { -+ grub_error (GRUB_ERR_OUT_OF_RANGE, "decode-unit failed\n"); -+ return -1; -+ } -+ -+ *phy_lo = args.tgt_l; -+ *phy_hi = args.tgt_h; -+ *lun_lo = args.lun_l; -+ *lun_hi = args.lun_h; -+ return 0; -+} -+ -+char * -+grub_ieee1275_encode_uint4 (grub_ieee1275_ihandle_t ihandle, -+ grub_uint32_t phy_lo, grub_uint32_t phy_hi, -+ grub_uint32_t lun_lo, grub_uint32_t lun_hi, -+ grub_size_t *size) -+{ -+ char *addr; -+ struct encode_args -+ { -+ struct grub_ieee1275_common_hdr common; -+ grub_ieee1275_cell_t method; -+ grub_ieee1275_cell_t ihandle; -+ grub_ieee1275_cell_t tgt_h; -+ grub_ieee1275_cell_t tgt_l; -+ grub_ieee1275_cell_t lun_h; -+ grub_ieee1275_cell_t lun_l; -+ grub_ieee1275_cell_t catch_result; -+ grub_ieee1275_cell_t size; -+ grub_ieee1275_cell_t addr; -+ } -+ args; -+ -+ INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 3); -+ args.method = (grub_ieee1275_cell_t) "encode-unit"; -+ args.ihandle = ihandle; -+ -+ args.tgt_l = phy_lo; -+ args.tgt_h = phy_hi; -+ args.lun_l = lun_lo; -+ args.lun_h = lun_hi; -+ args.catch_result = 1; -+ -+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result)) -+ { -+ grub_error (GRUB_ERR_OUT_OF_RANGE, "encode-unit failed\n"); -+ return 0; -+ } -+ -+ addr = (void *)args.addr; -+ *size = args.size; -+ addr = grub_strdup ((char *)args.addr); -+ return addr; -+} -+ - int - grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align, - grub_addr_t *result) -@@ -607,3 +693,117 @@ grub_ieee1275_milliseconds (grub_uint32_t *msecs) - *msecs = args.msecs; - return 0; - } -+ -+int -+grub_ieee1275_set_address (grub_ieee1275_ihandle_t ihandle, -+ grub_uint32_t target, grub_uint32_t lun) -+{ -+ struct set_address -+ { -+ struct grub_ieee1275_common_hdr common; -+ grub_ieee1275_cell_t method; -+ grub_ieee1275_cell_t ihandle; -+ grub_ieee1275_cell_t tgt; -+ grub_ieee1275_cell_t lun; -+ grub_ieee1275_cell_t catch_result; -+ } -+ args; -+ -+ INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 1); -+ -+ /* -+ * IEEE 1275-1994 Standard for Boot (Initialization Configuration) -+ * Firmware: Core Requirements and Practices -+ * E.3.2.2 Bus-specific methods for bus nodes -+ * -+ * A package implementing the scsi-2 device type shall implement the -+ * following bus-specific method: -+ * -+ * set-address ( unit# target# -- ) -+ * Sets the SCSI target number (0x0..0xf) and unit number (0..7) to which -+ * subsequent commands apply. -+ */ -+ args.method = (grub_ieee1275_cell_t) "set-address"; -+ args.ihandle = ihandle; -+ args.tgt = target; -+ args.lun = lun; -+ -+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1) -+ return -1; -+ -+ return args.catch_result; -+} -+ -+int -+grub_ieee1275_no_data_command (grub_ieee1275_ihandle_t ihandle, -+ const void *cmd_addr, grub_ssize_t *result) -+{ -+ struct set_address -+ { -+ struct grub_ieee1275_common_hdr common; -+ grub_ieee1275_cell_t method; -+ grub_ieee1275_cell_t ihandle; -+ grub_ieee1275_cell_t cmd_addr; -+ grub_ieee1275_cell_t error; -+ grub_ieee1275_cell_t catch_result; -+ } -+ args; -+ -+ INIT_IEEE1275_COMMON (&args.common, "call-method", 3, 2); -+ -+ /* -+ * IEEE 1275-1994 Standard for Boot (Initialization Configuration) -+ * Firmware: Core Requirements and Practices -+ * -+ * E.3.2.2 Bus-specific methods for bus nodes -+ * -+ * A package implementing the scsi-2 device type shall implement the -+ * following bus-specific method: -+ * -+ * no-data-command ( cmd-addr -- error? ) -+ * Executes a simple SCSI command, automatically retrying under -+ * certain conditions. cmd-addr is the address of a 6-byte command buffer -+ * containing an SCSI command that does not have a data transfer phase. -+ * Executes the command, retrying indefinitely with the same retry criteria -+ * as retry-command. -+ * -+ * error? is nonzero if an error occurred, zero otherwise. -+ * NOTE no-data-command is a convenience function. It provides -+ * no capabilities that are not present in retry-command, but for -+ * those commands that meet its restrictions, it is easier to use. -+ */ -+ args.method = (grub_ieee1275_cell_t) "no-data-command"; -+ args.ihandle = ihandle; -+ args.cmd_addr = (grub_ieee1275_cell_t) cmd_addr; -+ -+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1) -+ return -1; -+ -+ if (result) -+ *result = args.error; -+ -+ return args.catch_result; -+} -+ -+int -+grub_ieee1275_get_block_size (grub_ieee1275_ihandle_t ihandle) -+{ -+ struct size_args_ieee1275 -+ { -+ struct grub_ieee1275_common_hdr common; -+ grub_ieee1275_cell_t method; -+ grub_ieee1275_cell_t ihandle; -+ grub_ieee1275_cell_t result; -+ grub_ieee1275_cell_t size; -+ } args; -+ -+ INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 2); -+ args.method = (grub_ieee1275_cell_t) "block-size"; -+ args.ihandle = ihandle; -+ args.result = 1; -+ -+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result)) -+ return 0; -+ -+ return args.size; -+} -diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 12590225eca1483066ea5e7b7443cea3198f6d9b..0d8ebf58b95e220b233e043d2b380007b48e1235 100644 ---- a/grub-core/kern/ieee1275/init.c -+++ b/grub-core/kern/ieee1275/init.c -@@ -94,28 +94,12 @@ void - grub_machine_get_bootlocation (char **device, char **path) - { - char *bootpath; -- grub_ssize_t bootpath_size; - char *filename; - char *type; - -- if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath", -- &bootpath_size) -- || bootpath_size <= 0) -- { -- /* Should never happen. */ -- grub_printf ("/chosen/bootpath property missing!\n"); -- return; -- } -- -- bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64); -+ bootpath = grub_ieee1275_get_boot_dev (); - if (! bootpath) -- { -- grub_print_error (); -- return; -- } -- grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath, -- (grub_size_t) bootpath_size + 1, 0); -- bootpath[bootpath_size] = '\0'; -+ return; - - /* Transform an OF device path to a GRUB path. */ - -@@ -126,6 +110,8 @@ grub_machine_get_bootlocation (char **device, char **path) - char *ptr; - dev = grub_ieee1275_get_aliasdevname (bootpath); - canon = grub_ieee1275_canonicalise_devname (dev); -+ if (! canon) -+ return; - ptr = canon + grub_strlen (canon) - 1; - while (ptr > canon && (*ptr == ',' || *ptr == ':')) - ptr--; -diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c -index ddb778340e4ab74148898b32cd27139fd4f1465b..62929d983bfaa2c83158ee4fe6797125c6d6b844 100644 ---- a/grub-core/kern/ieee1275/openfw.c -+++ b/grub-core/kern/ieee1275/openfw.c -@@ -561,3 +561,30 @@ grub_ieee1275_canonicalise_devname (const char *path) - return NULL; - } - -+char * -+grub_ieee1275_get_boot_dev (void) -+{ -+ char *bootpath; -+ grub_ssize_t bootpath_size; -+ -+ if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath", -+ &bootpath_size) -+ || bootpath_size <= 0) -+ { -+ /* Should never happen. */ -+ grub_printf ("/chosen/bootpath property missing!\n"); -+ return NULL; -+ } -+ -+ bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64); -+ if (! bootpath) -+ { -+ grub_print_error (); -+ return NULL; -+ } -+ grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath, -+ (grub_size_t) bootpath_size + 1, 0); -+ bootpath[bootpath_size] = '\0'; -+ -+ return bootpath; -+} -diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index d1a54df6c12e3358e07aa86366c65af22ca3af5c..3b633d51f4c63e2983e8b3419dc057437224fb93 100644 ---- a/grub-core/kern/misc.c -+++ b/grub-core/kern/misc.c -@@ -391,12 +391,13 @@ grub_strtoull (const char *str, char **end, int base) - unsigned long digit; - - digit = grub_tolower (*str) - '0'; -- if (digit > 9) -- { -- digit += '0' - 'a' + 10; -- if (digit >= (unsigned long) base) -- break; -- } -+ if (digit >= 'a' - '0') -+ digit += '0' - 'a' + 10; -+ else if (digit > 9) -+ break; -+ -+ if (digit >= (unsigned long) base) -+ break; - - found = 1; - -diff --git a/grub-core/kern/sparc64/ieee1275/ieee1275.c b/grub-core/kern/sparc64/ieee1275/ieee1275.c -index 53be692c3d88940572d423ceb09e4187372fcb5b..5a59aaf06193442fa5ec7a537c9cfb10dd3081aa 100644 ---- a/grub-core/kern/sparc64/ieee1275/ieee1275.c -+++ b/grub-core/kern/sparc64/ieee1275/ieee1275.c -@@ -89,3 +89,59 @@ grub_ieee1275_alloc_physmem (grub_addr_t *paddr, grub_size_t size, - - return args.catch_result; - } -+ -+grub_uint64_t -+grub_ieee1275_num_blocks (grub_ieee1275_ihandle_t ihandle) -+{ -+ struct nblocks_args_ieee1275 -+ { -+ struct grub_ieee1275_common_hdr common; -+ grub_ieee1275_cell_t method; -+ grub_ieee1275_cell_t ihandle; -+ grub_ieee1275_cell_t catch_result; -+ grub_ieee1275_cell_t blocks; -+ } -+ args; -+ -+ INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 2); -+ args.method = (grub_ieee1275_cell_t) "#blocks"; -+ args.ihandle = ihandle; -+ args.catch_result = 1; -+ -+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result != 0)) -+ return -1; -+ -+ /* -+ * If the number of blocks exceeds the range of an unsigned number, -+ * return 0 to alert the caller to try the #blocks64 command. -+ */ -+ if (args.blocks >= 0xffffffffULL) -+ return 0; -+ -+ return args.blocks; -+} -+ -+grub_uint64_t -+grub_ieee1275_num_blocks64 (grub_ieee1275_ihandle_t ihandle) -+{ -+ struct nblocks_args_ieee1275 -+ { -+ struct grub_ieee1275_common_hdr common; -+ grub_ieee1275_cell_t method; -+ grub_ieee1275_cell_t ihandle; -+ grub_ieee1275_cell_t catch_result; -+ grub_ieee1275_cell_t hi_blocks; -+ grub_ieee1275_cell_t lo_blocks; -+ } -+ args; -+ -+ INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3); -+ args.method = (grub_ieee1275_cell_t) "#blocks64"; -+ args.ihandle = ihandle; -+ args.catch_result = 1; -+ -+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result != 0)) -+ return -1; -+ -+ return ((args.hi_blocks << 32) | (args.lo_blocks)); -+} -diff --git a/grub-core/kern/uboot/init.c b/grub-core/kern/uboot/init.c -index 5dcc106ed9bcc1fa2cdbe2ba6cbb9e709420ceb3..3e338645c573aa707343235029d9fc45d515a9dc 100644 ---- a/grub-core/kern/uboot/init.c -+++ b/grub-core/kern/uboot/init.c -@@ -36,30 +36,14 @@ - extern char __bss_start[]; - extern char _end[]; - extern grub_size_t grub_total_module_size; --extern int (*grub_uboot_syscall_ptr) (int, int *, ...); - static unsigned long timer_start; - --extern grub_uint32_t grub_uboot_machine_type; --extern grub_addr_t grub_uboot_boot_data; -- - void - grub_exit (void) - { - grub_uboot_return (0); - } - --grub_uint32_t --grub_uboot_get_machine_type (void) --{ -- return grub_uboot_machine_type; --} -- --grub_addr_t --grub_uboot_get_boot_data (void) --{ -- return grub_uboot_boot_data; --} -- - static grub_uint64_t - uboot_timer_ms (void) - { -diff --git a/grub-core/kern/uboot/uboot.c b/grub-core/kern/uboot/uboot.c -index 6800a4beb1c4e83ef9f4ac5da872d2557d8471e1..cf0168e62ddd26db50efd2351499fa7f74fce26c 100644 ---- a/grub-core/kern/uboot/uboot.c -+++ b/grub-core/kern/uboot/uboot.c -@@ -39,48 +39,13 @@ - * returns: 0 if the call not found, 1 if serviced - */ - --extern int (*grub_uboot_syscall_ptr) (int, int *, ...); - extern int grub_uboot_syscall (int, int *, ...); --extern grub_addr_t grub_uboot_search_hint; - - static struct sys_info uboot_sys_info; - static struct mem_region uboot_mem_info[5]; - static struct device_info * devices; - static int num_devices; - --int --grub_uboot_api_init (void) --{ -- struct api_signature *start, *end; -- struct api_signature *p; -- -- if (grub_uboot_search_hint) -- { -- /* Extended search range to work around Trim Slice U-Boot issue */ -- start = (struct api_signature *) ((grub_uboot_search_hint & ~0x000fffff) -- - 0x00500000); -- end = -- (struct api_signature *) ((grub_addr_t) start + UBOOT_API_SEARCH_LEN - -- API_SIG_MAGLEN + 0x00500000); -- } -- else -- { -- start = 0; -- end = (struct api_signature *) (256 * 1024 * 1024); -- } -- -- /* Structure alignment is (at least) 8 bytes */ -- for (p = start; p < end; p = (void *) ((grub_addr_t) p + 8)) -- { -- if (grub_memcmp (&(p->magic), API_SIG_MAGIC, API_SIG_MAGLEN) == 0) -- { -- grub_uboot_syscall_ptr = p->syscall; -- return p->version; -- } -- } -- -- return 0; --} - - /* - * All functions below are wrappers around the grub_uboot_syscall() function -diff --git a/grub-core/kern/x86_64/dl.c b/grub-core/kern/x86_64/dl.c -index 44069067312a890b4e3ebb5130861ed23572bc54..3a73e6e6ce2c5aefc33313e583cb259ea9bc2645 100644 ---- a/grub-core/kern/x86_64/dl.c -+++ b/grub-core/kern/x86_64/dl.c -@@ -70,6 +70,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, - break; - - case R_X86_64_PC32: -+ case R_X86_64_PLT32: - { - grub_int64_t value; - value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value - -diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c -index 683a8aaa711c4eab0208d116cd7275a6ac678986..ca334d5a40e0716bdc9afbb79135c47d174532da 100644 ---- a/grub-core/lib/crypto.c -+++ b/grub-core/lib/crypto.c -@@ -462,7 +462,7 @@ grub_password_get (char buf[], unsigned buf_size) - if (key == '\n' || key == '\r') - break; - -- if (key == '\e') -+ if (key == GRUB_TERM_ESC) - { - cur_len = 0; - break; -@@ -487,7 +487,7 @@ grub_password_get (char buf[], unsigned buf_size) - grub_xputs ("\n"); - grub_refresh (); - -- return (key != '\e'); -+ return (key != GRUB_TERM_ESC); - } - #endif - -diff --git a/grub-core/lib/uboot/datetime.c b/grub-core/lib/dummy/datetime.c -similarity index 91% -rename from grub-core/lib/uboot/datetime.c -rename to grub-core/lib/dummy/datetime.c -index 4be716928a55b789510dfdcdd1833e29e5cd11fe..cf693fc6b621376b5cae0ca0a74b4421799b5a9e 100644 ---- a/grub-core/lib/uboot/datetime.c -+++ b/grub-core/lib/dummy/datetime.c -@@ -18,7 +18,6 @@ - - #include - #include --#include - #include - #include - -@@ -30,12 +29,12 @@ grub_err_t - grub_get_datetime (struct grub_datetime *datetime __attribute__ ((unused))) - { - return grub_error (GRUB_ERR_INVALID_COMMAND, -- "can\'t get datetime using U-Boot"); -+ "can\'t get datetime on this machine"); - } - - grub_err_t - grub_set_datetime (struct grub_datetime * datetime __attribute__ ((unused))) - { - return grub_error (GRUB_ERR_INVALID_COMMAND, -- "can\'t set datetime using U-Boot"); -+ "can\'t set datetime on this machine"); - } -diff --git a/grub-core/lib/uboot/halt.c b/grub-core/lib/dummy/halt.c -similarity index 100% -rename from grub-core/lib/uboot/halt.c -rename to grub-core/lib/dummy/halt.c -diff --git a/grub-core/lib/efi/reboot.c b/grub-core/lib/dummy/reboot.c -similarity index 77% -rename from grub-core/lib/efi/reboot.c -rename to grub-core/lib/dummy/reboot.c -index 7de8bcb5d6ea128dd406001d970d18ff00ea0f3c..b8cbed8f8117ca9c53cc2087dee87ae68876d64f 100644 ---- a/grub-core/lib/efi/reboot.c -+++ b/grub-core/lib/dummy/reboot.c -@@ -1,6 +1,6 @@ - /* - * GRUB -- GRand Unified Bootloader -- * Copyright (C) 2011 Free Software Foundation, Inc. -+ * Copyright (C) 2013 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by -@@ -16,10 +16,8 @@ - * along with GRUB. If not, see . - */ - --#include --#include --#include - #include -+#include - #include - #include - -@@ -27,7 +25,8 @@ void - grub_reboot (void) - { - grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); -- efi_call_4 (grub_efi_system_table->runtime_services->reset_system, -- GRUB_EFI_RESET_COLD, GRUB_EFI_SUCCESS, 0, NULL); -- for (;;) ; -+ -+ /* Just stop here */ -+ -+ while (1); - } -diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c -index b5d520f208886aa663d4aac36cec9b43a2d0da42..0d371c5633e84bbf47114bfe2c23427982e25192 100644 ---- a/grub-core/lib/fdt.c -+++ b/grub-core/lib/fdt.c -@@ -41,11 +41,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); - (2 * sizeof(grub_uint32_t) \ - + ALIGN_UP (grub_strlen (name) + 1, sizeof(grub_uint32_t))) - --/* Size needed by a property entry: 1 token (FDT_PROPERTY), plus len and nameoff -- fields, plus the property value, plus padding if needed. */ --#define prop_entry_size(prop_len) \ -- (3 * sizeof(grub_uint32_t) + ALIGN_UP(prop_len, sizeof(grub_uint32_t))) -- - #define SKIP_NODE_NAME(name, token, end) \ - name = (char *) ((token) + 1); \ - while (name < (char *) end) \ -@@ -86,7 +81,7 @@ static grub_uint32_t *get_next_node (const void *fdt, char *node_name) - case FDT_PROP: - /* Skip property token and following data (len, nameoff and property - value). */ -- token += prop_entry_size(grub_be_to_cpu32(*(token + 1))) -+ token += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(token + 1))) - / sizeof(*token); - break; - case FDT_NOP: -@@ -102,13 +97,13 @@ static grub_uint32_t *get_next_node (const void *fdt, char *node_name) - static int get_mem_rsvmap_size (const void *fdt) - { - int size = 0; -- grub_uint64_t *ptr = (void *) ((grub_addr_t) fdt -- + grub_fdt_get_off_mem_rsvmap (fdt)); -+ grub_unaligned_uint64_t *ptr = (void *) ((grub_addr_t) fdt -+ + grub_fdt_get_off_mem_rsvmap (fdt)); - - do - { - size += 2 * sizeof(*ptr); -- if (!*ptr && !*(ptr + 1)) -+ if (!ptr[0].val && !ptr[1].val) - return size; - ptr += 2; - } while ((grub_addr_t) ptr <= (grub_addr_t) fdt + grub_fdt_get_totalsize (fdt) -@@ -150,7 +145,7 @@ static int add_subnode (void *fdt, int parentoffset, const char *name) - { - case FDT_PROP: - /* Skip len, nameoff and property value. */ -- token += prop_entry_size(grub_be_to_cpu32(*(token + 1))) -+ token += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(token + 1))) - / sizeof(*token); - break; - case FDT_BEGIN_NODE: -@@ -229,7 +224,7 @@ static int rearrange_blocks (void *fdt, unsigned int clearance) - return 0; - } - --static grub_uint32_t *find_prop (void *fdt, unsigned int nodeoffset, -+static grub_uint32_t *find_prop (const void *fdt, unsigned int nodeoffset, - const char *name) - { - grub_uint32_t *prop = (void *) ((grub_addr_t) fdt -@@ -249,12 +244,12 @@ static grub_uint32_t *find_prop (void *fdt, unsigned int nodeoffset, - && !grub_strcmp (name, (char *) fdt + - grub_fdt_get_off_dt_strings (fdt) + nameoff)) - { -- if (prop + prop_entry_size(grub_be_to_cpu32(*(prop + 1))) -+ if (prop + grub_fdt_prop_entry_size(grub_be_to_cpu32(*(prop + 1))) - / sizeof (*prop) >= end) - return NULL; - return prop; - } -- prop += prop_entry_size(grub_be_to_cpu32(*(prop + 1))) / sizeof (*prop); -+ prop += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(prop + 1))) / sizeof (*prop); - } - else if (grub_be_to_cpu32(*prop) == FDT_NOP) - prop++; -@@ -268,9 +263,9 @@ static grub_uint32_t *find_prop (void *fdt, unsigned int nodeoffset, - the size allocated for the FDT; if this function is called before the other - functions in this file and returns success, the other functions are - guaranteed not to access memory locations outside the allocated memory. */ --int grub_fdt_check_header_nosize (void *fdt) -+int grub_fdt_check_header_nosize (const void *fdt) - { -- if (((grub_addr_t) fdt & 0x7) || (grub_fdt_get_magic (fdt) != FDT_MAGIC) -+ if (((grub_addr_t) fdt & 0x3) || (grub_fdt_get_magic (fdt) != FDT_MAGIC) - || (grub_fdt_get_version (fdt) < FDT_SUPPORTED_VERSION) - || (grub_fdt_get_last_comp_version (fdt) > FDT_SUPPORTED_VERSION) - || (grub_fdt_get_off_dt_struct (fdt) & 0x00000003) -@@ -286,7 +281,7 @@ int grub_fdt_check_header_nosize (void *fdt) - return 0; - } - --int grub_fdt_check_header (void *fdt, unsigned int size) -+int grub_fdt_check_header (const void *fdt, unsigned int size) - { - if (size < sizeof (grub_fdt_header_t) - || (grub_fdt_get_totalsize (fdt) > size) -@@ -295,52 +290,105 @@ int grub_fdt_check_header (void *fdt, unsigned int size) - return 0; - } - -+static const grub_uint32_t * -+advance_token (const void *fdt, const grub_uint32_t *token, const grub_uint32_t *end, int skip_current) -+{ -+ for (; token < end; skip_current = 0) -+ { -+ switch (grub_be_to_cpu32 (*token)) -+ { -+ case FDT_BEGIN_NODE: -+ if (skip_current) -+ { -+ token = get_next_node (fdt, (char *) (token + 1)); -+ continue; -+ } -+ char *ptr; -+ for (ptr = (char *) (token + 1); *ptr && ptr < (char *) end; ptr++) -+ ; -+ if (ptr >= (char *) end) -+ return 0; -+ return token; -+ case FDT_PROP: -+ /* Skip property token and following data (len, nameoff and property -+ value). */ -+ if (token >= end - 1) -+ return 0; -+ token += grub_fdt_prop_entry_size(grub_be_to_cpu32(*(token + 1))) -+ / sizeof(*token); -+ break; -+ case FDT_NOP: -+ token++; -+ break; -+ default: -+ return 0; -+ } -+ } -+ return 0; -+} -+ -+int grub_fdt_next_node (const void *fdt, unsigned int currentoffset) -+{ -+ const grub_uint32_t *token = (const grub_uint32_t *) fdt + (currentoffset + grub_fdt_get_off_dt_struct (fdt)) / 4; -+ token = advance_token (fdt, token, (const void *) struct_end (fdt), 1); -+ if (!token) -+ return -1; -+ return (int) ((grub_addr_t) token - (grub_addr_t) fdt -+ - grub_fdt_get_off_dt_struct (fdt)); -+} -+ -+int grub_fdt_first_node (const void *fdt, unsigned int parentoffset) -+{ -+ const grub_uint32_t *token, *end; -+ char *node_name; -+ -+ if (parentoffset & 0x3) -+ return -1; -+ token = (const void *) ((grub_addr_t) fdt + grub_fdt_get_off_dt_struct(fdt) -+ + parentoffset); -+ end = (const void *) struct_end (fdt); -+ if ((token >= end) || (grub_be_to_cpu32(*token) != FDT_BEGIN_NODE)) -+ return -1; -+ SKIP_NODE_NAME(node_name, token, end); -+ token = advance_token (fdt, token, end, 0); -+ if (!token) -+ return -1; -+ return (int) ((grub_addr_t) token - (grub_addr_t) fdt -+ - grub_fdt_get_off_dt_struct (fdt)); -+} -+ - /* Find a direct sub-node of a given parent node. */ - int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset, - const char *name) - { -- grub_uint32_t *token, *end; -- char *node_name; -+ const grub_uint32_t *token, *end; -+ const char *node_name; -+ int skip_current = 0; - - if (parentoffset & 0x3) - return -1; -- token = (void *) ((grub_addr_t) fdt + grub_fdt_get_off_dt_struct(fdt) -+ token = (const void *) ((grub_addr_t) fdt + grub_fdt_get_off_dt_struct(fdt) - + parentoffset); -- end = (void *) struct_end (fdt); -+ end = (const void *) struct_end (fdt); - if ((token >= end) || (grub_be_to_cpu32(*token) != FDT_BEGIN_NODE)) - return -1; - SKIP_NODE_NAME(node_name, token, end); -- while (token < end) -- { -- switch (grub_be_to_cpu32(*token)) -- { -- case FDT_BEGIN_NODE: -- node_name = (char *) (token + 1); -- if (node_name + grub_strlen (name) >= (char *) end) -- return -1; -- if (!grub_strcmp (node_name, name)) -- return (int) ((grub_addr_t) token - (grub_addr_t) fdt -- - grub_fdt_get_off_dt_struct (fdt)); -- token = get_next_node (fdt, node_name); -- if (!token) -- return -1; -- break; -- case FDT_PROP: -- /* Skip property token and following data (len, nameoff and property -- value). */ -- if (token >= end - 1) -- return -1; -- token += prop_entry_size(grub_be_to_cpu32(*(token + 1))) -- / sizeof(*token); -- break; -- case FDT_NOP: -- token++; -- break; -- default: -- return -1; -- } -+ while (1) { -+ token = advance_token (fdt, token, end, skip_current); -+ if (!token) -+ return -1; -+ skip_current = 1; -+ node_name = (const char *) token + 4; -+ if (grub_strcmp (node_name, name) == 0) -+ return (int) ((grub_addr_t) token - (grub_addr_t) fdt -+ - grub_fdt_get_off_dt_struct (fdt)); - } -- return -1; -+} -+ -+const char * -+grub_fdt_get_nodename (const void *fdt, unsigned int nodeoffset) -+{ -+ return (const char *) fdt + grub_fdt_get_off_dt_struct(fdt) + nodeoffset + 4; - } - - int grub_fdt_add_subnode (void *fdt, unsigned int parentoffset, -@@ -359,6 +407,24 @@ int grub_fdt_add_subnode (void *fdt, unsigned int parentoffset, - return add_subnode (fdt, parentoffset, name); - } - -+const void * -+grub_fdt_get_prop (const void *fdt, unsigned int nodeoffset, const char *name, -+ grub_uint32_t *len) -+{ -+ grub_uint32_t *prop; -+ if ((nodeoffset >= grub_fdt_get_size_dt_struct (fdt)) || (nodeoffset & 0x3) -+ || (grub_be_to_cpu32(*(grub_uint32_t *) ((grub_addr_t) fdt -+ + grub_fdt_get_off_dt_struct (fdt) + nodeoffset)) -+ != FDT_BEGIN_NODE)) -+ return 0; -+ prop = find_prop (fdt, nodeoffset, name); -+ if (!prop) -+ return 0; -+ if (len) -+ *len = grub_be_to_cpu32 (*(prop + 1)); -+ return prop + 3; -+} -+ - int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, - const void *val, grub_uint32_t len) - { -@@ -396,12 +462,12 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, - unsigned int needed_space = 0; - - if (!prop) -- needed_space = prop_entry_size(len); -+ needed_space = grub_fdt_prop_entry_size(len); - if (!prop_name_present) - needed_space += grub_strlen (name) + 1; - if (needed_space > get_free_space (fdt)) - return -1; -- if (rearrange_blocks (fdt, !prop ? prop_entry_size(len) : 0) < 0) -+ if (rearrange_blocks (fdt, !prop ? grub_fdt_prop_entry_size(len) : 0) < 0) - return -1; - } - if (!prop_name_present) { -@@ -418,10 +484,10 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, - + sizeof(grub_uint32_t)); - - prop = (void *) (node_name + ALIGN_UP(grub_strlen(node_name) + 1, 4)); -- grub_memmove (prop + prop_entry_size(len) / sizeof(*prop), prop, -+ grub_memmove (prop + grub_fdt_prop_entry_size(len) / sizeof(*prop), prop, - struct_end(fdt) - (grub_addr_t) prop); - grub_fdt_set_size_dt_struct (fdt, grub_fdt_get_size_dt_struct (fdt) -- + prop_entry_size(len)); -+ + grub_fdt_prop_entry_size(len)); - *prop = grub_cpu_to_be32_compile_time (FDT_PROP); - *(prop + 2) = grub_cpu_to_be32 (nameoff); - } -@@ -429,7 +495,7 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, - - /* Insert padding bytes at the end of the value; if they are not needed, they - will be overwritten by the following memcpy. */ -- *(prop + prop_entry_size(len) / sizeof(grub_uint32_t) - 1) = 0; -+ *(prop + grub_fdt_prop_entry_size(len) / sizeof(grub_uint32_t) - 1) = 0; - - grub_memcpy (prop + 3, val, len); - return 0; -diff --git a/grub-core/lib/i386/reboot.c b/grub-core/lib/i386/reboot.c -index a234244dce5b4c5afd5c68e579c4519a870cda36..dce0b563dcd39ce7acc6d5ec0cc759e67c8c8b87 100644 ---- a/grub-core/lib/i386/reboot.c -+++ b/grub-core/lib/i386/reboot.c -@@ -16,6 +16,8 @@ - * along with GRUB. If not, see . - */ - -+#ifndef GRUB_MACHINE_EFI -+ - #include - #include - #include -@@ -58,3 +60,5 @@ grub_reboot (void) - - while (1); - } -+ -+#endif /* GRUB_MACHINE_EFI */ -diff --git a/grub-core/lib/libgcrypt/cipher/crc.c b/grub-core/lib/libgcrypt/cipher/crc.c -index 9e406f1b19b4d1d49c1ba5140c47d630972c0d8e..28454f8ab728c657d0b440371765030deb35a407 100644 ---- a/grub-core/lib/libgcrypt/cipher/crc.c -+++ b/grub-core/lib/libgcrypt/cipher/crc.c -@@ -28,116 +28,8 @@ - #include "cipher.h" - - #include "bithelp.h" -+#include "bufhelp.h" - --/* Table of CRCs of all 8-bit messages. Generated by running code -- from RFC 1952 modified to print out the table. */ --static u32 crc32_table[256] = { -- 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, -- 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, -- 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, -- 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, -- 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, -- 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, -- 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, -- 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, -- 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, -- 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, -- 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, -- 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, -- 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, -- 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, -- 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, -- 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, -- 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, -- 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, -- 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, -- 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, -- 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, -- 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, -- 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, -- 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, -- 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, -- 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, -- 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, -- 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, -- 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, -- 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, -- 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, -- 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, -- 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, -- 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, -- 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, -- 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, -- 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, -- 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, -- 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, -- 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, -- 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, -- 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, -- 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d --}; -- --/* -- * The following function was extracted from RFC 1952 by Simon -- * Josefsson, for the Shishi project, and modified to be compatible -- * with the modified CRC-32 used by RFC 1510, and subsequently -- * modified for GNU Libgcrypt to allow it to be used for calculating -- * both unmodified CRC-32 and modified CRC-32 values. Original -- * copyright and notice from the document follows: -- * -- * Copyright (c) 1996 L. Peter Deutsch -- * -- * Permission is granted to copy and distribute this document for -- * any purpose and without charge, including translations into -- * other languages and incorporation into compilations, provided -- * that the copyright notice and this notice are preserved, and -- * that any substantive changes or deletions from the original are -- * clearly marked. -- * -- * The copyright on RFCs, and consequently the function below, are -- * supposedly also retroactively claimed by the Internet Society -- * (according to rfc-editor@rfc-editor.org), with the following -- * copyright notice: -- * -- * Copyright (C) The Internet Society. All Rights Reserved. -- * -- * This document and translations of it may be copied and furnished -- * to others, and derivative works that comment on or otherwise -- * explain it or assist in its implementation may be prepared, -- * copied, published and distributed, in whole or in part, without -- * restriction of any kind, provided that the above copyright -- * notice and this paragraph are included on all such copies and -- * derivative works. However, this document itself may not be -- * modified in any way, such as by removing the copyright notice or -- * references to the Internet Society or other Internet -- * organizations, except as needed for the purpose of developing -- * Internet standards in which case the procedures for copyrights -- * defined in the Internet Standards process must be followed, or -- * as required to translate it into languages other than English. -- * -- * The limited permissions granted above are perpetual and will not be -- * revoked by the Internet Society or its successors or assigns. -- * -- * This document and the information contained herein is provided -- * on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET -- * ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR -- * IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE -- * OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY -- * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A -- * PARTICULAR PURPOSE. -- * -- */ --static u32 --update_crc32 (u32 crc, const void *buf_arg, size_t len) --{ -- const char *buf = buf_arg; -- size_t n; -- -- for (n = 0; n < len; n++) -- crc = crc32_table[(crc ^ buf[n]) & 0xff] ^ (crc >> 8); -- -- return crc; --} - - typedef struct - { -@@ -146,8 +38,302 @@ typedef struct - } - CRC_CONTEXT; - -+ -+/* -+ * Code generated by universal_crc by Danjel McGougan -+ * -+ * CRC parameters used: -+ * bits: 32 -+ * poly: 0x04c11db7 -+ * init: 0xffffffff -+ * xor: 0xffffffff -+ * reverse: true -+ * non-direct: false -+ * -+ * CRC of the string "123456789" is 0xcbf43926 -+ */ -+ -+static const u32 crc32_table[1024] = { -+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, -+ 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, -+ 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, -+ 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, -+ 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, -+ 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, -+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, -+ 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, -+ 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, -+ 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, -+ 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, -+ 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, -+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, -+ 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, -+ 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, -+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, -+ 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, -+ 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, -+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, -+ 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, -+ 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, -+ 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, -+ 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, -+ 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, -+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, -+ 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, -+ 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, -+ 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, -+ 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, -+ 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, -+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, -+ 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, -+ 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, -+ 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, -+ 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, -+ 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, -+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, -+ 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, -+ 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, -+ 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, -+ 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, -+ 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, -+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, -+ 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, -+ 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, -+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, -+ 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, -+ 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, -+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, -+ 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, -+ 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, -+ 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, -+ 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, -+ 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, -+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, -+ 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, -+ 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, -+ 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, -+ 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, -+ 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, -+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, -+ 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, -+ 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, -+ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, -+ 0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3, -+ 0x646cc504, 0x7d77f445, 0x565aa786, 0x4f4196c7, -+ 0xc8d98a08, 0xd1c2bb49, 0xfaefe88a, 0xe3f4d9cb, -+ 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, 0x87981ccf, -+ 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192, -+ 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496, -+ 0x821b9859, 0x9b00a918, 0xb02dfadb, 0xa936cb9a, -+ 0xe6775d5d, 0xff6c6c1c, 0xd4413fdf, 0xcd5a0e9e, -+ 0x958424a2, 0x8c9f15e3, 0xa7b24620, 0xbea97761, -+ 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265, -+ 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69, -+ 0x39316bae, 0x202a5aef, 0x0b07092c, 0x121c386d, -+ 0xdf4636f3, 0xc65d07b2, 0xed705471, 0xf46b6530, -+ 0xbb2af3f7, 0xa231c2b6, 0x891c9175, 0x9007a034, -+ 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38, -+ 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c, -+ 0xf0794f05, 0xe9627e44, 0xc24f2d87, 0xdb541cc6, -+ 0x94158a01, 0x8d0ebb40, 0xa623e883, 0xbf38d9c2, -+ 0x38a0c50d, 0x21bbf44c, 0x0a96a78f, 0x138d96ce, -+ 0x5ccc0009, 0x45d73148, 0x6efa628b, 0x77e153ca, -+ 0xbabb5d54, 0xa3a06c15, 0x888d3fd6, 0x91960e97, -+ 0xded79850, 0xc7cca911, 0xece1fad2, 0xf5facb93, -+ 0x7262d75c, 0x6b79e61d, 0x4054b5de, 0x594f849f, -+ 0x160e1258, 0x0f152319, 0x243870da, 0x3d23419b, -+ 0x65fd6ba7, 0x7ce65ae6, 0x57cb0925, 0x4ed03864, -+ 0x0191aea3, 0x188a9fe2, 0x33a7cc21, 0x2abcfd60, -+ 0xad24e1af, 0xb43fd0ee, 0x9f12832d, 0x8609b26c, -+ 0xc94824ab, 0xd05315ea, 0xfb7e4629, 0xe2657768, -+ 0x2f3f79f6, 0x362448b7, 0x1d091b74, 0x04122a35, -+ 0x4b53bcf2, 0x52488db3, 0x7965de70, 0x607eef31, -+ 0xe7e6f3fe, 0xfefdc2bf, 0xd5d0917c, 0xcccba03d, -+ 0x838a36fa, 0x9a9107bb, 0xb1bc5478, 0xa8a76539, -+ 0x3b83984b, 0x2298a90a, 0x09b5fac9, 0x10aecb88, -+ 0x5fef5d4f, 0x46f46c0e, 0x6dd93fcd, 0x74c20e8c, -+ 0xf35a1243, 0xea412302, 0xc16c70c1, 0xd8774180, -+ 0x9736d747, 0x8e2de606, 0xa500b5c5, 0xbc1b8484, -+ 0x71418a1a, 0x685abb5b, 0x4377e898, 0x5a6cd9d9, -+ 0x152d4f1e, 0x0c367e5f, 0x271b2d9c, 0x3e001cdd, -+ 0xb9980012, 0xa0833153, 0x8bae6290, 0x92b553d1, -+ 0xddf4c516, 0xc4eff457, 0xefc2a794, 0xf6d996d5, -+ 0xae07bce9, 0xb71c8da8, 0x9c31de6b, 0x852aef2a, -+ 0xca6b79ed, 0xd37048ac, 0xf85d1b6f, 0xe1462a2e, -+ 0x66de36e1, 0x7fc507a0, 0x54e85463, 0x4df36522, -+ 0x02b2f3e5, 0x1ba9c2a4, 0x30849167, 0x299fa026, -+ 0xe4c5aeb8, 0xfdde9ff9, 0xd6f3cc3a, 0xcfe8fd7b, -+ 0x80a96bbc, 0x99b25afd, 0xb29f093e, 0xab84387f, -+ 0x2c1c24b0, 0x350715f1, 0x1e2a4632, 0x07317773, -+ 0x4870e1b4, 0x516bd0f5, 0x7a468336, 0x635db277, -+ 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, 0xe0d7848d, -+ 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189, -+ 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85, -+ 0x674f9842, 0x7e54a903, 0x5579fac0, 0x4c62cb81, -+ 0x8138c51f, 0x9823f45e, 0xb30ea79d, 0xaa1596dc, -+ 0xe554001b, 0xfc4f315a, 0xd7626299, 0xce7953d8, -+ 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4, -+ 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0, -+ 0x5e7ef3ec, 0x4765c2ad, 0x6c48916e, 0x7553a02f, -+ 0x3a1236e8, 0x230907a9, 0x0824546a, 0x113f652b, -+ 0x96a779e4, 0x8fbc48a5, 0xa4911b66, 0xbd8a2a27, -+ 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23, -+ 0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e, -+ 0x70d024b9, 0x69cb15f8, 0x42e6463b, 0x5bfd777a, -+ 0xdc656bb5, 0xc57e5af4, 0xee530937, 0xf7483876, -+ 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, 0x9324fd72, -+ 0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59, -+ 0x0709a8dc, 0x06cbc2eb, 0x048d7cb2, 0x054f1685, -+ 0x0e1351b8, 0x0fd13b8f, 0x0d9785d6, 0x0c55efe1, -+ 0x091af964, 0x08d89353, 0x0a9e2d0a, 0x0b5c473d, -+ 0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29, -+ 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5, -+ 0x1235f2c8, 0x13f798ff, 0x11b126a6, 0x10734c91, -+ 0x153c5a14, 0x14fe3023, 0x16b88e7a, 0x177ae44d, -+ 0x384d46e0, 0x398f2cd7, 0x3bc9928e, 0x3a0bf8b9, -+ 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065, -+ 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901, -+ 0x3157bf84, 0x3095d5b3, 0x32d36bea, 0x331101dd, -+ 0x246be590, 0x25a98fa7, 0x27ef31fe, 0x262d5bc9, -+ 0x23624d4c, 0x22a0277b, 0x20e69922, 0x2124f315, -+ 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71, -+ 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad, -+ 0x709a8dc0, 0x7158e7f7, 0x731e59ae, 0x72dc3399, -+ 0x7793251c, 0x76514f2b, 0x7417f172, 0x75d59b45, -+ 0x7e89dc78, 0x7f4bb64f, 0x7d0d0816, 0x7ccf6221, -+ 0x798074a4, 0x78421e93, 0x7a04a0ca, 0x7bc6cafd, -+ 0x6cbc2eb0, 0x6d7e4487, 0x6f38fade, 0x6efa90e9, -+ 0x6bb5866c, 0x6a77ec5b, 0x68315202, 0x69f33835, -+ 0x62af7f08, 0x636d153f, 0x612bab66, 0x60e9c151, -+ 0x65a6d7d4, 0x6464bde3, 0x662203ba, 0x67e0698d, -+ 0x48d7cb20, 0x4915a117, 0x4b531f4e, 0x4a917579, -+ 0x4fde63fc, 0x4e1c09cb, 0x4c5ab792, 0x4d98dda5, -+ 0x46c49a98, 0x4706f0af, 0x45404ef6, 0x448224c1, -+ 0x41cd3244, 0x400f5873, 0x4249e62a, 0x438b8c1d, -+ 0x54f16850, 0x55330267, 0x5775bc3e, 0x56b7d609, -+ 0x53f8c08c, 0x523aaabb, 0x507c14e2, 0x51be7ed5, -+ 0x5ae239e8, 0x5b2053df, 0x5966ed86, 0x58a487b1, -+ 0x5deb9134, 0x5c29fb03, 0x5e6f455a, 0x5fad2f6d, -+ 0xe1351b80, 0xe0f771b7, 0xe2b1cfee, 0xe373a5d9, -+ 0xe63cb35c, 0xe7fed96b, 0xe5b86732, 0xe47a0d05, -+ 0xef264a38, 0xeee4200f, 0xeca29e56, 0xed60f461, -+ 0xe82fe2e4, 0xe9ed88d3, 0xebab368a, 0xea695cbd, -+ 0xfd13b8f0, 0xfcd1d2c7, 0xfe976c9e, 0xff5506a9, -+ 0xfa1a102c, 0xfbd87a1b, 0xf99ec442, 0xf85cae75, -+ 0xf300e948, 0xf2c2837f, 0xf0843d26, 0xf1465711, -+ 0xf4094194, 0xf5cb2ba3, 0xf78d95fa, 0xf64fffcd, -+ 0xd9785d60, 0xd8ba3757, 0xdafc890e, 0xdb3ee339, -+ 0xde71f5bc, 0xdfb39f8b, 0xddf521d2, 0xdc374be5, -+ 0xd76b0cd8, 0xd6a966ef, 0xd4efd8b6, 0xd52db281, -+ 0xd062a404, 0xd1a0ce33, 0xd3e6706a, 0xd2241a5d, -+ 0xc55efe10, 0xc49c9427, 0xc6da2a7e, 0xc7184049, -+ 0xc25756cc, 0xc3953cfb, 0xc1d382a2, 0xc011e895, -+ 0xcb4dafa8, 0xca8fc59f, 0xc8c97bc6, 0xc90b11f1, -+ 0xcc440774, 0xcd866d43, 0xcfc0d31a, 0xce02b92d, -+ 0x91af9640, 0x906dfc77, 0x922b422e, 0x93e92819, -+ 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5, -+ 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1, -+ 0x98b56f24, 0x99770513, 0x9b31bb4a, 0x9af3d17d, -+ 0x8d893530, 0x8c4b5f07, 0x8e0de15e, 0x8fcf8b69, -+ 0x8a809dec, 0x8b42f7db, 0x89044982, 0x88c623b5, -+ 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1, -+ 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d, -+ 0xa9e2d0a0, 0xa820ba97, 0xaa6604ce, 0xaba46ef9, -+ 0xaeeb787c, 0xaf29124b, 0xad6fac12, 0xacadc625, -+ 0xa7f18118, 0xa633eb2f, 0xa4755576, 0xa5b73f41, -+ 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d, -+ 0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89, -+ 0xb2cddb0c, 0xb30fb13b, 0xb1490f62, 0xb08b6555, -+ 0xbbd72268, 0xba15485f, 0xb853f606, 0xb9919c31, -+ 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, 0xbe9834ed, -+ 0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee, -+ 0x8f629757, 0x37def032, 0x256b5fdc, 0x9dd738b9, -+ 0xc5b428ef, 0x7d084f8a, 0x6fbde064, 0xd7018701, -+ 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, 0x58631056, -+ 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871, -+ 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26, -+ 0x95ad7f70, 0x2d111815, 0x3fa4b7fb, 0x8718d09e, -+ 0x1acfe827, 0xa2738f42, 0xb0c620ac, 0x087a47c9, -+ 0xa032af3e, 0x188ec85b, 0x0a3b67b5, 0xb28700d0, -+ 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787, -+ 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f, -+ 0xeae41086, 0x525877e3, 0x40edd80d, 0xf851bf68, -+ 0xf02bf8a1, 0x48979fc4, 0x5a22302a, 0xe29e574f, -+ 0x7f496ff6, 0xc7f50893, 0xd540a77d, 0x6dfcc018, -+ 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0, -+ 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7, -+ 0x9b14583d, 0x23a83f58, 0x311d90b6, 0x89a1f7d3, -+ 0x1476cf6a, 0xaccaa80f, 0xbe7f07e1, 0x06c36084, -+ 0x5ea070d2, 0xe61c17b7, 0xf4a9b859, 0x4c15df3c, -+ 0xd1c2e785, 0x697e80e0, 0x7bcb2f0e, 0xc377486b, -+ 0xcb0d0fa2, 0x73b168c7, 0x6104c729, 0xd9b8a04c, -+ 0x446f98f5, 0xfcd3ff90, 0xee66507e, 0x56da371b, -+ 0x0eb9274d, 0xb6054028, 0xa4b0efc6, 0x1c0c88a3, -+ 0x81dbb01a, 0x3967d77f, 0x2bd27891, 0x936e1ff4, -+ 0x3b26f703, 0x839a9066, 0x912f3f88, 0x299358ed, -+ 0xb4446054, 0x0cf80731, 0x1e4da8df, 0xa6f1cfba, -+ 0xfe92dfec, 0x462eb889, 0x549b1767, 0xec277002, -+ 0x71f048bb, 0xc94c2fde, 0xdbf98030, 0x6345e755, -+ 0x6b3fa09c, 0xd383c7f9, 0xc1366817, 0x798a0f72, -+ 0xe45d37cb, 0x5ce150ae, 0x4e54ff40, 0xf6e89825, -+ 0xae8b8873, 0x1637ef16, 0x048240f8, 0xbc3e279d, -+ 0x21e91f24, 0x99557841, 0x8be0d7af, 0x335cb0ca, -+ 0xed59b63b, 0x55e5d15e, 0x47507eb0, 0xffec19d5, -+ 0x623b216c, 0xda874609, 0xc832e9e7, 0x708e8e82, -+ 0x28ed9ed4, 0x9051f9b1, 0x82e4565f, 0x3a58313a, -+ 0xa78f0983, 0x1f336ee6, 0x0d86c108, 0xb53aa66d, -+ 0xbd40e1a4, 0x05fc86c1, 0x1749292f, 0xaff54e4a, -+ 0x322276f3, 0x8a9e1196, 0x982bbe78, 0x2097d91d, -+ 0x78f4c94b, 0xc048ae2e, 0xd2fd01c0, 0x6a4166a5, -+ 0xf7965e1c, 0x4f2a3979, 0x5d9f9697, 0xe523f1f2, -+ 0x4d6b1905, 0xf5d77e60, 0xe762d18e, 0x5fdeb6eb, -+ 0xc2098e52, 0x7ab5e937, 0x680046d9, 0xd0bc21bc, -+ 0x88df31ea, 0x3063568f, 0x22d6f961, 0x9a6a9e04, -+ 0x07bda6bd, 0xbf01c1d8, 0xadb46e36, 0x15080953, -+ 0x1d724e9a, 0xa5ce29ff, 0xb77b8611, 0x0fc7e174, -+ 0x9210d9cd, 0x2aacbea8, 0x38191146, 0x80a57623, -+ 0xd8c66675, 0x607a0110, 0x72cfaefe, 0xca73c99b, -+ 0x57a4f122, 0xef189647, 0xfdad39a9, 0x45115ecc, -+ 0x764dee06, 0xcef18963, 0xdc44268d, 0x64f841e8, -+ 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf, -+ 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907, -+ 0x3c9b51be, 0x842736db, 0x96929935, 0x2e2efe50, -+ 0x2654b999, 0x9ee8defc, 0x8c5d7112, 0x34e11677, -+ 0xa9362ece, 0x118a49ab, 0x033fe645, 0xbb838120, -+ 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98, -+ 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf, -+ 0xd67f4138, 0x6ec3265d, 0x7c7689b3, 0xc4caeed6, -+ 0x591dd66f, 0xe1a1b10a, 0xf3141ee4, 0x4ba87981, -+ 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, 0x017ec639, -+ 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e, -+ 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949, -+ 0x090481f0, 0xb1b8e695, 0xa30d497b, 0x1bb12e1e, -+ 0x43d23e48, 0xfb6e592d, 0xe9dbf6c3, 0x516791a6, -+ 0xccb0a91f, 0x740cce7a, 0x66b96194, 0xde0506f1 -+}; -+ - /* CRC32 */ - -+static inline u32 -+crc32_next (u32 crc, byte data) -+{ -+ return (crc >> 8) ^ crc32_table[(crc & 0xff) ^ data]; -+} -+ -+/* -+ * Process 4 bytes in one go -+ */ -+static inline u32 -+crc32_next4 (u32 crc, u32 data) -+{ -+ crc ^= data; -+ crc = crc32_table[(crc & 0xff) + 0x300] ^ -+ crc32_table[((crc >> 8) & 0xff) + 0x200] ^ -+ crc32_table[((crc >> 16) & 0xff) + 0x100] ^ -+ crc32_table[(crc >> 24) & 0xff]; -+ return crc; -+} -+ - static void - crc32_init (void *context) - { -@@ -156,12 +342,40 @@ crc32_init (void *context) - } - - static void --crc32_write (void *context, const void *inbuf, size_t inlen) -+crc32_write (void *context, const void *inbuf_arg, size_t inlen) - { - CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; -- if (!inbuf) -+ const byte *inbuf = inbuf_arg; -+ u32 crc; -+ -+ if (!inbuf || !inlen) - return; -- ctx->CRC = update_crc32 (ctx->CRC, inbuf, inlen); -+ -+ crc = ctx->CRC; -+ -+ while (inlen >= 16) -+ { -+ inlen -= 16; -+ crc = crc32_next4(crc, buf_get_le32(&inbuf[0])); -+ crc = crc32_next4(crc, buf_get_le32(&inbuf[4])); -+ crc = crc32_next4(crc, buf_get_le32(&inbuf[8])); -+ crc = crc32_next4(crc, buf_get_le32(&inbuf[12])); -+ inbuf += 16; -+ } -+ -+ while (inlen >= 4) -+ { -+ inlen -= 4; -+ crc = crc32_next4(crc, buf_get_le32(inbuf)); -+ inbuf += 4; -+ } -+ -+ while (inlen--) -+ { -+ crc = crc32_next(crc, *inbuf++); -+ } -+ -+ ctx->CRC = crc; - } - - static byte * -@@ -176,13 +390,12 @@ crc32_final (void *context) - { - CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; - ctx->CRC ^= 0xffffffffL; -- ctx->buf[0] = (ctx->CRC >> 24) & 0xFF; -- ctx->buf[1] = (ctx->CRC >> 16) & 0xFF; -- ctx->buf[2] = (ctx->CRC >> 8) & 0xFF; -- ctx->buf[3] = (ctx->CRC ) & 0xFF; -+ buf_put_be32 (ctx->buf, ctx->CRC); - } - - /* CRC32 a'la RFC 1510 */ -+/* CRC of the string "123456789" is 0x2dfd2d88 */ -+ - static void - crc32rfc1510_init (void *context) - { -@@ -194,82 +407,366 @@ static void - crc32rfc1510_final (void *context) - { - CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; -- ctx->buf[0] = (ctx->CRC >> 24) & 0xFF; -- ctx->buf[1] = (ctx->CRC >> 16) & 0xFF; -- ctx->buf[2] = (ctx->CRC >> 8) & 0xFF; -- ctx->buf[3] = (ctx->CRC ) & 0xFF; -+ buf_put_be32(ctx->buf, ctx->CRC); - } - - /* CRC24 a'la RFC 2440 */ - /* -- * The following CRC 24 routines are adapted from RFC 2440, which has -- * the following copyright notice: -+ * Code generated by universal_crc by Danjel McGougan - * -- * Copyright (C) The Internet Society (1998). All Rights Reserved. -+ * CRC parameters used: -+ * bits: 24 -+ * poly: 0x864cfb -+ * init: 0xb704ce -+ * xor: 0x000000 -+ * reverse: false -+ * non-direct: false - * -- * This document and translations of it may be copied and furnished -- * to others, and derivative works that comment on or otherwise -- * explain it or assist in its implementation may be prepared, -- * copied, published and distributed, in whole or in part, without -- * restriction of any kind, provided that the above copyright notice -- * and this paragraph are included on all such copies and derivative -- * works. However, this document itself may not be modified in any -- * way, such as by removing the copyright notice or references to -- * the Internet Society or other Internet organizations, except as -- * needed for the purpose of developing Internet standards in which -- * case the procedures for copyrights defined in the Internet -- * Standards process must be followed, or as required to translate -- * it into languages other than English. -- * -- * The limited permissions granted above are perpetual and will not be -- * revoked by the Internet Society or its successors or assigns. -- * -- * This document and the information contained herein is provided on -- * an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET -- * ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR -- * IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE -- * OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY -- * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR -- * PURPOSE. -+ * CRC of the string "123456789" is 0x21cf02 -+ */ -+ -+static const u32 crc24_table[1024] = -+{ -+ 0x00000000, 0x00fb4c86, 0x000dd58a, 0x00f6990c, -+ 0x00e1e693, 0x001aaa15, 0x00ec3319, 0x00177f9f, -+ 0x003981a1, 0x00c2cd27, 0x0034542b, 0x00cf18ad, -+ 0x00d86732, 0x00232bb4, 0x00d5b2b8, 0x002efe3e, -+ 0x00894ec5, 0x00720243, 0x00849b4f, 0x007fd7c9, -+ 0x0068a856, 0x0093e4d0, 0x00657ddc, 0x009e315a, -+ 0x00b0cf64, 0x004b83e2, 0x00bd1aee, 0x00465668, -+ 0x005129f7, 0x00aa6571, 0x005cfc7d, 0x00a7b0fb, -+ 0x00e9d10c, 0x00129d8a, 0x00e40486, 0x001f4800, -+ 0x0008379f, 0x00f37b19, 0x0005e215, 0x00feae93, -+ 0x00d050ad, 0x002b1c2b, 0x00dd8527, 0x0026c9a1, -+ 0x0031b63e, 0x00cafab8, 0x003c63b4, 0x00c72f32, -+ 0x00609fc9, 0x009bd34f, 0x006d4a43, 0x009606c5, -+ 0x0081795a, 0x007a35dc, 0x008cacd0, 0x0077e056, -+ 0x00591e68, 0x00a252ee, 0x0054cbe2, 0x00af8764, -+ 0x00b8f8fb, 0x0043b47d, 0x00b52d71, 0x004e61f7, -+ 0x00d2a319, 0x0029ef9f, 0x00df7693, 0x00243a15, -+ 0x0033458a, 0x00c8090c, 0x003e9000, 0x00c5dc86, -+ 0x00eb22b8, 0x00106e3e, 0x00e6f732, 0x001dbbb4, -+ 0x000ac42b, 0x00f188ad, 0x000711a1, 0x00fc5d27, -+ 0x005beddc, 0x00a0a15a, 0x00563856, 0x00ad74d0, -+ 0x00ba0b4f, 0x004147c9, 0x00b7dec5, 0x004c9243, -+ 0x00626c7d, 0x009920fb, 0x006fb9f7, 0x0094f571, -+ 0x00838aee, 0x0078c668, 0x008e5f64, 0x007513e2, -+ 0x003b7215, 0x00c03e93, 0x0036a79f, 0x00cdeb19, -+ 0x00da9486, 0x0021d800, 0x00d7410c, 0x002c0d8a, -+ 0x0002f3b4, 0x00f9bf32, 0x000f263e, 0x00f46ab8, -+ 0x00e31527, 0x001859a1, 0x00eec0ad, 0x00158c2b, -+ 0x00b23cd0, 0x00497056, 0x00bfe95a, 0x0044a5dc, -+ 0x0053da43, 0x00a896c5, 0x005e0fc9, 0x00a5434f, -+ 0x008bbd71, 0x0070f1f7, 0x008668fb, 0x007d247d, -+ 0x006a5be2, 0x00911764, 0x00678e68, 0x009cc2ee, -+ 0x00a44733, 0x005f0bb5, 0x00a992b9, 0x0052de3f, -+ 0x0045a1a0, 0x00beed26, 0x0048742a, 0x00b338ac, -+ 0x009dc692, 0x00668a14, 0x00901318, 0x006b5f9e, -+ 0x007c2001, 0x00876c87, 0x0071f58b, 0x008ab90d, -+ 0x002d09f6, 0x00d64570, 0x0020dc7c, 0x00db90fa, -+ 0x00ccef65, 0x0037a3e3, 0x00c13aef, 0x003a7669, -+ 0x00148857, 0x00efc4d1, 0x00195ddd, 0x00e2115b, -+ 0x00f56ec4, 0x000e2242, 0x00f8bb4e, 0x0003f7c8, -+ 0x004d963f, 0x00b6dab9, 0x004043b5, 0x00bb0f33, -+ 0x00ac70ac, 0x00573c2a, 0x00a1a526, 0x005ae9a0, -+ 0x0074179e, 0x008f5b18, 0x0079c214, 0x00828e92, -+ 0x0095f10d, 0x006ebd8b, 0x00982487, 0x00636801, -+ 0x00c4d8fa, 0x003f947c, 0x00c90d70, 0x003241f6, -+ 0x00253e69, 0x00de72ef, 0x0028ebe3, 0x00d3a765, -+ 0x00fd595b, 0x000615dd, 0x00f08cd1, 0x000bc057, -+ 0x001cbfc8, 0x00e7f34e, 0x00116a42, 0x00ea26c4, -+ 0x0076e42a, 0x008da8ac, 0x007b31a0, 0x00807d26, -+ 0x009702b9, 0x006c4e3f, 0x009ad733, 0x00619bb5, -+ 0x004f658b, 0x00b4290d, 0x0042b001, 0x00b9fc87, -+ 0x00ae8318, 0x0055cf9e, 0x00a35692, 0x00581a14, -+ 0x00ffaaef, 0x0004e669, 0x00f27f65, 0x000933e3, -+ 0x001e4c7c, 0x00e500fa, 0x001399f6, 0x00e8d570, -+ 0x00c62b4e, 0x003d67c8, 0x00cbfec4, 0x0030b242, -+ 0x0027cddd, 0x00dc815b, 0x002a1857, 0x00d154d1, -+ 0x009f3526, 0x006479a0, 0x0092e0ac, 0x0069ac2a, -+ 0x007ed3b5, 0x00859f33, 0x0073063f, 0x00884ab9, -+ 0x00a6b487, 0x005df801, 0x00ab610d, 0x00502d8b, -+ 0x00475214, 0x00bc1e92, 0x004a879e, 0x00b1cb18, -+ 0x00167be3, 0x00ed3765, 0x001bae69, 0x00e0e2ef, -+ 0x00f79d70, 0x000cd1f6, 0x00fa48fa, 0x0001047c, -+ 0x002ffa42, 0x00d4b6c4, 0x00222fc8, 0x00d9634e, -+ 0x00ce1cd1, 0x00355057, 0x00c3c95b, 0x003885dd, -+ 0x00000000, 0x00488f66, 0x00901ecd, 0x00d891ab, -+ 0x00db711c, 0x0093fe7a, 0x004b6fd1, 0x0003e0b7, -+ 0x00b6e338, 0x00fe6c5e, 0x0026fdf5, 0x006e7293, -+ 0x006d9224, 0x00251d42, 0x00fd8ce9, 0x00b5038f, -+ 0x006cc771, 0x00244817, 0x00fcd9bc, 0x00b456da, -+ 0x00b7b66d, 0x00ff390b, 0x0027a8a0, 0x006f27c6, -+ 0x00da2449, 0x0092ab2f, 0x004a3a84, 0x0002b5e2, -+ 0x00015555, 0x0049da33, 0x00914b98, 0x00d9c4fe, -+ 0x00d88ee3, 0x00900185, 0x0048902e, 0x00001f48, -+ 0x0003ffff, 0x004b7099, 0x0093e132, 0x00db6e54, -+ 0x006e6ddb, 0x0026e2bd, 0x00fe7316, 0x00b6fc70, -+ 0x00b51cc7, 0x00fd93a1, 0x0025020a, 0x006d8d6c, -+ 0x00b44992, 0x00fcc6f4, 0x0024575f, 0x006cd839, -+ 0x006f388e, 0x0027b7e8, 0x00ff2643, 0x00b7a925, -+ 0x0002aaaa, 0x004a25cc, 0x0092b467, 0x00da3b01, -+ 0x00d9dbb6, 0x009154d0, 0x0049c57b, 0x00014a1d, -+ 0x004b5141, 0x0003de27, 0x00db4f8c, 0x0093c0ea, -+ 0x0090205d, 0x00d8af3b, 0x00003e90, 0x0048b1f6, -+ 0x00fdb279, 0x00b53d1f, 0x006dacb4, 0x002523d2, -+ 0x0026c365, 0x006e4c03, 0x00b6dda8, 0x00fe52ce, -+ 0x00279630, 0x006f1956, 0x00b788fd, 0x00ff079b, -+ 0x00fce72c, 0x00b4684a, 0x006cf9e1, 0x00247687, -+ 0x00917508, 0x00d9fa6e, 0x00016bc5, 0x0049e4a3, -+ 0x004a0414, 0x00028b72, 0x00da1ad9, 0x009295bf, -+ 0x0093dfa2, 0x00db50c4, 0x0003c16f, 0x004b4e09, -+ 0x0048aebe, 0x000021d8, 0x00d8b073, 0x00903f15, -+ 0x00253c9a, 0x006db3fc, 0x00b52257, 0x00fdad31, -+ 0x00fe4d86, 0x00b6c2e0, 0x006e534b, 0x0026dc2d, -+ 0x00ff18d3, 0x00b797b5, 0x006f061e, 0x00278978, -+ 0x002469cf, 0x006ce6a9, 0x00b47702, 0x00fcf864, -+ 0x0049fbeb, 0x0001748d, 0x00d9e526, 0x00916a40, -+ 0x00928af7, 0x00da0591, 0x0002943a, 0x004a1b5c, -+ 0x0096a282, 0x00de2de4, 0x0006bc4f, 0x004e3329, -+ 0x004dd39e, 0x00055cf8, 0x00ddcd53, 0x00954235, -+ 0x002041ba, 0x0068cedc, 0x00b05f77, 0x00f8d011, -+ 0x00fb30a6, 0x00b3bfc0, 0x006b2e6b, 0x0023a10d, -+ 0x00fa65f3, 0x00b2ea95, 0x006a7b3e, 0x0022f458, -+ 0x002114ef, 0x00699b89, 0x00b10a22, 0x00f98544, -+ 0x004c86cb, 0x000409ad, 0x00dc9806, 0x00941760, -+ 0x0097f7d7, 0x00df78b1, 0x0007e91a, 0x004f667c, -+ 0x004e2c61, 0x0006a307, 0x00de32ac, 0x0096bdca, -+ 0x00955d7d, 0x00ddd21b, 0x000543b0, 0x004dccd6, -+ 0x00f8cf59, 0x00b0403f, 0x0068d194, 0x00205ef2, -+ 0x0023be45, 0x006b3123, 0x00b3a088, 0x00fb2fee, -+ 0x0022eb10, 0x006a6476, 0x00b2f5dd, 0x00fa7abb, -+ 0x00f99a0c, 0x00b1156a, 0x006984c1, 0x00210ba7, -+ 0x00940828, 0x00dc874e, 0x000416e5, 0x004c9983, -+ 0x004f7934, 0x0007f652, 0x00df67f9, 0x0097e89f, -+ 0x00ddf3c3, 0x00957ca5, 0x004ded0e, 0x00056268, -+ 0x000682df, 0x004e0db9, 0x00969c12, 0x00de1374, -+ 0x006b10fb, 0x00239f9d, 0x00fb0e36, 0x00b38150, -+ 0x00b061e7, 0x00f8ee81, 0x00207f2a, 0x0068f04c, -+ 0x00b134b2, 0x00f9bbd4, 0x00212a7f, 0x0069a519, -+ 0x006a45ae, 0x0022cac8, 0x00fa5b63, 0x00b2d405, -+ 0x0007d78a, 0x004f58ec, 0x0097c947, 0x00df4621, -+ 0x00dca696, 0x009429f0, 0x004cb85b, 0x0004373d, -+ 0x00057d20, 0x004df246, 0x009563ed, 0x00ddec8b, -+ 0x00de0c3c, 0x0096835a, 0x004e12f1, 0x00069d97, -+ 0x00b39e18, 0x00fb117e, 0x002380d5, 0x006b0fb3, -+ 0x0068ef04, 0x00206062, 0x00f8f1c9, 0x00b07eaf, -+ 0x0069ba51, 0x00213537, 0x00f9a49c, 0x00b12bfa, -+ 0x00b2cb4d, 0x00fa442b, 0x0022d580, 0x006a5ae6, -+ 0x00df5969, 0x0097d60f, 0x004f47a4, 0x0007c8c2, -+ 0x00042875, 0x004ca713, 0x009436b8, 0x00dcb9de, -+ 0x00000000, 0x00d70983, 0x00555f80, 0x00825603, -+ 0x0051f286, 0x0086fb05, 0x0004ad06, 0x00d3a485, -+ 0x0059a88b, 0x008ea108, 0x000cf70b, 0x00dbfe88, -+ 0x00085a0d, 0x00df538e, 0x005d058d, 0x008a0c0e, -+ 0x00491c91, 0x009e1512, 0x001c4311, 0x00cb4a92, -+ 0x0018ee17, 0x00cfe794, 0x004db197, 0x009ab814, -+ 0x0010b41a, 0x00c7bd99, 0x0045eb9a, 0x0092e219, -+ 0x0041469c, 0x00964f1f, 0x0014191c, 0x00c3109f, -+ 0x006974a4, 0x00be7d27, 0x003c2b24, 0x00eb22a7, -+ 0x00388622, 0x00ef8fa1, 0x006dd9a2, 0x00bad021, -+ 0x0030dc2f, 0x00e7d5ac, 0x006583af, 0x00b28a2c, -+ 0x00612ea9, 0x00b6272a, 0x00347129, 0x00e378aa, -+ 0x00206835, 0x00f761b6, 0x007537b5, 0x00a23e36, -+ 0x00719ab3, 0x00a69330, 0x0024c533, 0x00f3ccb0, -+ 0x0079c0be, 0x00aec93d, 0x002c9f3e, 0x00fb96bd, -+ 0x00283238, 0x00ff3bbb, 0x007d6db8, 0x00aa643b, -+ 0x0029a4ce, 0x00fead4d, 0x007cfb4e, 0x00abf2cd, -+ 0x00785648, 0x00af5fcb, 0x002d09c8, 0x00fa004b, -+ 0x00700c45, 0x00a705c6, 0x002553c5, 0x00f25a46, -+ 0x0021fec3, 0x00f6f740, 0x0074a143, 0x00a3a8c0, -+ 0x0060b85f, 0x00b7b1dc, 0x0035e7df, 0x00e2ee5c, -+ 0x00314ad9, 0x00e6435a, 0x00641559, 0x00b31cda, -+ 0x003910d4, 0x00ee1957, 0x006c4f54, 0x00bb46d7, -+ 0x0068e252, 0x00bfebd1, 0x003dbdd2, 0x00eab451, -+ 0x0040d06a, 0x0097d9e9, 0x00158fea, 0x00c28669, -+ 0x001122ec, 0x00c62b6f, 0x00447d6c, 0x009374ef, -+ 0x001978e1, 0x00ce7162, 0x004c2761, 0x009b2ee2, -+ 0x00488a67, 0x009f83e4, 0x001dd5e7, 0x00cadc64, -+ 0x0009ccfb, 0x00dec578, 0x005c937b, 0x008b9af8, -+ 0x00583e7d, 0x008f37fe, 0x000d61fd, 0x00da687e, -+ 0x00506470, 0x00876df3, 0x00053bf0, 0x00d23273, -+ 0x000196f6, 0x00d69f75, 0x0054c976, 0x0083c0f5, -+ 0x00a9041b, 0x007e0d98, 0x00fc5b9b, 0x002b5218, -+ 0x00f8f69d, 0x002fff1e, 0x00ada91d, 0x007aa09e, -+ 0x00f0ac90, 0x0027a513, 0x00a5f310, 0x0072fa93, -+ 0x00a15e16, 0x00765795, 0x00f40196, 0x00230815, -+ 0x00e0188a, 0x00371109, 0x00b5470a, 0x00624e89, -+ 0x00b1ea0c, 0x0066e38f, 0x00e4b58c, 0x0033bc0f, -+ 0x00b9b001, 0x006eb982, 0x00ecef81, 0x003be602, -+ 0x00e84287, 0x003f4b04, 0x00bd1d07, 0x006a1484, -+ 0x00c070bf, 0x0017793c, 0x00952f3f, 0x004226bc, -+ 0x00918239, 0x00468bba, 0x00c4ddb9, 0x0013d43a, -+ 0x0099d834, 0x004ed1b7, 0x00cc87b4, 0x001b8e37, -+ 0x00c82ab2, 0x001f2331, 0x009d7532, 0x004a7cb1, -+ 0x00896c2e, 0x005e65ad, 0x00dc33ae, 0x000b3a2d, -+ 0x00d89ea8, 0x000f972b, 0x008dc128, 0x005ac8ab, -+ 0x00d0c4a5, 0x0007cd26, 0x00859b25, 0x005292a6, -+ 0x00813623, 0x00563fa0, 0x00d469a3, 0x00036020, -+ 0x0080a0d5, 0x0057a956, 0x00d5ff55, 0x0002f6d6, -+ 0x00d15253, 0x00065bd0, 0x00840dd3, 0x00530450, -+ 0x00d9085e, 0x000e01dd, 0x008c57de, 0x005b5e5d, -+ 0x0088fad8, 0x005ff35b, 0x00dda558, 0x000aacdb, -+ 0x00c9bc44, 0x001eb5c7, 0x009ce3c4, 0x004bea47, -+ 0x00984ec2, 0x004f4741, 0x00cd1142, 0x001a18c1, -+ 0x009014cf, 0x00471d4c, 0x00c54b4f, 0x001242cc, -+ 0x00c1e649, 0x0016efca, 0x0094b9c9, 0x0043b04a, -+ 0x00e9d471, 0x003eddf2, 0x00bc8bf1, 0x006b8272, -+ 0x00b826f7, 0x006f2f74, 0x00ed7977, 0x003a70f4, -+ 0x00b07cfa, 0x00677579, 0x00e5237a, 0x00322af9, -+ 0x00e18e7c, 0x003687ff, 0x00b4d1fc, 0x0063d87f, -+ 0x00a0c8e0, 0x0077c163, 0x00f59760, 0x00229ee3, -+ 0x00f13a66, 0x002633e5, 0x00a465e6, 0x00736c65, -+ 0x00f9606b, 0x002e69e8, 0x00ac3feb, 0x007b3668, -+ 0x00a892ed, 0x007f9b6e, 0x00fdcd6d, 0x002ac4ee, -+ 0x00000000, 0x00520936, 0x00a4126c, 0x00f61b5a, -+ 0x004825d8, 0x001a2cee, 0x00ec37b4, 0x00be3e82, -+ 0x006b0636, 0x00390f00, 0x00cf145a, 0x009d1d6c, -+ 0x002323ee, 0x00712ad8, 0x00873182, 0x00d538b4, -+ 0x00d60c6c, 0x0084055a, 0x00721e00, 0x00201736, -+ 0x009e29b4, 0x00cc2082, 0x003a3bd8, 0x006832ee, -+ 0x00bd0a5a, 0x00ef036c, 0x00191836, 0x004b1100, -+ 0x00f52f82, 0x00a726b4, 0x00513dee, 0x000334d8, -+ 0x00ac19d8, 0x00fe10ee, 0x00080bb4, 0x005a0282, -+ 0x00e43c00, 0x00b63536, 0x00402e6c, 0x0012275a, -+ 0x00c71fee, 0x009516d8, 0x00630d82, 0x003104b4, -+ 0x008f3a36, 0x00dd3300, 0x002b285a, 0x0079216c, -+ 0x007a15b4, 0x00281c82, 0x00de07d8, 0x008c0eee, -+ 0x0032306c, 0x0060395a, 0x00962200, 0x00c42b36, -+ 0x00111382, 0x00431ab4, 0x00b501ee, 0x00e708d8, -+ 0x0059365a, 0x000b3f6c, 0x00fd2436, 0x00af2d00, -+ 0x00a37f36, 0x00f17600, 0x00076d5a, 0x0055646c, -+ 0x00eb5aee, 0x00b953d8, 0x004f4882, 0x001d41b4, -+ 0x00c87900, 0x009a7036, 0x006c6b6c, 0x003e625a, -+ 0x00805cd8, 0x00d255ee, 0x00244eb4, 0x00764782, -+ 0x0075735a, 0x00277a6c, 0x00d16136, 0x00836800, -+ 0x003d5682, 0x006f5fb4, 0x009944ee, 0x00cb4dd8, -+ 0x001e756c, 0x004c7c5a, 0x00ba6700, 0x00e86e36, -+ 0x005650b4, 0x00045982, 0x00f242d8, 0x00a04bee, -+ 0x000f66ee, 0x005d6fd8, 0x00ab7482, 0x00f97db4, -+ 0x00474336, 0x00154a00, 0x00e3515a, 0x00b1586c, -+ 0x006460d8, 0x003669ee, 0x00c072b4, 0x00927b82, -+ 0x002c4500, 0x007e4c36, 0x0088576c, 0x00da5e5a, -+ 0x00d96a82, 0x008b63b4, 0x007d78ee, 0x002f71d8, -+ 0x00914f5a, 0x00c3466c, 0x00355d36, 0x00675400, -+ 0x00b26cb4, 0x00e06582, 0x00167ed8, 0x004477ee, -+ 0x00fa496c, 0x00a8405a, 0x005e5b00, 0x000c5236, -+ 0x0046ff6c, 0x0014f65a, 0x00e2ed00, 0x00b0e436, -+ 0x000edab4, 0x005cd382, 0x00aac8d8, 0x00f8c1ee, -+ 0x002df95a, 0x007ff06c, 0x0089eb36, 0x00dbe200, -+ 0x0065dc82, 0x0037d5b4, 0x00c1ceee, 0x0093c7d8, -+ 0x0090f300, 0x00c2fa36, 0x0034e16c, 0x0066e85a, -+ 0x00d8d6d8, 0x008adfee, 0x007cc4b4, 0x002ecd82, -+ 0x00fbf536, 0x00a9fc00, 0x005fe75a, 0x000dee6c, -+ 0x00b3d0ee, 0x00e1d9d8, 0x0017c282, 0x0045cbb4, -+ 0x00eae6b4, 0x00b8ef82, 0x004ef4d8, 0x001cfdee, -+ 0x00a2c36c, 0x00f0ca5a, 0x0006d100, 0x0054d836, -+ 0x0081e082, 0x00d3e9b4, 0x0025f2ee, 0x0077fbd8, -+ 0x00c9c55a, 0x009bcc6c, 0x006dd736, 0x003fde00, -+ 0x003cead8, 0x006ee3ee, 0x0098f8b4, 0x00caf182, -+ 0x0074cf00, 0x0026c636, 0x00d0dd6c, 0x0082d45a, -+ 0x0057ecee, 0x0005e5d8, 0x00f3fe82, 0x00a1f7b4, -+ 0x001fc936, 0x004dc000, 0x00bbdb5a, 0x00e9d26c, -+ 0x00e5805a, 0x00b7896c, 0x00419236, 0x00139b00, -+ 0x00ada582, 0x00ffacb4, 0x0009b7ee, 0x005bbed8, -+ 0x008e866c, 0x00dc8f5a, 0x002a9400, 0x00789d36, -+ 0x00c6a3b4, 0x0094aa82, 0x0062b1d8, 0x0030b8ee, -+ 0x00338c36, 0x00618500, 0x00979e5a, 0x00c5976c, -+ 0x007ba9ee, 0x0029a0d8, 0x00dfbb82, 0x008db2b4, -+ 0x00588a00, 0x000a8336, 0x00fc986c, 0x00ae915a, -+ 0x0010afd8, 0x0042a6ee, 0x00b4bdb4, 0x00e6b482, -+ 0x00499982, 0x001b90b4, 0x00ed8bee, 0x00bf82d8, -+ 0x0001bc5a, 0x0053b56c, 0x00a5ae36, 0x00f7a700, -+ 0x00229fb4, 0x00709682, 0x00868dd8, 0x00d484ee, -+ 0x006aba6c, 0x0038b35a, 0x00cea800, 0x009ca136, -+ 0x009f95ee, 0x00cd9cd8, 0x003b8782, 0x00698eb4, -+ 0x00d7b036, 0x0085b900, 0x0073a25a, 0x0021ab6c, -+ 0x00f493d8, 0x00a69aee, 0x005081b4, 0x00028882, -+ 0x00bcb600, 0x00eebf36, 0x0018a46c, 0x004aad5a -+}; -+ -+static inline -+u32 crc24_init (void) -+{ -+ return 0xce04b7; -+} -+ -+static inline -+u32 crc24_next (u32 crc, byte data) -+{ -+ return (crc >> 8) ^ crc24_table[(crc & 0xff) ^ data]; -+} -+ -+/* -+ * Process 4 bytes in one go - */ -+static inline -+u32 crc24_next4 (u32 crc, u32 data) -+{ -+ crc ^= data; -+ crc = crc24_table[(crc & 0xff) + 0x300] ^ -+ crc24_table[((crc >> 8) & 0xff) + 0x200] ^ -+ crc24_table[((crc >> 16) & 0xff) + 0x100] ^ -+ crc24_table[(crc >> 24) & 0xff]; -+ return crc; -+} - --#define CRC24_INIT 0xb704ceL --#define CRC24_POLY 0x1864cfbL -+static inline -+u32 crc24_final (u32 crc) -+{ -+ return crc & 0xffffff; -+} - - static void - crc24rfc2440_init (void *context) - { - CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; -- ctx->CRC = CRC24_INIT; -+ ctx->CRC = crc24_init(); - } - - static void - crc24rfc2440_write (void *context, const void *inbuf_arg, size_t inlen) - { - const unsigned char *inbuf = inbuf_arg; -- int i; - CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; -+ u32 crc; - -- if (!inbuf) -+ if (!inbuf || !inlen) - return; - -- while (inlen--) { -- ctx->CRC ^= (*inbuf++) << 16; -- for (i = 0; i < 8; i++) { -- ctx->CRC <<= 1; -- if (ctx->CRC & 0x1000000) -- ctx->CRC ^= CRC24_POLY; -+ crc = ctx->CRC; -+ -+ while (inlen >= 16) -+ { -+ inlen -= 16; -+ crc = crc24_next4(crc, buf_get_le32(&inbuf[0])); -+ crc = crc24_next4(crc, buf_get_le32(&inbuf[4])); -+ crc = crc24_next4(crc, buf_get_le32(&inbuf[8])); -+ crc = crc24_next4(crc, buf_get_le32(&inbuf[12])); -+ inbuf += 16; - } -- } -+ -+ while (inlen >= 4) -+ { -+ inlen -= 4; -+ crc = crc24_next4(crc, buf_get_le32(inbuf)); -+ inbuf += 4; -+ } -+ -+ while (inlen--) -+ { -+ crc = crc24_next(crc, *inbuf++); -+ } -+ -+ ctx->CRC = crc; - } - - static void - crc24rfc2440_final (void *context) - { - CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; -- ctx->buf[0] = (ctx->CRC >> 16) & 0xFF; -- ctx->buf[1] = (ctx->CRC >> 8) & 0xFF; -- ctx->buf[2] = (ctx->CRC ) & 0xFF; -+ ctx->CRC = crc24_final(ctx->CRC); -+ buf_put_le32 (ctx->buf, ctx->CRC); - } - - gcry_md_spec_t _gcry_digest_spec_crc32 = -diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c -index 5b39f02bb2e592d85639891db6eb68a97ce12dfa..b4f609d2d01184b8d0a3e5aff448725f80a36a93 100644 ---- a/grub-core/loader/arm/linux.c -+++ b/grub-core/loader/arm/linux.c -@@ -42,21 +42,18 @@ static grub_size_t linux_size; - static char *linux_args; - - static grub_uint32_t machine_type; --static void *fdt_addr; -+static const void *current_fdt; - - typedef void (*kernel_entry_t) (int, unsigned long, void *); - --#define LINUX_ZIMAGE_OFFSET 0x24 --#define LINUX_ZIMAGE_MAGIC 0x016f2818 -- - #define LINUX_PHYS_OFFSET (0x00008000) - #define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000) - #define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000) - - static grub_size_t --get_atag_size (grub_uint32_t *atag) -+get_atag_size (const grub_uint32_t *atag) - { -- grub_uint32_t *atag0 = atag; -+ const grub_uint32_t *atag0 = atag; - while (atag[0] && atag[1]) - atag += atag[0]; - return atag - atag0; -@@ -68,10 +65,11 @@ get_atag_size (grub_uint32_t *atag) - * Merges in command line parameters and sets up initrd addresses. - */ - static grub_err_t --linux_prepare_atag (void) -+linux_prepare_atag (void *target_atag) - { -- grub_uint32_t *atag_orig = (grub_uint32_t *) fdt_addr; -- grub_uint32_t *tmp_atag, *from, *to; -+ const grub_uint32_t *atag_orig = (const grub_uint32_t *) current_fdt; -+ grub_uint32_t *tmp_atag, *to; -+ const grub_uint32_t *from; - grub_size_t tmp_size; - grub_size_t arg_size = grub_strlen (linux_args); - char *cmdline_orig = NULL; -@@ -142,7 +140,7 @@ linux_prepare_atag (void) - to += 2; - - /* Copy updated FDT to its launch location */ -- grub_memcpy (atag_orig, tmp_atag, sizeof (grub_uint32_t) * (to - tmp_atag)); -+ grub_memcpy (target_atag, tmp_atag, sizeof (grub_uint32_t) * (to - tmp_atag)); - grub_free (tmp_atag); - - grub_dprintf ("loader", "ATAG updated for Linux boot\n"); -@@ -156,19 +154,19 @@ linux_prepare_atag (void) - * Merges in command line parameters and sets up initrd addresses. - */ - static grub_err_t --linux_prepare_fdt (void) -+linux_prepare_fdt (void *target_fdt) - { - int node; - int retval; - int tmp_size; - void *tmp_fdt; - -- tmp_size = grub_fdt_get_totalsize (fdt_addr) + 0x100 + grub_strlen (linux_args); -+ tmp_size = grub_fdt_get_totalsize (current_fdt) + 0x100 + grub_strlen (linux_args); - tmp_fdt = grub_malloc (tmp_size); - if (!tmp_fdt) - return grub_errno; - -- grub_memcpy (tmp_fdt, fdt_addr, grub_fdt_get_totalsize (fdt_addr)); -+ grub_memcpy (tmp_fdt, current_fdt, grub_fdt_get_totalsize (current_fdt)); - grub_fdt_set_totalsize (tmp_fdt, tmp_size); - - /* Find or create '/chosen' node */ -@@ -209,7 +207,7 @@ linux_prepare_fdt (void) - } - - /* Copy updated FDT to its launch location */ -- grub_memcpy (fdt_addr, tmp_fdt, tmp_size); -+ grub_memcpy (target_fdt, tmp_fdt, tmp_size); - grub_free (tmp_fdt); - - grub_dprintf ("loader", "FDT updated for Linux boot\n"); -@@ -226,16 +224,17 @@ linux_boot (void) - { - kernel_entry_t linuxmain; - int fdt_valid, atag_valid; -+ void *target_fdt = 0; - -- fdt_valid = (fdt_addr && grub_fdt_check_header_nosize (fdt_addr) == 0); -- atag_valid = ((((grub_uint16_t *) fdt_addr)[3] & ~3) == 0x5440 -- && *((grub_uint32_t *) fdt_addr)); -+ fdt_valid = (current_fdt && grub_fdt_check_header_nosize (current_fdt) == 0); -+ atag_valid = ((((const grub_uint16_t *) current_fdt)[3] & ~3) == 0x5440 -+ && *((const grub_uint32_t *) current_fdt)); - grub_dprintf ("loader", "atag: %p, %x, %x, %s, %s\n", -- fdt_addr, -- ((grub_uint16_t *) fdt_addr)[3], -- *((grub_uint32_t *) fdt_addr), -- (char *) fdt_addr, -- (char *) fdt_addr + 1); -+ current_fdt, -+ ((const grub_uint16_t *) current_fdt)[3], -+ *((const grub_uint32_t *) current_fdt), -+ (const char *) current_fdt, -+ (const char *) current_fdt + 1); - - if (!fdt_valid && machine_type == GRUB_ARM_MACHINE_TYPE_FDT) - return grub_error (GRUB_ERR_FILE_NOT_FOUND, -@@ -245,23 +244,40 @@ linux_boot (void) - - grub_dprintf ("loader", "Kernel at: 0x%x\n", linux_addr); - -+ if (fdt_valid || atag_valid) -+ { -+#ifdef GRUB_MACHINE_EFI -+ grub_size_t size; -+ if (fdt_valid) -+ size = grub_fdt_get_totalsize (current_fdt); -+ else -+ size = 4 * get_atag_size (current_fdt); -+ size += grub_strlen (linux_args) + 256; -+ target_fdt = grub_efi_allocate_loader_memory (LINUX_FDT_PHYS_OFFSET, size); -+ if (!target_fdt) -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -+#else -+ target_fdt = (void *) LINUX_FDT_ADDRESS; -+#endif -+ } -+ - if (fdt_valid) - { - grub_err_t err; - -- err = linux_prepare_fdt (); -+ err = linux_prepare_fdt (target_fdt); - if (err) - return err; -- grub_dprintf ("loader", "FDT @ 0x%p\n", fdt_addr); -+ grub_dprintf ("loader", "FDT @ %p\n", target_fdt); - } - else if (atag_valid) - { - grub_err_t err; - -- err = linux_prepare_atag (); -+ err = linux_prepare_atag (target_fdt); - if (err) - return err; -- grub_dprintf ("loader", "ATAG @ 0x%p\n", fdt_addr); -+ grub_dprintf ("loader", "ATAG @ %p\n", target_fdt); - } - - grub_dprintf ("loader", "Jumping to Linux...\n"); -@@ -274,18 +290,9 @@ linux_boot (void) - */ - linuxmain = (kernel_entry_t) linux_addr; - --#ifdef GRUB_MACHINE_EFI -- { -- grub_err_t err; -- err = grub_efi_prepare_platform(); -- if (err != GRUB_ERR_NONE) -- return err; -- } --#endif -- - grub_arm_disable_caches_mmu (); - -- linuxmain (0, machine_type, fdt_addr); -+ linuxmain (0, machine_type, target_fdt); - - return grub_error (GRUB_ERR_BAD_OS, "Linux call returned"); - } -@@ -296,17 +303,12 @@ linux_boot (void) - static grub_err_t - linux_load (const char *filename, grub_file_t file) - { -+ struct linux_arm_kernel_header *lh; - int size; - - size = grub_file_size (file); - --#ifdef GRUB_MACHINE_EFI -- linux_addr = (grub_addr_t) grub_efi_allocate_loader_memory (LINUX_PHYS_OFFSET, size); -- if (!linux_addr) -- return grub_errno; --#else - linux_addr = LINUX_ADDRESS; --#endif - grub_dprintf ("loader", "Loading Linux to 0x%08x\n", - (grub_addr_t) linux_addr); - -@@ -318,9 +320,10 @@ linux_load (const char *filename, grub_file_t file) - return grub_errno; - } - -- if (size > LINUX_ZIMAGE_OFFSET + 4 -- && *(grub_uint32_t *) (linux_addr + LINUX_ZIMAGE_OFFSET) -- == LINUX_ZIMAGE_MAGIC) -+ lh = (void *) linux_addr; -+ -+ if ((grub_size_t) size > sizeof (*lh) && -+ lh->magic == GRUB_LINUX_ARM_MAGIC_SIGNATURE) - ; - else if (size > 0x8000 && *(grub_uint32_t *) (linux_addr) == 0xea000006 - && machine_type == GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI) -@@ -410,20 +413,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - - size = grub_get_initrd_size (&initrd_ctx); - --#ifdef GRUB_MACHINE_EFI -- if (initrd_start) -- grub_efi_free_pages (initrd_start, -- (initrd_end - initrd_start + 0xfff) >> 12); -- initrd_start = (grub_addr_t) grub_efi_allocate_loader_memory (LINUX_INITRD_PHYS_OFFSET, size); -- -- if (!initrd_start) -- { -- grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -- goto fail; -- } --#else - initrd_start = LINUX_INITRD_ADDRESS; --#endif - - grub_dprintf ("loader", "Loading initrd to 0x%08x\n", - (grub_addr_t) initrd_start); -@@ -444,11 +434,26 @@ fail: - static grub_err_t - load_dtb (grub_file_t dtb, int size) - { -- if ((grub_file_read (dtb, fdt_addr, size) != size) -- || (grub_fdt_check_header (fdt_addr, size) != 0)) -- return grub_error (GRUB_ERR_BAD_OS, N_("invalid device tree")); -+ void *new_fdt = grub_zalloc (size); -+ if (!new_fdt) -+ return grub_errno; -+ grub_dprintf ("loader", "Loading device tree to %p\n", -+ new_fdt); -+ if ((grub_file_read (dtb, new_fdt, size) != size) -+ || (grub_fdt_check_header (new_fdt, size) != 0)) -+ { -+ grub_free (new_fdt); -+ return grub_error (GRUB_ERR_BAD_OS, N_("invalid device tree")); -+ } -+ -+ grub_fdt_set_totalsize (new_fdt, size); -+ current_fdt = new_fdt; -+ /* -+ * We've successfully loaded an FDT, so any machine type passed -+ * from firmware is now obsolete. -+ */ -+ machine_type = GRUB_ARM_MACHINE_TYPE_FDT; - -- grub_fdt_set_totalsize (fdt_addr, size); - return GRUB_ERR_NONE; - } - -@@ -464,42 +469,13 @@ grub_cmd_devicetree (grub_command_t cmd __attribute__ ((unused)), - - dtb = grub_file_open (argv[0]); - if (!dtb) -- goto out; -+ return grub_errno; - - size = grub_file_size (dtb); - if (size == 0) -- { -- grub_error (GRUB_ERR_BAD_OS, "empty file"); -- goto out; -- } -- --#ifdef GRUB_MACHINE_EFI -- fdt_addr = grub_efi_allocate_loader_memory (LINUX_FDT_PHYS_OFFSET, size); -- if (!fdt_addr) -- { -- grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -- goto out; -- } --#else -- fdt_addr = (void *) LINUX_FDT_ADDRESS; --#endif -- -- grub_dprintf ("loader", "Loading device tree to 0x%08x\n", -- (grub_addr_t) fdt_addr); -- load_dtb (dtb, size); -- if (grub_errno != GRUB_ERR_NONE) -- { -- fdt_addr = NULL; -- goto out; -- } -- -- /* -- * We've successfully loaded an FDT, so any machine type passed -- * from firmware is now obsolete. -- */ -- machine_type = GRUB_ARM_MACHINE_TYPE_FDT; -- -- out: -+ grub_error (GRUB_ERR_BAD_OS, "empty file"); -+ else -+ load_dtb (dtb, size); - grub_file_close (dtb); - - return grub_errno; -@@ -517,7 +493,7 @@ GRUB_MOD_INIT (linux) - /* TRANSLATORS: DTB stands for device tree blob. */ - 0, N_("Load DTB file.")); - my_mod = mod; -- fdt_addr = (void *) grub_arm_firmware_get_boot_data (); -+ current_fdt = (const void *) grub_arm_firmware_get_boot_data (); - machine_type = grub_arm_firmware_get_machine_type (); - } - -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index 9519d2e4d3ec1229a76eb4bce773c78c7af24a6e..1f86229f86b01e4700bb13c9f936490ea9ac859f 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -26,8 +26,9 @@ - #include - #include - #include --#include - #include -+#include -+#include - #include - #include - #include -@@ -47,18 +48,16 @@ static grub_addr_t initrd_start; - static grub_addr_t initrd_end; - - grub_err_t --grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) -+grub_armxx_efi_linux_check_image (struct linux_armxx_kernel_header * lh) - { -- if (lh->magic != GRUB_ARM64_LINUX_MAGIC) -+ if (lh->magic != GRUB_LINUX_ARMXX_MAGIC_SIGNATURE) - return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); - -- if ((lh->code0 & 0xffff) != GRUB_EFI_PE_MAGIC) -+ if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC) - return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled")); - - grub_dprintf ("linux", "UEFI stub kernel:\n"); -- grub_dprintf ("linux", "text_offset = 0x%012llx\n", -- (long long unsigned) lh->text_offset); - grub_dprintf ("linux", "PE/COFF header @ %08x\n", lh->hdr_offset); - - return GRUB_ERR_NONE; -@@ -86,8 +85,8 @@ finalize_params_linux (void) - /* Set initrd info */ - if (initrd_start && initrd_end > initrd_start) - { -- grub_dprintf ("linux", "Initrd @ 0x%012lx-0x%012lx\n", -- initrd_start, initrd_end); -+ grub_dprintf ("linux", "Initrd @ %p-%p\n", -+ (void *) initrd_start, (void *) initrd_end); - - retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-start", - initrd_start); -@@ -110,7 +109,7 @@ failure: - } - - grub_err_t --grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) -+grub_armxx_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; -@@ -148,8 +147,7 @@ grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) - loaded_image->load_options_size = len = - (grub_strlen (args) + 1) * sizeof (grub_efi_char16_t); - loaded_image->load_options = -- grub_efi_allocate_pages (0, -- GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); -+ grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); - if (!loaded_image->load_options) - return grub_errno; - -@@ -162,7 +160,7 @@ grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) - - /* When successful, not reached */ - b->unload_image (image_handle); -- grub_efi_free_pages ((grub_efi_physical_address_t) loaded_image->load_options, -+ grub_efi_free_pages ((grub_addr_t) loaded_image->load_options, - GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); - - return grub_errno; -@@ -174,8 +172,8 @@ grub_linux_boot (void) - if (finalize_params_linux () != GRUB_ERR_NONE) - return grub_errno; - -- return (grub_arm64_uefi_boot_image((grub_addr_t)kernel_addr, -- kernel_size, linux_args)); -+ return (grub_armxx_efi_linux_boot_image((grub_addr_t)kernel_addr, -+ kernel_size, linux_args)); - } - - static grub_err_t -@@ -189,12 +187,48 @@ grub_linux_unload (void) - initrd_start = initrd_end = 0; - grub_free (linux_args); - if (kernel_addr) -- grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr, -+ grub_efi_free_pages ((grub_addr_t) kernel_addr, - GRUB_EFI_BYTES_TO_PAGES (kernel_size)); - grub_fdt_unload (); - return GRUB_ERR_NONE; - } - -+/* -+ * As per linux/Documentation/arm/Booting -+ * ARM initrd needs to be covered by kernel linear mapping, -+ * so place it in the first 512MB of DRAM. -+ * -+ * As per linux/Documentation/arm64/booting.txt -+ * ARM64 initrd needs to be contained entirely within a 1GB aligned window -+ * of up to 32GB of size that covers the kernel image as well. -+ * Since the EFI stub loader will attempt to load the kernel near start of -+ * RAM, place the buffer in the first 32GB of RAM. -+ */ -+#ifdef __arm__ -+#define INITRD_MAX_ADDRESS_OFFSET (512U * 1024 * 1024) -+#else /* __aarch64__ */ -+#define INITRD_MAX_ADDRESS_OFFSET (32ULL * 1024 * 1024 * 1024) -+#endif -+ -+/* -+ * This function returns a pointer to a legally allocated initrd buffer, -+ * or NULL if unsuccessful -+ */ -+static void * -+allocate_initrd_mem (int initrd_pages) -+{ -+ grub_addr_t max_addr; -+ -+ if (grub_efi_get_ram_base (&max_addr) != GRUB_ERR_NONE) -+ return NULL; -+ -+ max_addr += INITRD_MAX_ADDRESS_OFFSET - 1; -+ -+ return grub_efi_allocate_pages_real (max_addr, initrd_pages, -+ GRUB_EFI_ALLOCATE_MAX_ADDRESS, -+ GRUB_EFI_LOADER_DATA); -+} -+ - static grub_err_t - grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) -@@ -223,7 +257,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - grub_dprintf ("linux", "Loading initrd\n"); - - initrd_pages = (GRUB_EFI_BYTES_TO_PAGES (initrd_size)); -- initrd_mem = grub_efi_allocate_pages (0, initrd_pages); -+ initrd_mem = allocate_initrd_mem (initrd_pages); -+ - if (!initrd_mem) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -@@ -241,8 +276,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - fail: - grub_initrd_close (&initrd_ctx); - if (initrd_mem && !initrd_start) -- grub_efi_free_pages ((grub_efi_physical_address_t) initrd_mem, -- initrd_pages); -+ grub_efi_free_pages ((grub_addr_t) initrd_mem, initrd_pages); - - return grub_errno; - } -@@ -252,7 +286,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) - { - grub_file_t file = 0; -- struct grub_arm64_linux_kernel_header lh; -+ struct linux_armxx_kernel_header lh; - - grub_dl_ref (my_mod); - -@@ -271,13 +305,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh)) - return grub_errno; - -- if (grub_arm64_uefi_check_image (&lh) != GRUB_ERR_NONE) -+ if (grub_armxx_efi_linux_check_image (&lh) != GRUB_ERR_NONE) - goto fail; - - grub_loader_unset(); - - grub_dprintf ("linux", "kernel file size: %lld\n", (long long) kernel_size); -- kernel_addr = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (kernel_size)); -+ kernel_addr = grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (kernel_size)); - grub_dprintf ("linux", "kernel numpages: %lld\n", - (long long) GRUB_EFI_BYTES_TO_PAGES (kernel_size)); - if (!kernel_addr) -@@ -329,7 +363,7 @@ fail: - grub_free (linux_args); - - if (kernel_addr && !loaded) -- grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr, -+ grub_efi_free_pages ((grub_addr_t) kernel_addr, - GRUB_EFI_BYTES_TO_PAGES (kernel_size)); - - return grub_errno; -diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c -index a914eb8e2df24ebaab41a2eb0ed205bcebafcf5d..1003a0b9997a46ea7e5106da02ef77e9be3a21fc 100644 ---- a/grub-core/loader/arm64/xen_boot.c -+++ b/grub-core/loader/arm64/xen_boot.c -@@ -27,9 +27,10 @@ - #include - #include - #include --#include - #include - #include -+#include -+#include - #include /* required by struct xen_hypervisor_header */ - #include - #include -@@ -66,7 +67,7 @@ typedef enum module_type module_type_t; - - struct xen_hypervisor_header - { -- struct grub_arm64_linux_kernel_header efi_head; -+ struct linux_arm64_kernel_header efi_head; - - /* This is always PE\0\0. */ - grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE]; -@@ -115,6 +116,17 @@ prepare_xen_hypervisor_params (void *xen_boot_fdt) - if (chosen_node < 1) - return grub_error (GRUB_ERR_IO, "failed to get chosen node in FDT"); - -+ /* -+ * The address and size are always written using 64-bits value. Set -+ * #address-cells and #size-cells accordingly. -+ */ -+ retval = grub_fdt_set_prop32 (xen_boot_fdt, chosen_node, "#address-cells", 2); -+ if (retval) -+ return grub_error (GRUB_ERR_IO, "failed to set #address-cells"); -+ retval = grub_fdt_set_prop32 (xen_boot_fdt, chosen_node, "#size-cells", 2); -+ if (retval) -+ return grub_error (GRUB_ERR_IO, "failed to set #size-cells"); -+ - grub_dprintf ("xen_loader", - "Xen Hypervisor cmdline : %s @ %p size:%d\n", - xen_hypervisor->cmdline, xen_hypervisor->cmdline, -@@ -156,7 +168,7 @@ prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt) - grub_fdt_add_subnode (xen_boot_fdt, chosen_node, module_name); - - retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "compatible", -- MODULE_CUSTOM_COMPATIBLE, sizeof(MODULE_CUSTOM_COMPATIBLE) - 1); -+ MODULE_CUSTOM_COMPATIBLE, sizeof(MODULE_CUSTOM_COMPATIBLE)); - if (retval) - return grub_error (GRUB_ERR_IO, "failed to update FDT"); - -@@ -253,9 +265,9 @@ xen_boot (void) - if (err) - return err; - -- return grub_arm64_uefi_boot_image (xen_hypervisor->start, -- xen_hypervisor->size, -- xen_hypervisor->cmdline); -+ return grub_armxx_efi_linux_boot_image (xen_hypervisor->start, -+ xen_hypervisor->size, -+ xen_hypervisor->cmdline); - } - - static void -@@ -324,10 +336,9 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, - grub_dprintf ("xen_loader", "Xen_boot file size: 0x%lx\n", binary->size); - - binary->start -- = (grub_addr_t) grub_efi_allocate_pages (0, -- GRUB_EFI_BYTES_TO_PAGES -- (binary->size + -- binary->align)); -+ = (grub_addr_t) grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES -+ (binary->size + -+ binary->align)); - if (!binary->start) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -@@ -379,6 +390,20 @@ grub_cmd_xen_module (grub_command_t cmd __attribute__((unused)), - - struct xen_boot_binary *module = NULL; - grub_file_t file = 0; -+ int nounzip = 0; -+ -+ if (!argc) -+ { -+ grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -+ goto fail; -+ } -+ -+ if (grub_strcmp (argv[0], "--nounzip") == 0) -+ { -+ argv++; -+ argc--; -+ nounzip = 1; -+ } - - if (!argc) - { -@@ -403,6 +428,8 @@ grub_cmd_xen_module (grub_command_t cmd __attribute__((unused)), - - grub_dprintf ("xen_loader", "Init module and node info\n"); - -+ if (nounzip) -+ grub_file_filter_disable_compression (); - file = grub_file_open (argv[0]); - if (!file) - goto fail; -@@ -441,8 +468,8 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), - - if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh)) - goto fail; -- if (grub_arm64_uefi_check_image -- ((struct grub_arm64_linux_kernel_header *) &sh) != GRUB_ERR_NONE) -+ if (grub_armxx_efi_linux_check_image -+ ((struct linux_armxx_kernel_header *) &sh) != GRUB_ERR_NONE) - goto fail; - grub_file_seek (file, 0); - -diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/efi/fdt.c -similarity index 79% -rename from grub-core/loader/arm64/fdt.c -rename to grub-core/loader/efi/fdt.c -index db49cf64991764686c3f643e5289abbd4874a559..a4c6e8036454c1a53deefad791133488281462ea 100644 ---- a/grub-core/loader/arm64/fdt.c -+++ b/grub-core/loader/efi/fdt.c -@@ -18,26 +18,33 @@ - - #include - #include --#include - #include - #include - #include - #include - #include -+#include -+#include - - static void *loaded_fdt; - static void *fdt; - -+#define FDT_ADDR_CELLS_STRING "#address-cells" -+#define FDT_SIZE_CELLS_STRING "#size-cells" -+#define FDT_ADDR_SIZE_EXTRA ((2 * grub_fdt_prop_entry_size (sizeof(grub_uint32_t))) + \ -+ sizeof (FDT_ADDR_CELLS_STRING) + \ -+ sizeof (FDT_SIZE_CELLS_STRING)) -+ - void * - grub_fdt_load (grub_size_t additional_size) - { - void *raw_fdt; -- grub_size_t size; -+ unsigned int size; - - if (fdt) - { - size = GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)); -- grub_efi_free_pages ((grub_efi_physical_address_t) fdt, size); -+ grub_efi_free_pages ((grub_addr_t) fdt, size); - } - - if (loaded_fdt) -@@ -45,12 +52,15 @@ grub_fdt_load (grub_size_t additional_size) - else - raw_fdt = grub_efi_get_firmware_fdt(); - -- size = -- raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ; -+ if (raw_fdt) -+ size = grub_fdt_get_totalsize (raw_fdt); -+ else -+ size = GRUB_FDT_EMPTY_TREE_SZ + FDT_ADDR_SIZE_EXTRA; -+ - size += additional_size; - -- grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size); -- fdt = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (size)); -+ grub_dprintf ("linux", "allocating %d bytes for fdt\n", size); -+ fdt = grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (size)); - if (!fdt) - return NULL; - -@@ -62,6 +72,8 @@ grub_fdt_load (grub_size_t additional_size) - else - { - grub_fdt_create_empty_tree (fdt, size); -+ grub_fdt_set_prop32 (fdt, 0, FDT_ADDR_CELLS_STRING, 2); -+ grub_fdt_set_prop32 (fdt, 0, FDT_SIZE_CELLS_STRING, 2); - } - return fdt; - } -@@ -88,7 +100,7 @@ grub_fdt_unload (void) { - if (!fdt) { - return; - } -- grub_efi_free_pages ((grub_efi_physical_address_t) fdt, -+ grub_efi_free_pages ((grub_addr_t) fdt, - GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt))); - fdt = NULL; - } -diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index 083f9417cb65e509e673dba09a71616c5661ab05..9b53d3168f9bb78eab7a124518e83915183912b9 100644 ---- a/grub-core/loader/i386/linux.c -+++ b/grub-core/loader/i386/linux.c -@@ -306,6 +306,12 @@ grub_linux_setup_video (struct linux_kernel_params *params) - params->lfb_line_len = mode_info.pitch; - - params->lfb_base = (grub_size_t) framebuffer; -+ -+#if defined (GRUB_MACHINE_EFI) && defined (__x86_64__) -+ params->ext_lfb_base = (grub_size_t) (((grub_uint64_t)(grub_size_t) framebuffer) >> 32); -+ params->capabilities |= VIDEO_CAPABILITY_64BIT_BASE; -+#endif -+ - params->lfb_size = ALIGN_UP (params->lfb_line_len * params->lfb_height, 65536); - - params->red_mask_size = mode_info.red_mask_size; -@@ -678,7 +684,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) - { - grub_file_t file = 0; -- struct linux_kernel_header lh; -+ struct linux_i386_kernel_header lh; - grub_uint8_t setup_sects; - grub_size_t real_size, prot_size, prot_file_size; - grub_ssize_t len; -@@ -721,7 +727,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - /* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and - still not support 32-bit boot. */ -- if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) -+ if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) - || grub_le_to_cpu16 (lh.version) < 0x0203) - { - grub_error (GRUB_ERR_BAD_OS, "version too old for 32-bit boot" -diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c -index fd7b41b0cad4f26d1170d70692ac1ac27fd6bd73..dc98dbcae258b340e155c64f1f73213ac724806a 100644 ---- a/grub-core/loader/i386/multiboot_mbi.c -+++ b/grub-core/loader/i386/multiboot_mbi.c -@@ -239,7 +239,7 @@ grub_multiboot_get_mbi_size (void) - ret = sizeof (struct multiboot_info) + ALIGN_UP (cmdline_size, 4) - + modcnt * sizeof (struct multiboot_mod_list) + total_modcmd - + ALIGN_UP (sizeof(PACKAGE_STRING), 4) -- + grub_get_multiboot_mmap_count () * sizeof (struct multiboot_mmap_entry) -+ + grub_multiboot_get_mmap_count () * sizeof (struct multiboot_mmap_entry) - + elf_sec_entsize * elf_sec_num - + 256 * sizeof (struct multiboot_color) - #if GRUB_MACHINE_HAS_VBE || GRUB_MACHINE_HAS_VGA_TEXT -@@ -542,7 +542,7 @@ grub_multiboot_make_mbi (grub_uint32_t *target) - mbi->mods_count = 0; - } - -- mmap_size = grub_get_multiboot_mmap_count () -+ mmap_size = grub_multiboot_get_mmap_count () - * sizeof (struct multiboot_mmap_entry); - grub_fill_multiboot_mmap ((struct multiboot_mmap_entry *) ptrorig); - mbi->mmap_length = mmap_size; -diff --git a/grub-core/loader/i386/pc/chainloader.c b/grub-core/loader/i386/pc/chainloader.c -index c79c4fe0fc99a876b3e92f0a24f16cd636e00a0d..ef3a322b78cf10a406c0420780f821e2e1d1b284 100644 ---- a/grub-core/loader/i386/pc/chainloader.c -+++ b/grub-core/loader/i386/pc/chainloader.c -@@ -19,6 +19,7 @@ - - #include - #include -+#include - #include - #include - #include -@@ -86,9 +87,16 @@ grub_chainloader_unload (void) - void - grub_chainloader_patch_bpb (void *bs, grub_device_t dev, grub_uint8_t dl) - { -- grub_uint32_t part_start = 0; -+ grub_uint32_t part_start = 0, heads = 0, sectors = 0; - if (dev && dev->disk) -- part_start = grub_partition_get_start (dev->disk->partition); -+ { -+ part_start = grub_partition_get_start (dev->disk->partition); -+ if (dev->disk->data) -+ { -+ heads = ((struct grub_biosdisk_data *)(dev->disk->data))->heads; -+ sectors = ((struct grub_biosdisk_data *)(dev->disk->data))->sectors; -+ } -+ } - if (grub_memcmp ((char *) &((struct grub_ntfs_bpb *) bs)->oem_name, - "NTFS", 4) == 0) - { -@@ -117,7 +125,7 @@ grub_chainloader_patch_bpb (void *bs, grub_device_t dev, grub_uint8_t dl) - - if (bpb->num_reserved_sectors == 0) - break; -- if (bpb->num_total_sectors_16 == 0 || bpb->num_total_sectors_32 == 0) -+ if (bpb->num_total_sectors_16 == 0 && bpb->num_total_sectors_32 == 0) - break; - - if (bpb->num_fats == 0) -@@ -127,12 +135,20 @@ grub_chainloader_patch_bpb (void *bs, grub_device_t dev, grub_uint8_t dl) - { - bpb->num_hidden_sectors = grub_cpu_to_le32 (part_start); - bpb->version_specific.fat12_or_fat16.num_ph_drive = dl; -+ if (sectors) -+ bpb->sectors_per_track = grub_cpu_to_le16 (sectors); -+ if (heads) -+ bpb->num_heads = grub_cpu_to_le16 (heads); - return; - } - if (bpb->version_specific.fat32.sectors_per_fat_32) - { - bpb->num_hidden_sectors = grub_cpu_to_le32 (part_start); - bpb->version_specific.fat32.num_ph_drive = dl; -+ if (sectors) -+ bpb->sectors_per_track = grub_cpu_to_le16 (sectors); -+ if (heads) -+ bpb->num_heads = grub_cpu_to_le16 (heads); - return; - } - break; -diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index a293b17aa101b308635bbed4086ae1547b91b884..b69cb7a3a7f8a9ca96a91a78c47fa1515e628699 100644 ---- a/grub-core/loader/i386/pc/linux.c -+++ b/grub-core/loader/i386/pc/linux.c -@@ -121,7 +121,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) - { - grub_file_t file = 0; -- struct linux_kernel_header lh; -+ struct linux_i386_kernel_header lh; - grub_uint8_t setup_sects; - grub_size_t real_size; - grub_ssize_t len; -@@ -169,7 +169,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - maximal_cmdline_size = 256; - -- if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) -+ if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) - && grub_le_to_cpu16 (lh.version) >= 0x0200) - { - grub_linux_is_bzimage = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL); -@@ -322,7 +322,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) -+ if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) - || grub_le_to_cpu16 (lh.version) < 0x0200) - /* Clear the heap space. */ - grub_memset (grub_linux_real_chunk -@@ -387,7 +387,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - { - grub_size_t size = 0; - grub_addr_t addr_max, addr_min; -- struct linux_kernel_header *lh; -+ struct linux_i386_kernel_header *lh; - grub_uint8_t *initrd_chunk; - grub_addr_t initrd_addr; - grub_err_t err; -@@ -405,9 +405,9 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- lh = (struct linux_kernel_header *) grub_linux_real_chunk; -+ lh = (struct linux_i386_kernel_header *) grub_linux_real_chunk; - -- if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) -+ if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) - && grub_le_to_cpu16 (lh->version) >= 0x0200)) - { - grub_error (GRUB_ERR_BAD_OS, "the kernel is too old for initrd"); -diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c -index 99fad4cadae42ab09497babca15cd9606557fcd2..77a93e7b228316e1df731e01e51e67f9225b4482 100644 ---- a/grub-core/loader/i386/xen_file.c -+++ b/grub-core/loader/i386/xen_file.c -@@ -26,7 +26,7 @@ grub_elf_t - grub_xen_file (grub_file_t file) - { - grub_elf_t elf; -- struct linux_kernel_header lh; -+ struct linux_i386_kernel_header lh; - grub_file_t off_file; - grub_uint32_t payload_offset, payload_length; - grub_uint8_t magic[6]; -@@ -43,7 +43,7 @@ grub_xen_file (grub_file_t file) - goto fail; - - if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55) -- || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) -+ || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE) - || grub_le_to_cpu16 (lh.version) < 0x0208) - { - grub_error (GRUB_ERR_BAD_OS, "version too old for xen boot"); -diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c -index efaa42ccdd2bf74321de20cf5033a80676cc7dc3..750330d4572d0dcd09d02b4b75c1f03045fa897b 100644 ---- a/grub-core/loader/ia64/efi/linux.c -+++ b/grub-core/loader/ia64/efi/linux.c -@@ -252,7 +252,7 @@ allocate_pages (grub_uint64_t align, grub_uint64_t size_pages, - aligned_start += align; - if (aligned_start + size > end) - continue; -- mem = grub_efi_allocate_pages (aligned_start, size_pages); -+ mem = grub_efi_allocate_fixed (aligned_start, size_pages); - if (! mem) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory"); -@@ -326,7 +326,7 @@ grub_linux_boot (void) - mmap_size = find_mmap_size (); - if (! mmap_size) - return grub_errno; -- mmap_buf = grub_efi_allocate_pages (0, page_align (mmap_size) >> 12); -+ mmap_buf = grub_efi_allocate_any_pages (page_align (mmap_size) >> 12); - if (! mmap_buf) - return grub_error (GRUB_ERR_IO, "cannot allocate memory map"); - err = grub_efi_finish_boot_services (&mmap_size, mmap_buf, &map_key, -@@ -422,7 +422,7 @@ grub_load_elf64 (grub_file_t file, void *buffer, const char *filename) - relocate = grub_env_get ("linux_relocate"); - if (!relocate || grub_strcmp (relocate, "force") != 0) - { -- kernel_mem = grub_efi_allocate_pages (low_addr, kernel_pages); -+ kernel_mem = grub_efi_allocate_fixed (low_addr, kernel_pages); - reloc_offset = 0; - } - /* Try to relocate. */ -@@ -524,7 +524,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - len += grub_strlen (argv[i]) + 1; - len += sizeof (struct ia64_boot_param) + 512; /* Room for extensions. */ - boot_param_pages = page_align (len) >> 12; -- boot_param = grub_efi_allocate_pages (0, boot_param_pages); -+ boot_param = grub_efi_allocate_any_pages (boot_param_pages); - if (boot_param == 0) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, -@@ -589,7 +589,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), - grub_dprintf ("linux", "Loading initrd\n"); - - initrd_pages = (page_align (initrd_size) >> 12); -- initrd_mem = grub_efi_allocate_pages (0, initrd_pages); -+ initrd_mem = grub_efi_allocate_any_pages (initrd_pages); - if (! initrd_mem) - { - grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate pages"); -diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c -index bd9d5b3e698588db594a2c334d715e0e883bab92..40c67e82489ec3ecf891ae564cde810bf280b242 100644 ---- a/grub-core/loader/multiboot.c -+++ b/grub-core/loader/multiboot.c -@@ -28,7 +28,15 @@ - - #include - #include -+#ifdef GRUB_USE_MULTIBOOT2 -+#include -+#define GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER GRUB_MULTIBOOT2_CONSOLE_FRAMEBUFFER -+#define GRUB_MULTIBOOT_CONSOLE_EGA_TEXT GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT -+#define GRUB_MULTIBOOT(x) grub_multiboot2_ ## x -+#else - #include -+#define GRUB_MULTIBOOT(x) grub_multiboot_ ## x -+#endif - #include - #include - #include -@@ -49,8 +57,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #include - #endif - --struct grub_relocator *grub_multiboot_relocator = NULL; --grub_uint32_t grub_multiboot_payload_eip; -+struct grub_relocator *GRUB_MULTIBOOT (relocator) = NULL; -+grub_uint32_t GRUB_MULTIBOOT (payload_eip); - #if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) - #define DEFAULT_VIDEO_MODE "text" - #else -@@ -78,7 +86,7 @@ count_hook (grub_uint64_t addr __attribute__ ((unused)), - /* Return the length of the Multiboot mmap that will be needed to allocate - our platform's map. */ - grub_uint32_t --grub_get_multiboot_mmap_count (void) -+GRUB_MULTIBOOT (get_mmap_count) (void) - { - grub_size_t count = 0; - -@@ -88,7 +96,7 @@ grub_get_multiboot_mmap_count (void) - } - - grub_err_t --grub_multiboot_set_video_mode (void) -+GRUB_MULTIBOOT (set_video_mode) (void) - { - grub_err_t err; - const char *modevar; -@@ -130,9 +138,12 @@ static void - efi_boot (struct grub_relocator *rel, - grub_uint32_t target) - { -+#ifdef GRUB_USE_MULTIBOOT2 -+ struct grub_relocator_efi_state state_efi = MULTIBOOT2_EFI_INITIAL_STATE; -+#else - struct grub_relocator_efi_state state_efi = MULTIBOOT_EFI_INITIAL_STATE; -- -- state_efi.MULTIBOOT_EFI_ENTRY_REGISTER = grub_multiboot_payload_eip; -+#endif -+ state_efi.MULTIBOOT_EFI_ENTRY_REGISTER = GRUB_MULTIBOOT (payload_eip); - state_efi.MULTIBOOT_EFI_MBI_REGISTER = target; - - grub_relocator_efi_boot (rel, state_efi); -@@ -164,19 +175,23 @@ static grub_err_t - grub_multiboot_boot (void) - { - grub_err_t err; -+ -+#ifdef GRUB_USE_MULTIBOOT2 -+ struct grub_relocator32_state state = MULTIBOOT2_INITIAL_STATE; -+#else - struct grub_relocator32_state state = MULTIBOOT_INITIAL_STATE; -+#endif -+ state.MULTIBOOT_ENTRY_REGISTER = GRUB_MULTIBOOT (payload_eip); - -- state.MULTIBOOT_ENTRY_REGISTER = grub_multiboot_payload_eip; -- -- err = grub_multiboot_make_mbi (&state.MULTIBOOT_MBI_REGISTER); -+ err = GRUB_MULTIBOOT (make_mbi) (&state.MULTIBOOT_MBI_REGISTER); - - if (err) - return err; - - if (grub_efi_is_finished) -- normal_boot (grub_multiboot_relocator, state); -+ normal_boot (GRUB_MULTIBOOT (relocator), state); - else -- efi_boot (grub_multiboot_relocator, state.MULTIBOOT_MBI_REGISTER); -+ efi_boot (GRUB_MULTIBOOT (relocator), state.MULTIBOOT_MBI_REGISTER); - - /* Not reached. */ - return GRUB_ERR_NONE; -@@ -185,10 +200,10 @@ grub_multiboot_boot (void) - static grub_err_t - grub_multiboot_unload (void) - { -- grub_multiboot_free_mbi (); -+ GRUB_MULTIBOOT (free_mbi) (); - -- grub_relocator_unload (grub_multiboot_relocator); -- grub_multiboot_relocator = NULL; -+ grub_relocator_unload (GRUB_MULTIBOOT (relocator)); -+ GRUB_MULTIBOOT (relocator) = NULL; - - grub_dl_unref (my_mod); - -@@ -207,7 +222,7 @@ static grub_uint64_t highest_load; - - /* Load ELF32 or ELF64. */ - grub_err_t --grub_multiboot_load_elf (mbi_load_data_t *mld) -+GRUB_MULTIBOOT (load_elf) (mbi_load_data_t *mld) - { - if (grub_multiboot_is_elf32 (mld->buffer)) - return grub_multiboot_load_elf32 (mld); -@@ -218,9 +233,9 @@ grub_multiboot_load_elf (mbi_load_data_t *mld) - } - - grub_err_t --grub_multiboot_set_console (int console_type, int accepted_consoles, -- int width, int height, int depth, -- int console_req) -+GRUB_MULTIBOOT (set_console) (int console_type, int accepted_consoles, -+ int width, int height, int depth, -+ int console_req) - { - console_required = console_req; - if (!(accepted_consoles -@@ -313,19 +328,19 @@ grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)), - grub_dl_ref (my_mod); - - /* Skip filename. */ -- grub_multiboot_init_mbi (argc - 1, argv + 1); -+ GRUB_MULTIBOOT (init_mbi) (argc - 1, argv + 1); - -- grub_relocator_unload (grub_multiboot_relocator); -- grub_multiboot_relocator = grub_relocator_new (); -+ grub_relocator_unload (GRUB_MULTIBOOT (relocator)); -+ GRUB_MULTIBOOT (relocator) = grub_relocator_new (); - -- if (!grub_multiboot_relocator) -+ if (!GRUB_MULTIBOOT (relocator)) - goto fail; - -- err = grub_multiboot_load (file, argv[0]); -+ err = GRUB_MULTIBOOT (load) (file, argv[0]); - if (err) - goto fail; - -- grub_multiboot_set_bootdev (); -+ GRUB_MULTIBOOT (set_bootdev) (); - - grub_loader_set (grub_multiboot_boot, grub_multiboot_unload, 0); - -@@ -335,8 +350,8 @@ grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)), - - if (grub_errno != GRUB_ERR_NONE) - { -- grub_relocator_unload (grub_multiboot_relocator); -- grub_multiboot_relocator = NULL; -+ grub_relocator_unload (GRUB_MULTIBOOT (relocator)); -+ GRUB_MULTIBOOT (relocator) = NULL; - grub_dl_unref (my_mod); - } - -@@ -368,7 +383,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), - if (argc == 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - -- if (!grub_multiboot_relocator) -+ if (!GRUB_MULTIBOOT (relocator)) - return grub_error (GRUB_ERR_BAD_ARGUMENT, - N_("you need to load the kernel first")); - -@@ -389,7 +404,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), - if (size) - { - grub_relocator_chunk_t ch; -- err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, -+ err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch, - lowest_addr, (0xffffffff - size) + 1, - size, MULTIBOOT_MOD_ALIGN, - GRUB_RELOCATOR_PREFERENCE_NONE, 1); -@@ -407,7 +422,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), - target = 0; - } - -- err = grub_multiboot_add_module (target, size, argc - 1, argv + 1); -+ err = GRUB_MULTIBOOT (add_module) (target, size, argc - 1, argv + 1); - if (err) - { - grub_file_close (file); -diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c -index 5e649ed2545bee3fbe9602c9d97079160dc6420a..70cd1db513e679f0e02e06dc2de24747a62b88ba 100644 ---- a/grub-core/loader/multiboot_elfxx.c -+++ b/grub-core/loader/multiboot_elfxx.c -@@ -57,9 +57,9 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) - char *phdr_base; - grub_err_t err; - grub_relocator_chunk_t ch; -- grub_uint32_t load_offset, load_size; -+ grub_uint32_t load_offset = 0, load_size; - int i; -- void *source; -+ void *source = NULL; - - if (ehdr->e_ident[EI_MAG0] != ELFMAG0 - || ehdr->e_ident[EI_MAG1] != ELFMAG1 -@@ -97,38 +97,38 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) - return grub_error (GRUB_ERR_BAD_OS, "segment crosses 4 GiB border"); - #endif - -- load_size = highest_load - mld->link_base_addr; -- - if (mld->relocatable) - { -+ load_size = highest_load - mld->link_base_addr; -+ -+ grub_dprintf ("multiboot_loader", "align=0x%lx, preference=0x%x, " -+ "load_size=0x%x, avoid_efi_boot_services=%d\n", -+ (long) mld->align, mld->preference, load_size, -+ mld->avoid_efi_boot_services); -+ - if (load_size > mld->max_addr || mld->min_addr > mld->max_addr - load_size) - return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load size"); - -- err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, -+ err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch, - mld->min_addr, mld->max_addr - load_size, - load_size, mld->align ? mld->align : 1, - mld->preference, mld->avoid_efi_boot_services); -+ -+ if (err) -+ { -+ grub_dprintf ("multiboot_loader", "Cannot allocate memory for OS image\n"); -+ return err; -+ } -+ -+ mld->load_base_addr = get_physical_target_address (ch); -+ source = get_virtual_current_address (ch); - } - else -- err = grub_relocator_alloc_chunk_addr (grub_multiboot_relocator, &ch, -- mld->link_base_addr, load_size); -+ mld->load_base_addr = mld->link_base_addr; - -- if (err) -- { -- grub_dprintf ("multiboot_loader", "Cannot allocate memory for OS image\n"); -- return err; -- } -- -- mld->load_base_addr = get_physical_target_address (ch); -- source = get_virtual_current_address (ch); -- -- grub_dprintf ("multiboot_loader", "link_base_addr=0x%x, load_base_addr=0x%x, " -- "load_size=0x%x, relocatable=%d\n", mld->link_base_addr, -- mld->load_base_addr, load_size, mld->relocatable); -- -- if (mld->relocatable) -- grub_dprintf ("multiboot_loader", "align=0x%lx, preference=0x%x, avoid_efi_boot_services=%d\n", -- (long) mld->align, mld->preference, mld->avoid_efi_boot_services); -+ grub_dprintf ("multiboot_loader", "relocatable=%d, link_base_addr=0x%x, " -+ "load_base_addr=0x%x\n", mld->relocatable, -+ mld->link_base_addr, mld->load_base_addr); - - /* Load every loadable segment in memory. */ - for (i = 0; i < ehdr->e_phnum; i++) -@@ -139,7 +139,24 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) - grub_dprintf ("multiboot_loader", "segment %d: paddr=0x%lx, memsz=0x%lx, vaddr=0x%lx\n", - i, (long) phdr(i)->p_paddr, (long) phdr(i)->p_memsz, (long) phdr(i)->p_vaddr); - -- load_offset = phdr(i)->p_paddr - mld->link_base_addr; -+ if (mld->relocatable) -+ { -+ load_offset = phdr(i)->p_paddr - mld->link_base_addr; -+ grub_dprintf ("multiboot_loader", "segment %d: load_offset=0x%x\n", i, load_offset); -+ } -+ else -+ { -+ err = grub_relocator_alloc_chunk_addr (GRUB_MULTIBOOT (relocator), &ch, -+ phdr(i)->p_paddr, phdr(i)->p_memsz); -+ -+ if (err) -+ { -+ grub_dprintf ("multiboot_loader", "Cannot allocate memory for OS image\n"); -+ return err; -+ } -+ -+ source = get_virtual_current_address (ch); -+ } - - if (phdr(i)->p_filesz != 0) - { -@@ -167,7 +184,7 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) - if (phdr(i)->p_vaddr <= ehdr->e_entry - && phdr(i)->p_vaddr + phdr(i)->p_memsz > ehdr->e_entry) - { -- grub_multiboot_payload_eip = (ehdr->e_entry - phdr(i)->p_vaddr) -+ GRUB_MULTIBOOT (payload_eip) = (ehdr->e_entry - phdr(i)->p_vaddr) - + phdr(i)->p_paddr; - #ifdef MULTIBOOT_LOAD_ELF64 - # ifdef __mips -@@ -191,7 +208,7 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) - #if defined (__i386__) || defined (__x86_64__) - - #elif defined (__mips) -- grub_multiboot_payload_eip |= 0x80000000; -+ GRUB_MULTIBOOT (payload_eip) |= 0x80000000; - #else - #error Please complete this - #endif -@@ -238,7 +255,7 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) - if (sh->sh_size == 0) - continue; - -- err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, 0, -+ err = grub_relocator_alloc_chunk_align (GRUB_MULTIBOOT (relocator), &ch, 0, - (0xffffffff - sh->sh_size) + 1, - sh->sh_size, sh->sh_addralign, - GRUB_RELOCATOR_PREFERENCE_NONE, -@@ -264,8 +281,8 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) - } - sh->sh_addr = target; - } -- grub_multiboot_add_elfsyms (ehdr->e_shnum, ehdr->e_shentsize, -- ehdr->e_shstrndx, shdr); -+ GRUB_MULTIBOOT (add_elfsyms) (ehdr->e_shnum, ehdr->e_shentsize, -+ ehdr->e_shstrndx, shdr); - } - - #undef phdr -diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c -index b0679a9f6c9848d81cb74cf799ad3a7b235d937c..4df6595954d889028e4525bb66b42cf391f4c9ce 100644 ---- a/grub-core/loader/multiboot_mbi2.c -+++ b/grub-core/loader/multiboot_mbi2.c -@@ -22,7 +22,7 @@ - #include - #include - #endif --#include -+#include - #include - #include - #include -@@ -71,7 +71,7 @@ static int keep_bs = 0; - static grub_uint32_t load_base_addr; - - void --grub_multiboot_add_elfsyms (grub_size_t num, grub_size_t entsize, -+grub_multiboot2_add_elfsyms (grub_size_t num, grub_size_t entsize, - unsigned shndx, void *data) - { - elf_sec_num = num; -@@ -90,17 +90,17 @@ find_header (grub_properly_aligned_t *buffer, grub_ssize_t len) - ((char *) header <= (char *) buffer + len - 12); - header = (struct multiboot_header *) ((grub_uint32_t *) header + MULTIBOOT_HEADER_ALIGN / 4)) - { -- if (header->magic == MULTIBOOT_HEADER_MAGIC -+ if (header->magic == MULTIBOOT2_HEADER_MAGIC - && !(header->magic + header->architecture - + header->header_length + header->checksum) -- && header->architecture == MULTIBOOT_ARCHITECTURE_CURRENT) -+ && header->architecture == MULTIBOOT2_ARCHITECTURE_CURRENT) - return header; - } - return NULL; - } - - grub_err_t --grub_multiboot_load (grub_file_t file, const char *filename) -+grub_multiboot2_load (grub_file_t file, const char *filename) - { - grub_ssize_t len; - struct multiboot_header *header; -@@ -112,7 +112,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) - grub_addr_t entry = 0, efi_entry = 0; - grub_uint32_t console_required = 0; - struct multiboot_header_tag_framebuffer *fbtag = NULL; -- int accepted_consoles = GRUB_MULTIBOOT_CONSOLE_EGA_TEXT; -+ int accepted_consoles = GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT; - mbi_load_data_t mld; - - mld.mbi_ver = 2; -@@ -210,7 +210,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) - case MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS: - if (!(((struct multiboot_header_tag_console_flags *) tag)->console_flags - & MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED)) -- accepted_consoles &= ~GRUB_MULTIBOOT_CONSOLE_EGA_TEXT; -+ accepted_consoles &= ~GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT; - if (((struct multiboot_header_tag_console_flags *) tag)->console_flags - & MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED) - console_required = 1; -@@ -218,7 +218,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) - - case MULTIBOOT_HEADER_TAG_FRAMEBUFFER: - fbtag = (struct multiboot_header_tag_framebuffer *) tag; -- accepted_consoles |= GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER; -+ accepted_consoles |= GRUB_MULTIBOOT2_CONSOLE_FRAMEBUFFER; - break; - - case MULTIBOOT_HEADER_TAG_RELOCATABLE: -@@ -295,13 +295,13 @@ grub_multiboot_load (grub_file_t file, const char *filename) - return grub_error (GRUB_ERR_BAD_OS, "invalid min/max address and/or load size"); - } - -- err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, -+ err = grub_relocator_alloc_chunk_align (grub_multiboot2_relocator, &ch, - mld.min_addr, mld.max_addr - code_size, - code_size, mld.align ? mld.align : 1, - mld.preference, keep_bs); - } - else -- err = grub_relocator_alloc_chunk_addr (grub_multiboot_relocator, -+ err = grub_relocator_alloc_chunk_addr (grub_multiboot2_relocator, - &ch, load_addr, code_size); - if (err) - { -@@ -343,7 +343,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) - mld.file = file; - mld.filename = filename; - mld.avoid_efi_boot_services = keep_bs; -- err = grub_multiboot_load_elf (&mld); -+ err = grub_multiboot2_load_elf (&mld); - if (err) - { - grub_free (mld.buffer); -@@ -354,9 +354,9 @@ grub_multiboot_load (grub_file_t file, const char *filename) - load_base_addr = mld.load_base_addr; - - if (keep_bs && efi_entry_specified) -- grub_multiboot_payload_eip = efi_entry; -+ grub_multiboot2_payload_eip = efi_entry; - else if (entry_specified) -- grub_multiboot_payload_eip = entry; -+ grub_multiboot2_payload_eip = entry; - - if (mld.relocatable) - { -@@ -370,20 +370,20 @@ grub_multiboot_load (grub_file_t file, const char *filename) - * 64-bit int here. - */ - if (mld.load_base_addr >= mld.link_base_addr) -- grub_multiboot_payload_eip += mld.load_base_addr - mld.link_base_addr; -+ grub_multiboot2_payload_eip += mld.load_base_addr - mld.link_base_addr; - else -- grub_multiboot_payload_eip -= mld.link_base_addr - mld.load_base_addr; -+ grub_multiboot2_payload_eip -= mld.link_base_addr - mld.load_base_addr; - } - - if (fbtag) -- err = grub_multiboot_set_console (GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER, -- accepted_consoles, -- fbtag->width, fbtag->height, -- fbtag->depth, console_required); -+ err = grub_multiboot2_set_console (GRUB_MULTIBOOT2_CONSOLE_FRAMEBUFFER, -+ accepted_consoles, -+ fbtag->width, fbtag->height, -+ fbtag->depth, console_required); - else -- err = grub_multiboot_set_console (GRUB_MULTIBOOT_CONSOLE_EGA_TEXT, -- accepted_consoles, -- 0, 0, 0, console_required); -+ err = grub_multiboot2_set_console (GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT, -+ accepted_consoles, -+ 0, 0, 0, console_required); - return err; - } - -@@ -459,7 +459,7 @@ net_size (void) - } - - static grub_size_t --grub_multiboot_get_mbi_size (void) -+grub_multiboot2_get_mbi_size (void) - { - #ifdef GRUB_MACHINE_EFI - if (!keep_bs && !efi_mmap_size) -@@ -478,7 +478,7 @@ grub_multiboot_get_mbi_size (void) - + ALIGN_UP (sizeof (struct multiboot_tag_elf_sections), MULTIBOOT_TAG_ALIGN) - + ALIGN_UP (elf_sec_entsize * elf_sec_num, MULTIBOOT_TAG_ALIGN) - + ALIGN_UP ((sizeof (struct multiboot_tag_mmap) -- + grub_get_multiboot_mmap_count () -+ + grub_multiboot2_get_mmap_count () - * sizeof (struct multiboot_mmap_entry)), MULTIBOOT_TAG_ALIGN) - + ALIGN_UP (sizeof (struct multiboot_tag_framebuffer), MULTIBOOT_TAG_ALIGN) - + ALIGN_UP (sizeof (struct multiboot_tag_old_acpi) -@@ -522,7 +522,7 @@ grub_fill_multiboot_mmap (struct multiboot_tag_mmap *tag) - - tag->type = MULTIBOOT_TAG_TYPE_MMAP; - tag->size = sizeof (struct multiboot_tag_mmap) -- + sizeof (struct multiboot_mmap_entry) * grub_get_multiboot_mmap_count (); -+ + sizeof (struct multiboot_mmap_entry) * grub_multiboot2_get_mmap_count (); - tag->entry_size = sizeof (struct multiboot_mmap_entry); - tag->entry_version = 0; - -@@ -588,7 +588,7 @@ retrieve_video_parameters (grub_properly_aligned_t **ptrorig) - struct multiboot_tag_framebuffer *tag - = (struct multiboot_tag_framebuffer *) *ptrorig; - -- err = grub_multiboot_set_video_mode (); -+ err = grub_multiboot2_set_video_mode (); - if (err) - { - grub_print_error (); -@@ -731,7 +731,7 @@ retrieve_video_parameters (grub_properly_aligned_t **ptrorig) - } - - grub_err_t --grub_multiboot_make_mbi (grub_uint32_t *target) -+grub_multiboot2_make_mbi (grub_uint32_t *target) - { - grub_properly_aligned_t *ptrorig; - grub_properly_aligned_t *mbistart; -@@ -739,11 +739,11 @@ grub_multiboot_make_mbi (grub_uint32_t *target) - grub_size_t bufsize; - grub_relocator_chunk_t ch; - -- bufsize = grub_multiboot_get_mbi_size (); -+ bufsize = grub_multiboot2_get_mbi_size (); - - COMPILE_TIME_ASSERT (MULTIBOOT_TAG_ALIGN % sizeof (grub_properly_aligned_t) == 0); - -- err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, -+ err = grub_relocator_alloc_chunk_align (grub_multiboot2_relocator, &ch, - 0, 0xffffffff - bufsize, - bufsize, MULTIBOOT_TAG_ALIGN, - GRUB_RELOCATOR_PREFERENCE_NONE, 1); -@@ -1039,7 +1039,7 @@ grub_multiboot_make_mbi (grub_uint32_t *target) - } - - void --grub_multiboot_free_mbi (void) -+grub_multiboot2_free_mbi (void) - { - struct module *cur, *next; - -@@ -1061,11 +1061,11 @@ grub_multiboot_free_mbi (void) - } - - grub_err_t --grub_multiboot_init_mbi (int argc, char *argv[]) -+grub_multiboot2_init_mbi (int argc, char *argv[]) - { - grub_ssize_t len = 0; - -- grub_multiboot_free_mbi (); -+ grub_multiboot2_free_mbi (); - - len = grub_loader_cmdline_size (argc, argv); - -@@ -1081,7 +1081,7 @@ grub_multiboot_init_mbi (int argc, char *argv[]) - } - - grub_err_t --grub_multiboot_add_module (grub_addr_t start, grub_size_t size, -+grub_multiboot2_add_module (grub_addr_t start, grub_size_t size, - int argc, char *argv[]) - { - struct module *newmod; -@@ -1119,7 +1119,7 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size, - } - - void --grub_multiboot_set_bootdev (void) -+grub_multiboot2_set_bootdev (void) - { - grub_device_t dev; - -diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c -index 4b68c4151a11db214602f74e111e7552801d8450..54306e3b16d25fe5d3bdf9502683822237be488d 100644 ---- a/grub-core/net/arp.c -+++ b/grub-core/net/arp.c -@@ -111,8 +111,8 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf, - } - - grub_err_t --grub_net_arp_receive (struct grub_net_buff *nb, -- struct grub_net_card *card) -+grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card, -+ grub_uint16_t *vlantag) - { - struct arppkt *arp_packet = (struct arppkt *) nb->data; - grub_net_network_level_address_t sender_addr, target_addr; -@@ -138,6 +138,14 @@ grub_net_arp_receive (struct grub_net_buff *nb, - - FOR_NET_NETWORK_LEVEL_INTERFACES (inf) - { -+ /* Verify vlantag id */ -+ if (inf->card == card && inf->vlantag != *vlantag) -+ { -+ grub_dprintf ("net", "invalid vlantag! %x != %x\n", -+ inf->vlantag, *vlantag); -+ break; -+ } -+ - /* Am I the protocol address target? */ - if (grub_net_addr_cmp (&inf->address, &target_addr) == 0 - && arp_packet->op == grub_cpu_to_be16_compile_time (ARP_REQUEST)) -diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c -index a78d164db1a0abbaf0417f70dc7180b9b2c4df76..002446be1c385934762824a965806ffb75f422a0 100644 ---- a/grub-core/net/drivers/ieee1275/ofnet.c -+++ b/grub-core/net/drivers/ieee1275/ofnet.c -@@ -153,11 +153,11 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, - char *comma_char = 0; - char *equal_char = 0; - grub_size_t field_counter = 0; -- - grub_net_network_level_address_t client_addr, gateway_addr, subnet_mask; - grub_net_link_level_address_t hw_addr; - grub_net_interface_flags_t flags = 0; - struct grub_net_network_level_interface *inter = NULL; -+ grub_uint16_t vlantag = 0; - - hw_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; - -@@ -175,6 +175,11 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, - *equal_char = 0; - grub_env_set_net_property ((*card)->name, args, equal_char + 1, - grub_strlen(equal_char + 1)); -+ -+ if ((grub_strcmp (args, "vtag") == 0) && -+ (grub_strlen (equal_char + 1) == 8)) -+ vlantag = grub_strtoul (equal_char + 1 + 4, 0, 16); -+ - *equal_char = '='; - } - else -@@ -213,8 +218,10 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, - hw_addr.mac, sizeof(hw_addr.mac), 0); - inter = grub_net_add_addr ((*card)->name, *card, &client_addr, &hw_addr, - flags); -+ inter->vlantag = vlantag; - grub_net_add_ipv4_local (inter, - __builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4))); -+ - } - - if (gateway_addr.ipv4 != 0) -diff --git a/grub-core/net/ethernet.c b/grub-core/net/ethernet.c -index c397b1b348ce559070cabe1e0b6e28e4dbf254d8..4d7ceed6f93c7e87019546b544a4365a504f5f9f 100644 ---- a/grub-core/net/ethernet.c -+++ b/grub-core/net/ethernet.c -@@ -18,6 +18,7 @@ - - #include - #include -+#include - #include - #include - #include -@@ -56,10 +57,17 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf, - { - struct etherhdr *eth; - grub_err_t err; -+ grub_uint8_t etherhdr_size; -+ grub_uint16_t vlantag_id = VLANTAG_IDENTIFIER; - -- COMPILE_TIME_ASSERT (sizeof (*eth) < GRUB_NET_MAX_LINK_HEADER_SIZE); -+ etherhdr_size = sizeof (*eth); -+ COMPILE_TIME_ASSERT (sizeof (*eth) + 4 < GRUB_NET_MAX_LINK_HEADER_SIZE); - -- err = grub_netbuff_push (nb, sizeof (*eth)); -+ /* Increase ethernet header in case of vlantag */ -+ if (inf->vlantag != 0) -+ etherhdr_size += 4; -+ -+ err = grub_netbuff_push (nb, etherhdr_size); - if (err) - return err; - eth = (struct etherhdr *) nb->data; -@@ -76,6 +84,19 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf, - return err; - inf->card->opened = 1; - } -+ -+ /* Check and add a vlan-tag if needed. */ -+ if (inf->vlantag != 0) -+ { -+ /* Move eth type to the right */ -+ grub_memcpy ((char *) nb->data + etherhdr_size - 2, -+ (char *) nb->data + etherhdr_size - 6, 2); -+ -+ /* Add the tag in the middle */ -+ grub_memcpy ((char *) nb->data + etherhdr_size - 6, &vlantag_id, 2); -+ grub_memcpy ((char *) nb->data + etherhdr_size - 4, (char *) &(inf->vlantag), 2); -+ } -+ - return inf->card->driver->send (inf->card, nb); - } - -@@ -90,10 +111,25 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb, - grub_net_link_level_address_t hwaddress; - grub_net_link_level_address_t src_hwaddress; - grub_err_t err; -+ grub_uint8_t etherhdr_size = sizeof (*eth); -+ grub_uint16_t vlantag = 0; -+ -+ -+ /* Check if a vlan-tag is present. If so, the ethernet header is 4 bytes */ -+ /* longer than the original one. The vlantag id is extracted and the header */ -+ /* is reseted to the original size. */ -+ if (grub_get_unaligned16 (nb->data + etherhdr_size - 2) == VLANTAG_IDENTIFIER) -+ { -+ vlantag = grub_get_unaligned16 (nb->data + etherhdr_size); -+ etherhdr_size += 4; -+ /* Move eth type to the original position */ -+ grub_memcpy((char *) nb->data + etherhdr_size - 6, -+ (char *) nb->data + etherhdr_size - 2, 2); -+ } - - eth = (struct etherhdr *) nb->data; - type = grub_be_to_cpu16 (eth->type); -- err = grub_netbuff_pull (nb, sizeof (*eth)); -+ err = grub_netbuff_pull (nb, etherhdr_size); - if (err) - return err; - -@@ -121,13 +157,14 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb, - { - /* ARP packet. */ - case GRUB_NET_ETHERTYPE_ARP: -- grub_net_arp_receive (nb, card); -+ grub_net_arp_receive (nb, card, &vlantag); - grub_netbuff_free (nb); - return GRUB_ERR_NONE; - /* IP packet. */ - case GRUB_NET_ETHERTYPE_IP: - case GRUB_NET_ETHERTYPE_IP6: -- return grub_net_recv_ip_packets (nb, card, &hwaddress, &src_hwaddress); -+ return grub_net_recv_ip_packets (nb, card, &hwaddress, &src_hwaddress, -+ &vlantag); - } - grub_netbuff_free (nb); - return GRUB_ERR_NONE; -diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c -index aba4f89087bc14b1fe28a77794dd6792beb0bf36..7c95cc7464a09af4b223c94d6653a03f0dbee062 100644 ---- a/grub-core/net/ip.c -+++ b/grub-core/net/ip.c -@@ -228,12 +228,13 @@ handle_dgram (struct grub_net_buff *nb, - grub_net_ip_protocol_t proto, - const grub_net_network_level_address_t *source, - const grub_net_network_level_address_t *dest, -+ grub_uint16_t *vlantag, - grub_uint8_t ttl) - { - struct grub_net_network_level_interface *inf = NULL; - grub_err_t err; - int multicast = 0; -- -+ - /* DHCP needs special treatment since we don't know IP yet. */ - { - struct udphdr *udph; -@@ -293,6 +294,15 @@ handle_dgram (struct grub_net_buff *nb, - && grub_net_addr_cmp (&inf->address, dest) == 0 - && grub_net_hwaddr_cmp (&inf->hwaddress, hwaddress) == 0) - break; -+ -+ /* Verify vlantag id */ -+ if (inf->card == card && inf->vlantag != *vlantag) -+ { -+ grub_dprintf ("net", "invalid vlantag! %x != %x\n", -+ inf->vlantag, *vlantag); -+ break; -+ } -+ - /* Solicited node multicast. */ - if (inf->card == card - && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6 -@@ -383,7 +393,8 @@ static grub_err_t - grub_net_recv_ip4_packets (struct grub_net_buff *nb, - struct grub_net_card *card, - const grub_net_link_level_address_t *hwaddress, -- const grub_net_link_level_address_t *src_hwaddress) -+ const grub_net_link_level_address_t *src_hwaddress, -+ grub_uint16_t *vlantag) - { - struct iphdr *iph = (struct iphdr *) nb->data; - grub_err_t err; -@@ -458,7 +469,7 @@ grub_net_recv_ip4_packets (struct grub_net_buff *nb, - dest.ipv4 = iph->dest; - - return handle_dgram (nb, card, src_hwaddress, hwaddress, iph->protocol, -- &source, &dest, iph->ttl); -+ &source, &dest, vlantag, iph->ttl); - } - - for (prev = &reassembles, rsm = *prev; rsm; prev = &rsm->next, rsm = *prev) -@@ -594,7 +605,7 @@ grub_net_recv_ip4_packets (struct grub_net_buff *nb, - dest.ipv4 = dst; - - return handle_dgram (ret, card, src_hwaddress, -- hwaddress, proto, &source, &dest, -+ hwaddress, proto, &source, &dest, vlantag, - ttl); - } - } -@@ -652,7 +663,8 @@ static grub_err_t - grub_net_recv_ip6_packets (struct grub_net_buff *nb, - struct grub_net_card *card, - const grub_net_link_level_address_t *hwaddress, -- const grub_net_link_level_address_t *src_hwaddress) -+ const grub_net_link_level_address_t *src_hwaddress, -+ grub_uint16_t *vlantag) - { - struct ip6hdr *iph = (struct ip6hdr *) nb->data; - grub_err_t err; -@@ -703,21 +715,24 @@ grub_net_recv_ip6_packets (struct grub_net_buff *nb, - grub_memcpy (dest.ipv6, &iph->dest, sizeof (dest.ipv6)); - - return handle_dgram (nb, card, src_hwaddress, hwaddress, iph->protocol, -- &source, &dest, iph->ttl); -+ &source, &dest, vlantag, iph->ttl); - } - - grub_err_t - grub_net_recv_ip_packets (struct grub_net_buff *nb, - struct grub_net_card *card, - const grub_net_link_level_address_t *hwaddress, -- const grub_net_link_level_address_t *src_hwaddress) -+ const grub_net_link_level_address_t *src_hwaddress, -+ grub_uint16_t *vlantag) - { - struct iphdr *iph = (struct iphdr *) nb->data; - - if ((iph->verhdrlen >> 4) == 4) -- return grub_net_recv_ip4_packets (nb, card, hwaddress, src_hwaddress); -+ return grub_net_recv_ip4_packets (nb, card, hwaddress, src_hwaddress, -+ vlantag); - if ((iph->verhdrlen >> 4) == 6) -- return grub_net_recv_ip6_packets (nb, card, hwaddress, src_hwaddress); -+ return grub_net_recv_ip6_packets (nb, card, hwaddress, src_hwaddress, -+ vlantag); - grub_dprintf ("net", "Bad IP version: %d\n", (iph->verhdrlen >> 4)); - grub_netbuff_free (nb); - return GRUB_ERR_NONE; -diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c -index 7338f8245e3a9bbe47e821fb43c2b699b9527ffb..6be678c0de1ac236b60f765e767ae43d113b1117 100644 ---- a/grub-core/normal/auth.c -+++ b/grub-core/normal/auth.c -@@ -166,13 +166,13 @@ grub_username_get (char buf[], unsigned buf_size) - if (key == '\n' || key == '\r') - break; - -- if (key == '\e') -+ if (key == GRUB_TERM_ESC) - { - cur_len = 0; - break; - } - -- if (key == '\b') -+ if (key == GRUB_TERM_BACKSPACE) - { - if (cur_len) - { -@@ -197,7 +197,7 @@ grub_username_get (char buf[], unsigned buf_size) - grub_xputs ("\n"); - grub_refresh (); - -- return (key != '\e'); -+ return (key != GRUB_TERM_ESC); - } - - grub_err_t -diff --git a/grub-core/normal/cmdline.c b/grub-core/normal/cmdline.c -index a36180d75305f421e96903a46acb9dd99af06572..c037d5050ed2b34fa3b2ac0c7564e4208ca143c4 100644 ---- a/grub-core/normal/cmdline.c -+++ b/grub-core/normal/cmdline.c -@@ -626,12 +626,12 @@ grub_cmdline_get (const char *prompt_translated) - cl_insert (cl_terms, nterms, &lpos, &llen, &max_len, &buf, kill_buf); - break; - -- case '\e': -+ case GRUB_TERM_ESC: - grub_free (cl_terms); - grub_free (buf); - return 0; - -- case '\b': -+ case GRUB_TERM_BACKSPACE: - if (lpos > 0) - { - lpos--; -diff --git a/grub-core/normal/crypto.c b/grub-core/normal/crypto.c -index 2bfd67c8ef388097701a7415df3cd7321c6a1e57..e6d345f33458a167e703235d611afdd8c2a245b0 100644 ---- a/grub-core/normal/crypto.c -+++ b/grub-core/normal/crypto.c -@@ -147,8 +147,8 @@ read_crypto_list (const char *prefix) - if (! cur->modname) - { - grub_errno = GRUB_ERR_NONE; -- grub_free (cur); - grub_free (cur->name); -+ grub_free (cur); - continue; - } - cur->next = crypto_specs; -diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index 719e2fb1c260b16d96cea2b787d7f7e592b428b7..e7a83c2d6e2aaa8248ed739b28f2c6be76622eb4 100644 ---- a/grub-core/normal/menu.c -+++ b/grub-core/normal/menu.c -@@ -763,7 +763,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) - *auto_boot = 0; - return current_entry; - -- case '\e': -+ case GRUB_TERM_ESC: - if (nested) - { - menu_fini (); -diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c -index eeeee5580abea9798278ef85cf417366cf4f0e0a..cdf3590a3646ce4be0caf99cafedcbc38cbe51e4 100644 ---- a/grub-core/normal/menu_entry.c -+++ b/grub-core/normal/menu_entry.c -@@ -1403,7 +1403,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) - goto fail; - break; - -- case '\e': -+ case GRUB_TERM_ESC: - destroy_screen (screen); - return; - -diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c -index a79682a5e31e1b4e77d9b99f55cc5a1fca9e159b..a6153d359546d237933cba0f300e7d59fdb1007b 100644 ---- a/grub-core/osdep/linux/ofpath.c -+++ b/grub-core/osdep/linux/ofpath.c -@@ -38,6 +38,46 @@ - #include - #include - -+#ifdef __sparc__ -+typedef enum -+ { -+ GRUB_OFPATH_SPARC_WWN_ADDR = 1, -+ GRUB_OFPATH_SPARC_TGT_LUN, -+ } ofpath_sparc_addressing; -+ -+struct ofpath_sparc_hba -+{ -+ grub_uint32_t device_id; -+ ofpath_sparc_addressing addressing; -+}; -+ -+static struct ofpath_sparc_hba sparc_lsi_hba[] = { -+ /* Rhea, Jasper 320, LSI53C1020/1030. */ -+ {0x30, GRUB_OFPATH_SPARC_TGT_LUN}, -+ /* SAS-1068E. */ -+ {0x50, GRUB_OFPATH_SPARC_TGT_LUN}, -+ /* SAS-1064E. */ -+ {0x56, GRUB_OFPATH_SPARC_TGT_LUN}, -+ /* Pandora SAS-1068E. */ -+ {0x58, GRUB_OFPATH_SPARC_TGT_LUN}, -+ /* Aspen, Invader, LSI SAS-3108. */ -+ {0x5d, GRUB_OFPATH_SPARC_TGT_LUN}, -+ /* Niwot, SAS 2108. */ -+ {0x79, GRUB_OFPATH_SPARC_TGT_LUN}, -+ /* Erie, Falcon, LSI SAS 2008. */ -+ {0x72, GRUB_OFPATH_SPARC_WWN_ADDR}, -+ /* LSI WarpDrive 6203. */ -+ {0x7e, GRUB_OFPATH_SPARC_WWN_ADDR}, -+ /* LSI SAS 2308. */ -+ {0x87, GRUB_OFPATH_SPARC_WWN_ADDR}, -+ /* LSI SAS 3008. */ -+ {0x97, GRUB_OFPATH_SPARC_WWN_ADDR}, -+ {0, 0} -+}; -+ -+static const int LSI_VENDOR_ID = 0x1000; -+#endif -+ - #ifdef OFPATH_STANDALONE - #define xmalloc malloc - void -@@ -120,6 +160,8 @@ find_obppath (const char *sysfs_path_orig) - #endif - - fd = open(path, O_RDONLY); -+ -+#ifndef __sparc__ - if (fd < 0 || fstat (fd, &st) < 0) - { - if (fd >= 0) -@@ -127,6 +169,7 @@ find_obppath (const char *sysfs_path_orig) - snprintf(path, path_size, "%s/devspec", sysfs_path); - fd = open(path, O_RDONLY); - } -+#endif - - if (fd < 0 || fstat (fd, &st) < 0) - { -@@ -307,6 +350,55 @@ of_path_of_ide(const char *sys_devname __attribute__((unused)), const char *devi - return ret; - } - -+#ifdef __sparc__ -+static char * -+of_path_of_nvme(const char *sys_devname __attribute__((unused)), -+ const char *device, -+ const char *devnode __attribute__((unused)), -+ const char *devicenode) -+{ -+ char *sysfs_path, *of_path, disk[MAX_DISK_CAT]; -+ const char *digit_string, *part_end; -+ -+ digit_string = trailing_digits (device); -+ part_end = devicenode + strlen (devicenode) - 1; -+ -+ if ((*digit_string != '\0') && (*part_end == 'p')) -+ { -+ /* We have a partition number, strip it off. */ -+ int part; -+ char *nvmedev, *end; -+ -+ nvmedev = strdup (devicenode); -+ -+ if (!nvmedev) -+ return NULL; -+ -+ end = nvmedev + strlen (nvmedev) - 1; -+ /* Remove the p. */ -+ *end = '\0'; -+ sscanf (digit_string, "%d", &part); -+ snprintf (disk, sizeof (disk), "/disk@1:%c", 'a' + (part - 1)); -+ sysfs_path = block_device_get_sysfs_path_and_link (nvmedev); -+ free (nvmedev); -+ } -+ else -+ { -+ /* We do not have the parition. */ -+ snprintf (disk, sizeof (disk), "/disk@1"); -+ sysfs_path = block_device_get_sysfs_path_and_link (device); -+ } -+ -+ of_path = find_obppath (sysfs_path); -+ -+ if (of_path) -+ strcat (of_path, disk); -+ -+ free (sysfs_path); -+ return of_path; -+} -+#endif -+ - static int - vendor_is_ATA(const char *path) - { -@@ -335,6 +427,64 @@ vendor_is_ATA(const char *path) - return (memcmp(bufcont, "ATA", 3) == 0); - } - -+#ifdef __sparc__ -+static void -+check_hba_identifiers (const char *sysfs_path, int *vendor, int *device_id) -+{ -+ char *ed = strstr (sysfs_path, "host"); -+ size_t path_size; -+ char *p, *path; -+ char buf[8]; -+ int fd; -+ -+ if (!ed) -+ return; -+ -+ p = xstrdup (sysfs_path); -+ ed = strstr (p, "host"); -+ -+ *ed = '\0'; -+ -+ path_size = (strlen (p) + sizeof ("vendor")); -+ path = xmalloc (path_size); -+ -+ if (!path) -+ goto out; -+ -+ snprintf (path, path_size, "%svendor", p); -+ fd = open (path, O_RDONLY); -+ -+ if (fd < 0) -+ goto out; -+ -+ memset (buf, 0, sizeof (buf)); -+ -+ if (read (fd, buf, sizeof (buf) - 1) < 0) -+ goto out; -+ -+ close (fd); -+ sscanf (buf, "%x", vendor); -+ -+ snprintf (path, path_size, "%sdevice", p); -+ fd = open (path, O_RDONLY); -+ -+ if (fd < 0) -+ goto out; -+ -+ memset (buf, 0, sizeof (buf)); -+ -+ if (read (fd, buf, sizeof (buf) - 1) < 0) -+ goto out; -+ -+ close (fd); -+ sscanf (buf, "%x", device_id); -+ -+ out: -+ free (path); -+ free (p); -+} -+#endif -+ - static void - check_sas (const char *sysfs_path, int *tgt, unsigned long int *sas_address) - { -@@ -396,7 +546,7 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev - { - const char *p, *digit_string, *disk_name; - int host, bus, tgt, lun; -- unsigned long int sas_address; -+ unsigned long int sas_address = 0; - char *sysfs_path, disk[MAX_DISK_CAT - sizeof ("/fp@0,0")]; - char *of_path; - -@@ -413,9 +563,8 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev - } - - of_path = find_obppath(sysfs_path); -- free (sysfs_path); - if (!of_path) -- return NULL; -+ goto out; - - if (strstr (of_path, "qlc")) - strcat (of_path, "/fp@0,0"); -@@ -444,6 +593,46 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev - } - else - { -+#ifdef __sparc__ -+ ofpath_sparc_addressing addressing = GRUB_OFPATH_SPARC_TGT_LUN; -+ int vendor = 0, device_id = 0; -+ char *optr = disk; -+ -+ check_hba_identifiers (sysfs_path, &vendor, &device_id); -+ -+ if (vendor == LSI_VENDOR_ID) -+ { -+ struct ofpath_sparc_hba *lsi_hba; -+ -+ /* -+ * Over time different OF addressing schemes have been supported. -+ * There is no generic addressing scheme that works across -+ * every HBA. -+ */ -+ for (lsi_hba = sparc_lsi_hba; lsi_hba->device_id; lsi_hba++) -+ if (lsi_hba->device_id == device_id) -+ { -+ addressing = lsi_hba->addressing; -+ break; -+ } -+ } -+ -+ if (addressing == GRUB_OFPATH_SPARC_WWN_ADDR) -+ optr += snprintf (disk, sizeof (disk), "/%s@w%lx,%x", disk_name, -+ sas_address, lun); -+ else -+ optr += snprintf (disk, sizeof (disk), "/%s@%x,%x", disk_name, tgt, -+ lun); -+ -+ if (*digit_string != '\0') -+ { -+ int part; -+ -+ sscanf (digit_string, "%d", &part); -+ snprintf (optr, sizeof (disk) - (optr - disk - 1), ":%c", 'a' -+ + (part - 1)); -+ } -+#else - if (lun == 0) - { - int sas_id = 0; -@@ -491,8 +680,12 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev - } - free (lunstr); - } -+#endif - } - strcat(of_path, disk); -+ -+ out: -+ free (sysfs_path); - return of_path; - } - -@@ -537,6 +730,11 @@ grub_util_devname_to_ofpath (const char *sys_devname) - /* All the models I've seen have a devalias "floppy". - New models have no floppy at all. */ - ofpath = xstrdup ("floppy"); -+#ifdef __sparc__ -+ else if (device[0] == 'n' && device[1] == 'v' && device[2] == 'm' -+ && device[3] == 'e') -+ ofpath = of_path_of_nvme (name_buf, device, devnode, devicenode); -+#endif - else - { - grub_util_warn (_("unknown device type %s"), device); -diff --git a/grub-core/osdep/unix/exec.c b/grub-core/osdep/unix/exec.c -index 935ff120ebe117f7492715813789db364ef1b12f..db3259f6504d5d5958cfa330bfd4a8b12b64f970 100644 ---- a/grub-core/osdep/unix/exec.c -+++ b/grub-core/osdep/unix/exec.c -@@ -99,7 +99,7 @@ grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file, - { - fd = open (stdin_file, O_RDONLY); - if (fd < 0) -- exit (127); -+ _exit (127); - dup2 (fd, STDIN_FILENO); - close (fd); - } -@@ -108,7 +108,7 @@ grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file, - { - fd = open (stdout_file, O_WRONLY | O_CREAT, 0700); - if (fd < 0) -- exit (127); -+ _exit (127); - dup2 (fd, STDOUT_FILENO); - close (fd); - } -@@ -117,7 +117,7 @@ grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file, - { - fd = open (stderr_file, O_WRONLY | O_CREAT, 0700); - if (fd < 0) -- exit (127); -+ _exit (127); - dup2 (fd, STDERR_FILENO); - close (fd); - } -@@ -126,7 +126,7 @@ grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file, - setenv ("LC_ALL", "C", 1); - - execvp ((char *) argv[0], (char **) argv); -- exit (127); -+ _exit (127); - } - waitpid (pid, &status, 0); - if (!WIFEXITED (status)) -diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c -index 4bf37b027be660a14994fb316f08dd478490c4e2..3046e22cc012d1012add87931a018043e3ecc714 100644 ---- a/grub-core/osdep/unix/getroot.c -+++ b/grub-core/osdep/unix/getroot.c -@@ -428,8 +428,11 @@ grub_find_device (const char *dir, dev_t dev) - { - #ifdef __linux__ - /* Skip device names like /dev/dm-0, which are short-hand aliases -- to more descriptive device names, e.g. those under /dev/mapper */ -- if (ent->d_name[0] == 'd' && -+ to more descriptive device names, e.g. those under /dev/mapper. -+ Also, don't skip devices which names start with dm-[0-9] in -+ directories below /dev, e.g. /dev/mapper/dm-0-luks. */ -+ if (strcmp (dir, "/dev") == 0 && -+ ent->d_name[0] == 'd' && - ent->d_name[1] == 'm' && - ent->d_name[2] == '-' && - ent->d_name[3] >= '0' && -diff --git a/grub-core/osdep/unix/hostdisk.c b/grub-core/osdep/unix/hostdisk.c -index 2a8c5882e3d10b98bc305a116f8cca06acfe89f5..5450cf4166e04c2cfab806e93dfa63c6abdb9698 100644 ---- a/grub-core/osdep/unix/hostdisk.c -+++ b/grub-core/osdep/unix/hostdisk.c -@@ -77,11 +77,19 @@ grub_util_get_fd_size (grub_util_fd_t fd, const char *name, unsigned *log_secsiz - int - grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off) - { -+#if SIZEOF_OFF_T == 8 - off_t offset = (off_t) off; - - if (lseek (fd, offset, SEEK_SET) != offset) - return -1; -+#elif SIZEOF_OFF64_T == 8 -+ off64_t offset = (off64_t) off; - -+ if (lseek64 (fd, offset, SEEK_SET) != offset) -+ return -1; -+#else -+#error "No large file support" -+#endif - return 0; - } - -diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c -index a3fcfcacaa814d3ab62104f0dd406ef0c2163613..ca448bc11a05b9e0c6203a799ff62ab1dd75274f 100644 ---- a/grub-core/osdep/unix/platform.c -+++ b/grub-core/osdep/unix/platform.c -@@ -78,19 +78,20 @@ get_ofpathname (const char *dev) - dev); - } - --static void -+static int - grub_install_remove_efi_entries_by_distributor (const char *efi_distributor) - { - int fd; - pid_t pid = grub_util_exec_pipe ((const char * []){ "efibootmgr", NULL }, &fd); - char *line = NULL; - size_t len = 0; -+ int rc; - - if (!pid) - { - grub_util_warn (_("Unable to open stream from %s: %s"), - "efibootmgr", strerror (errno)); -- return; -+ return errno; - } - - FILE *fp = fdopen (fd, "r"); -@@ -98,7 +99,7 @@ grub_install_remove_efi_entries_by_distributor (const char *efi_distributor) - { - grub_util_warn (_("Unable to open stream from %s: %s"), - "efibootmgr", strerror (errno)); -- return; -+ return errno; - } - - line = xmalloc (80); -@@ -119,23 +120,25 @@ grub_install_remove_efi_entries_by_distributor (const char *efi_distributor) - bootnum = line + sizeof ("Boot") - 1; - bootnum[4] = '\0'; - if (!verbosity) -- grub_util_exec ((const char * []){ "efibootmgr", "-q", -+ rc = grub_util_exec ((const char * []){ "efibootmgr", "-q", - "-b", bootnum, "-B", NULL }); - else -- grub_util_exec ((const char * []){ "efibootmgr", -+ rc = grub_util_exec ((const char * []){ "efibootmgr", - "-b", bootnum, "-B", NULL }); - } - - free (line); -+ return rc; - } - --void -+int - grub_install_register_efi (grub_device_t efidir_grub_dev, - const char *efifile_path, - const char *efi_distributor) - { - const char * efidir_disk; - int efidir_part; -+ int ret; - efidir_disk = grub_util_biosdisk_get_osdev (efidir_grub_dev->disk); - efidir_part = efidir_grub_dev->disk->partition ? efidir_grub_dev->disk->partition->number + 1 : 1; - -@@ -151,23 +154,26 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, - grub_util_exec ((const char * []){ "modprobe", "-q", "efivars", NULL }); - #endif - /* Delete old entries from the same distributor. */ -- grub_install_remove_efi_entries_by_distributor (efi_distributor); -+ ret = grub_install_remove_efi_entries_by_distributor (efi_distributor); -+ if (ret) -+ return ret; - - char *efidir_part_str = xasprintf ("%d", efidir_part); - - if (!verbosity) -- grub_util_exec ((const char * []){ "efibootmgr", "-q", -+ ret = grub_util_exec ((const char * []){ "efibootmgr", "-q", - "-c", "-d", efidir_disk, - "-p", efidir_part_str, "-w", - "-L", efi_distributor, "-l", - efifile_path, NULL }); - else -- grub_util_exec ((const char * []){ "efibootmgr", -+ ret = grub_util_exec ((const char * []){ "efibootmgr", - "-c", "-d", efidir_disk, - "-p", efidir_part_str, "-w", - "-L", efi_distributor, "-l", - efifile_path, NULL }); - free (efidir_part_str); -+ return ret; - } - - void -diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c -index 83bcba7791421825da6922a7ee346f4fd5fcd7a4..103f6796f39f38209b0f554842aa6697faa5df2f 100644 ---- a/grub-core/partmap/gpt.c -+++ b/grub-core/partmap/gpt.c -@@ -33,10 +33,10 @@ static grub_uint8_t grub_gpt_magic[8] = - 0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54 - }; - --static const grub_gpt_part_type_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY; -+static const grub_gpt_part_guid_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY; - - #ifdef GRUB_UTIL --static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT; -+static const grub_gpt_part_guid_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT; - #endif - - /* 512 << 7 = 65536 byte sectors. */ -diff --git a/grub-core/term/arm/cros.c b/grub-core/term/arm/cros.c -new file mode 100644 -index 0000000000000000000000000000000000000000..1ff9f8ccfb8270884ba962a05ca99df4c6ed1f41 ---- /dev/null -+++ b/grub-core/term/arm/cros.c -@@ -0,0 +1,125 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * -+ * Copyright (C) 2012 Google Inc. -+ * Copyright (C) 2016 Free Software Foundation, Inc. -+ * -+ * This is based on depthcharge code. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+struct grub_ps2_state ps2_state; -+ -+struct grub_cros_ec_keyscan old_scan; -+ -+static const struct grub_fdtbus_dev *cros_ec; -+ -+static grub_uint8_t map_code[GRUB_CROS_EC_KEYSCAN_COLS][GRUB_CROS_EC_KEYSCAN_ROWS]; -+ -+static grub_uint8_t e0_translate[16] = -+ { -+ 0x1c, 0x1d, 0x35, 0x00, -+ 0x38, 0x00, 0x47, 0x48, -+ 0x49, 0x4b, 0x4d, 0x4f, -+ 0x50, 0x51, 0x52, 0x53, -+ }; -+ -+/* If there is a character pending, return it; -+ otherwise return GRUB_TERM_NO_KEY. */ -+static int -+grub_cros_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused))) -+{ -+ struct grub_cros_ec_keyscan scan; -+ int i, j; -+ if (grub_cros_ec_scan_keyboard (cros_ec, &scan) < 0) -+ return GRUB_TERM_NO_KEY; -+ for (i = 0; i < GRUB_CROS_EC_KEYSCAN_COLS; i++) -+ if (scan.data[i] ^ old_scan.data[i]) -+ for (j = 0; j < GRUB_CROS_EC_KEYSCAN_ROWS; j++) -+ if ((scan.data[i] ^ old_scan.data[i]) & (1 << j)) -+ { -+ grub_uint8_t code = map_code[i][j]; -+ int ret; -+ grub_uint8_t brk = 0; -+ if (!(scan.data[i] & (1 << j))) -+ brk = 0x80; -+ grub_dprintf ("cros_keyboard", "key <%d, %d> code %x\n", i, j, code); -+ if (code < 0x60) -+ ret = grub_ps2_process_incoming_byte (&ps2_state, code | brk); -+ else if (code >= 0x60 && code < 0x70 && e0_translate[code - 0x60]) -+ { -+ grub_ps2_process_incoming_byte (&ps2_state, 0xe0); -+ ret = grub_ps2_process_incoming_byte (&ps2_state, e0_translate[code - 0x60] | brk); -+ } -+ else -+ ret = GRUB_TERM_NO_KEY; -+ old_scan.data[i] ^= (1 << j); -+ if (ret != GRUB_TERM_NO_KEY) -+ return ret; -+ } -+ return GRUB_TERM_NO_KEY; -+} -+ -+static struct grub_term_input grub_cros_keyboard_term = -+ { -+ .name = "cros_keyboard", -+ .getkey = grub_cros_keyboard_getkey -+ }; -+ -+static grub_err_t -+cros_attach (const struct grub_fdtbus_dev *dev) -+{ -+ grub_size_t keymap_size, i; -+ const grub_uint8_t *keymap = grub_fdtbus_get_prop (dev, "linux,keymap", &keymap_size); -+ -+ if (!dev->parent || !grub_cros_ec_validate (dev->parent)) -+ return GRUB_ERR_IO; -+ -+ if (keymap) -+ { -+ for (i = 0; i + 3 < keymap_size; i += 4) -+ if (keymap[i+1] < GRUB_CROS_EC_KEYSCAN_COLS && keymap[i] < GRUB_CROS_EC_KEYSCAN_ROWS -+ && keymap[i+2] == 0 && keymap[i+3] < 0x80) -+ map_code[keymap[i+1]][keymap[i]] = keymap[i+3]; -+ } -+ -+ cros_ec = dev->parent; -+ ps2_state.current_set = 1; -+ ps2_state.at_keyboard_status = 0; -+ grub_term_register_input ("cros_keyboard", &grub_cros_keyboard_term); -+ return GRUB_ERR_NONE; -+} -+ -+static struct grub_fdtbus_driver cros = -+{ -+ .compatible = "google,cros-ec-keyb", -+ .attach = cros_attach -+}; -+ -+void -+grub_cros_init (void) -+{ -+ grub_fdtbus_register (&cros); -+} -diff --git a/grub-core/term/arm/cros_ec.c b/grub-core/term/arm/cros_ec.c -new file mode 100644 -index 0000000000000000000000000000000000000000..f4144818b5bfdb9a512316ccc321586d539653ac ---- /dev/null -+++ b/grub-core/term/arm/cros_ec.c -@@ -0,0 +1,238 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * -+ * Copyright (C) 2012 Google Inc. -+ * Copyright (C) 2016 Free Software Foundation, Inc. -+ * -+ * This is based on depthcharge code. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+static const grub_uint64_t FRAMING_TIMEOUT_MS = 300; -+ -+static const grub_uint8_t EC_FRAMING_BYTE = 0xec; -+ -+#define EC_CMD_MKBP_STATE 0x60 -+#define EC_CMD_VERSION0 0xdc -+ -+static grub_uint64_t last_transfer; -+ -+static void -+stop_bus (const struct grub_fdtbus_dev *spi) -+{ -+ spi->driver->stop (spi); -+ last_transfer = grub_get_time_ms (); -+} -+ -+static int -+wait_for_frame (const struct grub_fdtbus_dev *spi) -+{ -+ grub_uint64_t start = grub_get_time_ms (); -+ grub_uint8_t byte; -+ do -+ { -+ if (spi->driver->receive (spi, &byte, 1)) -+ return -1; -+ if (byte != EC_FRAMING_BYTE && -+ grub_get_time_ms () - start > FRAMING_TIMEOUT_MS) -+ { -+ grub_dprintf ("cros", "Timeout waiting for framing byte.\n"); -+ return -1; -+ } -+ } -+ while (byte != EC_FRAMING_BYTE); -+ return 0; -+} -+ -+/* -+ * Calculate a simple 8-bit checksum of a data block -+ * -+ * @param data Data block to checksum -+ * @param size Size of data block in bytes -+ * @return checksum value (0 to 255) -+ */ -+static grub_uint8_t -+cros_ec_calc_checksum (const void *data, int size) -+{ -+ grub_uint8_t csum; -+ const grub_uint8_t *bytes = data; -+ int i; -+ -+ for (i = csum = 0; i < size; i++) -+ csum += bytes[i]; -+ return csum & 0xff; -+} -+ -+enum -+{ -+ /* response, arglen */ -+ CROS_EC_SPI_IN_HDR_SIZE = 2, -+ /* version, cmd, arglen */ -+ CROS_EC_SPI_OUT_HDR_SIZE = 3 -+}; -+ -+static grub_uint8_t busbuf[256]; -+#define MSG_BYTES ((int)sizeof (busbuf)) -+ -+static int -+ec_command (const struct grub_fdtbus_dev *dev, int cmd, int cmd_version, -+ const void *dout, int dout_len, void *din, int din_len) -+{ -+ const struct grub_fdtbus_dev *spi = dev->parent; -+ grub_uint8_t *bytes; -+ -+ /* Header + data + checksum. */ -+ grub_uint32_t out_bytes = CROS_EC_SPI_OUT_HDR_SIZE + dout_len + 1; -+ grub_uint32_t in_bytes = CROS_EC_SPI_IN_HDR_SIZE + din_len + 1; -+ -+ /* -+ * Sanity-check I/O sizes given transaction overhead in internal -+ * buffers. -+ */ -+ if (out_bytes > MSG_BYTES) -+ { -+ grub_dprintf ("cros", "Cannot send %d bytes\n", dout_len); -+ return -1; -+ } -+ if (in_bytes > MSG_BYTES) -+ { -+ grub_dprintf ("cros", "Cannot receive %d bytes\n", din_len); -+ return -1; -+ } -+ -+ /* Prepare the output. */ -+ bytes = busbuf; -+ *bytes++ = EC_CMD_VERSION0 + cmd_version; -+ *bytes++ = cmd; -+ *bytes++ = dout_len; -+ grub_memcpy (bytes, dout, dout_len); -+ bytes += dout_len; -+ -+ *bytes++ = cros_ec_calc_checksum (busbuf, -+ CROS_EC_SPI_OUT_HDR_SIZE + dout_len); -+ -+ /* Depthcharge uses 200 us here but GRUB timer resolution is only 1ms, -+ decrease this when we increase timer resolution. */ -+ while (grub_get_time_ms () - last_transfer < 1) -+ ; -+ -+ if (spi->driver->start (spi)) -+ return -1; -+ -+ /* Allow EC to ramp up clock after being awoken. */ -+ /* Depthcharge only waits 100 us here but GRUB timer resolution is only 1ms, -+ decrease this when we increase timer resolution. */ -+ grub_millisleep (1); -+ -+ if (spi->driver->send (spi, busbuf, out_bytes)) -+ { -+ stop_bus (spi); -+ return -1; -+ } -+ -+ /* Wait until the EC is ready. */ -+ if (wait_for_frame (spi)) -+ { -+ stop_bus (spi); -+ return -1; -+ } -+ -+ /* Read the response code and the data length. */ -+ bytes = busbuf; -+ if (spi->driver->receive (spi, bytes, 2)) -+ { -+ stop_bus (spi); -+ return -1; -+ } -+ grub_uint8_t result = *bytes++; -+ grub_uint8_t length = *bytes++; -+ -+ /* Make sure there's enough room for the data. */ -+ if (CROS_EC_SPI_IN_HDR_SIZE + length + 1 > MSG_BYTES) -+ { -+ grub_dprintf ("cros", "Received length %#02x too large\n", length); -+ stop_bus (spi); -+ return -1; -+ } -+ -+ /* Read the data and the checksum, and finish up. */ -+ if (spi->driver->receive (spi, bytes, length + 1)) -+ { -+ stop_bus (spi); -+ return -1; -+ } -+ bytes += length; -+ int expected = *bytes++; -+ stop_bus (spi); -+ -+ /* Check the integrity of the response. */ -+ if (result != 0) -+ { -+ grub_dprintf ("cros", "Received bad result code %d\n", result); -+ return -result; -+ } -+ -+ int csum = cros_ec_calc_checksum (busbuf, -+ CROS_EC_SPI_IN_HDR_SIZE + length); -+ -+ if (csum != expected) -+ { -+ grub_dprintf ("cros", "Invalid checksum rx %#02x, calced %#02x\n", -+ expected, csum); -+ return -1; -+ } -+ -+ /* If the caller wants the response, copy it out for them. */ -+ if (length < din_len) -+ din_len = length; -+ if (din) -+ { -+ grub_memcpy (din, (grub_uint8_t *) busbuf + CROS_EC_SPI_IN_HDR_SIZE, din_len); -+ } -+ -+ return din_len; -+} -+ -+int -+grub_cros_ec_scan_keyboard (const struct grub_fdtbus_dev *dev, struct grub_cros_ec_keyscan *scan) -+{ -+ if (ec_command (dev, EC_CMD_MKBP_STATE, 0, NULL, 0, scan, -+ sizeof (*scan)) < (int) sizeof (*scan)) -+ return -1; -+ -+ return 0; -+} -+ -+int -+grub_cros_ec_validate (const struct grub_fdtbus_dev *dev) -+{ -+ if (!grub_fdtbus_is_compatible("google,cros-ec-spi", dev)) -+ return 0; -+ if (!dev->parent) -+ return 0; -+ if (!dev->parent->driver) -+ return 0; -+ if (!dev->parent->driver->send -+ || !dev->parent->driver->receive) -+ return 0; -+ return 1; -+} -+ -diff --git a/grub-core/term/arm/pl050.c b/grub-core/term/arm/pl050.c -new file mode 100644 -index 0000000000000000000000000000000000000000..e4cda305666df20eba26e10d74b879361e83d6ea ---- /dev/null -+++ b/grub-core/term/arm/pl050.c -@@ -0,0 +1,189 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2007,2008,2009 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+static volatile grub_uint32_t *pl050_regs; -+ -+struct grub_ps2_state ps2_state; -+ -+static void -+keyboard_controller_wait_until_ready (void) -+{ -+ while (! (pl050_regs[1] & 0x40)); -+} -+ -+static grub_uint8_t -+wait_ack (void) -+{ -+ grub_uint64_t endtime; -+ grub_uint8_t ack; -+ -+ endtime = grub_get_time_ms () + 20; -+ do -+ ack = pl050_regs[2]; -+ while (ack != GRUB_AT_ACK && ack != GRUB_AT_NACK -+ && grub_get_time_ms () < endtime); -+ return ack; -+} -+ -+ -+static int -+write_mode (int mode) -+{ -+ unsigned i; -+ for (i = 0; i < GRUB_AT_TRIES; i++) -+ { -+ grub_uint8_t ack; -+ keyboard_controller_wait_until_ready (); -+ pl050_regs[2] = 0xf0; -+ keyboard_controller_wait_until_ready (); -+ pl050_regs[2] = mode; -+ keyboard_controller_wait_until_ready (); -+ ack = wait_ack (); -+ if (ack == GRUB_AT_NACK) -+ continue; -+ if (ack == GRUB_AT_ACK) -+ break; -+ return 0; -+ } -+ -+ return (i != GRUB_AT_TRIES); -+} -+ -+static int -+query_mode (void) -+{ -+ grub_uint8_t ret; -+ int e; -+ -+ e = write_mode (0); -+ if (!e) -+ return 0; -+ -+ keyboard_controller_wait_until_ready (); -+ -+ do -+ ret = pl050_regs[2]; -+ while (ret == GRUB_AT_ACK); -+ -+ /* QEMU translates the set even in no-translate mode. */ -+ if (ret == 0x43 || ret == 1) -+ return 1; -+ if (ret == 0x41 || ret == 2) -+ return 2; -+ if (ret == 0x3f || ret == 3) -+ return 3; -+ return 0; -+} -+ -+static void -+set_scancodes (void) -+{ -+ write_mode (2); -+ ps2_state.current_set = query_mode (); -+ grub_dprintf ("atkeyb", "returned set %d\n", ps2_state.current_set); -+ if (ps2_state.current_set == 2) -+ return; -+ -+ write_mode (1); -+ ps2_state.current_set = query_mode (); -+ grub_dprintf ("atkeyb", "returned set %d\n", ps2_state.current_set); -+ if (ps2_state.current_set == 1) -+ return; -+ grub_dprintf ("atkeyb", "no supported scancode set found\n"); -+} -+ -+static void -+keyboard_controller_led (grub_uint8_t leds) -+{ -+ keyboard_controller_wait_until_ready (); -+ pl050_regs[2] = 0xed; -+ keyboard_controller_wait_until_ready (); -+ pl050_regs[2] = leds & 0x7; -+} -+ -+/* If there is a character pending, return it; -+ otherwise return GRUB_TERM_NO_KEY. */ -+static int -+grub_pl050_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused))) -+{ -+ grub_uint8_t at_key; -+ int ret; -+ grub_uint8_t old_led; -+ -+ if (!(pl050_regs[1] & 0x10)) -+ return -1; -+ at_key = pl050_regs[2]; -+ old_led = ps2_state.led_status; -+ -+ ret = grub_ps2_process_incoming_byte (&ps2_state, at_key); -+ if (old_led != ps2_state.led_status) -+ keyboard_controller_led (ps2_state.led_status); -+ return ret; -+} -+ -+static struct grub_term_input grub_pl050_keyboard_term = -+ { -+ .name = "pl050_keyboard", -+ .getkey = grub_pl050_keyboard_getkey -+ }; -+ -+static grub_err_t -+pl050_attach(const struct grub_fdtbus_dev *dev) -+{ -+ const grub_uint32_t *reg; -+ reg = grub_fdtbus_get_prop (dev, "reg", 0); -+ -+ /* Mouse. Nothing to do. */ -+ if (grub_be_to_cpu32 (*reg) == 0x7000) -+ return 0; -+ -+ pl050_regs = grub_fdtbus_map_reg (dev, 0, 0); -+ -+ if (!grub_fdtbus_is_mapping_valid (pl050_regs)) -+ return grub_error (GRUB_ERR_IO, "could not map pl050"); -+ -+ ps2_state.at_keyboard_status = 0; -+ set_scancodes (); -+ keyboard_controller_led (ps2_state.led_status); -+ -+ grub_term_register_input ("pl050_keyboard", &grub_pl050_keyboard_term); -+ return GRUB_ERR_NONE; -+} -+ -+struct grub_fdtbus_driver pl050 = -+{ -+ .compatible = "arm,pl050", -+ .attach = pl050_attach -+}; -+ -+void -+grub_pl050_init (void) -+{ -+ grub_fdtbus_register (&pl050); -+} -diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c -index b4ea9ff7e637f59c653b86cea79d4d664c78af84..f0a986eb176aef6c4fe3f5a65c646756e5bbde56 100644 ---- a/grub-core/term/at_keyboard.c -+++ b/grub-core/term/at_keyboard.c -@@ -22,215 +22,26 @@ - #include - #include - #include --#include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - --static short at_keyboard_status = 0; --static int e0_received = 0; --static int f0_received = 0; -- --static grub_uint8_t led_status; -- --#define KEYBOARD_LED_SCROLL (1 << 0) --#define KEYBOARD_LED_NUM (1 << 1) --#define KEYBOARD_LED_CAPS (1 << 2) -- - static grub_uint8_t grub_keyboard_controller_orig; - static grub_uint8_t grub_keyboard_orig_set; --static grub_uint8_t current_set; -- --static void --grub_keyboard_controller_init (void); -- --static const grub_uint8_t set1_mapping[128] = -- { -- /* 0x00 */ 0 /* Unused */, GRUB_KEYBOARD_KEY_ESCAPE, -- /* 0x02 */ GRUB_KEYBOARD_KEY_1, GRUB_KEYBOARD_KEY_2, -- /* 0x04 */ GRUB_KEYBOARD_KEY_3, GRUB_KEYBOARD_KEY_4, -- /* 0x06 */ GRUB_KEYBOARD_KEY_5, GRUB_KEYBOARD_KEY_6, -- /* 0x08 */ GRUB_KEYBOARD_KEY_7, GRUB_KEYBOARD_KEY_8, -- /* 0x0a */ GRUB_KEYBOARD_KEY_9, GRUB_KEYBOARD_KEY_0, -- /* 0x0c */ GRUB_KEYBOARD_KEY_DASH, GRUB_KEYBOARD_KEY_EQUAL, -- /* 0x0e */ GRUB_KEYBOARD_KEY_BACKSPACE, GRUB_KEYBOARD_KEY_TAB, -- /* 0x10 */ GRUB_KEYBOARD_KEY_Q, GRUB_KEYBOARD_KEY_W, -- /* 0x12 */ GRUB_KEYBOARD_KEY_E, GRUB_KEYBOARD_KEY_R, -- /* 0x14 */ GRUB_KEYBOARD_KEY_T, GRUB_KEYBOARD_KEY_Y, -- /* 0x16 */ GRUB_KEYBOARD_KEY_U, GRUB_KEYBOARD_KEY_I, -- /* 0x18 */ GRUB_KEYBOARD_KEY_O, GRUB_KEYBOARD_KEY_P, -- /* 0x1a */ GRUB_KEYBOARD_KEY_LBRACKET, GRUB_KEYBOARD_KEY_RBRACKET, -- /* 0x1c */ GRUB_KEYBOARD_KEY_ENTER, GRUB_KEYBOARD_KEY_LEFT_CTRL, -- /* 0x1e */ GRUB_KEYBOARD_KEY_A, GRUB_KEYBOARD_KEY_S, -- /* 0x20 */ GRUB_KEYBOARD_KEY_D, GRUB_KEYBOARD_KEY_F, -- /* 0x22 */ GRUB_KEYBOARD_KEY_G, GRUB_KEYBOARD_KEY_H, -- /* 0x24 */ GRUB_KEYBOARD_KEY_J, GRUB_KEYBOARD_KEY_K, -- /* 0x26 */ GRUB_KEYBOARD_KEY_L, GRUB_KEYBOARD_KEY_SEMICOLON, -- /* 0x28 */ GRUB_KEYBOARD_KEY_DQUOTE, GRUB_KEYBOARD_KEY_RQUOTE, -- /* 0x2a */ GRUB_KEYBOARD_KEY_LEFT_SHIFT, GRUB_KEYBOARD_KEY_BACKSLASH, -- /* 0x2c */ GRUB_KEYBOARD_KEY_Z, GRUB_KEYBOARD_KEY_X, -- /* 0x2e */ GRUB_KEYBOARD_KEY_C, GRUB_KEYBOARD_KEY_V, -- /* 0x30 */ GRUB_KEYBOARD_KEY_B, GRUB_KEYBOARD_KEY_N, -- /* 0x32 */ GRUB_KEYBOARD_KEY_M, GRUB_KEYBOARD_KEY_COMMA, -- /* 0x34 */ GRUB_KEYBOARD_KEY_DOT, GRUB_KEYBOARD_KEY_SLASH, -- /* 0x36 */ GRUB_KEYBOARD_KEY_RIGHT_SHIFT, GRUB_KEYBOARD_KEY_NUMMUL, -- /* 0x38 */ GRUB_KEYBOARD_KEY_LEFT_ALT, GRUB_KEYBOARD_KEY_SPACE, -- /* 0x3a */ GRUB_KEYBOARD_KEY_CAPS_LOCK, GRUB_KEYBOARD_KEY_F1, -- /* 0x3c */ GRUB_KEYBOARD_KEY_F2, GRUB_KEYBOARD_KEY_F3, -- /* 0x3e */ GRUB_KEYBOARD_KEY_F4, GRUB_KEYBOARD_KEY_F5, -- /* 0x40 */ GRUB_KEYBOARD_KEY_F6, GRUB_KEYBOARD_KEY_F7, -- /* 0x42 */ GRUB_KEYBOARD_KEY_F8, GRUB_KEYBOARD_KEY_F9, -- /* 0x44 */ GRUB_KEYBOARD_KEY_F10, GRUB_KEYBOARD_KEY_NUM_LOCK, -- /* 0x46 */ GRUB_KEYBOARD_KEY_SCROLL_LOCK, GRUB_KEYBOARD_KEY_NUM7, -- /* 0x48 */ GRUB_KEYBOARD_KEY_NUM8, GRUB_KEYBOARD_KEY_NUM9, -- /* 0x4a */ GRUB_KEYBOARD_KEY_NUMMINUS, GRUB_KEYBOARD_KEY_NUM4, -- /* 0x4c */ GRUB_KEYBOARD_KEY_NUM5, GRUB_KEYBOARD_KEY_NUM6, -- /* 0x4e */ GRUB_KEYBOARD_KEY_NUMPLUS, GRUB_KEYBOARD_KEY_NUM1, -- /* 0x50 */ GRUB_KEYBOARD_KEY_NUM2, GRUB_KEYBOARD_KEY_NUM3, -- /* 0x52 */ GRUB_KEYBOARD_KEY_NUM0, GRUB_KEYBOARD_KEY_NUMDOT, -- /* 0x54 */ 0, 0, -- /* 0x56 */ GRUB_KEYBOARD_KEY_102ND, GRUB_KEYBOARD_KEY_F11, -- /* 0x58 */ GRUB_KEYBOARD_KEY_F12, 0, -- /* 0x5a */ 0, 0, -- /* 0x5c */ 0, 0, -- /* 0x5e */ 0, 0, -- /* 0x60 */ 0, 0, -- /* 0x62 */ 0, 0, -- /* OLPC keys. Just mapped to normal keys. */ -- /* 0x64 */ 0, GRUB_KEYBOARD_KEY_UP, -- /* 0x66 */ GRUB_KEYBOARD_KEY_DOWN, GRUB_KEYBOARD_KEY_LEFT, -- /* 0x68 */ GRUB_KEYBOARD_KEY_RIGHT, 0, -- /* 0x6a */ 0, 0, -- /* 0x6c */ 0, 0, -- /* 0x6e */ 0, 0, -- /* 0x70 */ 0, 0, -- /* 0x72 */ 0, GRUB_KEYBOARD_KEY_JP_RO, -- /* 0x74 */ 0, 0, -- /* 0x76 */ 0, 0, -- /* 0x78 */ 0, 0, -- /* 0x7a */ 0, 0, -- /* 0x7c */ 0, GRUB_KEYBOARD_KEY_JP_YEN, -- /* 0x7e */ GRUB_KEYBOARD_KEY_KPCOMMA -- }; -- --static const struct --{ -- grub_uint8_t from, to; --} set1_e0_mapping[] = -- { -- {0x1c, GRUB_KEYBOARD_KEY_NUMENTER}, -- {0x1d, GRUB_KEYBOARD_KEY_RIGHT_CTRL}, -- {0x35, GRUB_KEYBOARD_KEY_NUMSLASH }, -- {0x38, GRUB_KEYBOARD_KEY_RIGHT_ALT}, -- {0x47, GRUB_KEYBOARD_KEY_HOME}, -- {0x48, GRUB_KEYBOARD_KEY_UP}, -- {0x49, GRUB_KEYBOARD_KEY_PPAGE}, -- {0x4b, GRUB_KEYBOARD_KEY_LEFT}, -- {0x4d, GRUB_KEYBOARD_KEY_RIGHT}, -- {0x4f, GRUB_KEYBOARD_KEY_END}, -- {0x50, GRUB_KEYBOARD_KEY_DOWN}, -- {0x51, GRUB_KEYBOARD_KEY_NPAGE}, -- {0x52, GRUB_KEYBOARD_KEY_INSERT}, -- {0x53, GRUB_KEYBOARD_KEY_DELETE}, -- }; -- --static const grub_uint8_t set2_mapping[256] = -- { -- /* 0x00 */ 0, GRUB_KEYBOARD_KEY_F9, -- /* 0x02 */ 0, GRUB_KEYBOARD_KEY_F5, -- /* 0x04 */ GRUB_KEYBOARD_KEY_F3, GRUB_KEYBOARD_KEY_F1, -- /* 0x06 */ GRUB_KEYBOARD_KEY_F2, GRUB_KEYBOARD_KEY_F12, -- /* 0x08 */ 0, GRUB_KEYBOARD_KEY_F10, -- /* 0x0a */ GRUB_KEYBOARD_KEY_F8, GRUB_KEYBOARD_KEY_F6, -- /* 0x0c */ GRUB_KEYBOARD_KEY_F4, GRUB_KEYBOARD_KEY_TAB, -- /* 0x0e */ GRUB_KEYBOARD_KEY_RQUOTE, 0, -- /* 0x10 */ 0, GRUB_KEYBOARD_KEY_LEFT_ALT, -- /* 0x12 */ GRUB_KEYBOARD_KEY_LEFT_SHIFT, 0, -- /* 0x14 */ GRUB_KEYBOARD_KEY_LEFT_CTRL, GRUB_KEYBOARD_KEY_Q, -- /* 0x16 */ GRUB_KEYBOARD_KEY_1, 0, -- /* 0x18 */ 0, 0, -- /* 0x1a */ GRUB_KEYBOARD_KEY_Z, GRUB_KEYBOARD_KEY_S, -- /* 0x1c */ GRUB_KEYBOARD_KEY_A, GRUB_KEYBOARD_KEY_W, -- /* 0x1e */ GRUB_KEYBOARD_KEY_2, 0, -- /* 0x20 */ 0, GRUB_KEYBOARD_KEY_C, -- /* 0x22 */ GRUB_KEYBOARD_KEY_X, GRUB_KEYBOARD_KEY_D, -- /* 0x24 */ GRUB_KEYBOARD_KEY_E, GRUB_KEYBOARD_KEY_4, -- /* 0x26 */ GRUB_KEYBOARD_KEY_3, 0, -- /* 0x28 */ 0, GRUB_KEYBOARD_KEY_SPACE, -- /* 0x2a */ GRUB_KEYBOARD_KEY_V, GRUB_KEYBOARD_KEY_F, -- /* 0x2c */ GRUB_KEYBOARD_KEY_T, GRUB_KEYBOARD_KEY_R, -- /* 0x2e */ GRUB_KEYBOARD_KEY_5, 0, -- /* 0x30 */ 0, GRUB_KEYBOARD_KEY_N, -- /* 0x32 */ GRUB_KEYBOARD_KEY_B, GRUB_KEYBOARD_KEY_H, -- /* 0x34 */ GRUB_KEYBOARD_KEY_G, GRUB_KEYBOARD_KEY_Y, -- /* 0x36 */ GRUB_KEYBOARD_KEY_6, 0, -- /* 0x38 */ 0, 0, -- /* 0x3a */ GRUB_KEYBOARD_KEY_M, GRUB_KEYBOARD_KEY_J, -- /* 0x3c */ GRUB_KEYBOARD_KEY_U, GRUB_KEYBOARD_KEY_7, -- /* 0x3e */ GRUB_KEYBOARD_KEY_8, 0, -- /* 0x40 */ 0, GRUB_KEYBOARD_KEY_COMMA, -- /* 0x42 */ GRUB_KEYBOARD_KEY_K, GRUB_KEYBOARD_KEY_I, -- /* 0x44 */ GRUB_KEYBOARD_KEY_O, GRUB_KEYBOARD_KEY_0, -- /* 0x46 */ GRUB_KEYBOARD_KEY_9, 0, -- /* 0x48 */ 0, GRUB_KEYBOARD_KEY_DOT, -- /* 0x4a */ GRUB_KEYBOARD_KEY_SLASH, GRUB_KEYBOARD_KEY_L, -- /* 0x4c */ GRUB_KEYBOARD_KEY_SEMICOLON, GRUB_KEYBOARD_KEY_P, -- /* 0x4e */ GRUB_KEYBOARD_KEY_DASH, 0, -- /* 0x50 */ 0, GRUB_KEYBOARD_KEY_JP_RO, -- /* 0x52 */ GRUB_KEYBOARD_KEY_DQUOTE, 0, -- /* 0x54 */ GRUB_KEYBOARD_KEY_LBRACKET, GRUB_KEYBOARD_KEY_EQUAL, -- /* 0x56 */ 0, 0, -- /* 0x58 */ GRUB_KEYBOARD_KEY_CAPS_LOCK, GRUB_KEYBOARD_KEY_RIGHT_SHIFT, -- /* 0x5a */ GRUB_KEYBOARD_KEY_ENTER, GRUB_KEYBOARD_KEY_RBRACKET, -- /* 0x5c */ 0, GRUB_KEYBOARD_KEY_BACKSLASH, -- /* 0x5e */ 0, 0, -- /* 0x60 */ 0, GRUB_KEYBOARD_KEY_102ND, -- /* 0x62 */ 0, 0, -- /* 0x64 */ 0, 0, -- /* 0x66 */ GRUB_KEYBOARD_KEY_BACKSPACE, 0, -- /* 0x68 */ 0, GRUB_KEYBOARD_KEY_NUM1, -- /* 0x6a */ GRUB_KEYBOARD_KEY_JP_YEN, GRUB_KEYBOARD_KEY_NUM4, -- /* 0x6c */ GRUB_KEYBOARD_KEY_NUM7, GRUB_KEYBOARD_KEY_KPCOMMA, -- /* 0x6e */ 0, 0, -- /* 0x70 */ GRUB_KEYBOARD_KEY_NUM0, GRUB_KEYBOARD_KEY_NUMDOT, -- /* 0x72 */ GRUB_KEYBOARD_KEY_NUM2, GRUB_KEYBOARD_KEY_NUM5, -- /* 0x74 */ GRUB_KEYBOARD_KEY_NUM6, GRUB_KEYBOARD_KEY_NUM8, -- /* 0x76 */ GRUB_KEYBOARD_KEY_ESCAPE, GRUB_KEYBOARD_KEY_NUM_LOCK, -- /* 0x78 */ GRUB_KEYBOARD_KEY_F11, GRUB_KEYBOARD_KEY_NUMPLUS, -- /* 0x7a */ GRUB_KEYBOARD_KEY_NUM3, GRUB_KEYBOARD_KEY_NUMMINUS, -- /* 0x7c */ GRUB_KEYBOARD_KEY_NUMMUL, GRUB_KEYBOARD_KEY_NUM9, -- /* 0x7e */ GRUB_KEYBOARD_KEY_SCROLL_LOCK, 0, -- /* 0x80 */ 0, 0, -- /* 0x82 */ 0, GRUB_KEYBOARD_KEY_F7, -- }; -- --static const struct --{ -- grub_uint8_t from, to; --} set2_e0_mapping[] = -- { -- {0x11, GRUB_KEYBOARD_KEY_RIGHT_ALT}, -- {0x14, GRUB_KEYBOARD_KEY_RIGHT_CTRL}, -- {0x4a, GRUB_KEYBOARD_KEY_NUMSLASH}, -- {0x5a, GRUB_KEYBOARD_KEY_NUMENTER}, -- {0x69, GRUB_KEYBOARD_KEY_END}, -- {0x6b, GRUB_KEYBOARD_KEY_LEFT}, -- {0x6c, GRUB_KEYBOARD_KEY_HOME}, -- {0x70, GRUB_KEYBOARD_KEY_INSERT}, -- {0x71, GRUB_KEYBOARD_KEY_DELETE}, -- {0x72, GRUB_KEYBOARD_KEY_DOWN}, -- {0x74, GRUB_KEYBOARD_KEY_RIGHT}, -- {0x75, GRUB_KEYBOARD_KEY_UP}, -- {0x7a, GRUB_KEYBOARD_KEY_NPAGE}, -- {0x7d, GRUB_KEYBOARD_KEY_PPAGE}, -- }; -+struct grub_ps2_state ps2_state; - - static int ping_sent; - -+static void -+grub_keyboard_controller_init (void); -+ - static void - keyboard_controller_wait_until_ready (void) - { -+ /* 50 us would be enough but our current time resolution is 1ms. */ -+ grub_millisleep (1); - while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS))); - } - -@@ -241,10 +52,11 @@ wait_ack (void) - grub_uint8_t ack; - - endtime = grub_get_time_ms () + 20; -- do -+ do { -+ keyboard_controller_wait_until_ready (); - ack = grub_inb (KEYBOARD_REG_DATA); -- while (ack != GRUB_AT_ACK && ack != GRUB_AT_NACK -- && grub_get_time_ms () < endtime); -+ } while (ack != GRUB_AT_ACK && ack != GRUB_AT_NACK -+ && grub_get_time_ms () < endtime); - return ack; - } - -@@ -326,12 +138,10 @@ query_mode (void) - if (!e) - return 0; - -- keyboard_controller_wait_until_ready (); -- -- do -+ do { -+ keyboard_controller_wait_until_ready (); - ret = grub_inb (KEYBOARD_REG_DATA); -- while (ret == GRUB_AT_ACK); -- -+ } while (ret == GRUB_AT_ACK); - /* QEMU translates the set even in no-translate mode. */ - if (ret == 0x43 || ret == 1) - return 1; -@@ -350,28 +160,32 @@ set_scancodes (void) - if (!grub_keyboard_orig_set) - { - grub_dprintf ("atkeyb", "No sets support assumed\n"); -- current_set = 1; -+ ps2_state.current_set = 1; - return; - } - - #if !USE_SCANCODE_SET -- current_set = 1; -+ ps2_state.current_set = 1; - return; - #else - - grub_keyboard_controller_write (grub_keyboard_controller_orig -- & ~KEYBOARD_AT_TRANSLATE); -+ & ~KEYBOARD_AT_TRANSLATE -+ & ~KEYBOARD_AT_DISABLE); -+ -+ keyboard_controller_wait_until_ready (); -+ grub_outb (KEYBOARD_COMMAND_ENABLE, KEYBOARD_REG_DATA); - - write_mode (2); -- current_set = query_mode (); -- grub_dprintf ("atkeyb", "returned set %d\n", current_set); -- if (current_set == 2) -+ ps2_state.current_set = query_mode (); -+ grub_dprintf ("atkeyb", "returned set %d\n", ps2_state.current_set); -+ if (ps2_state.current_set == 2) - return; - - write_mode (1); -- current_set = query_mode (); -- grub_dprintf ("atkeyb", "returned set %d\n", current_set); -- if (current_set == 1) -+ ps2_state.current_set = query_mode (); -+ grub_dprintf ("atkeyb", "returned set %d\n", ps2_state.current_set); -+ if (ps2_state.current_set == 1) - return; - grub_dprintf ("atkeyb", "no supported scancode set found\n"); - #endif -@@ -386,164 +200,10 @@ keyboard_controller_led (grub_uint8_t leds) - grub_outb (leds & 0x7, KEYBOARD_REG_DATA); - } - --static int --fetch_key (int *is_break) --{ -- int was_ext = 0; -- grub_uint8_t at_key; -- int ret = 0; -- -- if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS))) -- return -1; -- at_key = grub_inb (KEYBOARD_REG_DATA); -- /* May happen if no keyboard is connected. Just ignore this. */ -- if (at_key == 0xff) -- return -1; -- if (at_key == 0xe0) -- { -- e0_received = 1; -- return -1; -- } -- -- if ((current_set == 2 || current_set == 3) && at_key == 0xf0) -- { -- f0_received = 1; -- return -1; -- } -- -- /* Setting LEDs may generate ACKs. */ -- if (at_key == GRUB_AT_ACK) -- return -1; -- -- was_ext = e0_received; -- e0_received = 0; -- -- switch (current_set) -- { -- case 1: -- *is_break = !!(at_key & 0x80); -- if (!was_ext) -- ret = set1_mapping[at_key & 0x7f]; -- else -- { -- unsigned i; -- for (i = 0; i < ARRAY_SIZE (set1_e0_mapping); i++) -- if (set1_e0_mapping[i].from == (at_key & 0x7f)) -- { -- ret = set1_e0_mapping[i].to; -- break; -- } -- } -- break; -- case 2: -- *is_break = f0_received; -- f0_received = 0; -- if (!was_ext) -- ret = set2_mapping[at_key]; -- else -- { -- unsigned i; -- for (i = 0; i < ARRAY_SIZE (set2_e0_mapping); i++) -- if (set2_e0_mapping[i].from == at_key) -- { -- ret = set2_e0_mapping[i].to; -- break; -- } -- } -- break; -- default: -- return -1; -- } -- if (!ret) -- { -- if (was_ext) -- grub_dprintf ("atkeyb", "Unknown key 0xe0+0x%02x from set %d\n", -- at_key, current_set); -- else -- grub_dprintf ("atkeyb", "Unknown key 0x%02x from set %d\n", -- at_key, current_set); -- return -1; -- } -- return ret; --} -- --/* FIXME: This should become an interrupt service routine. For now -- it's just used to catch events from control keys. */ --static int --grub_keyboard_isr (grub_keyboard_key_t key, int is_break) --{ -- if (!is_break) -- switch (key) -- { -- case GRUB_KEYBOARD_KEY_LEFT_SHIFT: -- at_keyboard_status |= GRUB_TERM_STATUS_LSHIFT; -- return 1; -- case GRUB_KEYBOARD_KEY_RIGHT_SHIFT: -- at_keyboard_status |= GRUB_TERM_STATUS_RSHIFT; -- return 1; -- case GRUB_KEYBOARD_KEY_LEFT_CTRL: -- at_keyboard_status |= GRUB_TERM_STATUS_LCTRL; -- return 1; -- case GRUB_KEYBOARD_KEY_RIGHT_CTRL: -- at_keyboard_status |= GRUB_TERM_STATUS_RCTRL; -- return 1; -- case GRUB_KEYBOARD_KEY_RIGHT_ALT: -- at_keyboard_status |= GRUB_TERM_STATUS_RALT; -- return 1; -- case GRUB_KEYBOARD_KEY_LEFT_ALT: -- at_keyboard_status |= GRUB_TERM_STATUS_LALT; -- return 1; -- default: -- return 0; -- } -- else -- switch (key) -- { -- case GRUB_KEYBOARD_KEY_LEFT_SHIFT: -- at_keyboard_status &= ~GRUB_TERM_STATUS_LSHIFT; -- return 1; -- case GRUB_KEYBOARD_KEY_RIGHT_SHIFT: -- at_keyboard_status &= ~GRUB_TERM_STATUS_RSHIFT; -- return 1; -- case GRUB_KEYBOARD_KEY_LEFT_CTRL: -- at_keyboard_status &= ~GRUB_TERM_STATUS_LCTRL; -- return 1; -- case GRUB_KEYBOARD_KEY_RIGHT_CTRL: -- at_keyboard_status &= ~GRUB_TERM_STATUS_RCTRL; -- return 1; -- case GRUB_KEYBOARD_KEY_RIGHT_ALT: -- at_keyboard_status &= ~GRUB_TERM_STATUS_RALT; -- return 1; -- case GRUB_KEYBOARD_KEY_LEFT_ALT: -- at_keyboard_status &= ~GRUB_TERM_STATUS_LALT; -- return 1; -- default: -- return 0; -- } --} -- --/* If there is a raw key pending, return it; otherwise return -1. */ --static int --grub_keyboard_getkey (void) --{ -- int key; -- int is_break = 0; -- -- key = fetch_key (&is_break); -- if (key == -1) -- return -1; -- -- if (grub_keyboard_isr (key, is_break)) -- return -1; -- if (is_break) -- return -1; -- return key; --} -- - int - grub_at_keyboard_is_alive (void) - { -- if (current_set != 0) -+ if (ps2_state.current_set != 0) - return 1; - if (ping_sent - && KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS)) -@@ -566,51 +226,28 @@ grub_at_keyboard_is_alive (void) - static int - grub_at_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused))) - { -- int code; -+ grub_uint8_t at_key; -+ int ret; -+ grub_uint8_t old_led; - - if (!grub_at_keyboard_is_alive ()) - return GRUB_TERM_NO_KEY; - -- code = grub_keyboard_getkey (); -- if (code == -1) -- return GRUB_TERM_NO_KEY; --#ifdef DEBUG_AT_KEYBOARD -- grub_dprintf ("atkeyb", "Detected key 0x%x\n", code); --#endif -- switch (code) -- { -- case GRUB_KEYBOARD_KEY_CAPS_LOCK: -- at_keyboard_status ^= GRUB_TERM_STATUS_CAPS; -- led_status ^= KEYBOARD_LED_CAPS; -- keyboard_controller_led (led_status); -+ if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS))) -+ return -1; -+ at_key = grub_inb (KEYBOARD_REG_DATA); -+ old_led = ps2_state.led_status; - --#ifdef DEBUG_AT_KEYBOARD -- grub_dprintf ("atkeyb", "caps_lock = %d\n", !!(at_keyboard_status & GRUB_KEYBOARD_STATUS_CAPS_LOCK)); --#endif -- return GRUB_TERM_NO_KEY; -- case GRUB_KEYBOARD_KEY_NUM_LOCK: -- at_keyboard_status ^= GRUB_TERM_STATUS_NUM; -- led_status ^= KEYBOARD_LED_NUM; -- keyboard_controller_led (led_status); -- --#ifdef DEBUG_AT_KEYBOARD -- grub_dprintf ("atkeyb", "num_lock = %d\n", !!(at_keyboard_status & GRUB_KEYBOARD_STATUS_NUM_LOCK)); --#endif -- return GRUB_TERM_NO_KEY; -- case GRUB_KEYBOARD_KEY_SCROLL_LOCK: -- at_keyboard_status ^= GRUB_TERM_STATUS_SCROLL; -- led_status ^= KEYBOARD_LED_SCROLL; -- keyboard_controller_led (led_status); -- return GRUB_TERM_NO_KEY; -- default: -- return grub_term_map_key (code, at_keyboard_status); -- } -+ ret = grub_ps2_process_incoming_byte (&ps2_state, at_key); -+ if (old_led != ps2_state.led_status) -+ keyboard_controller_led (ps2_state.led_status); -+ return ret; - } - - static void - grub_keyboard_controller_init (void) - { -- at_keyboard_status = 0; -+ ps2_state.at_keyboard_status = 0; - /* Drain input buffer. */ - while (1) - { -@@ -632,13 +269,13 @@ grub_keyboard_controller_init (void) - grub_keyboard_orig_set = query_mode (); - #endif - set_scancodes (); -- keyboard_controller_led (led_status); -+ keyboard_controller_led (ps2_state.led_status); - } - - static grub_err_t - grub_keyboard_controller_fini (struct grub_term_input *term __attribute__ ((unused))) - { -- if (current_set == 0) -+ if (ps2_state.current_set == 0) - return GRUB_ERR_NONE; - if (grub_keyboard_orig_set) - write_mode (grub_keyboard_orig_set); -@@ -655,7 +292,7 @@ grub_at_fini_hw (int noreturn __attribute__ ((unused))) - static grub_err_t - grub_at_restore_hw (void) - { -- if (current_set == 0) -+ if (ps2_state.current_set == 0) - return GRUB_ERR_NONE; - - /* Drain input buffer. */ -@@ -668,7 +305,7 @@ grub_at_restore_hw (void) - grub_inb (KEYBOARD_REG_DATA); - } - set_scancodes (); -- keyboard_controller_led (led_status); -+ keyboard_controller_led (ps2_state.led_status); - - return GRUB_ERR_NONE; - } -diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c -index 7d31095b1ef8d01886a0516343f2e5c5601265dd..4840cc59d3f68944fb2ca6b40cc6488e74b5da02 100644 ---- a/grub-core/term/efi/console.c -+++ b/grub-core/term/efi/console.c -@@ -104,7 +104,7 @@ const unsigned efi_codes[] = - GRUB_TERM_KEY_DC, GRUB_TERM_KEY_PPAGE, GRUB_TERM_KEY_NPAGE, GRUB_TERM_KEY_F1, - GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3, GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5, - GRUB_TERM_KEY_F6, GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9, -- GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12, '\e' -+ GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12, GRUB_TERM_ESC - }; - - static int -@@ -122,6 +122,9 @@ grub_efi_translate_key (grub_efi_input_key_t key) - else - return key.unicode_char; - } -+ /* Some devices send enter with scan_code 0x0d (F3) and unicode_char 0x0d. */ -+ else if (key.scan_code == '\r' && key.unicode_char == '\r') -+ return key.unicode_char; - else if (key.scan_code < ARRAY_SIZE (efi_codes)) - return efi_codes[key.scan_code]; - -diff --git a/grub-core/term/i386/coreboot/cbmemc.c b/grub-core/term/i386/coreboot/cbmemc.c -index 25e64a05c03286f644b39398e9e68cbdde333510..cea9b84315bdaf3b1238acc915f35ba6148ffbcf 100644 ---- a/grub-core/term/i386/coreboot/cbmemc.c -+++ b/grub-core/term/i386/coreboot/cbmemc.c -@@ -23,17 +23,20 @@ - #include - #include - #include --#include -+#include - #include - #include - - GRUB_MOD_LICENSE ("GPLv3+"); - -+#define CURSOR_MASK ((1 << 28) - 1) -+#define OVERFLOW (1 << 31) -+ - struct grub_linuxbios_cbmemc - { - grub_uint32_t size; -- grub_uint32_t pointer; -- char data[0]; -+ grub_uint32_t cursor; -+ char body[0]; - }; - - static struct grub_linuxbios_cbmemc *cbmemc; -@@ -41,11 +44,20 @@ static struct grub_linuxbios_cbmemc *cbmemc; - static void - put (struct grub_term_output *term __attribute__ ((unused)), const int c) - { -+ grub_uint32_t flags, cursor; - if (!cbmemc) - return; -- if (cbmemc->pointer < cbmemc->size) -- cbmemc->data[cbmemc->pointer] = c; -- cbmemc->pointer++; -+ flags = cbmemc->cursor & ~CURSOR_MASK; -+ cursor = cbmemc->cursor & CURSOR_MASK; -+ if (cursor >= cbmemc->size) -+ return; -+ cbmemc->body[cursor++] = c; -+ if (cursor >= cbmemc->size) -+ { -+ cursor = 0; -+ flags |= OVERFLOW; -+ } -+ cbmemc->cursor = flags | cursor; - } - - struct grub_terminfo_output_state grub_cbmemc_terminfo_output = -@@ -87,21 +99,29 @@ grub_cmd_cbmemc (struct grub_command *cmd __attribute__ ((unused)), - int argc __attribute__ ((unused)), - char *argv[] __attribute__ ((unused))) - { -- grub_size_t len; -- char *str; -- struct grub_linuxbios_cbmemc *cbmemc_saved; -+ grub_size_t size, cursor; -+ struct grub_linuxbios_cbmemc *real_cbmemc; - - if (!cbmemc) - return grub_error (GRUB_ERR_IO, "no CBMEM console found"); - -- len = cbmemc->pointer; -- if (len > cbmemc->size) -- len = cbmemc->size; -- str = cbmemc->data; -- cbmemc_saved = cbmemc; -+ real_cbmemc = cbmemc; - cbmemc = 0; -- grub_xnputs (str, len); -- cbmemc = cbmemc_saved; -+ cursor = real_cbmemc->cursor & CURSOR_MASK; -+ if (!(real_cbmemc->cursor & OVERFLOW) && cursor < real_cbmemc->size) -+ size = cursor; -+ else -+ size = real_cbmemc->size; -+ if (real_cbmemc->cursor & OVERFLOW) -+ { -+ if (cursor > size) -+ cursor = 0; -+ grub_xnputs(real_cbmemc->body + cursor, size - cursor); -+ grub_xnputs(real_cbmemc->body, cursor); -+ } -+ else -+ grub_xnputs(real_cbmemc->body, size); -+ cbmemc = real_cbmemc; - return 0; - } - -diff --git a/grub-core/term/i386/pc/console.c b/grub-core/term/i386/pc/console.c -index 28de46b576a667fd40c5852b16a4bcc3ea681849..f6142a2dea8036f5301c81a9e2fbd5ddbff5fd90 100644 ---- a/grub-core/term/i386/pc/console.c -+++ b/grub-core/term/i386/pc/console.c -@@ -204,7 +204,7 @@ static int - grub_console_getkey (struct grub_term_input *term __attribute__ ((unused))) - { - const grub_uint16_t bypass_table[] = { -- 0x0100 | '\e', 0x0f00 | '\t', 0x0e00 | '\b', 0x1c00 | '\r', 0x1c00 | '\n' -+ 0x0100 | GRUB_TERM_ESC, 0x0f00 | GRUB_TERM_TAB, 0x0e00 | GRUB_TERM_BACKSPACE, 0x1c00 | '\r', 0x1c00 | '\n' - }; - struct grub_bios_int_registers regs; - unsigned i; -diff --git a/grub-core/term/ps2.c b/grub-core/term/ps2.c -new file mode 100644 -index 0000000000000000000000000000000000000000..7ae4e9f2f8cd4a0ba4405c21581f906f7b458379 ---- /dev/null -+++ b/grub-core/term/ps2.c -@@ -0,0 +1,387 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2007,2008,2009 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#define KEYBOARD_LED_SCROLL (1 << 0) -+#define KEYBOARD_LED_NUM (1 << 1) -+#define KEYBOARD_LED_CAPS (1 << 2) -+ -+static const grub_uint8_t set1_mapping[128] = -+ { -+ /* 0x00 */ 0 /* Unused */, GRUB_KEYBOARD_KEY_ESCAPE, -+ /* 0x02 */ GRUB_KEYBOARD_KEY_1, GRUB_KEYBOARD_KEY_2, -+ /* 0x04 */ GRUB_KEYBOARD_KEY_3, GRUB_KEYBOARD_KEY_4, -+ /* 0x06 */ GRUB_KEYBOARD_KEY_5, GRUB_KEYBOARD_KEY_6, -+ /* 0x08 */ GRUB_KEYBOARD_KEY_7, GRUB_KEYBOARD_KEY_8, -+ /* 0x0a */ GRUB_KEYBOARD_KEY_9, GRUB_KEYBOARD_KEY_0, -+ /* 0x0c */ GRUB_KEYBOARD_KEY_DASH, GRUB_KEYBOARD_KEY_EQUAL, -+ /* 0x0e */ GRUB_KEYBOARD_KEY_BACKSPACE, GRUB_KEYBOARD_KEY_TAB, -+ /* 0x10 */ GRUB_KEYBOARD_KEY_Q, GRUB_KEYBOARD_KEY_W, -+ /* 0x12 */ GRUB_KEYBOARD_KEY_E, GRUB_KEYBOARD_KEY_R, -+ /* 0x14 */ GRUB_KEYBOARD_KEY_T, GRUB_KEYBOARD_KEY_Y, -+ /* 0x16 */ GRUB_KEYBOARD_KEY_U, GRUB_KEYBOARD_KEY_I, -+ /* 0x18 */ GRUB_KEYBOARD_KEY_O, GRUB_KEYBOARD_KEY_P, -+ /* 0x1a */ GRUB_KEYBOARD_KEY_LBRACKET, GRUB_KEYBOARD_KEY_RBRACKET, -+ /* 0x1c */ GRUB_KEYBOARD_KEY_ENTER, GRUB_KEYBOARD_KEY_LEFT_CTRL, -+ /* 0x1e */ GRUB_KEYBOARD_KEY_A, GRUB_KEYBOARD_KEY_S, -+ /* 0x20 */ GRUB_KEYBOARD_KEY_D, GRUB_KEYBOARD_KEY_F, -+ /* 0x22 */ GRUB_KEYBOARD_KEY_G, GRUB_KEYBOARD_KEY_H, -+ /* 0x24 */ GRUB_KEYBOARD_KEY_J, GRUB_KEYBOARD_KEY_K, -+ /* 0x26 */ GRUB_KEYBOARD_KEY_L, GRUB_KEYBOARD_KEY_SEMICOLON, -+ /* 0x28 */ GRUB_KEYBOARD_KEY_DQUOTE, GRUB_KEYBOARD_KEY_RQUOTE, -+ /* 0x2a */ GRUB_KEYBOARD_KEY_LEFT_SHIFT, GRUB_KEYBOARD_KEY_BACKSLASH, -+ /* 0x2c */ GRUB_KEYBOARD_KEY_Z, GRUB_KEYBOARD_KEY_X, -+ /* 0x2e */ GRUB_KEYBOARD_KEY_C, GRUB_KEYBOARD_KEY_V, -+ /* 0x30 */ GRUB_KEYBOARD_KEY_B, GRUB_KEYBOARD_KEY_N, -+ /* 0x32 */ GRUB_KEYBOARD_KEY_M, GRUB_KEYBOARD_KEY_COMMA, -+ /* 0x34 */ GRUB_KEYBOARD_KEY_DOT, GRUB_KEYBOARD_KEY_SLASH, -+ /* 0x36 */ GRUB_KEYBOARD_KEY_RIGHT_SHIFT, GRUB_KEYBOARD_KEY_NUMMUL, -+ /* 0x38 */ GRUB_KEYBOARD_KEY_LEFT_ALT, GRUB_KEYBOARD_KEY_SPACE, -+ /* 0x3a */ GRUB_KEYBOARD_KEY_CAPS_LOCK, GRUB_KEYBOARD_KEY_F1, -+ /* 0x3c */ GRUB_KEYBOARD_KEY_F2, GRUB_KEYBOARD_KEY_F3, -+ /* 0x3e */ GRUB_KEYBOARD_KEY_F4, GRUB_KEYBOARD_KEY_F5, -+ /* 0x40 */ GRUB_KEYBOARD_KEY_F6, GRUB_KEYBOARD_KEY_F7, -+ /* 0x42 */ GRUB_KEYBOARD_KEY_F8, GRUB_KEYBOARD_KEY_F9, -+ /* 0x44 */ GRUB_KEYBOARD_KEY_F10, GRUB_KEYBOARD_KEY_NUM_LOCK, -+ /* 0x46 */ GRUB_KEYBOARD_KEY_SCROLL_LOCK, GRUB_KEYBOARD_KEY_NUM7, -+ /* 0x48 */ GRUB_KEYBOARD_KEY_NUM8, GRUB_KEYBOARD_KEY_NUM9, -+ /* 0x4a */ GRUB_KEYBOARD_KEY_NUMMINUS, GRUB_KEYBOARD_KEY_NUM4, -+ /* 0x4c */ GRUB_KEYBOARD_KEY_NUM5, GRUB_KEYBOARD_KEY_NUM6, -+ /* 0x4e */ GRUB_KEYBOARD_KEY_NUMPLUS, GRUB_KEYBOARD_KEY_NUM1, -+ /* 0x50 */ GRUB_KEYBOARD_KEY_NUM2, GRUB_KEYBOARD_KEY_NUM3, -+ /* 0x52 */ GRUB_KEYBOARD_KEY_NUM0, GRUB_KEYBOARD_KEY_NUMDOT, -+ /* 0x54 */ 0, 0, -+ /* 0x56 */ GRUB_KEYBOARD_KEY_102ND, GRUB_KEYBOARD_KEY_F11, -+ /* 0x58 */ GRUB_KEYBOARD_KEY_F12, 0, -+ /* 0x5a */ 0, 0, -+ /* 0x5c */ 0, 0, -+ /* 0x5e */ 0, 0, -+ /* 0x60 */ 0, 0, -+ /* 0x62 */ 0, 0, -+ /* OLPC keys. Just mapped to normal keys. */ -+ /* 0x64 */ 0, GRUB_KEYBOARD_KEY_UP, -+ /* 0x66 */ GRUB_KEYBOARD_KEY_DOWN, GRUB_KEYBOARD_KEY_LEFT, -+ /* 0x68 */ GRUB_KEYBOARD_KEY_RIGHT, 0, -+ /* 0x6a */ 0, 0, -+ /* 0x6c */ 0, 0, -+ /* 0x6e */ 0, 0, -+ /* 0x70 */ 0, 0, -+ /* 0x72 */ 0, GRUB_KEYBOARD_KEY_JP_RO, -+ /* 0x74 */ 0, 0, -+ /* 0x76 */ 0, 0, -+ /* 0x78 */ 0, 0, -+ /* 0x7a */ 0, 0, -+ /* 0x7c */ 0, GRUB_KEYBOARD_KEY_JP_YEN, -+ /* 0x7e */ GRUB_KEYBOARD_KEY_KPCOMMA -+ }; -+ -+static const struct -+{ -+ grub_uint8_t from, to; -+} set1_e0_mapping[] = -+ { -+ {0x1c, GRUB_KEYBOARD_KEY_NUMENTER}, -+ {0x1d, GRUB_KEYBOARD_KEY_RIGHT_CTRL}, -+ {0x35, GRUB_KEYBOARD_KEY_NUMSLASH }, -+ {0x38, GRUB_KEYBOARD_KEY_RIGHT_ALT}, -+ {0x47, GRUB_KEYBOARD_KEY_HOME}, -+ {0x48, GRUB_KEYBOARD_KEY_UP}, -+ {0x49, GRUB_KEYBOARD_KEY_PPAGE}, -+ {0x4b, GRUB_KEYBOARD_KEY_LEFT}, -+ {0x4d, GRUB_KEYBOARD_KEY_RIGHT}, -+ {0x4f, GRUB_KEYBOARD_KEY_END}, -+ {0x50, GRUB_KEYBOARD_KEY_DOWN}, -+ {0x51, GRUB_KEYBOARD_KEY_NPAGE}, -+ {0x52, GRUB_KEYBOARD_KEY_INSERT}, -+ {0x53, GRUB_KEYBOARD_KEY_DELETE}, -+ }; -+ -+static const grub_uint8_t set2_mapping[256] = -+ { -+ /* 0x00 */ 0, GRUB_KEYBOARD_KEY_F9, -+ /* 0x02 */ 0, GRUB_KEYBOARD_KEY_F5, -+ /* 0x04 */ GRUB_KEYBOARD_KEY_F3, GRUB_KEYBOARD_KEY_F1, -+ /* 0x06 */ GRUB_KEYBOARD_KEY_F2, GRUB_KEYBOARD_KEY_F12, -+ /* 0x08 */ 0, GRUB_KEYBOARD_KEY_F10, -+ /* 0x0a */ GRUB_KEYBOARD_KEY_F8, GRUB_KEYBOARD_KEY_F6, -+ /* 0x0c */ GRUB_KEYBOARD_KEY_F4, GRUB_KEYBOARD_KEY_TAB, -+ /* 0x0e */ GRUB_KEYBOARD_KEY_RQUOTE, 0, -+ /* 0x10 */ 0, GRUB_KEYBOARD_KEY_LEFT_ALT, -+ /* 0x12 */ GRUB_KEYBOARD_KEY_LEFT_SHIFT, 0, -+ /* 0x14 */ GRUB_KEYBOARD_KEY_LEFT_CTRL, GRUB_KEYBOARD_KEY_Q, -+ /* 0x16 */ GRUB_KEYBOARD_KEY_1, 0, -+ /* 0x18 */ 0, 0, -+ /* 0x1a */ GRUB_KEYBOARD_KEY_Z, GRUB_KEYBOARD_KEY_S, -+ /* 0x1c */ GRUB_KEYBOARD_KEY_A, GRUB_KEYBOARD_KEY_W, -+ /* 0x1e */ GRUB_KEYBOARD_KEY_2, 0, -+ /* 0x20 */ 0, GRUB_KEYBOARD_KEY_C, -+ /* 0x22 */ GRUB_KEYBOARD_KEY_X, GRUB_KEYBOARD_KEY_D, -+ /* 0x24 */ GRUB_KEYBOARD_KEY_E, GRUB_KEYBOARD_KEY_4, -+ /* 0x26 */ GRUB_KEYBOARD_KEY_3, 0, -+ /* 0x28 */ 0, GRUB_KEYBOARD_KEY_SPACE, -+ /* 0x2a */ GRUB_KEYBOARD_KEY_V, GRUB_KEYBOARD_KEY_F, -+ /* 0x2c */ GRUB_KEYBOARD_KEY_T, GRUB_KEYBOARD_KEY_R, -+ /* 0x2e */ GRUB_KEYBOARD_KEY_5, 0, -+ /* 0x30 */ 0, GRUB_KEYBOARD_KEY_N, -+ /* 0x32 */ GRUB_KEYBOARD_KEY_B, GRUB_KEYBOARD_KEY_H, -+ /* 0x34 */ GRUB_KEYBOARD_KEY_G, GRUB_KEYBOARD_KEY_Y, -+ /* 0x36 */ GRUB_KEYBOARD_KEY_6, 0, -+ /* 0x38 */ 0, 0, -+ /* 0x3a */ GRUB_KEYBOARD_KEY_M, GRUB_KEYBOARD_KEY_J, -+ /* 0x3c */ GRUB_KEYBOARD_KEY_U, GRUB_KEYBOARD_KEY_7, -+ /* 0x3e */ GRUB_KEYBOARD_KEY_8, 0, -+ /* 0x40 */ 0, GRUB_KEYBOARD_KEY_COMMA, -+ /* 0x42 */ GRUB_KEYBOARD_KEY_K, GRUB_KEYBOARD_KEY_I, -+ /* 0x44 */ GRUB_KEYBOARD_KEY_O, GRUB_KEYBOARD_KEY_0, -+ /* 0x46 */ GRUB_KEYBOARD_KEY_9, 0, -+ /* 0x48 */ 0, GRUB_KEYBOARD_KEY_DOT, -+ /* 0x4a */ GRUB_KEYBOARD_KEY_SLASH, GRUB_KEYBOARD_KEY_L, -+ /* 0x4c */ GRUB_KEYBOARD_KEY_SEMICOLON, GRUB_KEYBOARD_KEY_P, -+ /* 0x4e */ GRUB_KEYBOARD_KEY_DASH, 0, -+ /* 0x50 */ 0, GRUB_KEYBOARD_KEY_JP_RO, -+ /* 0x52 */ GRUB_KEYBOARD_KEY_DQUOTE, 0, -+ /* 0x54 */ GRUB_KEYBOARD_KEY_LBRACKET, GRUB_KEYBOARD_KEY_EQUAL, -+ /* 0x56 */ 0, 0, -+ /* 0x58 */ GRUB_KEYBOARD_KEY_CAPS_LOCK, GRUB_KEYBOARD_KEY_RIGHT_SHIFT, -+ /* 0x5a */ GRUB_KEYBOARD_KEY_ENTER, GRUB_KEYBOARD_KEY_RBRACKET, -+ /* 0x5c */ 0, GRUB_KEYBOARD_KEY_BACKSLASH, -+ /* 0x5e */ 0, 0, -+ /* 0x60 */ 0, GRUB_KEYBOARD_KEY_102ND, -+ /* 0x62 */ 0, 0, -+ /* 0x64 */ 0, 0, -+ /* 0x66 */ GRUB_KEYBOARD_KEY_BACKSPACE, 0, -+ /* 0x68 */ 0, GRUB_KEYBOARD_KEY_NUM1, -+ /* 0x6a */ GRUB_KEYBOARD_KEY_JP_YEN, GRUB_KEYBOARD_KEY_NUM4, -+ /* 0x6c */ GRUB_KEYBOARD_KEY_NUM7, GRUB_KEYBOARD_KEY_KPCOMMA, -+ /* 0x6e */ 0, 0, -+ /* 0x70 */ GRUB_KEYBOARD_KEY_NUM0, GRUB_KEYBOARD_KEY_NUMDOT, -+ /* 0x72 */ GRUB_KEYBOARD_KEY_NUM2, GRUB_KEYBOARD_KEY_NUM5, -+ /* 0x74 */ GRUB_KEYBOARD_KEY_NUM6, GRUB_KEYBOARD_KEY_NUM8, -+ /* 0x76 */ GRUB_KEYBOARD_KEY_ESCAPE, GRUB_KEYBOARD_KEY_NUM_LOCK, -+ /* 0x78 */ GRUB_KEYBOARD_KEY_F11, GRUB_KEYBOARD_KEY_NUMPLUS, -+ /* 0x7a */ GRUB_KEYBOARD_KEY_NUM3, GRUB_KEYBOARD_KEY_NUMMINUS, -+ /* 0x7c */ GRUB_KEYBOARD_KEY_NUMMUL, GRUB_KEYBOARD_KEY_NUM9, -+ /* 0x7e */ GRUB_KEYBOARD_KEY_SCROLL_LOCK, 0, -+ /* 0x80 */ 0, 0, -+ /* 0x82 */ 0, GRUB_KEYBOARD_KEY_F7, -+ }; -+ -+static const struct -+{ -+ grub_uint8_t from, to; -+} set2_e0_mapping[] = -+ { -+ {0x11, GRUB_KEYBOARD_KEY_RIGHT_ALT}, -+ {0x14, GRUB_KEYBOARD_KEY_RIGHT_CTRL}, -+ {0x4a, GRUB_KEYBOARD_KEY_NUMSLASH}, -+ {0x5a, GRUB_KEYBOARD_KEY_NUMENTER}, -+ {0x69, GRUB_KEYBOARD_KEY_END}, -+ {0x6b, GRUB_KEYBOARD_KEY_LEFT}, -+ {0x6c, GRUB_KEYBOARD_KEY_HOME}, -+ {0x70, GRUB_KEYBOARD_KEY_INSERT}, -+ {0x71, GRUB_KEYBOARD_KEY_DELETE}, -+ {0x72, GRUB_KEYBOARD_KEY_DOWN}, -+ {0x74, GRUB_KEYBOARD_KEY_RIGHT}, -+ {0x75, GRUB_KEYBOARD_KEY_UP}, -+ {0x7a, GRUB_KEYBOARD_KEY_NPAGE}, -+ {0x7d, GRUB_KEYBOARD_KEY_PPAGE}, -+ }; -+ -+static int -+fetch_key (struct grub_ps2_state *ps2_state, grub_uint8_t at_key, int *is_break) -+{ -+ int was_ext = 0; -+ int ret = 0; -+ -+ /* May happen if no keyboard is connected. Just ignore this. */ -+ if (at_key == 0xff) -+ return -1; -+ if (at_key == 0xe0) -+ { -+ ps2_state->e0_received = 1; -+ return -1; -+ } -+ -+ if ((ps2_state->current_set == 2 || ps2_state->current_set == 3) && at_key == 0xf0) -+ { -+ ps2_state->f0_received = 1; -+ return -1; -+ } -+ -+ /* Setting LEDs may generate ACKs. */ -+ if (at_key == GRUB_AT_ACK) -+ return -1; -+ -+ was_ext = ps2_state->e0_received; -+ ps2_state->e0_received = 0; -+ -+ switch (ps2_state->current_set) -+ { -+ case 1: -+ *is_break = !!(at_key & 0x80); -+ if (!was_ext) -+ ret = set1_mapping[at_key & 0x7f]; -+ else -+ { -+ unsigned i; -+ for (i = 0; i < ARRAY_SIZE (set1_e0_mapping); i++) -+ if (set1_e0_mapping[i].from == (at_key & 0x7f)) -+ { -+ ret = set1_e0_mapping[i].to; -+ break; -+ } -+ } -+ break; -+ case 2: -+ *is_break = ps2_state->f0_received; -+ ps2_state->f0_received = 0; -+ if (!was_ext) -+ ret = set2_mapping[at_key]; -+ else -+ { -+ unsigned i; -+ for (i = 0; i < ARRAY_SIZE (set2_e0_mapping); i++) -+ if (set2_e0_mapping[i].from == at_key) -+ { -+ ret = set2_e0_mapping[i].to; -+ break; -+ } -+ } -+ break; -+ default: -+ return -1; -+ } -+ if (!ret) -+ { -+ if (was_ext) -+ grub_dprintf ("atkeyb", "Unknown key 0xe0+0x%02x from set %d\n", -+ at_key, ps2_state->current_set); -+ else -+ grub_dprintf ("atkeyb", "Unknown key 0x%02x from set %d\n", -+ at_key, ps2_state->current_set); -+ return -1; -+ } -+ return ret; -+} -+ -+/* FIXME: This should become an interrupt service routine. For now -+ it's just used to catch events from control keys. */ -+static int -+grub_keyboard_isr (struct grub_ps2_state *ps2_state, -+ grub_keyboard_key_t key, int is_break) -+{ -+ if (!is_break) -+ switch (key) -+ { -+ case GRUB_KEYBOARD_KEY_LEFT_SHIFT: -+ ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_LSHIFT; -+ return 1; -+ case GRUB_KEYBOARD_KEY_RIGHT_SHIFT: -+ ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_RSHIFT; -+ return 1; -+ case GRUB_KEYBOARD_KEY_LEFT_CTRL: -+ ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_LCTRL; -+ return 1; -+ case GRUB_KEYBOARD_KEY_RIGHT_CTRL: -+ ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_RCTRL; -+ return 1; -+ case GRUB_KEYBOARD_KEY_RIGHT_ALT: -+ ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_RALT; -+ return 1; -+ case GRUB_KEYBOARD_KEY_LEFT_ALT: -+ ps2_state->at_keyboard_status |= GRUB_TERM_STATUS_LALT; -+ return 1; -+ default: -+ return 0; -+ } -+ else -+ switch (key) -+ { -+ case GRUB_KEYBOARD_KEY_LEFT_SHIFT: -+ ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_LSHIFT; -+ return 1; -+ case GRUB_KEYBOARD_KEY_RIGHT_SHIFT: -+ ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_RSHIFT; -+ return 1; -+ case GRUB_KEYBOARD_KEY_LEFT_CTRL: -+ ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_LCTRL; -+ return 1; -+ case GRUB_KEYBOARD_KEY_RIGHT_CTRL: -+ ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_RCTRL; -+ return 1; -+ case GRUB_KEYBOARD_KEY_RIGHT_ALT: -+ ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_RALT; -+ return 1; -+ case GRUB_KEYBOARD_KEY_LEFT_ALT: -+ ps2_state->at_keyboard_status &= ~GRUB_TERM_STATUS_LALT; -+ return 1; -+ default: -+ return 0; -+ } -+} -+ -+/* If there is a key pending, return it; otherwise return GRUB_TERM_NO_KEY. */ -+int -+grub_ps2_process_incoming_byte (struct grub_ps2_state *ps2_state, -+ grub_uint8_t at_key) -+{ -+ int code; -+ int is_break = 0; -+ -+ code = fetch_key (ps2_state, at_key, &is_break); -+ if (code == -1) -+ return GRUB_TERM_NO_KEY; -+ -+ if (grub_keyboard_isr (ps2_state, code, is_break)) -+ return GRUB_TERM_NO_KEY; -+ if (is_break) -+ return GRUB_TERM_NO_KEY; -+#ifdef DEBUG_AT_KEYBOARD -+ grub_dprintf ("atkeyb", "Detected key 0x%x\n", code); -+#endif -+ switch (code) -+ { -+ case GRUB_KEYBOARD_KEY_CAPS_LOCK: -+ ps2_state->at_keyboard_status ^= GRUB_TERM_STATUS_CAPS; -+ ps2_state->led_status ^= KEYBOARD_LED_CAPS; -+ -+#ifdef DEBUG_AT_KEYBOARD -+ grub_dprintf ("atkeyb", "caps_lock = %d\n", !!(ps2_state->at_keyboard_status & GRUB_KEYBOARD_STATUS_CAPS_LOCK)); -+#endif -+ return GRUB_TERM_NO_KEY; -+ case GRUB_KEYBOARD_KEY_NUM_LOCK: -+ ps2_state->at_keyboard_status ^= GRUB_TERM_STATUS_NUM; -+ ps2_state->led_status ^= KEYBOARD_LED_NUM; -+ -+#ifdef DEBUG_AT_KEYBOARD -+ grub_dprintf ("atkeyb", "num_lock = %d\n", !!(ps2_state->at_keyboard_status & GRUB_KEYBOARD_STATUS_NUM_LOCK)); -+#endif -+ return GRUB_TERM_NO_KEY; -+ case GRUB_KEYBOARD_KEY_SCROLL_LOCK: -+ ps2_state->at_keyboard_status ^= GRUB_TERM_STATUS_SCROLL; -+ ps2_state->led_status ^= KEYBOARD_LED_SCROLL; -+ return GRUB_TERM_NO_KEY; -+ default: -+ return grub_term_map_key (code, ps2_state->at_keyboard_status); -+ } -+} -diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c -index f0d3e3debc60aa8dd04a5643a8a0537ffb88ec26..d317efa368d846963743a243fd672026a2221933 100644 ---- a/grub-core/term/terminfo.c -+++ b/grub-core/term/terminfo.c -@@ -426,12 +426,12 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, - } - *len = 1; - keys[0] = c; -- if (c != ANSI_CSI && c != '\e') -+ if (c != ANSI_CSI && c != GRUB_TERM_ESC) - { - /* Backspace: Ctrl-h. */ - if (c == 0x7f) -- c = '\b'; -- if (c < 0x20 && c != '\t' && c!= '\b' && c != '\n' && c != '\r') -+ c = GRUB_TERM_BACKSPACE; -+ if (c < 0x20 && c != GRUB_TERM_TAB && c!= GRUB_TERM_BACKSPACE && c != '\n' && c != '\r') - c = GRUB_TERM_CTRL | (c - 1 + 'a'); - *len = 1; - keys[0] = c; -@@ -487,7 +487,7 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, - GRUB_TERM_KEY_HOME, GRUB_TERM_KEY_END }; - unsigned i; - -- if (c == '\e') -+ if (c == GRUB_TERM_ESC) - { - CONTINUE_READ; - -@@ -606,7 +606,7 @@ grub_terminfo_getkey (struct grub_term_input *termi) - &data->npending, data->readkey); - - #if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275) -- if (data->npending == 1 && data->input_buf[0] == '\e' -+ if (data->npending == 1 && data->input_buf[0] == GRUB_TERM_ESC - && grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_REPEAT) - && grub_get_time_ms () - data->last_key_time < 1000 - && (data->last_key & GRUB_TERM_EXTENDED)) -diff --git a/grub-core/tests/cmdline_cat_test.c b/grub-core/tests/cmdline_cat_test.c -index f1e21439e2be229d386cb310d62164fc9a5f4f92..baea7688a1d3c49d37a2c03e585109ccd04328f8 100644 ---- a/grub-core/tests/cmdline_cat_test.c -+++ b/grub-core/tests/cmdline_cat_test.c -@@ -103,7 +103,7 @@ cmdline_cat_test (void) - '/', 't', 'e', 's', 't', '.', - 't', 'x', 't', '\n', - GRUB_TERM_NO_KEY, -- GRUB_TERM_NO_KEY, '\e'}, -+ GRUB_TERM_NO_KEY, GRUB_TERM_ESC}, - 23); - - grub_video_checksum ("cmdline_cat"); -diff --git a/grub-core/tests/gfxterm_menu.c b/grub-core/tests/gfxterm_menu.c -index 8f63dc27a35bd769ecb5d94599de3ba9e97cf5dc..12836fb96598d98b5cbf371a953e6ec702eb50de 100644 ---- a/grub-core/tests/gfxterm_menu.c -+++ b/grub-core/tests/gfxterm_menu.c -@@ -146,7 +146,7 @@ gfxterm_menu (void) - return; - } - grub_terminal_input_fake_sequence ((int []) { -1, -1, -1, GRUB_TERM_KEY_DOWN, -1, 'e', -- -1, GRUB_TERM_KEY_RIGHT, -1, 'x', -1, '\e', -1, '\e' }, 14); -+ -1, GRUB_TERM_KEY_RIGHT, -1, 'x', -1, GRUB_TERM_ESC, -1, GRUB_TERM_ESC }, 14); - - grub_video_checksum (tests[j].name); - -diff --git a/grub-core/tests/lib/functional_test.c b/grub-core/tests/lib/functional_test.c -index d4822a12456525e4abc5f587bc897364db4e52b7..96781fb39b5f37b201345f60fe4297629bb672cf 100644 ---- a/grub-core/tests/lib/functional_test.c -+++ b/grub-core/tests/lib/functional_test.c -@@ -26,14 +26,23 @@ GRUB_MOD_LICENSE ("GPLv3+"); - - static grub_err_t - grub_functional_test (grub_extcmd_context_t ctxt __attribute__ ((unused)), -- int argc __attribute__ ((unused)), -- char **args __attribute__ ((unused))) -+ int argc, -+ char **args) - { - grub_test_t test; - int ok = 1; -+ int i; - - FOR_LIST_ELEMENTS (test, grub_test_list) - { -+ if (argc != 0) -+ { -+ for (i = 0; i < argc; i++) -+ if (grub_strcmp(args[i], test->name) == 0) -+ break; -+ if (i == argc) -+ continue; -+ } - grub_errno = 0; - ok = ok && !grub_test_run (test); - grub_errno = 0; -diff --git a/grub-core/video/i386/coreboot/cbfb.c b/grub-core/video/coreboot/cbfb.c -similarity index 99% -rename from grub-core/video/i386/coreboot/cbfb.c -rename to grub-core/video/coreboot/cbfb.c -index dede0c37ea3e8a8948cd6535d26d008e117206bc..9af81fa5b01b63677d97ba9a242e60080df84e5a 100644 ---- a/grub-core/video/i386/coreboot/cbfb.c -+++ b/grub-core/video/coreboot/cbfb.c -@@ -25,7 +25,7 @@ - #include - #include - #include --#include -+#include - #include - - struct grub_linuxbios_table_framebuffer *grub_video_coreboot_fbtable; -diff --git a/grub-core/video/efi_uga.c b/grub-core/video/efi_uga.c -index 464ede874daff480fb4199927cb30d48f0558e8b..044af1d20d38f08e3b5c5dcec4281c0b452cf8ea 100644 ---- a/grub-core/video/efi_uga.c -+++ b/grub-core/video/efi_uga.c -@@ -94,10 +94,19 @@ static int - find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data) - { - struct find_framebuf_ctx *ctx = data; -- grub_pci_address_t addr; -+ grub_pci_address_t addr, rcaddr; -+ grub_uint32_t subclass; - - addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS); -- if (grub_pci_read (addr) >> 24 == 0x3) -+ subclass = (grub_pci_read (addr) >> 16) & 0xffff; -+ -+ if (subclass != GRUB_PCI_CLASS_SUBCLASS_VGA) -+ return 0; -+ -+ /* Enable MEM address spaces */ -+ rcaddr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND); -+ grub_pci_write_word (rcaddr, grub_pci_read_word (rcaddr) | GRUB_PCI_COMMAND_MEM_ENABLED); -+ - { - int i; - -diff --git a/tests/printf_unit_test.c b/tests/printf_unit_test.c -index d7b12c6dbee6e84ace9d9f81d476622194810b26..098c29fd9ce2d28a5b83b74afc0f9e40b7c401ec 100644 ---- a/tests/printf_unit_test.c -+++ b/tests/printf_unit_test.c -@@ -23,6 +23,10 @@ - - #define MSG "printf test failed: %s, %s", real, expected - -+#if defined(__GNUC__) && __GNUC__ >= 7 -+#pragma GCC diagnostic ignored "-Wformat-truncation=" -+#endif -+ - static void - printf_test (void) - { -diff --git a/util/grub-install-common.c b/util/grub-install-common.c -index 452b230daedc3db0296cab014e89ddacf1c21347..0a2e24a79f11916527650d124e38c6184c4ceb93 100644 ---- a/util/grub-install-common.c -+++ b/util/grub-install-common.c -@@ -73,6 +73,7 @@ grub_install_help_filter (int key, const char *text, - - static int (*compress_func) (const char *src, const char *dest) = NULL; - char *grub_install_copy_buffer; -+static char *dtb; - - int - grub_install_copy_file (const char *src, -@@ -364,6 +365,11 @@ grub_install_parse (int key, char *arg) - case GRUB_INSTALL_OPTIONS_INSTALL_FONTS: - handle_install_list (&install_fonts, arg, 0); - return 1; -+ case GRUB_INSTALL_OPTIONS_DTB: -+ if (dtb) -+ free (dtb); -+ dtb = xstrdup (arg); -+ return 1; - case GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS: - if (strcmp (arg, "no") == 0 - || strcmp (arg, "none") == 0) -@@ -486,9 +492,10 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, - - grub_util_info ("grub-mkimage --directory '%s' --prefix '%s'" - " --output '%s' " -+ " --dtb '%s' " - "--format '%s' --compression '%s' %s %s\n", - dir, prefix, -- outname, mkimage_target, -+ outname, dtb ? : "", mkimage_target, - compnames[compression], note ? "--note" : "", s); - free (s); - -@@ -499,7 +506,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, - grub_install_generate_image (dir, prefix, fp, outname, - modules.entries, memdisk_path, - pubkeys, npubkeys, config_path, tgt, -- note, compression); -+ note, compression, dtb); - while (dc--) - grub_install_pop_module (); - } -@@ -585,6 +592,7 @@ copy_all (const char *srcd, - grub_util_fd_closedir (d); - } - -+#if !(defined (GRUB_UTIL) && defined(ENABLE_NLS) && ENABLE_NLS) - static const char * - get_localedir (void) - { -@@ -639,6 +647,59 @@ copy_locales (const char *dstd) - } - grub_util_fd_closedir (d); - } -+#endif -+ -+static void -+grub_install_copy_nls(const char *src __attribute__ ((unused)), -+ const char *dst __attribute__ ((unused))) -+{ -+#if !(defined (GRUB_UTIL) && defined(ENABLE_NLS) && ENABLE_NLS) -+ char *dst_locale; -+ -+ dst_locale = grub_util_path_concat (2, dst, "locale"); -+ grub_install_mkdir_p (dst_locale); -+ clean_grub_dir (dst_locale); -+ -+ if (install_locales.is_default) -+ { -+ char *srcd = grub_util_path_concat (2, src, "po"); -+ copy_by_ext (srcd, dst_locale, ".mo", 0); -+ copy_locales (dst_locale); -+ free (srcd); -+ } -+ else -+ { -+ size_t i; -+ const char *locale_dir = get_localedir (); -+ -+ for (i = 0; i < install_locales.n_entries; i++) -+ { -+ char *srcf = grub_util_path_concat_ext (3, src, "po", -+ install_locales.entries[i], -+ ".mo"); -+ char *dstf = grub_util_path_concat_ext (2, dst_locale, -+ install_locales.entries[i], -+ ".mo"); -+ if (grub_install_compress_file (srcf, dstf, 0)) -+ { -+ free (srcf); -+ free (dstf); -+ continue; -+ } -+ free (srcf); -+ srcf = grub_util_path_concat_ext (4, locale_dir, -+ install_locales.entries[i], -+ "LC_MESSAGES", PACKAGE, ".mo"); -+ if (grub_install_compress_file (srcf, dstf, 0) == 0) -+ grub_util_error (_("cannot find locale `%s'"), -+ install_locales.entries[i]); -+ free (srcf); -+ free (dstf); -+ } -+ } -+ free (dst_locale); -+#endif -+} - - static struct - { -@@ -666,6 +727,7 @@ static struct - [GRUB_INSTALL_PLATFORM_ARM_EFI] = { "arm", "efi" }, - [GRUB_INSTALL_PLATFORM_ARM64_EFI] = { "arm64", "efi" }, - [GRUB_INSTALL_PLATFORM_ARM_UBOOT] = { "arm", "uboot" }, -+ [GRUB_INSTALL_PLATFORM_ARM_COREBOOT] = { "arm", "coreboot" }, - }; - - char * -@@ -723,7 +785,7 @@ grub_install_copy_files (const char *src, - const char *dst, - enum grub_install_plat platid) - { -- char *dst_platform, *dst_locale, *dst_fonts; -+ char *dst_platform, *dst_fonts; - const char *pkgdatadir = grub_util_get_pkgdatadir (); - char *themes_dir; - -@@ -734,13 +796,12 @@ grub_install_copy_files (const char *src, - dst_platform = grub_util_path_concat (2, dst, platform); - free (platform); - } -- dst_locale = grub_util_path_concat (2, dst, "locale"); - dst_fonts = grub_util_path_concat (2, dst, "fonts"); - grub_install_mkdir_p (dst_platform); -- grub_install_mkdir_p (dst_locale); - clean_grub_dir (dst); - clean_grub_dir (dst_platform); -- clean_grub_dir (dst_locale); -+ -+ grub_install_copy_nls(src, dst); - - if (install_modules.is_default) - copy_by_ext (src, dst_platform, ".mod", 1); -@@ -789,50 +850,6 @@ grub_install_copy_files (const char *src, - free (dstf); - } - -- if (install_locales.is_default) -- { -- char *srcd = grub_util_path_concat (2, src, "po"); -- copy_by_ext (srcd, dst_locale, ".mo", 0); -- copy_locales (dst_locale); -- free (srcd); -- } -- else -- { -- const char *locale_dir = get_localedir (); -- -- for (i = 0; i < install_locales.n_entries; i++) -- { -- char *srcf = grub_util_path_concat_ext (3, src, -- "po", -- install_locales.entries[i], -- ".mo"); -- char *dstf = grub_util_path_concat_ext (2, dst_locale, -- install_locales.entries[i], -- ".mo"); -- if (grub_install_compress_file (srcf, dstf, 0)) -- { -- free (srcf); -- free (dstf); -- continue; -- } -- free (srcf); -- srcf = grub_util_path_concat_ext (4, -- locale_dir, -- install_locales.entries[i], -- "LC_MESSAGES", -- PACKAGE, -- ".mo"); -- if (grub_install_compress_file (srcf, dstf, 0)) -- { -- free (srcf); -- free (dstf); -- continue; -- } -- grub_util_error (_("cannot find locale `%s'"), -- install_locales.entries[i]); -- } -- } -- - if (install_themes.is_default) - { - install_themes.is_default = 0; -@@ -895,7 +912,6 @@ grub_install_copy_files (const char *src, - } - - free (dst_platform); -- free (dst_locale); - free (dst_fonts); - } - -diff --git a/util/grub-install.c b/util/grub-install.c -index 9074d3e9e52d2a2e215a10b2f8b3cf627ca80db3..78d0138cb0a8c891f8140f1804d68d275eb690f6 100644 ---- a/util/grub-install.c -+++ b/util/grub-install.c -@@ -486,6 +486,7 @@ have_bootdev (enum grub_install_plat pl) - - case GRUB_INSTALL_PLATFORM_I386_QEMU: - case GRUB_INSTALL_PLATFORM_I386_COREBOOT: -+ case GRUB_INSTALL_PLATFORM_ARM_COREBOOT: - case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT: - case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: - case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS: -@@ -713,7 +714,7 @@ is_prep_partition (grub_device_t dev) - if (grub_disk_read (dev->disk, p->offset, p->index, - sizeof (gptdata), &gptdata) == 0) - { -- const grub_gpt_part_type_t template = { -+ const grub_gpt_part_guid_t template = { - grub_cpu_to_le32_compile_time (0x9e1a2d38), - grub_cpu_to_le16_compile_time (0xc612), - grub_cpu_to_le16_compile_time (0x4316), -@@ -911,6 +912,7 @@ main (int argc, char *argv[]) - - case GRUB_INSTALL_PLATFORM_I386_QEMU: - case GRUB_INSTALL_PLATFORM_I386_COREBOOT: -+ case GRUB_INSTALL_PLATFORM_ARM_COREBOOT: - case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT: - case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON: - case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: -@@ -946,6 +948,7 @@ main (int argc, char *argv[]) - case GRUB_INSTALL_PLATFORM_ARM_UBOOT: - case GRUB_INSTALL_PLATFORM_I386_QEMU: - case GRUB_INSTALL_PLATFORM_I386_COREBOOT: -+ case GRUB_INSTALL_PLATFORM_ARM_COREBOOT: - case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT: - case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON: - case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: -@@ -1448,6 +1451,7 @@ main (int argc, char *argv[]) - case GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON: - case GRUB_INSTALL_PLATFORM_I386_QEMU: - case GRUB_INSTALL_PLATFORM_I386_COREBOOT: -+ case GRUB_INSTALL_PLATFORM_ARM_COREBOOT: - case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT: - case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: - case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS: -@@ -1468,6 +1472,7 @@ main (int argc, char *argv[]) - { - grub_util_fprint_full_disk_name (load_cfg_f, g, dev); - fprintf (load_cfg_f, " "); -+ free (g); - } - if (dev != grub_dev) - grub_device_close (dev); -@@ -1542,6 +1547,7 @@ main (int argc, char *argv[]) - break; - - case GRUB_INSTALL_PLATFORM_I386_COREBOOT: -+ case GRUB_INSTALL_PLATFORM_ARM_COREBOOT: - case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT: - case GRUB_INSTALL_PLATFORM_I386_IEEE1275: - case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275: -@@ -1629,6 +1635,7 @@ main (int argc, char *argv[]) - case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: - case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS: - case GRUB_INSTALL_PLATFORM_I386_COREBOOT: -+ case GRUB_INSTALL_PLATFORM_ARM_COREBOOT: - case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT: - case GRUB_INSTALL_PLATFORM_I386_PC: - case GRUB_INSTALL_PLATFORM_MIPSEL_ARC: -@@ -1841,9 +1848,13 @@ main (int argc, char *argv[]) - if (!removable && update_nvram) - { - /* Try to make this image bootable using the EFI Boot Manager, if available. */ -- grub_install_register_efi (efidir_grub_dev, -- "\\System\\Library\\CoreServices", -- efi_distributor); -+ int ret; -+ ret = grub_install_register_efi (efidir_grub_dev, -+ "\\System\\Library\\CoreServices", -+ efi_distributor); -+ if (ret) -+ grub_util_error (_("efibootmgr failed to register the boot entry: %s"), -+ strerror (ret)); - } - - grub_device_close (ins_dev); -@@ -1864,6 +1875,7 @@ main (int argc, char *argv[]) - { - char * efifile_path; - char * part; -+ int ret; - - /* Try to make this image bootable using the EFI Boot Manager, if available. */ - if (!efi_distributor || efi_distributor[0] == '\0') -@@ -1880,8 +1892,11 @@ main (int argc, char *argv[]) - efidir_grub_dev->disk->name, - (part ? ",": ""), (part ? : "")); - grub_free (part); -- grub_install_register_efi (efidir_grub_dev, -- efifile_path, efi_distributor); -+ ret = grub_install_register_efi (efidir_grub_dev, -+ efifile_path, efi_distributor); -+ if (ret) -+ grub_util_error (_("efibootmgr failed to register the boot entry: %s"), -+ strerror (ret)); - } - break; - -@@ -1889,6 +1904,7 @@ main (int argc, char *argv[]) - case GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS: - case GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS: - case GRUB_INSTALL_PLATFORM_I386_COREBOOT: -+ case GRUB_INSTALL_PLATFORM_ARM_COREBOOT: - case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT: - case GRUB_INSTALL_PLATFORM_MIPSEL_ARC: - case GRUB_INSTALL_PLATFORM_ARM_UBOOT: -diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c -index aba19d21b9a774e63ad49f166554d90f8c667e36..98d24cc06ea57b88a4f02f38f177f44ec4f38f3f 100644 ---- a/util/grub-mkimage.c -+++ b/util/grub-mkimage.c -@@ -71,6 +71,7 @@ static struct argp_option options[] = { - N_("embed FILE as a memdisk image\n" - "Implies `-p (memdisk)/boot/grub' and overrides any prefix supplied previously," - " but the prefix itself can be overridden by later options"), 0}, -+ {"dtb", 'D', N_("FILE"), 0, N_("embed FILE as a device tree (DTB)\n"), 0}, - /* TRANSLATORS: "embed" is a verb (command description). "*/ - {"config", 'c', N_("FILE"), 0, N_("embed FILE as an early config"), 0}, - /* TRANSLATORS: "embed" is a verb (command description). "*/ -@@ -117,6 +118,7 @@ struct arguments - char *dir; - char *prefix; - char *memdisk; -+ char *dtb; - char **pubkeys; - size_t npubkeys; - char *font; -@@ -176,6 +178,13 @@ argp_parser (int key, char *arg, struct argp_state *state) - arguments->prefix = xstrdup ("(memdisk)/boot/grub"); - break; - -+ case 'D': -+ if (arguments->dtb) -+ free (arguments->dtb); -+ -+ arguments->dtb = xstrdup (arg); -+ break; -+ - case 'k': - arguments->pubkeys = xrealloc (arguments->pubkeys, - sizeof (arguments->pubkeys[0]) -@@ -300,7 +309,7 @@ main (int argc, char *argv[]) - arguments.memdisk, arguments.pubkeys, - arguments.npubkeys, arguments.config, - arguments.image_target, arguments.note, -- arguments.comp); -+ arguments.comp, arguments.dtb); - - grub_util_file_sync (fp); - fclose (fp); -diff --git a/util/grub-mkimage32.c b/util/grub-mkimage32.c -index 9b31397bc40b95b69a1edc4f2d4c4b5d6eaa63cd..1f2ccccd225bbbb32e7e38801ddafeb90d9a69bb 100644 ---- a/util/grub-mkimage32.c -+++ b/util/grub-mkimage32.c -@@ -19,4 +19,6 @@ - # define ELF_ST_TYPE(val) ELF32_ST_TYPE(val) - #define XEN_NOTE_SIZE 132 - -+#ifndef GRUB_MKIMAGEXX - #include "grub-mkimagexx.c" -+#endif -diff --git a/util/grub-mkimage64.c b/util/grub-mkimage64.c -index d83345924705353b3c20a1e4dd087371ec5383ec..4ff72a625e0030d05cee0675a481b0803cda081e 100644 ---- a/util/grub-mkimage64.c -+++ b/util/grub-mkimage64.c -@@ -19,4 +19,6 @@ - # define ELF_ST_TYPE(val) ELF64_ST_TYPE(val) - #define XEN_NOTE_SIZE 120 - -+#ifndef GRUB_MKIMAGEXX - #include "grub-mkimagexx.c" -+#endif -diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c -index e63f148e48cf6f66852b15063405f81371d95ae9..a483c674c4908bca02ecda73de78d04456667a37 100644 ---- a/util/grub-mkimagexx.c -+++ b/util/grub-mkimagexx.c -@@ -50,6 +50,15 @@ - - #pragma GCC diagnostic ignored "-Wcast-align" - -+#define GRUB_MKIMAGEXX -+#if !defined(MKIMAGE_ELF32) && !defined(MKIMAGE_ELF64) -+#if __SIZEOF_POINTER__ == 8 -+#include "grub-mkimage64.c" -+#else -+#include "grub-mkimage32.c" -+#endif -+#endif -+ - /* These structures are defined according to the CHRP binding to IEEE1275, - "Client Program Format" section. */ - -@@ -84,10 +93,22 @@ struct fixup_block_list - - #define ALIGN_ADDR(x) (ALIGN_UP((x), image_target->voidp_sizeof)) - -+struct section_metadata -+{ -+ Elf_Half num_sections; -+ Elf_Shdr *sections; -+ Elf_Addr *addrs; -+ Elf_Addr *vaddrs; -+ Elf_Half section_entsize; -+ Elf_Shdr *symtab; -+ const char *strtab; -+}; -+ - static int - is_relocatable (const struct grub_install_image_target_desc *image_target) - { -- return image_target->id == IMAGE_EFI || image_target->id == IMAGE_UBOOT; -+ return image_target->id == IMAGE_EFI || image_target->id == IMAGE_UBOOT -+ || (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_ARM); - } - - #ifdef MKIMAGE_ELF32 -@@ -185,8 +206,8 @@ grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr) - void - SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc *image_target, - int note, char **core_img, size_t *core_size, -- Elf_Addr target_addr, grub_size_t align, -- size_t kernel_size, size_t bss_size) -+ Elf_Addr target_addr, -+ struct grub_mkimage_layout *layout) - { - char *elf_img; - size_t program_size; -@@ -214,7 +235,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc - footer_size += XEN_NOTE_SIZE; - } - header_size = ALIGN_UP (sizeof (*ehdr) + phnum * sizeof (*phdr) -- + shnum * sizeof (*shdr) + string_size, align); -+ + shnum * sizeof (*shdr) + string_size, layout->align); - - program_size = ALIGN_ADDR (*core_size); - -@@ -258,7 +279,8 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc - ehdr->e_entry = grub_host_to_target32 (target_addr); - phdr->p_vaddr = grub_host_to_target32 (target_addr); - phdr->p_paddr = grub_host_to_target32 (target_addr); -- phdr->p_align = grub_host_to_target32 (align > image_target->link_align ? align : image_target->link_align); -+ phdr->p_align = grub_host_to_target32 (layout->align > image_target->link_align ? -+ layout->align : image_target->link_align); - if (image_target->id == IMAGE_LOONGSON_ELF) - ehdr->e_flags = grub_host_to_target32 (0x1000 | EF_MIPS_NOREORDER - | EF_MIPS_PIC | EF_MIPS_CPIC); -@@ -272,27 +294,34 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc - else - { - grub_uint32_t target_addr_mods; -- phdr->p_filesz = grub_host_to_target32 (kernel_size); -- phdr->p_memsz = grub_host_to_target32 (kernel_size + bss_size); -+ phdr->p_filesz = grub_host_to_target32 (layout->kernel_size); -+ if (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_ARM) -+ phdr->p_memsz = grub_host_to_target32 (layout->kernel_size); -+ else -+ phdr->p_memsz = grub_host_to_target32 (layout->kernel_size + layout->bss_size); - - phdr++; - phdr->p_type = grub_host_to_target32 (PT_GNU_STACK); -- phdr->p_offset = grub_host_to_target32 (header_size + kernel_size); -+ phdr->p_offset = grub_host_to_target32 (header_size + layout->kernel_size); - phdr->p_paddr = phdr->p_vaddr = phdr->p_filesz = phdr->p_memsz = 0; - phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X); - phdr->p_align = grub_host_to_target32 (image_target->link_align); - - phdr++; - phdr->p_type = grub_host_to_target32 (PT_LOAD); -- phdr->p_offset = grub_host_to_target32 (header_size + kernel_size); -+ phdr->p_offset = grub_host_to_target32 (header_size + layout->kernel_size); - phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X); - phdr->p_filesz = phdr->p_memsz -- = grub_host_to_target32 (*core_size - kernel_size); -+ = grub_host_to_target32 (*core_size - layout->kernel_size); - -- if (image_target->id == IMAGE_COREBOOT) -+ if (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_386) - target_addr_mods = GRUB_KERNEL_I386_COREBOOT_MODULES_ADDR; -+ else if (image_target->id == IMAGE_COREBOOT && image_target->elf_target == EM_ARM) -+ target_addr_mods = ALIGN_UP (target_addr + layout->end -+ + image_target->mod_gap, -+ image_target->mod_align); - else -- target_addr_mods = ALIGN_UP (target_addr + kernel_size + bss_size -+ target_addr_mods = ALIGN_UP (target_addr + layout->kernel_size + layout->bss_size - + image_target->mod_gap, - image_target->mod_align); - phdr->p_vaddr = grub_host_to_target_addr (target_addr_mods); -@@ -434,7 +463,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc - shdr->sh_size = grub_host_to_target32 (string_size); - shdr->sh_link = grub_host_to_target32 (0); - shdr->sh_info = grub_host_to_target32 (0); -- shdr->sh_addralign = grub_host_to_target32 (align); -+ shdr->sh_addralign = grub_host_to_target32 (layout->align); - shdr->sh_entsize = grub_host_to_target32 (0); - shdr++; - -@@ -445,10 +474,10 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc - shdr->sh_type = grub_host_to_target32 (SHT_PROGBITS); - shdr->sh_addr = grub_host_to_target_addr (target_addr); - shdr->sh_offset = grub_host_to_target_addr (header_size); -- shdr->sh_size = grub_host_to_target32 (kernel_size); -+ shdr->sh_size = grub_host_to_target32 (layout->kernel_size); - shdr->sh_link = grub_host_to_target32 (0); - shdr->sh_info = grub_host_to_target32 (0); -- shdr->sh_addralign = grub_host_to_target32 (align); -+ shdr->sh_addralign = grub_host_to_target32 (layout->align); - shdr->sh_entsize = grub_host_to_target32 (0); - shdr++; - -@@ -456,9 +485,9 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc - shdr->sh_name = grub_host_to_target32 (ptr - str_start); - ptr += sizeof ("mods"); - shdr->sh_type = grub_host_to_target32 (SHT_PROGBITS); -- shdr->sh_addr = grub_host_to_target_addr (target_addr + kernel_size); -- shdr->sh_offset = grub_host_to_target_addr (header_size + kernel_size); -- shdr->sh_size = grub_host_to_target32 (*core_size - kernel_size); -+ shdr->sh_addr = grub_host_to_target_addr (target_addr + layout->kernel_size); -+ shdr->sh_offset = grub_host_to_target_addr (header_size + layout->kernel_size); -+ shdr->sh_size = grub_host_to_target32 (*core_size - layout->kernel_size); - shdr->sh_link = grub_host_to_target32 (0); - shdr->sh_info = grub_host_to_target32 (0); - shdr->sh_addralign = grub_host_to_target32 (image_target->voidp_sizeof); -@@ -471,7 +500,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc - shdr->sh_name = grub_host_to_target32 (ptr - str_start); - ptr += sizeof (".xen"); - shdr->sh_type = grub_host_to_target32 (SHT_PROGBITS); -- shdr->sh_addr = grub_host_to_target_addr (target_addr + kernel_size); -+ shdr->sh_addr = grub_host_to_target_addr (target_addr + layout->kernel_size); - shdr->sh_offset = grub_host_to_target_addr (program_size + header_size); - shdr->sh_size = grub_host_to_target32 (XEN_NOTE_SIZE); - shdr->sh_link = grub_host_to_target32 (0); -@@ -490,9 +519,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc - /* Relocate symbols; note that this function overwrites the symbol table. - Return the address of a start symbol. */ - static Elf_Addr --SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, -- Elf_Shdr *symtab_section, Elf_Addr *section_addresses, -- Elf_Half section_entsize, Elf_Half num_sections, -+SUFFIX (relocate_symbols) (Elf_Ehdr *e, struct section_metadata *smd, - void *jumpers, Elf_Addr jumpers_addr, - Elf_Addr bss_start, Elf_Addr end, - const struct grub_install_image_target_desc *image_target) -@@ -502,19 +529,18 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, - Elf_Addr start_address = (Elf_Addr) -1; - Elf_Sym *sym; - Elf_Word i; -- Elf_Shdr *strtab_section; -- const char *strtab; -+ Elf_Shdr *symtab_section; -+ const char *symtab; - grub_uint64_t *jptr = jumpers; - -- strtab_section -- = (Elf_Shdr *) ((char *) sections -- + (grub_target_to_host32 (symtab_section->sh_link) -- * section_entsize)); -- strtab = (char *) e + grub_target_to_host (strtab_section->sh_offset); -+ symtab_section = (Elf_Shdr *) ((char *) smd->sections -+ + grub_target_to_host32 (smd->symtab->sh_link) -+ * smd->section_entsize); -+ symtab = (char *) e + grub_target_to_host (symtab_section->sh_offset); - -- symtab_size = grub_target_to_host (symtab_section->sh_size); -- sym_size = grub_target_to_host (symtab_section->sh_entsize); -- symtab_offset = grub_target_to_host (symtab_section->sh_offset); -+ symtab_size = grub_target_to_host (smd->symtab->sh_size); -+ sym_size = grub_target_to_host (smd->symtab->sh_entsize); -+ symtab_offset = grub_target_to_host (smd->symtab->sh_offset); - num_syms = symtab_size / sym_size; - - for (i = 0, sym = (Elf_Sym *) ((char *) e + symtab_offset); -@@ -524,7 +550,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, - Elf_Section cur_index; - const char *name; - -- name = strtab + grub_target_to_host32 (sym->st_name); -+ name = symtab + grub_target_to_host32 (sym->st_name); - - cur_index = grub_target_to_host16 (sym->st_shndx); - if (cur_index == STN_ABS) -@@ -542,12 +568,12 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, - else - continue; - } -- else if (cur_index >= num_sections) -+ else if (cur_index >= smd->num_sections) - grub_util_error ("section %d does not exist", cur_index); - else - { - sym->st_value = (grub_target_to_host (sym->st_value) -- + section_addresses[cur_index]); -+ + smd->vaddrs[cur_index]); - } - - if (image_target->elf_target == EM_IA_64 && ELF_ST_TYPE (sym->st_info) -@@ -562,7 +588,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, - grub_util_info ("locating %s at 0x%" GRUB_HOST_PRIxLONG_LONG - " (0x%" GRUB_HOST_PRIxLONG_LONG ")", name, - (unsigned long long) sym->st_value, -- (unsigned long long) section_addresses[cur_index]); -+ (unsigned long long) smd->vaddrs[cur_index]); - - if (start_address == (Elf_Addr)-1) - if (strcmp (name, "_start") == 0 || strcmp (name, "start") == 0) -@@ -699,17 +725,19 @@ arm_get_trampoline_size (Elf_Ehdr *e, - } - #endif - -+static int -+SUFFIX (is_kept_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target); -+static int -+SUFFIX (is_kept_reloc_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target, -+ struct section_metadata *smd); -+ - /* Deal with relocation information. This function relocates addresses - within the virtual address space starting from 0. So only relative - addresses can be fully resolved. Absolute addresses must be relocated - again by a PE32 relocator when loaded. */ - static void --SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, -- Elf_Addr *section_addresses, -- Elf_Half section_entsize, Elf_Half num_sections, -- const char *strtab, -- char *pe_target, Elf_Addr tramp_off, -- Elf_Addr got_off, -+SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, -+ char *pe_target, Elf_Addr tramp_off, Elf_Addr got_off, - const struct grub_install_image_target_desc *image_target) - { - Elf_Half i; -@@ -723,33 +751,37 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, - grub_uint32_t *tr = (void *) (pe_target + tramp_off); - #endif - -- for (i = 0, s = sections; -- i < num_sections; -- i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) -+ for (i = 0, s = smd->sections; -+ i < smd->num_sections; -+ i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize)) - if ((s->sh_type == grub_host_to_target32 (SHT_REL)) || - (s->sh_type == grub_host_to_target32 (SHT_RELA))) - { - Elf_Rela *r; - Elf_Word rtab_size, r_size, num_rs; - Elf_Off rtab_offset; -- Elf_Shdr *symtab_section; - Elf_Word target_section_index; - Elf_Addr target_section_addr; - Elf_Shdr *target_section; - Elf_Word j; - -- symtab_section = (Elf_Shdr *) ((char *) sections -- + (grub_target_to_host32 (s->sh_link) -- * section_entsize)); -+ if (!SUFFIX (is_kept_section) (s, image_target) && -+ !SUFFIX (is_kept_reloc_section) (s, image_target, smd)) -+ { -+ grub_util_info ("not translating relocations for omitted section %s", -+ smd->strtab + grub_le_to_cpu32 (s->sh_name)); -+ continue; -+ } -+ - target_section_index = grub_target_to_host32 (s->sh_info); -- target_section_addr = section_addresses[target_section_index]; -- target_section = (Elf_Shdr *) ((char *) sections -+ target_section_addr = smd->addrs[target_section_index]; -+ target_section = (Elf_Shdr *) ((char *) smd->sections - + (target_section_index -- * section_entsize)); -+ * smd->section_entsize)); - - grub_util_info ("dealing with the relocation section %s for %s", -- strtab + grub_target_to_host32 (s->sh_name), -- strtab + grub_target_to_host32 (target_section->sh_name)); -+ smd->strtab + grub_target_to_host32 (s->sh_name), -+ smd->strtab + grub_target_to_host32 (target_section->sh_name)); - - rtab_size = grub_target_to_host (s->sh_size); - r_size = grub_target_to_host (s->sh_entsize); -@@ -770,7 +802,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, - target = SUFFIX (get_target_address) (e, target_section, - offset, image_target); - info = grub_target_to_host (r->r_info); -- sym_addr = SUFFIX (get_symbol_address) (e, symtab_section, -+ sym_addr = SUFFIX (get_symbol_address) (e, smd->symtab, - ELF_R_SYM (info), image_target); - - addend = (s->sh_type == grub_target_to_host32 (SHT_RELA)) ? -@@ -832,6 +864,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, - break; - - case R_X86_64_PC32: -+ case R_X86_64_PLT32: - { - grub_uint32_t *t32 = (grub_uint32_t *) target; - *t32 = grub_host_to_target64 (grub_target_to_host32 (*t32) -@@ -900,8 +933,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, - Elf_Sym *sym; - - sym = (Elf_Sym *) ((char *) e -- + grub_target_to_host (symtab_section->sh_offset) -- + ELF_R_SYM (info) * grub_target_to_host (symtab_section->sh_entsize)); -+ + grub_target_to_host (smd->symtab->sh_offset) -+ + ELF_R_SYM (info) * grub_target_to_host (smd->symtab->sh_entsize)); - if (ELF_ST_TYPE (sym->st_info) == STT_FUNC) - sym_addr = grub_target_to_host64 (*(grub_uint64_t *) (pe_target - + sym->st_value -@@ -1086,8 +1119,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, - - (char *) e), - sym_addr); - sym = (Elf_Sym *) ((char *) e -- + grub_target_to_host (symtab_section->sh_offset) -- + ELF_R_SYM (info) * grub_target_to_host (symtab_section->sh_entsize)); -+ + grub_target_to_host (smd->symtab->sh_offset) -+ + ELF_R_SYM (info) * grub_target_to_host (smd->symtab->sh_entsize)); - if (ELF_ST_TYPE (sym->st_info) != STT_FUNC) - sym_addr |= 1; - if (!(sym_addr & 1)) -@@ -1625,9 +1658,7 @@ create_u64_fixups (struct translate_context *ctx, - /* Make a .reloc section. */ - static void - make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, -- Elf_Addr *section_addresses, Elf_Shdr *sections, -- Elf_Half section_entsize, Elf_Half num_sections, -- const char *strtab, -+ struct section_metadata *smd, - const struct grub_install_image_target_desc *image_target) - { - unsigned i; -@@ -1636,8 +1667,8 @@ make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, - - translate_reloc_start (&ctx, image_target); - -- for (i = 0, s = sections; i < num_sections; -- i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) -+ for (i = 0, s = smd->sections; i < smd->num_sections; -+ i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize)) - if ((grub_target_to_host32 (s->sh_type) == SHT_REL) || - (grub_target_to_host32 (s->sh_type) == SHT_RELA)) - { -@@ -1647,15 +1678,22 @@ make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, - Elf_Addr section_address; - Elf_Word j; - -+ if (!SUFFIX (is_kept_reloc_section) (s, image_target, smd)) -+ { -+ grub_util_info ("not translating the skipped relocation section %s", -+ smd->strtab + grub_le_to_cpu32 (s->sh_name)); -+ continue; -+ } -+ - grub_util_info ("translating the relocation section %s", -- strtab + grub_le_to_cpu32 (s->sh_name)); -+ smd->strtab + grub_le_to_cpu32 (s->sh_name)); - - rtab_size = grub_target_to_host (s->sh_size); - r_size = grub_target_to_host (s->sh_entsize); - rtab_offset = grub_target_to_host (s->sh_offset); - num_rs = rtab_size / r_size; - -- section_address = section_addresses[grub_le_to_cpu32 (s->sh_info)]; -+ section_address = smd->vaddrs[grub_le_to_cpu32 (s->sh_info)]; - - for (j = 0, r = (Elf_Rel *) ((char *) e + rtab_offset); - j < num_rs; -@@ -1722,6 +1760,56 @@ SUFFIX (is_bss_section) (Elf_Shdr *s, const struct grub_install_image_target_des - == SHF_ALLOC) && (grub_target_to_host32 (s->sh_type) == SHT_NOBITS); - } - -+/* Determine if a section is going to be in the final output */ -+static int -+SUFFIX (is_kept_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target) -+{ -+ /* We keep .text and .data */ -+ if (SUFFIX (is_text_section) (s, image_target) -+ || SUFFIX (is_data_section) (s, image_target)) -+ return 1; -+ -+ /* -+ * And we keep .bss if we're producing PE binaries or the target doesn't -+ * have a relocating loader. Platforms other than EFI and U-boot shouldn't -+ * have .bss in their binaries as we build with -Wl,-Ttext. -+ */ -+ if (SUFFIX (is_bss_section) (s, image_target) -+ && (image_target->id == IMAGE_EFI || !is_relocatable (image_target))) -+ return 1; -+ -+ /* Otherwise this is not a section we're keeping in the final output. */ -+ return 0; -+} -+ -+static int -+SUFFIX (is_kept_reloc_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target, -+ struct section_metadata *smd) -+{ -+ int i; -+ int r = 0; -+ const char *name = smd->strtab + grub_host_to_target32 (s->sh_name); -+ -+ if (!strncmp (name, ".rela.", 6)) -+ name += 5; -+ else if (!strncmp (name, ".rel.", 5)) -+ name += 4; -+ else -+ return 1; -+ -+ for (i = 0, s = smd->sections; i < smd->num_sections; -+ i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize)) -+ { -+ const char *sname = smd->strtab + grub_host_to_target32 (s->sh_name); -+ if (strcmp (sname, name)) -+ continue; -+ -+ return SUFFIX (is_kept_section) (s, image_target); -+ } -+ -+ return r; -+} -+ - /* Return if the ELF header is valid. */ - static int - SUFFIX (check_elf_header) (Elf_Ehdr *e, size_t size, const struct grub_install_image_target_desc *image_target) -@@ -1742,12 +1830,11 @@ SUFFIX (check_elf_header) (Elf_Ehdr *e, size_t size, const struct grub_install_i - static Elf_Addr - SUFFIX (put_section) (Elf_Shdr *s, int i, - Elf_Addr current_address, -- Elf_Addr *section_addresses, -- const char *strtab, -+ struct section_metadata *smd, - const struct grub_install_image_target_desc *image_target) - { - Elf_Word align = grub_host_to_target_addr (s->sh_addralign); -- const char *name = strtab + grub_host_to_target32 (s->sh_name); -+ const char *name = smd->strtab + grub_host_to_target32 (s->sh_name); - - if (align) - current_address = ALIGN_UP (current_address + image_target->vaddr_offset, -@@ -1759,24 +1846,23 @@ SUFFIX (put_section) (Elf_Shdr *s, int i, - name, (unsigned long long) current_address); - if (!is_relocatable (image_target)) - current_address = grub_host_to_target_addr (s->sh_addr) -- - image_target->link_addr; -- section_addresses[i] = current_address; -+ - image_target->link_addr; -+ smd->addrs[i] = current_address; - current_address += grub_host_to_target_addr (s->sh_size); - return current_address; - } - --/* Locate section addresses by merging code sections and data sections -- into .text and .data, respectively. Return the array of section -- addresses. */ --static Elf_Addr * -+/* -+ * Locate section addresses by merging code sections and data sections -+ * into .text and .data, respectively. -+ */ -+static void - SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, -- Elf_Shdr *sections, Elf_Half section_entsize, -- Elf_Half num_sections, const char *strtab, -+ struct section_metadata *smd, - struct grub_mkimage_layout *layout, - const struct grub_install_image_target_desc *image_target) - { - int i; -- Elf_Addr *section_addresses; - Elf_Shdr *s; - - layout->align = 1; -@@ -1784,30 +1870,23 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, - if (image_target->elf_target == EM_AARCH64) - layout->align = 4096; - -- section_addresses = xmalloc (sizeof (*section_addresses) * num_sections); -- memset (section_addresses, 0, sizeof (*section_addresses) * num_sections); -- - layout->kernel_size = 0; - -- for (i = 0, s = sections; -- i < num_sections; -- i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) -- if ((grub_target_to_host (s->sh_flags) & SHF_ALLOC) -+ for (i = 0, s = smd->sections; -+ i < smd->num_sections; -+ i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize)) -+ if ((grub_target_to_host (s->sh_flags) & SHF_ALLOC) - && grub_host_to_target32 (s->sh_addralign) > layout->align) - layout->align = grub_host_to_target32 (s->sh_addralign); - -- - /* .text */ -- for (i = 0, s = sections; -- i < num_sections; -- i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) -+ for (i = 0, s = smd->sections; -+ i < smd->num_sections; -+ i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize)) - if (SUFFIX (is_text_section) (s, image_target)) - { -- layout->kernel_size = SUFFIX (put_section) (s, i, -- layout->kernel_size, -- section_addresses, -- strtab, -- image_target); -+ layout->kernel_size = SUFFIX (put_section) (s, i, layout->kernel_size, -+ smd, image_target); - if (!is_relocatable (image_target) && - grub_host_to_target_addr (s->sh_addr) != image_target->link_addr) - { -@@ -1827,15 +1906,12 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, - layout->exec_size = layout->kernel_size; - - /* .data */ -- for (i = 0, s = sections; -- i < num_sections; -- i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) -+ for (i = 0, s = smd->sections; -+ i < smd->num_sections; -+ i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize)) - if (SUFFIX (is_data_section) (s, image_target)) -- layout->kernel_size = SUFFIX (put_section) (s, i, -- layout->kernel_size, -- section_addresses, -- strtab, -- image_target); -+ layout->kernel_size = SUFFIX (put_section) (s, i, layout->kernel_size, smd, -+ image_target); - - #ifdef MKIMAGE_ELF32 - if (image_target->elf_target == EM_ARM) -@@ -1846,8 +1922,8 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, - - layout->kernel_size = ALIGN_UP (layout->kernel_size, 16); - -- tramp = arm_get_trampoline_size (e, sections, section_entsize, -- num_sections, image_target); -+ tramp = arm_get_trampoline_size (e, smd->sections, smd->section_entsize, -+ smd->num_sections, image_target); - - layout->tramp_off = layout->kernel_size; - layout->kernel_size += ALIGN_UP (tramp, 16); -@@ -1858,15 +1934,18 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, - layout->end = layout->kernel_size; - - /* .bss */ -- for (i = 0, s = sections; -- i < num_sections; -- i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) -- if (SUFFIX (is_bss_section) (s, image_target)) -- layout->end = SUFFIX (put_section) (s, i, -- layout->end, -- section_addresses, -- strtab, -- image_target); -+ for (i = 0, s = smd->sections; -+ i < smd->num_sections; -+ i++, s = (Elf_Shdr *) ((char *) s + smd->section_entsize)) -+ { -+ if (SUFFIX (is_bss_section) (s, image_target)) -+ layout->end = SUFFIX (put_section) (s, i, layout->end, smd, image_target); -+ -+ /* -+ * This must to be in the last time this function passes through the loop. -+ */ -+ smd->vaddrs[i] = smd->addrs[i] + image_target->vaddr_offset; -+ } - - layout->end = ALIGN_UP (layout->end + image_target->vaddr_offset, - image_target->section_align) - image_target->vaddr_offset; -@@ -1875,10 +1954,8 @@ SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, - Platforms other than EFI and U-boot shouldn't have .bss in - their binaries as we build with -Wl,-Ttext. - */ -- if (image_target->id != IMAGE_UBOOT) -+ if (image_target->id == IMAGE_EFI || !is_relocatable (image_target)) - layout->kernel_size = layout->end; -- -- return section_addresses; - } - - char * -@@ -1888,18 +1965,12 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, - const struct grub_install_image_target_desc *image_target) - { - char *kernel_img, *out_img; -- const char *strtab; -+ struct section_metadata smd = { 0, 0, 0, 0, 0, 0, 0 }; - Elf_Ehdr *e; -- Elf_Shdr *sections; -- Elf_Addr *section_addresses; -- Elf_Addr *section_vaddresses; - int i; - Elf_Shdr *s; -- Elf_Half num_sections; - Elf_Off section_offset; -- Elf_Half section_entsize; - grub_size_t kernel_size; -- Elf_Shdr *symtab_section = 0; - - grub_memset (layout, 0, sizeof (*layout)); - -@@ -1914,48 +1985,45 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, - grub_util_error ("invalid ELF header"); - - section_offset = grub_target_to_host (e->e_shoff); -- section_entsize = grub_target_to_host16 (e->e_shentsize); -- num_sections = grub_target_to_host16 (e->e_shnum); -+ smd.section_entsize = grub_target_to_host16 (e->e_shentsize); -+ smd.num_sections = grub_target_to_host16 (e->e_shnum); - -- if (kernel_size < section_offset + (grub_uint32_t) section_entsize * num_sections) -+ if (kernel_size < section_offset -+ + (grub_uint32_t) smd.section_entsize * smd.num_sections) - grub_util_error (_("premature end of file %s"), kernel_path); - -- sections = (Elf_Shdr *) (kernel_img + section_offset); -+ smd.sections = (Elf_Shdr *) (kernel_img + section_offset); - - /* Relocate sections then symbols in the virtual address space. */ -- s = (Elf_Shdr *) ((char *) sections -- + grub_host_to_target16 (e->e_shstrndx) * section_entsize); -- strtab = (char *) e + grub_host_to_target_addr (s->sh_offset); -+ s = (Elf_Shdr *) ((char *) smd.sections -+ + grub_host_to_target16 (e->e_shstrndx) * smd.section_entsize); -+ smd.strtab = (char *) e + grub_host_to_target_addr (s->sh_offset); - -- section_addresses = SUFFIX (locate_sections) (e, kernel_path, -- sections, section_entsize, -- num_sections, strtab, -- layout, -- image_target); -+ smd.addrs = xmalloc (sizeof (*smd.addrs) * smd.num_sections); -+ memset (smd.addrs, 0, sizeof (*smd.addrs) * smd.num_sections); -+ smd.vaddrs = xmalloc (sizeof (*smd.vaddrs) * smd.num_sections); -+ memset (smd.vaddrs, 0, sizeof (*smd.vaddrs) * smd.num_sections); - -- section_vaddresses = xmalloc (sizeof (*section_addresses) * num_sections); -- -- for (i = 0; i < num_sections; i++) -- section_vaddresses[i] = section_addresses[i] + image_target->vaddr_offset; -+ SUFFIX (locate_sections) (e, kernel_path, &smd, layout, image_target); - - if (!is_relocatable (image_target)) - { - Elf_Addr current_address = layout->kernel_size; - -- for (i = 0, s = sections; -- i < num_sections; -- i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) -+ for (i = 0, s = smd.sections; -+ i < smd.num_sections; -+ i++, s = (Elf_Shdr *) ((char *) s + smd.section_entsize)) - if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS) - { - Elf_Word sec_align = grub_host_to_target_addr (s->sh_addralign); -- const char *name = strtab + grub_host_to_target32 (s->sh_name); -+ const char *name = smd.strtab + grub_host_to_target32 (s->sh_name); - - if (sec_align) - current_address = ALIGN_UP (current_address - + image_target->vaddr_offset, - sec_align) - - image_target->vaddr_offset; -- -+ - grub_util_info ("locating the section %s at 0x%" - GRUB_HOST_PRIxLONG_LONG, - name, (unsigned long long) current_address); -@@ -1963,7 +2031,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, - current_address = grub_host_to_target_addr (s->sh_addr) - - image_target->link_addr; - -- section_vaddresses[i] = current_address -+ smd.vaddrs[i] = current_address - + image_target->vaddr_offset; - current_address += grub_host_to_target_addr (s->sh_size); - } -@@ -1978,21 +2046,22 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, - if (image_target->id == IMAGE_SPARC64_AOUT - || image_target->id == IMAGE_SPARC64_RAW - || image_target->id == IMAGE_UBOOT -+ || image_target->id == IMAGE_COREBOOT - || image_target->id == IMAGE_SPARC64_CDCORE) - layout->kernel_size = ALIGN_UP (layout->kernel_size, image_target->mod_align); - - if (is_relocatable (image_target)) - { -- symtab_section = NULL; -- for (i = 0, s = sections; -- i < num_sections; -- i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) -+ smd.symtab = NULL; -+ for (i = 0, s = smd.sections; -+ i < smd.num_sections; -+ i++, s = (Elf_Shdr *) ((char *) s + smd.section_entsize)) - if (s->sh_type == grub_host_to_target32 (SHT_SYMTAB)) - { -- symtab_section = s; -+ smd.symtab = s; - break; - } -- if (! symtab_section) -+ if (! smd.symtab) - grub_util_error ("%s", _("no symbol table")); - #ifdef MKIMAGE_ELF64 - if (image_target->elf_target == EM_IA_64) -@@ -2007,7 +2076,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, - layout->kernel_size += ALIGN_UP (tramp, 16); - - layout->ia64jmp_off = layout->kernel_size; -- layout->ia64jmpnum = SUFFIX (count_funcs) (e, symtab_section, -+ layout->ia64jmpnum = SUFFIX (count_funcs) (e, smd.symtab, - image_target); - layout->kernel_size += 16 * layout->ia64jmpnum; - -@@ -2038,31 +2107,19 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, - - if (is_relocatable (image_target)) - { -- layout->start_address = SUFFIX (relocate_symbols) (e, sections, symtab_section, -- section_vaddresses, section_entsize, -- num_sections, -- (char *) out_img + layout->ia64jmp_off, -- layout->ia64jmp_off -- + image_target->vaddr_offset, -- layout->bss_start, -- layout->end, -- image_target); -+ layout->start_address = SUFFIX (relocate_symbols) (e, &smd, -+ (char *) out_img + layout->ia64jmp_off, -+ layout->ia64jmp_off + image_target->vaddr_offset, -+ layout->bss_start, layout->end, image_target); -+ - if (layout->start_address == (Elf_Addr) -1) - grub_util_error ("start symbol is not defined"); - -- /* Resolve addresses in the virtual address space. */ -- SUFFIX (relocate_addresses) (e, sections, section_addresses, -- section_entsize, -- num_sections, strtab, -- out_img, layout->tramp_off, -- layout->got_off, -- image_target); -+ /* Resolve addrs in the virtual address space. */ -+ SUFFIX (relocate_addrs) (e, &smd, out_img, layout->tramp_off, -+ layout->got_off, image_target); - -- make_reloc_section (e, layout, -- section_vaddresses, sections, -- section_entsize, num_sections, -- strtab, -- image_target); -+ make_reloc_section (e, layout, &smd, image_target); - if (image_target->id != IMAGE_EFI) - { - out_img = xrealloc (out_img, layout->kernel_size + total_module_size -@@ -2074,30 +2131,25 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, - } - } - -- for (i = 0, s = sections; -- i < num_sections; -- i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) -- if (SUFFIX (is_data_section) (s, image_target) -- /* Explicitly initialize BSS -- when producing PE32 to avoid a bug in EFI implementations. -- Platforms other than EFI and U-boot shouldn't have .bss in -- their binaries as we build with -Wl,-Ttext. -- */ -- || (SUFFIX (is_bss_section) (s, image_target) && (image_target->id != IMAGE_UBOOT)) -- || SUFFIX (is_text_section) (s, image_target)) -+ for (i = 0, s = smd.sections; -+ i < smd.num_sections; -+ i++, s = (Elf_Shdr *) ((char *) s + smd.section_entsize)) -+ if (SUFFIX (is_kept_section) (s, image_target)) - { - if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS) -- memset (out_img + section_addresses[i], 0, -+ memset (out_img + smd.addrs[i], 0, - grub_host_to_target_addr (s->sh_size)); - else -- memcpy (out_img + section_addresses[i], -+ memcpy (out_img + smd.addrs[i], - kernel_img + grub_host_to_target_addr (s->sh_offset), - grub_host_to_target_addr (s->sh_size)); - } - free (kernel_img); - -- free (section_vaddresses); -- free (section_addresses); -+ free (smd.vaddrs); -+ smd.vaddrs = NULL; -+ free (smd.addrs); -+ smd.addrs = NULL; - - return out_img; - } -diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c -index 238d4840e2f9613c6392e16cb88e7f413cae41c4..9545945d8f3b1a85dea8404fe1a0c9b3a3b84ba1 100644 ---- a/util/grub-mkrescue.c -+++ b/util/grub-mkrescue.c -@@ -323,6 +323,7 @@ check_xorriso (const char *val) - char *buf = NULL; - size_t len = 0; - int ret = 0; -+ int wstatus = 0; - - argv[0] = xorriso; - argv[1] = "-as"; -@@ -347,8 +348,10 @@ check_xorriso (const char *val) - } - - close (fd); -- waitpid (pid, NULL, 0); -+ waitpid (pid, &wstatus, 0); - free (buf); -+ if (!WIFEXITED (wstatus) || WEXITSTATUS(wstatus) != 0) -+ return 0; - return ret; - } - -@@ -426,6 +429,7 @@ main (int argc, char *argv[]) - char **argp_argv; - int xorriso_tail_argc; - char **xorriso_tail_argv; -+ int rv; - - grub_util_host_init (&argc, &argv); - grub_util_disable_fd_syncs (); -@@ -478,6 +482,10 @@ main (int argc, char *argv[]) - if (!output_image) - grub_util_error ("%s", _("output file must be specified")); - -+ if (!check_xorriso ("graft-points")) { -+ grub_util_error ("%s", _("xorriso not found")); -+ } -+ - grub_init_all (); - grub_hostfs_init (); - grub_host_init (); -@@ -787,7 +795,6 @@ main (int argc, char *argv[]) - free (efidir_efi_boot); - - efiimgfat = grub_util_path_concat (2, iso9660_dir, "efi.img"); -- int rv; - rv = grub_util_exec ((const char * []) { "mformat", "-C", "-f", "2880", "-L", "16", "-i", - efiimgfat, "::", NULL }); - if (rv != 0) -@@ -960,7 +967,9 @@ main (int argc, char *argv[]) - - xorriso_argv[xorriso_argc] = NULL; - -- grub_util_exec ((const char *const *)xorriso_argv); -+ rv = grub_util_exec ((const char *const *)xorriso_argv); -+ if (rv != 0) -+ grub_util_error ("`%s` invocation failed\n", "xorriso"); - - grub_util_unlink_recursive (iso9660_dir); - -diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c -index 9179285a5ffe5d641a4c2726ce8367dba623d29e..a79271f663166f4d302e1f73d1bcd400c9e8604e 100644 ---- a/util/grub-module-verifier.c -+++ b/util/grub-module-verifier.c -@@ -19,6 +19,7 @@ struct grub_module_verifier_arch archs[] = { - -1 - }, (int[]){ - R_X86_64_PC32, -+ R_X86_64_PLT32, - -1 - } - }, -diff --git a/util/grub-probe.c b/util/grub-probe.c -index 8ac527d2f2a17142c5cf873d27c5818477d2c1a4..e45dbf9e049bd41f3122793330b2d0f7bcc844f8 100644 ---- a/util/grub-probe.c -+++ b/util/grub-probe.c -@@ -28,6 +28,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -62,6 +63,7 @@ enum { - PRINT_DRIVE, - PRINT_DEVICE, - PRINT_PARTMAP, -+ PRINT_PARTUUID, - PRINT_ABSTRACTION, - PRINT_CRYPTODISK_UUID, - PRINT_HINT_STR, -@@ -85,6 +87,7 @@ static const char *targets[] = - [PRINT_DRIVE] = "drive", - [PRINT_DEVICE] = "device", - [PRINT_PARTMAP] = "partmap", -+ [PRINT_PARTUUID] = "partuuid", - [PRINT_ABSTRACTION] = "abstraction", - [PRINT_CRYPTODISK_UUID] = "cryptodisk_uuid", - [PRINT_HINT_STR] = "hints_string", -@@ -129,6 +132,20 @@ get_targets_string (void) - return str; - } - -+static int -+print_gpt_guid (grub_gpt_part_guid_t guid) -+{ -+ guid.data1 = grub_le_to_cpu32 (guid.data1); -+ guid.data2 = grub_le_to_cpu16 (guid.data2); -+ guid.data3 = grub_le_to_cpu16 (guid.data3); -+ -+ return grub_printf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", -+ guid.data1, guid.data2, guid.data3, guid.data4[0], -+ guid.data4[1], guid.data4[2], guid.data4[3], -+ guid.data4[4], guid.data4[5], guid.data4[6], -+ guid.data4[7]); -+} -+ - static void - do_print (const char *x, void *data) - { -@@ -167,6 +184,45 @@ probe_partmap (grub_disk_t disk, char delim) - } - } - -+static void -+probe_partuuid (grub_disk_t disk, char delim) -+{ -+ grub_partition_t p = disk->partition; -+ -+ /* -+ * Nested partitions not supported for now. -+ * Non-nested partitions must have disk->partition->parent == NULL -+ */ -+ if (p && p->parent == NULL) -+ { -+ disk->partition = p->parent; -+ -+ if (strcmp(p->partmap->name, "msdos") == 0) -+ { -+ /* -+ * The partition GUID for MSDOS is the partition number (starting -+ * with 1) prepended with the NT disk signature. -+ */ -+ grub_uint32_t nt_disk_sig; -+ -+ if (grub_disk_read (disk, 0, GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, -+ sizeof(nt_disk_sig), &nt_disk_sig) == 0) -+ grub_printf ("%08x-%02x", -+ grub_le_to_cpu32(nt_disk_sig), 1 + p->number); -+ } -+ else if (strcmp(p->partmap->name, "gpt") == 0) -+ { -+ struct grub_gpt_partentry gptdata; -+ -+ if (grub_disk_read (disk, p->offset, p->index, -+ sizeof(gptdata), &gptdata) == 0) -+ print_gpt_guid(gptdata.guid); -+ } -+ -+ disk->partition = p; -+ } -+} -+ - static void - probe_cryptodisk_uuid (grub_disk_t disk, char delim) - { -@@ -621,6 +677,12 @@ probe (const char *path, char **device_names, char delim) - /* Check if dev->disk itself is contained in a partmap. */ - probe_partmap (dev->disk, delim); - -+ else if (print == PRINT_PARTUUID) -+ { -+ probe_partuuid (dev->disk, delim); -+ putchar (delim); -+ } -+ - else if (print == PRINT_MSDOS_PARTTYPE) - { - if (dev->disk->partition -@@ -641,21 +703,7 @@ probe (const char *path, char **device_names, char delim) - - if (grub_disk_read (dev->disk, p->offset, p->index, - sizeof (gptdata), &gptdata) == 0) -- { -- grub_gpt_part_type_t gpttype; -- gpttype.data1 = grub_le_to_cpu32 (gptdata.type.data1); -- gpttype.data2 = grub_le_to_cpu16 (gptdata.type.data2); -- gpttype.data3 = grub_le_to_cpu16 (gptdata.type.data3); -- grub_memcpy (gpttype.data4, gptdata.type.data4, 8); -- -- grub_printf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", -- gpttype.data1, gpttype.data2, -- gpttype.data3, gpttype.data4[0], -- gpttype.data4[1], gpttype.data4[2], -- gpttype.data4[3], gpttype.data4[4], -- gpttype.data4[5], gpttype.data4[6], -- gpttype.data4[7]); -- } -+ print_gpt_guid(gptdata.type); - dev->disk->partition = p; - } - putchar (delim); -diff --git a/util/ieee1275/grub-ofpathname.c b/util/ieee1275/grub-ofpathname.c -index 8e5d766cb63871c1479a42626c8cfa7fddd6f771..300fbddad7c54e2b52d90a7de5eb868a9a1ae705 100644 ---- a/util/ieee1275/grub-ofpathname.c -+++ b/util/ieee1275/grub-ofpathname.c -@@ -46,7 +46,9 @@ int main(int argc, char **argv) - } - - of_path = grub_util_devname_to_ofpath (argv[1]); -- printf("%s\n", of_path); -+ -+ if (of_path) -+ printf ("%s\n", of_path); - - free (of_path); - -diff --git a/util/mkimage.c b/util/mkimage.c -index 9ad4cfe4223b661c11ab9d3783cb13c88100631c..e22d82afa61a6aa4209c7ab6d2aa5b58f95e1bfe 100644 ---- a/util/mkimage.c -+++ b/util/mkimage.c -@@ -533,6 +533,45 @@ static const struct grub_install_image_target_desc image_targets[] = - .mod_align = GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN, - .link_align = 4 - }, -+ /* For coreboot versions that don't support self-relocating images. */ -+ { -+ .dirname = "arm-coreboot-vexpress", -+ .names = { "arm-coreboot-vexpress", NULL }, -+ .voidp_sizeof = 4, -+ .bigendian = 0, -+ .id = IMAGE_COREBOOT, -+ .flags = PLATFORM_FLAGS_NONE, -+ .total_module_size = GRUB_KERNEL_ARM_COREBOOT_TOTAL_MODULE_SIZE, -+ .decompressor_compressed_size = TARGET_NO_FIELD, -+ .decompressor_uncompressed_size = TARGET_NO_FIELD, -+ .decompressor_uncompressed_addr = TARGET_NO_FIELD, -+ .section_align = GRUB_KERNEL_ARM_COREBOOT_MOD_ALIGN, -+ .vaddr_offset = 0, -+ .elf_target = EM_ARM, -+ .mod_gap = GRUB_KERNEL_ARM_COREBOOT_MOD_GAP, -+ .mod_align = GRUB_KERNEL_ARM_COREBOOT_MOD_ALIGN, -+ .link_align = 4, -+ .link_addr = 0x62000000, -+ }, -+ { -+ .dirname = "arm-coreboot-veyron", -+ .names = { "arm-coreboot-veyron", NULL }, -+ .voidp_sizeof = 4, -+ .bigendian = 0, -+ .id = IMAGE_COREBOOT, -+ .flags = PLATFORM_FLAGS_NONE, -+ .total_module_size = GRUB_KERNEL_ARM_COREBOOT_TOTAL_MODULE_SIZE, -+ .decompressor_compressed_size = TARGET_NO_FIELD, -+ .decompressor_uncompressed_size = TARGET_NO_FIELD, -+ .decompressor_uncompressed_addr = TARGET_NO_FIELD, -+ .section_align = GRUB_KERNEL_ARM_COREBOOT_MOD_ALIGN, -+ .vaddr_offset = 0, -+ .elf_target = EM_ARM, -+ .mod_gap = GRUB_KERNEL_ARM_COREBOOT_MOD_GAP, -+ .mod_align = GRUB_KERNEL_ARM_COREBOOT_MOD_ALIGN, -+ .link_align = 4, -+ .link_addr = 0x43000000, -+ }, - { - .dirname = "arm-efi", - .names = { "arm-efi", NULL }, -@@ -738,13 +777,12 @@ grub_install_generate_image (const char *dir, const char *prefix, - char *memdisk_path, char **pubkey_paths, - size_t npubkeys, char *config_path, - const struct grub_install_image_target_desc *image_target, -- int note, -- grub_compression_t comp) -+ int note, grub_compression_t comp, const char *dtb_path) - { - char *kernel_img, *core_img; - size_t total_module_size, core_size; - size_t memdisk_size = 0, config_size = 0; -- size_t prefix_size = 0; -+ size_t prefix_size = 0, dtb_size = 0; - char *kernel_path; - size_t offset; - struct grub_util_path_list *path_list, *p; -@@ -789,6 +827,12 @@ grub_install_generate_image (const char *dir, const char *prefix, - total_module_size += memdisk_size + sizeof (struct grub_module_header); - } - -+ if (dtb_path) -+ { -+ dtb_size = ALIGN_UP(grub_util_get_image_size (dtb_path), 4); -+ total_module_size += dtb_size + sizeof (struct grub_module_header); -+ } -+ - if (config_path) - { - config_size = ALIGN_ADDR (grub_util_get_image_size (config_path) + 1); -@@ -911,6 +955,19 @@ grub_install_generate_image (const char *dir, const char *prefix, - offset += memdisk_size; - } - -+ if (dtb_path) -+ { -+ struct grub_module_header *header; -+ -+ header = (struct grub_module_header *) (kernel_img + offset); -+ header->type = grub_host_to_target32 (OBJ_TYPE_DTB); -+ header->size = grub_host_to_target32 (dtb_size + sizeof (*header)); -+ offset += sizeof (*header); -+ -+ grub_util_load_image (dtb_path, kernel_img + offset); -+ offset += dtb_size; -+ } -+ - if (config_path) - { - struct grub_module_header *header; -@@ -1033,7 +1090,7 @@ grub_install_generate_image (const char *dir, const char *prefix, - /* fallthrough */ - case IMAGE_COREBOOT: - case IMAGE_QEMU: -- if (layout.kernel_size + layout.bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000) -+ if (image_target->elf_target != EM_ARM && layout.kernel_size + layout.bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000) - grub_util_error (_("kernel image is too big (0x%x > 0x%x)"), - (unsigned) layout.kernel_size + (unsigned) layout.bss_size - + GRUB_KERNEL_I386_PC_LINK_ADDR, -@@ -1638,10 +1695,10 @@ grub_install_generate_image (const char *dir, const char *prefix, - target_addr = image_target->link_addr; - if (image_target->voidp_sizeof == 4) - grub_mkimage_generate_elf32 (image_target, note, &core_img, &core_size, -- target_addr, layout.align, layout.kernel_size, layout.bss_size); -+ target_addr, &layout); - else - grub_mkimage_generate_elf64 (image_target, note, &core_img, &core_size, -- target_addr, layout.align, layout.kernel_size, layout.bss_size); -+ target_addr, &layout); - } - break; - } -diff --git a/util/setup.c b/util/setup.c -index 8aa5a39a79465c33b0ff6a5a6b1bc82128df2e18..9c1e1b7da6a85ea7aece6433f2eaf81a6ccde451 100644 ---- a/util/setup.c -+++ b/util/setup.c -@@ -137,6 +137,9 @@ struct blocklists - struct grub_boot_blocklist *first_block, *block; - #ifdef GRUB_SETUP_BIOS - grub_uint16_t current_segment; -+#endif -+#ifdef GRUB_SETUP_SPARC64 -+ grub_uint64_t gpt_offset; - #endif - grub_uint16_t last_length; - grub_disk_addr_t first_sector; -@@ -151,6 +154,10 @@ save_blocklists (grub_disk_addr_t sector, unsigned offset, unsigned length, - struct grub_boot_blocklist *prev = bl->block + 1; - grub_uint64_t seclen; - -+#ifdef GRUB_SETUP_SPARC64 -+ sector -= bl->gpt_offset; -+#endif -+ - grub_util_info ("saving <%" GRUB_HOST_PRIuLONG_LONG ",%u,%u>", - (unsigned long long) sector, offset, length); - -@@ -298,9 +305,8 @@ SETUP (const char *dir, - bl.first_block = (struct grub_boot_blocklist *) (core_img - + GRUB_DISK_SECTOR_SIZE - - sizeof (*bl.block)); -- grub_util_info ("root is `%s', dest is `%s'", root, dest); - -- grub_util_info ("Opening dest"); -+ grub_util_info ("Opening dest `%s'", dest); - dest_dev = grub_device_open (dest); - if (! dest_dev) - grub_util_error ("%s", grub_errmsg); -@@ -662,6 +668,16 @@ unable_to_embed: - - bl.block = bl.first_block; - -+#ifdef GRUB_SETUP_SPARC64 -+ { -+ grub_partition_t container = root_dev->disk->partition; -+ bl.gpt_offset = 0; -+ -+ if (grub_strstr (container->partmap->name, "gpt")) -+ bl.gpt_offset = grub_partition_get_start (container); -+ } -+#endif -+ - grub_install_get_blocklist (root_dev, core_path, core_img, core_size, - save_blocklists, &bl); - -@@ -721,15 +737,18 @@ unable_to_embed: - { - char *buf, *ptr = core_img; - size_t len = core_size; -- grub_uint64_t blk; -+ grub_uint64_t blk, offset = 0; - grub_partition_t container = core_dev->disk->partition; - grub_err_t err; - - core_dev->disk->partition = 0; -+#ifdef GRUB_SETUP_SPARC64 -+ offset = bl.gpt_offset; -+#endif - - buf = xmalloc (core_size); - blk = bl.first_sector; -- err = grub_disk_read (core_dev->disk, blk, 0, GRUB_DISK_SECTOR_SIZE, buf); -+ err = grub_disk_read (core_dev->disk, blk + offset, 0, GRUB_DISK_SECTOR_SIZE, buf); - if (err) - grub_util_error (_("cannot read `%s': %s"), core_dev->disk->name, - grub_errmsg); -@@ -748,7 +767,7 @@ unable_to_embed: - if (cur > len) - cur = len; - -- err = grub_disk_read (core_dev->disk, blk, 0, cur, buf); -+ err = grub_disk_read (core_dev->disk, blk + offset, 0, cur, buf); - if (err) - grub_util_error (_("cannot read `%s': %s"), core_dev->disk->name, - grub_errmsg); -diff --git a/grub-core/lib/libgcrypt/cipher/bufhelp.h b/grub-core/lib/libgcrypt/cipher/bufhelp.h -new file mode 100644 -index 0000000000000000000000000000000000000000..df3559472312d8c6c0c038e27571c546ce489283 ---- /dev/null -+++ b/grub-core/lib/libgcrypt/cipher/bufhelp.h -@@ -0,0 +1,432 @@ -+/* bufhelp.h - Some buffer manipulation helpers -+ * Copyright (C) 2012 Jussi Kivilinna -+ * -+ * This file is part of Libgcrypt. -+ * -+ * Libgcrypt is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU Lesser General Public License as -+ * published by the Free Software Foundation; either version 2.1 of -+ * the License, or (at your option) any later version. -+ * -+ * Libgcrypt is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this program; if not, see . -+ */ -+#ifndef GCRYPT_BUFHELP_H -+#define GCRYPT_BUFHELP_H -+ -+ -+#include "bithelp.h" -+ -+ -+#undef BUFHELP_FAST_UNALIGNED_ACCESS -+#if defined(HAVE_GCC_ATTRIBUTE_PACKED) && \ -+ defined(HAVE_GCC_ATTRIBUTE_ALIGNED) && \ -+ (defined(__i386__) || defined(__x86_64__) || \ -+ (defined(__arm__) && defined(__ARM_FEATURE_UNALIGNED)) || \ -+ defined(__aarch64__)) -+/* These architectures are able of unaligned memory accesses and can -+ handle those fast. -+ */ -+# define BUFHELP_FAST_UNALIGNED_ACCESS 1 -+#endif -+ -+ -+#ifdef BUFHELP_FAST_UNALIGNED_ACCESS -+/* Define type with one-byte alignment on architectures with fast unaligned -+ memory accesses. -+ */ -+typedef struct bufhelp_int_s -+{ -+ uintptr_t a; -+} __attribute__((packed, aligned(1))) bufhelp_int_t; -+#else -+/* Define type with default alignment for other architectures (unaligned -+ accessed handled in per byte loops). -+ */ -+typedef struct bufhelp_int_s -+{ -+ uintptr_t a; -+} bufhelp_int_t; -+#endif -+ -+ -+/* Optimized function for small buffer copying */ -+static inline void -+buf_cpy(void *_dst, const void *_src, size_t len) -+{ -+#if __GNUC__ >= 4 && (defined(__x86_64__) || defined(__i386__)) -+ /* For AMD64 and i386, memcpy is faster. */ -+ memcpy(_dst, _src, len); -+#else -+ byte *dst = _dst; -+ const byte *src = _src; -+ bufhelp_int_t *ldst; -+ const bufhelp_int_t *lsrc; -+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS -+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1; -+ -+ /* Skip fast processing if buffers are unaligned. */ -+ if (((uintptr_t)dst | (uintptr_t)src) & longmask) -+ goto do_bytes; -+#endif -+ -+ ldst = (bufhelp_int_t *)(void *)dst; -+ lsrc = (const bufhelp_int_t *)(const void *)src; -+ -+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t)) -+ (ldst++)->a = (lsrc++)->a; -+ -+ dst = (byte *)ldst; -+ src = (const byte *)lsrc; -+ -+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS -+do_bytes: -+#endif -+ /* Handle tail. */ -+ for (; len; len--) -+ *dst++ = *src++; -+#endif /*__GNUC__ >= 4 && (__x86_64__ || __i386__)*/ -+} -+ -+ -+/* Optimized function for buffer xoring */ -+static inline void -+buf_xor(void *_dst, const void *_src1, const void *_src2, size_t len) -+{ -+ byte *dst = _dst; -+ const byte *src1 = _src1; -+ const byte *src2 = _src2; -+ bufhelp_int_t *ldst; -+ const bufhelp_int_t *lsrc1, *lsrc2; -+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS -+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1; -+ -+ /* Skip fast processing if buffers are unaligned. */ -+ if (((uintptr_t)dst | (uintptr_t)src1 | (uintptr_t)src2) & longmask) -+ goto do_bytes; -+#endif -+ -+ ldst = (bufhelp_int_t *)(void *)dst; -+ lsrc1 = (const bufhelp_int_t *)(const void *)src1; -+ lsrc2 = (const bufhelp_int_t *)(const void *)src2; -+ -+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t)) -+ (ldst++)->a = (lsrc1++)->a ^ (lsrc2++)->a; -+ -+ dst = (byte *)ldst; -+ src1 = (const byte *)lsrc1; -+ src2 = (const byte *)lsrc2; -+ -+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS -+do_bytes: -+#endif -+ /* Handle tail. */ -+ for (; len; len--) -+ *dst++ = *src1++ ^ *src2++; -+} -+ -+ -+/* Optimized function for in-place buffer xoring. */ -+static inline void -+buf_xor_1(void *_dst, const void *_src, size_t len) -+{ -+ byte *dst = _dst; -+ const byte *src = _src; -+ bufhelp_int_t *ldst; -+ const bufhelp_int_t *lsrc; -+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS -+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1; -+ -+ /* Skip fast processing if buffers are unaligned. */ -+ if (((uintptr_t)dst | (uintptr_t)src) & longmask) -+ goto do_bytes; -+#endif -+ -+ ldst = (bufhelp_int_t *)(void *)dst; -+ lsrc = (const bufhelp_int_t *)(const void *)src; -+ -+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t)) -+ (ldst++)->a ^= (lsrc++)->a; -+ -+ dst = (byte *)ldst; -+ src = (const byte *)lsrc; -+ -+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS -+do_bytes: -+#endif -+ /* Handle tail. */ -+ for (; len; len--) -+ *dst++ ^= *src++; -+} -+ -+ -+/* Optimized function for buffer xoring with two destination buffers. Used -+ mainly by CFB mode encryption. */ -+static inline void -+buf_xor_2dst(void *_dst1, void *_dst2, const void *_src, size_t len) -+{ -+ byte *dst1 = _dst1; -+ byte *dst2 = _dst2; -+ const byte *src = _src; -+ bufhelp_int_t *ldst1, *ldst2; -+ const bufhelp_int_t *lsrc; -+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS -+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1; -+ -+ /* Skip fast processing if buffers are unaligned. */ -+ if (((uintptr_t)src | (uintptr_t)dst1 | (uintptr_t)dst2) & longmask) -+ goto do_bytes; -+#endif -+ -+ ldst1 = (bufhelp_int_t *)(void *)dst1; -+ ldst2 = (bufhelp_int_t *)(void *)dst2; -+ lsrc = (const bufhelp_int_t *)(const void *)src; -+ -+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t)) -+ (ldst1++)->a = ((ldst2++)->a ^= (lsrc++)->a); -+ -+ dst1 = (byte *)ldst1; -+ dst2 = (byte *)ldst2; -+ src = (const byte *)lsrc; -+ -+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS -+do_bytes: -+#endif -+ /* Handle tail. */ -+ for (; len; len--) -+ *dst1++ = (*dst2++ ^= *src++); -+} -+ -+ -+/* Optimized function for combined buffer xoring and copying. Used by mainly -+ CBC mode decryption. */ -+static inline void -+buf_xor_n_copy_2(void *_dst_xor, const void *_src_xor, void *_srcdst_cpy, -+ const void *_src_cpy, size_t len) -+{ -+ byte *dst_xor = _dst_xor; -+ byte *srcdst_cpy = _srcdst_cpy; -+ const byte *src_xor = _src_xor; -+ const byte *src_cpy = _src_cpy; -+ byte temp; -+ bufhelp_int_t *ldst_xor, *lsrcdst_cpy; -+ const bufhelp_int_t *lsrc_cpy, *lsrc_xor; -+ uintptr_t ltemp; -+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS -+ const unsigned int longmask = sizeof(bufhelp_int_t) - 1; -+ -+ /* Skip fast processing if buffers are unaligned. */ -+ if (((uintptr_t)src_cpy | (uintptr_t)src_xor | (uintptr_t)dst_xor | -+ (uintptr_t)srcdst_cpy) & longmask) -+ goto do_bytes; -+#endif -+ -+ ldst_xor = (bufhelp_int_t *)(void *)dst_xor; -+ lsrc_xor = (const bufhelp_int_t *)(void *)src_xor; -+ lsrcdst_cpy = (bufhelp_int_t *)(void *)srcdst_cpy; -+ lsrc_cpy = (const bufhelp_int_t *)(const void *)src_cpy; -+ -+ for (; len >= sizeof(bufhelp_int_t); len -= sizeof(bufhelp_int_t)) -+ { -+ ltemp = (lsrc_cpy++)->a; -+ (ldst_xor++)->a = (lsrcdst_cpy)->a ^ (lsrc_xor++)->a; -+ (lsrcdst_cpy++)->a = ltemp; -+ } -+ -+ dst_xor = (byte *)ldst_xor; -+ src_xor = (const byte *)lsrc_xor; -+ srcdst_cpy = (byte *)lsrcdst_cpy; -+ src_cpy = (const byte *)lsrc_cpy; -+ -+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS -+do_bytes: -+#endif -+ /* Handle tail. */ -+ for (; len; len--) -+ { -+ temp = *src_cpy++; -+ *dst_xor++ = *srcdst_cpy ^ *src_xor++; -+ *srcdst_cpy++ = temp; -+ } -+} -+ -+ -+/* Optimized function for combined buffer xoring and copying. Used by mainly -+ CFB mode decryption. */ -+static inline void -+buf_xor_n_copy(void *_dst_xor, void *_srcdst_cpy, const void *_src, size_t len) -+{ -+ buf_xor_n_copy_2(_dst_xor, _src, _srcdst_cpy, _src, len); -+} -+ -+ -+/* Constant-time compare of two buffers. Returns 1 if buffers are equal, -+ and 0 if buffers differ. */ -+static inline int -+buf_eq_const(const void *_a, const void *_b, size_t len) -+{ -+ const byte *a = _a; -+ const byte *b = _b; -+ size_t diff, i; -+ -+ /* Constant-time compare. */ -+ for (i = 0, diff = 0; i < len; i++) -+ diff -= !!(a[i] - b[i]); -+ -+ return !diff; -+} -+ -+ -+#ifndef BUFHELP_FAST_UNALIGNED_ACCESS -+ -+/* Functions for loading and storing unaligned u32 values of different -+ endianness. */ -+static inline u32 buf_get_be32(const void *_buf) -+{ -+ const byte *in = _buf; -+ return ((u32)in[0] << 24) | ((u32)in[1] << 16) | \ -+ ((u32)in[2] << 8) | (u32)in[3]; -+} -+ -+static inline u32 buf_get_le32(const void *_buf) -+{ -+ const byte *in = _buf; -+ return ((u32)in[3] << 24) | ((u32)in[2] << 16) | \ -+ ((u32)in[1] << 8) | (u32)in[0]; -+} -+ -+static inline void buf_put_be32(void *_buf, u32 val) -+{ -+ byte *out = _buf; -+ out[0] = val >> 24; -+ out[1] = val >> 16; -+ out[2] = val >> 8; -+ out[3] = val; -+} -+ -+static inline void buf_put_le32(void *_buf, u32 val) -+{ -+ byte *out = _buf; -+ out[3] = val >> 24; -+ out[2] = val >> 16; -+ out[1] = val >> 8; -+ out[0] = val; -+} -+ -+ -+/* Functions for loading and storing unaligned u64 values of different -+ endianness. */ -+static inline u64 buf_get_be64(const void *_buf) -+{ -+ const byte *in = _buf; -+ return ((u64)in[0] << 56) | ((u64)in[1] << 48) | \ -+ ((u64)in[2] << 40) | ((u64)in[3] << 32) | \ -+ ((u64)in[4] << 24) | ((u64)in[5] << 16) | \ -+ ((u64)in[6] << 8) | (u64)in[7]; -+} -+ -+static inline u64 buf_get_le64(const void *_buf) -+{ -+ const byte *in = _buf; -+ return ((u64)in[7] << 56) | ((u64)in[6] << 48) | \ -+ ((u64)in[5] << 40) | ((u64)in[4] << 32) | \ -+ ((u64)in[3] << 24) | ((u64)in[2] << 16) | \ -+ ((u64)in[1] << 8) | (u64)in[0]; -+} -+ -+static inline void buf_put_be64(void *_buf, u64 val) -+{ -+ byte *out = _buf; -+ out[0] = val >> 56; -+ out[1] = val >> 48; -+ out[2] = val >> 40; -+ out[3] = val >> 32; -+ out[4] = val >> 24; -+ out[5] = val >> 16; -+ out[6] = val >> 8; -+ out[7] = val; -+} -+ -+static inline void buf_put_le64(void *_buf, u64 val) -+{ -+ byte *out = _buf; -+ out[7] = val >> 56; -+ out[6] = val >> 48; -+ out[5] = val >> 40; -+ out[4] = val >> 32; -+ out[3] = val >> 24; -+ out[2] = val >> 16; -+ out[1] = val >> 8; -+ out[0] = val; -+} -+ -+#else /*BUFHELP_FAST_UNALIGNED_ACCESS*/ -+ -+typedef struct bufhelp_u32_s -+{ -+ u32 a; -+} __attribute__((packed, aligned(1))) bufhelp_u32_t; -+ -+/* Functions for loading and storing unaligned u32 values of different -+ endianness. */ -+static inline u32 buf_get_be32(const void *_buf) -+{ -+ return be_bswap32(((const bufhelp_u32_t *)_buf)->a); -+} -+ -+static inline u32 buf_get_le32(const void *_buf) -+{ -+ return le_bswap32(((const bufhelp_u32_t *)_buf)->a); -+} -+ -+static inline void buf_put_be32(void *_buf, u32 val) -+{ -+ bufhelp_u32_t *out = _buf; -+ out->a = be_bswap32(val); -+} -+ -+static inline void buf_put_le32(void *_buf, u32 val) -+{ -+ bufhelp_u32_t *out = _buf; -+ out->a = le_bswap32(val); -+} -+ -+ -+typedef struct bufhelp_u64_s -+{ -+ u64 a; -+} __attribute__((packed, aligned(1))) bufhelp_u64_t; -+ -+/* Functions for loading and storing unaligned u64 values of different -+ endianness. */ -+static inline u64 buf_get_be64(const void *_buf) -+{ -+ return be_bswap64(((const bufhelp_u64_t *)_buf)->a); -+} -+ -+static inline u64 buf_get_le64(const void *_buf) -+{ -+ return le_bswap64(((const bufhelp_u64_t *)_buf)->a); -+} -+ -+static inline void buf_put_be64(void *_buf, u64 val) -+{ -+ bufhelp_u64_t *out = _buf; -+ out->a = be_bswap64(val); -+} -+ -+static inline void buf_put_le64(void *_buf, u64 val) -+{ -+ bufhelp_u64_t *out = _buf; -+ out->a = le_bswap64(val); -+} -+ -+ -+#endif /*BUFHELP_FAST_UNALIGNED_ACCESS*/ -+ -+#endif /*GCRYPT_BUFHELP_H*/ -diff --git a/grub-core/tests/checksums.h b/grub-core/tests/checksums.h -index 68d8ce7c7753ff721ab0d5a12d40b2aff20c694c..8273bd105deec0bf21f507e0eddb867f104afc5d 100644 ---- a/grub-core/tests/checksums.h -+++ b/grub-core/tests/checksums.h -@@ -1,129 +1,129 @@ -- { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xcd5fc34e, 0xcd5fc34e, 0xeabbecab, 0xeabbecab, 0xc9950151, 0xc9950151, 0x2be222b6, 0x2be222b6, 0xe88c769e, 0xe88c769e, 0x6be4910e, 0x6be4910e, 0x1dc1fe4f, 0x1dc1fe4f, 0xd7613e8f, 0xd7613e8f, 0xf8124196, 0xf8124196, 0x130f5935, 0x130f5935, 0x2872330e, 0x2872330e, 0xaa7b7868, 0xaa7b7868, 0x558eaeea, 0x558eaeea, 0x92f7960f, 0x92f7960f, 0xc5bfc709, 0xc5bfc709, 0x699732fe, 0x699732fe, 0xc859125f, 0xc859125f, 0xfc6ac729, 0xfc6ac729, 0xcdab6cd4, 0xcdab6cd4, 0x58a8b7f8, 0x58a8b7f8, 0xc0e73385, 0x6560d6ef, 0x3be8bb5d, 0x3be8bb5d, }, 45 }, -- { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x13029f94, 0x13029f94, 0x7785fdab, 0x7785fdab, 0x95a7c1e8, 0x95a7c1e8, 0x315ab3e3, 0x315ab3e3, 0x6787f012, 0x6787f012, 0x79b1ecdc, 0x79b1ecdc, 0xdbc67810, 0xdbc67810, 0xafaa982e, 0xafaa982e, 0xc5cd0157, 0xc5cd0157, 0x3c50dd64, 0x3c50dd64, 0x1056cac0, 0x1056cac0, 0x1d7a41fa, 0x1d7a41fa, 0x5690b1e8, 0x5690b1e8, 0x616831d6, 0x616831d6, 0xfaf8e726, 0xfaf8e726, 0xd1ec5e26, 0xd1ec5e26, 0x3c269e1f, 0x3c269e1f, 0x1aa7952d, 0x1aa7952d, 0x6e7e2f99, 0x6e7e2f99, 0x98f4c02, 0x98f4c02, 0xc3f1abf2, 0xe348bb73, 0xea53cd60, 0xea53cd60, }, 45 }, -- { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x8fbb4f4c, 0x8fbb4f4c, 0x5dc00167, 0x5dc00167, 0xbc124df8, 0xbc124df8, 0x31cf0f8e, 0x31cf0f8e, 0x798cc4ed, 0x798cc4ed, 0xc5d2a091, 0xc5d2a091, 0xb58a0591, 0xb58a0591, 0x4d118aca, 0x4d118aca, 0xbb06c7ee, 0xbb06c7ee, 0x42179db7, 0x42179db7, 0x65f2d81e, 0x65f2d81e, 0xa2628bcb, 0xa2628bcb, 0xbdb7f4b, 0xbdb7f4b, 0x66b10309, 0x66b10309, 0x1a550ea9, 0x1a550ea9, 0x377a297d, 0x377a297d, 0x2ea99015, 0x2ea99015, 0x4e20d7bc, 0x4e20d7bc, 0x8ecbde02, 0x8ecbde02, 0xdfa2195a, 0xdfa2195a, 0xe113d2a, 0xe204ee5b, 0x734679c1, 0x734679c1, }, 45 }, -- { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xe2f6bfe1, 0xe2f6bfe1, 0xf18aee15, 0xf18aee15, 0x5e83b689, 0x5e83b689, 0xb7e8b42c, 0xb7e8b42c, 0x85d78f92, 0x85d78f92, 0xd56fadae, 0xd56fadae, 0x7632f5bf, 0x7632f5bf, 0x2769a748, 0x2769a748, 0x4a6112cd, 0x4a6112cd, 0x4f9b66a4, 0x4f9b66a4, 0x70457d38, 0x70457d38, 0x8cadb1a7, 0x8cadb1a7, 0x451341f, 0x451341f, 0x8a62e741, 0x8a62e741, 0x1b1f9031, 0x1b1f9031, 0x75ab630e, 0x75ab630e, 0xd5ff53ac, 0xd5ff53ac, 0x73a2b3c7, 0x73a2b3c7, 0x7b52acd5, 0x7b52acd5, 0xf6f3e48c, 0xf6f3e48c, 0x8d0db133, 0x8db24310, 0x7aef56d4, 0x7aef56d4, }, 45 }, -- { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x838a3f40, 0x838a3f40, 0x7351ba96, 0x7351ba96, 0x660963bb, 0x660963bb, 0x6f3362a6, 0x6f3362a6, 0x915d35d9, 0x915d35d9, 0xc7edaee9, 0xc7edaee9, 0xbc8ec24c, 0xbc8ec24c, 0xeb120ffd, 0xeb120ffd, 0x8f6d8232, 0x8f6d8232, 0x2de5d515, 0x2de5d515, 0x4f2ecd91, 0x4f2ecd91, 0x555a9b90, 0x555a9b90, 0x8f7b0d77, 0x8f7b0d77, 0x5f9536af, 0x5f9536af, 0x3dd79dbe, 0x3dd79dbe, 0xb555a0, 0xb555a0, 0x75aec882, 0x75aec882, 0xd5da89cb, 0xd5da89cb, 0xb47b3257, 0xb47b3257, 0x7c97c046, 0x7c97c046, 0x726a7abe, 0x4c8b8a56, 0xcffa0854, 0xcffa0854, }, 45 }, -- { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7bf761e, 0x7bf761e, 0xaf0b6dae, 0xaf0b6dae, 0x7db15930, 0x7db15930, 0xc9720d56, 0xc9720d56, 0x55590d6c, 0x55590d6c, 0xa0d193d9, 0xa0d193d9, 0x728987b2, 0x728987b2, 0x28aecde6, 0x28aecde6, 0xa59bb094, 0xa59bb094, 0x2d0b049d, 0x2d0b049d, 0xd8421240, 0xd8421240, 0x51fa339, 0x51fa339, 0xc625cc46, 0xc625cc46, 0x2c9e6fcc, 0x2c9e6fcc, 0x3d06ffd5, 0x3d06ffd5, 0x8dd72816, 0x8dd72816, 0xfcf2a982, 0xfcf2a982, 0x6ef2870f, 0x6ef2870f, 0xba2caab7, 0xba2caab7, 0x8e5a5872, 0x8e5a5872, 0x62b2fedc, 0x2bd3b588, 0x34ebdb15, 0x34ebdb15, }, 45 }, -- { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa133280a, 0xa133280a, 0x1e8f4227, 0x1e8f4227, 0xa01cd911, 0xa01cd911, 0xdcb3d617, 0xdcb3d617, 0x51200351, 0x51200351, 0x609ba305, 0x609ba305, 0x5d96abfd, 0x5d96abfd, 0xd855cc70, 0xd855cc70, 0xdbfaf18d, 0xdbfaf18d, 0x84814843, 0x84814843, 0x4b00e630, 0x4b00e630, 0xd362b0f5, 0xd362b0f5, 0xec863355, 0xec863355, 0x195898d0, 0x195898d0, 0xe8c698c7, 0xe8c698c7, 0x884229e7, 0x884229e7, 0xb41ed3a9, 0xb41ed3a9, 0x2be1ce40, 0x2be1ce40, 0x8c33eb7c, 0x8c33eb7c, 0xbbce1da, 0xbbce1da, 0xef9415fa, 0x22fbc0d, 0xd82c182c, 0xd82c182c, }, 45 }, -- { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xbe029c, 0x6671ee1f, 0xbe029c, 0x4348cfdb, 0x59c36f00, 0x59c36f00, 0x3ad73295, 0x3ad73295, 0x3ad73295, 0x44575ff3, 0x44575ff3, 0x44575ff3, 0x26a14a21, 0x26a14a21, 0x26a14a21, 0x59c36f00, 0x4348cfdb, 0x4348cfdb, 0x59c36f00, }, 20 }, -- { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x14e228ef, 0xb0c8af57, 0x14e228ef, 0x3ae7ad90, 0xaa4593fe, 0xaa4593fe, 0xbec19c1b, 0xbec19c1b, 0xbec19c1b, 0x1834917c, 0x1834917c, 0x1834917c, 0x350c3a04, 0x350c3a04, 0x350c3a04, 0xaa4593fe, 0x3ae7ad90, 0x3ae7ad90, 0xaa4593fe, }, 20 }, -- { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x651fb144, 0xdf93ee9c, 0x651fb144, 0x3808dcc0, 0xc9cbf769, 0xc9cbf769, 0xe4861949, 0xe4861949, 0xe4861949, 0x1a5ed885, 0x1a5ed885, 0x1a5ed885, 0xf314678d, 0xf314678d, 0xf314678d, 0xc9cbf769, 0x3808dcc0, 0x3808dcc0, 0xc9cbf769, }, 20 }, -- { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xdfd0119e, 0x6c7018a9, 0xdfd0119e, 0x71865846, 0x9813a416, 0x9813a416, 0xb5e8801c, 0xb5e8801c, 0xb5e8801c, 0x2433062f, 0x2433062f, 0x2433062f, 0x3d893bff, 0x3d893bff, 0x3d893bff, 0x9813a416, 0x71865846, 0x71865846, 0x9813a416, }, 20 }, -- { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x4e4844e0, 0x5ebe5f81, 0x4e4844e0, 0x38ee7153, 0x5fcf013d, 0x5fcf013d, 0x819b5c4e, 0x819b5c4e, 0x819b5c4e, 0x538b4438, 0x538b4438, 0x538b4438, 0x45f87ba7, 0x45f87ba7, 0x45f87ba7, 0x5fcf013d, 0x38ee7153, 0x38ee7153, 0x5fcf013d, }, 20 }, -- { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x701427d4, 0x246c830a, 0x701427d4, 0x6b11fdd3, 0xdd28f52b, 0xdd28f52b, 0xcd83646c, 0xcd83646c, 0xcd83646c, 0xecbf9d88, 0xecbf9d88, 0xecbf9d88, 0x91075604, 0x91075604, 0x91075604, 0xdd28f52b, 0x6b11fdd3, 0x6b11fdd3, 0xdd28f52b, }, 20 }, -- { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x7b5bd4c, 0xac246af1, 0x7b5bd4c, 0xf80aa6cc, 0x43d1f34, 0x43d1f34, 0xb200c08a, 0xb200c08a, 0xb200c08a, 0xcd0a6922, 0xcd0a6922, 0xcd0a6922, 0x545b6ca4, 0x545b6ca4, 0x545b6ca4, 0x43d1f34, 0xf80aa6cc, 0xf80aa6cc, 0x43d1f34, }, 20 }, -- { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1027210c, 0x64e51c81, 0x1027210c, 0x45ca4a8a, 0x9a2e0d26, 0x12fd0f21, 0x12fd0f21, 0x12fd0f21, 0x4e25f9e1, 0x4e25f9e1, 0x4e25f9e1, 0x67bd3773, 0x67bd3773, 0x67bd3773, 0x59c36f00, 0x45ca4a8a, 0x45ca4a8a, }, 18 }, -- { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8d12f697, 0xc5b32248, 0x8d12f697, 0x56720aa4, 0xa9d58ccd, 0xf766a14d, 0xf766a14d, 0xf766a14d, 0xa2390b47, 0xa2390b47, 0xa2390b47, 0xcb0ac30e, 0xcb0ac30e, 0xcb0ac30e, 0xaa4593fe, 0x56720aa4, 0x56720aa4, }, 18 }, -- { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa5ec9f45, 0xdb7085d8, 0xa5ec9f45, 0x9caf1d3f, 0x5411be8b, 0xedc0ad83, 0xedc0ad83, 0xedc0ad83, 0x927e0b17, 0x927e0b17, 0x927e0b17, 0xd00a6b6f, 0xd00a6b6f, 0xd00a6b6f, 0xc9cbf769, 0x9caf1d3f, 0x9caf1d3f, }, 18 }, -- { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xce8e83bf, 0xeb96c838, 0xce8e83bf, 0x73cb3bc1, 0x740d78cf, 0xb35c7e64, 0xb35c7e64, 0xb35c7e64, 0x58f99418, 0x58f99418, 0x58f99418, 0x5eb294e8, 0x5eb294e8, 0x5eb294e8, 0x1c3742c9, 0x73cb3bc1, 0x73cb3bc1, }, 18 }, -- { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x56a03e51, 0xee7d8d4b, 0x56a03e51, 0x5bdf9413, 0xbcda144c, 0x220f7a5e, 0x220f7a5e, 0x220f7a5e, 0x4d46a64f, 0x4d46a64f, 0x4d46a64f, 0x40b0384c, 0x40b0384c, 0x40b0384c, 0xcc5a7bed, 0x5bdf9413, 0x5bdf9413, }, 18 }, -- { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0xea8a9cf0, 0x8929e522, 0xea8a9cf0, 0x78f3dfbc, 0x5d55a141, 0x377f1aeb, 0x377f1aeb, 0x377f1aeb, 0xf1cd5ef5, 0xf1cd5ef5, 0xf1cd5ef5, 0xe5a88e4a, 0xe5a88e4a, 0xe5a88e4a, 0xef4a3312, 0x78f3dfbc, 0x78f3dfbc, }, 18 }, -- { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0x6dcf1d57, 0x925a4c8f, 0x6dcf1d57, 0x69005b38, 0x6d6bb4bc, 0x756a36b9, 0x756a36b9, 0x756a36b9, 0xf499c068, 0xf499c068, 0xf499c068, 0x623d7907, 0x623d7907, 0x623d7907, 0x54e48d80, 0x69005b38, 0x69005b38, }, 18 }, -- { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa49d26b0, 0xaa7d9b28, 0xa49d26b0, 0xe76bebf7, 0x59c36f00, 0x59c36f00, 0xea6ab252, 0xea6ab252, 0xea6ab252, 0x94eadf34, 0x94eadf34, 0x94eadf34, 0xf61ccae6, 0xf61ccae6, 0xf61ccae6, 0x59c36f00, 0xe76bebf7, 0xe76bebf7, 0x59c36f00, }, 20 }, -- { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x7a277db, 0xf3bf80f7, 0x7a277db, 0x29a7f2a4, 0xaa4593fe, 0xaa4593fe, 0xf1cd57e3, 0xf1cd57e3, 0xf1cd57e3, 0x57385a84, 0x57385a84, 0x57385a84, 0x7a00f1fc, 0x7a00f1fc, 0x7a00f1fc, 0xaa4593fe, 0x29a7f2a4, 0x29a7f2a4, 0xaa4593fe, }, 20 }, -- { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x631edf85, 0x71926408, 0x631edf85, 0x3e09b201, 0xc9cbf769, 0xc9cbf769, 0xf224ab3, 0xf224ab3, 0xf224ab3, 0xf1fa8b7f, 0xf1fa8b7f, 0xf1fa8b7f, 0x18b03477, 0x18b03477, 0x18b03477, 0xc9cbf769, 0x3e09b201, 0x3e09b201, 0xc9cbf769, }, 20 }, -- { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xfbaf4635, 0xe69ef474, 0xfbaf4635, 0x55f90fed, 0x9813a416, 0x9813a416, 0x3aad8f41, 0x3aad8f41, 0x3aad8f41, 0xab760972, 0xab760972, 0xab760972, 0xb2cc34a2, 0xb2cc34a2, 0xb2cc34a2, 0x9813a416, 0x55f90fed, 0x55f90fed, 0x9813a416, }, 20 }, -- { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xdce50745, 0x1d8009e4, 0xdce50745, 0xaa4332f6, 0x5fcf013d, 0x5fcf013d, 0x354e5749, 0x354e5749, 0x354e5749, 0xe75e4f3f, 0xe75e4f3f, 0xe75e4f3f, 0xf12d70a0, 0xf12d70a0, 0xf12d70a0, 0x5fcf013d, 0xaa4332f6, 0xaa4332f6, 0x5fcf013d, }, 20 }, -- { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x3efebeff, 0xf101dfe2, 0x3efebeff, 0x25fb64f8, 0xdd28f52b, 0xdd28f52b, 0x70c69ebd, 0x70c69ebd, 0x70c69ebd, 0x51fa6759, 0x51fa6759, 0x51fa6759, 0x2c42acd5, 0x2c42acd5, 0x2c42acd5, 0xdd28f52b, 0x25fb64f8, 0x25fb64f8, 0xdd28f52b, }, 20 }, -- { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x59a34c64, 0x281cca78, 0x59a34c64, 0xa61c57e4, 0x43d1f34, 0x43d1f34, 0x95131d4, 0x95131d4, 0x95131d4, 0x765b987c, 0x765b987c, 0x765b987c, 0xef0a9dfa, 0xef0a9dfa, 0xef0a9dfa, 0x43d1f34, 0xa61c57e4, 0xa61c57e4, 0x43d1f34, }, 20 }, -- { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa37c165, 0x72063383, 0xa37c165, 0x49c10c22, 0x59c36f00, 0x59c36f00, 0x4e53de8e, 0x4e53de8e, 0x4e53de8e, 0x30d3b3e8, 0x30d3b3e8, 0x30d3b3e8, 0x5225a63a, 0x5225a63a, 0x5225a63a, 0x59c36f00, 0x49c10c22, 0x49c10c22, 0x59c36f00, }, 20 }, -- { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x45bba0ba, 0xe60fd0b6, 0x45bba0ba, 0x6bbe25c5, 0xaa4593fe, 0xaa4593fe, 0x28de2b41, 0x28de2b41, 0x28de2b41, 0x8e2b2626, 0x8e2b2626, 0x8e2b2626, 0xa3138d5e, 0xa3138d5e, 0xa3138d5e, 0xaa4593fe, 0x6bbe25c5, 0x6bbe25c5, 0xaa4593fe, }, 20 }, -- { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb43d4e9d, 0x16f88820, 0xb43d4e9d, 0xe92a2319, 0xc9cbf769, 0xc9cbf769, 0xb8959ec7, 0xb8959ec7, 0xb8959ec7, 0x464d5f0b, 0x464d5f0b, 0x464d5f0b, 0xaf07e003, 0xaf07e003, 0xaf07e003, 0xc9cbf769, 0xe92a2319, 0xe92a2319, 0xc9cbf769, }, 20 }, -- { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x46760365, 0x685ae30e, 0x46760365, 0xe8204abd, 0x9813a416, 0x9813a416, 0x8896050a, 0x8896050a, 0x8896050a, 0x194d8339, 0x194d8339, 0x194d8339, 0xf7bee9, 0xf7bee9, 0xf7bee9, 0x9813a416, 0xe8204abd, 0xe8204abd, 0x9813a416, }, 20 }, -- { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x6859aa86, 0xf3f11deb, 0x6859aa86, 0x1eff9f35, 0x5fcf013d, 0x5fcf013d, 0xd72b1482, 0xd72b1482, 0xd72b1482, 0x53b0cf4, 0x53b0cf4, 0x53b0cf4, 0x1348336b, 0x1348336b, 0x1348336b, 0x5fcf013d, 0x1eff9f35, 0x1eff9f35, 0x5fcf013d, }, 20 }, -- { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x688451e7, 0xf6936b72, 0x688451e7, 0x73818be0, 0xdd28f52b, 0xdd28f52b, 0xf12a65ac, 0xf12a65ac, 0xf12a65ac, 0xd0169c48, 0xd0169c48, 0xd0169c48, 0xadae57c4, 0xadae57c4, 0xadae57c4, 0xdd28f52b, 0x73818be0, 0x73818be0, 0xdd28f52b, }, 20 }, -- { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x9616af94, 0xd466be40, 0x9616af94, 0x69a9b414, 0x43d1f34, 0x43d1f34, 0xf3bb3240, 0xf3bb3240, 0xf3bb3240, 0x8cb19be8, 0x8cb19be8, 0x8cb19be8, 0x15e09e6e, 0x15e09e6e, 0x15e09e6e, 0x43d1f34, 0x69a9b414, 0x69a9b414, 0x43d1f34, }, 20 }, -- { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x8708d1bd, 0x85dd5e9c, 0x8708d1bd, 0xc4fe1cfa, 0x59c36f00, 0x59c36f00, 0x7ae8aced, 0x7ae8aced, 0x7ae8aced, 0x468c18b, 0x468c18b, 0x468c18b, 0x669ed459, 0x669ed459, 0x669ed459, 0x59c36f00, 0xc4fe1cfa, 0xc4fe1cfa, 0x59c36f00, }, 20 }, -- { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xa72b1043, 0x147d4ce0, 0xa72b1043, 0x892e953c, 0xaa4593fe, 0xaa4593fe, 0xb7b1dd40, 0xb7b1dd40, 0xb7b1dd40, 0x1144d027, 0x1144d027, 0x1144d027, 0x3c7c7b5f, 0x3c7c7b5f, 0x3c7c7b5f, 0xaa4593fe, 0x892e953c, 0x892e953c, 0xaa4593fe, }, 20 }, -- { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xc5fb1817, 0x745fb26c, 0xc5fb1817, 0x98ec7593, 0xc9cbf769, 0xc9cbf769, 0xf5f17e2d, 0xf5f17e2d, 0xf5f17e2d, 0xb29bfe1, 0xb29bfe1, 0xb29bfe1, 0xe26300e9, 0xe26300e9, 0xe26300e9, 0xc9cbf769, 0x98ec7593, 0x98ec7593, 0xc9cbf769, }, 20 }, -- { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4be837e1, 0xbf4963ca, 0x4be837e1, 0xe5be7e39, 0x9813a416, 0x9813a416, 0xd886fca0, 0xd886fca0, 0xd886fca0, 0x495d7a93, 0x495d7a93, 0x495d7a93, 0x50e74743, 0x50e74743, 0x50e74743, 0x9813a416, 0xe5be7e39, 0xe5be7e39, 0x9813a416, }, 20 }, -- { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x21a8ccb8, 0x17719be, 0x21a8ccb8, 0x570ef90b, 0x5fcf013d, 0x5fcf013d, 0x2a7b5333, 0x2a7b5333, 0x2a7b5333, 0xf86b4b45, 0xf86b4b45, 0xf86b4b45, 0xee1874da, 0xee1874da, 0xee1874da, 0x5fcf013d, 0x570ef90b, 0x570ef90b, 0x5fcf013d, }, 20 }, -- { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7001fe50, 0x4798153f, 0x7001fe50, 0x6b042457, 0xdd28f52b, 0xdd28f52b, 0x46489369, 0x46489369, 0x46489369, 0x67746a8d, 0x67746a8d, 0x67746a8d, 0x1acca101, 0x1acca101, 0x1acca101, 0xdd28f52b, 0x6b042457, 0x6b042457, 0xdd28f52b, }, 20 }, -- { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x6e10591c, 0x48bd926e, 0x6e10591c, 0x91af429c, 0x43d1f34, 0x43d1f34, 0x59cb829, 0x59cb829, 0x59cb829, 0x7a961181, 0x7a961181, 0x7a961181, 0xe3c71407, 0xe3c71407, 0xe3c71407, 0x43d1f34, 0x91af429c, 0x91af429c, 0x43d1f34, }, 20 }, -- { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x67627ed5, 0xdb276cef, 0x67627ed5, 0x2494b392, 0x59c36f00, 0x59c36f00, 0x43f511f3, 0x43f511f3, 0x43f511f3, 0x3d757c95, 0x3d757c95, 0x3d757c95, 0x5f836947, 0x5f836947, 0x5f836947, 0x59c36f00, 0x2494b392, 0x2494b392, 0x59c36f00, }, 20 }, -- { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x987cbf71, 0x6e4c645c, 0x987cbf71, 0xb6793a0e, 0xaa4593fe, 0xaa4593fe, 0xb943d716, 0xb943d716, 0xb943d716, 0x1fb6da71, 0x1fb6da71, 0x1fb6da71, 0x328e7109, 0x328e7109, 0x328e7109, 0xaa4593fe, 0xb6793a0e, 0xb6793a0e, 0xaa4593fe, }, 20 }, -- { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf9987c07, 0x4a92eed9, 0xf9987c07, 0xa48f1183, 0xc9cbf769, 0xc9cbf769, 0x5eb3ddf4, 0x5eb3ddf4, 0x5eb3ddf4, 0xa06b1c38, 0xa06b1c38, 0xa06b1c38, 0x4921a330, 0x4921a330, 0x4921a330, 0xc9cbf769, 0xa48f1183, 0xa48f1183, 0xc9cbf769, }, 20 }, -- { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xccd804e2, 0xb99e8d91, 0xccd804e2, 0x628e4d3a, 0x9813a416, 0x9813a416, 0x5aec5acc, 0x5aec5acc, 0x5aec5acc, 0xcb37dcff, 0xcb37dcff, 0xcb37dcff, 0xd28de12f, 0xd28de12f, 0xd28de12f, 0x9813a416, 0x628e4d3a, 0x628e4d3a, 0x9813a416, }, 20 }, -- { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x4990d896, 0x2b3aa242, 0x4990d896, 0x3f36ed25, 0x5fcf013d, 0x5fcf013d, 0x3cc6048d, 0x3cc6048d, 0x3cc6048d, 0xeed61cfb, 0xeed61cfb, 0xeed61cfb, 0xf8a52364, 0xf8a52364, 0xf8a52364, 0x5fcf013d, 0x3f36ed25, 0x3f36ed25, 0x5fcf013d, }, 20 }, -- { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x4ff5c69f, 0x66586489, 0x4ff5c69f, 0x54f01c98, 0xdd28f52b, 0xdd28f52b, 0xc3ff0bf5, 0xc3ff0bf5, 0xc3ff0bf5, 0xe2c3f211, 0xe2c3f211, 0xe2c3f211, 0x9f7b399d, 0x9f7b399d, 0x9f7b399d, 0xdd28f52b, 0x54f01c98, 0x54f01c98, 0xdd28f52b, }, 20 }, -- { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x909b7bb4, 0x2bb2a58c, 0x909b7bb4, 0x6f246034, 0x43d1f34, 0x43d1f34, 0x2df40751, 0x2df40751, 0x2df40751, 0x52feaef9, 0x52feaef9, 0x52feaef9, 0xcbafab7f, 0xcbafab7f, 0xcbafab7f, 0x43d1f34, 0x6f246034, 0x6f246034, 0x43d1f34, }, 20 }, -- { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xc77bfcc6, 0xffcdf45d, 0xc77bfcc6, 0x848d3181, 0x59c36f00, 0x59c36f00, 0xd79cd5e, 0xd79cd5e, 0xd79cd5e, 0x73f9a038, 0x73f9a038, 0x73f9a038, 0x110fb5ea, 0x110fb5ea, 0x110fb5ea, 0x59c36f00, 0x848d3181, 0x848d3181, 0x59c36f00, }, 20 }, -- { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd5494aa5, 0xa0924ec, 0xd5494aa5, 0xfb4ccfda, 0xaa4593fe, 0xaa4593fe, 0x8692c636, 0x8692c636, 0x8692c636, 0x2067cb51, 0x2067cb51, 0x2067cb51, 0xd5f6029, 0xd5f6029, 0xd5f6029, 0xaa4593fe, 0xfb4ccfda, 0xfb4ccfda, 0xaa4593fe, }, 20 }, -- { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x2436c4f, 0x2cde4e0c, 0x2436c4f, 0x5f5401cb, 0xc9cbf769, 0xc9cbf769, 0x558f50ae, 0x558f50ae, 0x558f50ae, 0xab579162, 0xab579162, 0xab579162, 0x421d2e6a, 0x421d2e6a, 0x421d2e6a, 0xc9cbf769, 0x5f5401cb, 0x5f5401cb, 0xc9cbf769, }, 20 }, -- { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x86f8a68c, 0xf4116451, 0x86f8a68c, 0x28aeef54, 0x9813a416, 0x9813a416, 0x7befbe43, 0x7befbe43, 0x7befbe43, 0xea343870, 0xea343870, 0xea343870, 0xf38e05a0, 0xf38e05a0, 0xf38e05a0, 0x9813a416, 0x28aeef54, 0x28aeef54, 0x9813a416, }, 20 }, -- { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x156c292f, 0x3c8eb473, 0x156c292f, 0x63ca1c9c, 0x5fcf013d, 0x5fcf013d, 0x895ea16b, 0x895ea16b, 0x895ea16b, 0x5b4eb91d, 0x5b4eb91d, 0x5b4eb91d, 0x4d3d8682, 0x4d3d8682, 0x4d3d8682, 0x5fcf013d, 0x63ca1c9c, 0x63ca1c9c, 0x5fcf013d, }, 20 }, -- { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf57ebf12, 0x798b299b, 0xf57ebf12, 0xee7b6515, 0xdd28f52b, 0xdd28f52b, 0x22563fc6, 0x22563fc6, 0x22563fc6, 0x36ac622, 0x36ac622, 0x36ac622, 0x7ed20dae, 0x7ed20dae, 0x7ed20dae, 0xdd28f52b, 0xee7b6515, 0xee7b6515, 0xdd28f52b, }, 20 }, -- { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x2bc82eb1, 0x94064cc8, 0x2bc82eb1, 0xd4773531, 0x43d1f34, 0x43d1f34, 0x44cbf2f0, 0x44cbf2f0, 0x44cbf2f0, 0x3bc15b58, 0x3bc15b58, 0x3bc15b58, 0xa2905ede, 0xa2905ede, 0xa2905ede, 0x43d1f34, 0xd4773531, 0xd4773531, 0x43d1f34, }, 20 }, -- { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x7f6dd146, 0x548af474, 0x7f6dd146, 0x3c9b1c01, 0x59c36f00, 0x59c36f00, 0x7d913e8d, 0x7d913e8d, 0x7d913e8d, 0x31153eb, 0x31153eb, 0x31153eb, 0x61e74639, 0x61e74639, 0x61e74639, 0x59c36f00, 0x3c9b1c01, 0x3c9b1c01, 0x59c36f00, }, 20 }, -- { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf29ad079, 0x50d47c0, 0xf29ad079, 0xdc9f5506, 0xaa4593fe, 0xaa4593fe, 0x6bcf4c90, 0x6bcf4c90, 0x6bcf4c90, 0xcd3a41f7, 0xcd3a41f7, 0xcd3a41f7, 0xe002ea8f, 0xe002ea8f, 0xe002ea8f, 0xaa4593fe, 0xdc9f5506, 0xdc9f5506, 0xaa4593fe, }, 20 }, -- { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb25e3082, 0x2ed845dd, 0xb25e3082, 0xef495d06, 0xc9cbf769, 0xc9cbf769, 0xd5322575, 0xd5322575, 0xd5322575, 0x2beae4b9, 0x2beae4b9, 0x2beae4b9, 0xc2a05bb1, 0xc2a05bb1, 0xc2a05bb1, 0xc9cbf769, 0xef495d06, 0xef495d06, 0xc9cbf769, }, 20 }, -- { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4cdfcd2e, 0x8bf091f, 0x4cdfcd2e, 0xe28984f6, 0x9813a416, 0x9813a416, 0x8217f630, 0x8217f630, 0x8217f630, 0x13cc7003, 0x13cc7003, 0x13cc7003, 0xa764dd3, 0xa764dd3, 0xa764dd3, 0x9813a416, 0xe28984f6, 0xe28984f6, 0x9813a416, }, 20 }, -- { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf2b49f88, 0x2eff252d, 0xf2b49f88, 0x8412aa3b, 0x5fcf013d, 0x5fcf013d, 0x5d3b9fe7, 0x5d3b9fe7, 0x5d3b9fe7, 0x8f2b8791, 0x8f2b8791, 0x8f2b8791, 0x9958b80e, 0x9958b80e, 0x9958b80e, 0x5fcf013d, 0x8412aa3b, 0x8412aa3b, 0x5fcf013d, }, 20 }, -- { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x786673be, 0x536f1359, 0x786673be, 0x6363a9b9, 0xdd28f52b, 0xdd28f52b, 0x38653b12, 0x38653b12, 0x38653b12, 0x1959c2f6, 0x1959c2f6, 0x1959c2f6, 0x64e1097a, 0x64e1097a, 0x64e1097a, 0xdd28f52b, 0x6363a9b9, 0x6363a9b9, 0xdd28f52b, }, 20 }, -- { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xac4a1127, 0x699c2ad8, 0xac4a1127, 0x53f50aa7, 0x43d1f34, 0x43d1f34, 0xfa47dfba, 0xfa47dfba, 0xfa47dfba, 0x854d7612, 0x854d7612, 0x854d7612, 0x1c1c7394, 0x1c1c7394, 0x1c1c7394, 0x43d1f34, 0x53f50aa7, 0x53f50aa7, 0x43d1f34, }, 20 }, -- { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xbc5f6633, 0xda908ab0, 0xbc5f6633, 0xffa9ab74, 0x59c36f00, 0x59c36f00, 0x3ad73295, 0x3ad73295, 0x3ad73295, 0x44575ff3, 0x44575ff3, 0x44575ff3, 0x26a14a21, 0x26a14a21, 0x26a14a21, 0x59c36f00, 0xffa9ab74, 0xffa9ab74, 0x59c36f00, }, 20 }, -- { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xad820d6b, 0x9a88ad3, 0xad820d6b, 0x83878814, 0xaa4593fe, 0xaa4593fe, 0xbec19c1b, 0xbec19c1b, 0xbec19c1b, 0x1834917c, 0x1834917c, 0x1834917c, 0x350c3a04, 0x350c3a04, 0x350c3a04, 0xaa4593fe, 0x83878814, 0x83878814, 0xaa4593fe, }, 20 }, -- { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe5774112, 0x5ffb1eca, 0xe5774112, 0xb8602c96, 0xc9cbf769, 0xc9cbf769, 0xe4861949, 0xe4861949, 0xe4861949, 0x1a5ed885, 0x1a5ed885, 0x1a5ed885, 0xf314678d, 0xf314678d, 0xf314678d, 0xc9cbf769, 0xb8602c96, 0xb8602c96, 0xc9cbf769, }, 20 }, -- { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6af1a2bc, 0xd951ab8b, 0x6af1a2bc, 0xc4a7eb64, 0x9813a416, 0x9813a416, 0xb5e8801c, 0xb5e8801c, 0xb5e8801c, 0x2433062f, 0x2433062f, 0x2433062f, 0x3d893bff, 0x3d893bff, 0x3d893bff, 0x9813a416, 0xc4a7eb64, 0xc4a7eb64, 0x9813a416, }, 20 }, -- { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc6baa18, 0x1c9db179, 0xc6baa18, 0x7acd9fab, 0x5fcf013d, 0x5fcf013d, 0x819b5c4e, 0x819b5c4e, 0x819b5c4e, 0x538b4438, 0x538b4438, 0x538b4438, 0x45f87ba7, 0x45f87ba7, 0x45f87ba7, 0x5fcf013d, 0x7acd9fab, 0x7acd9fab, 0x5fcf013d, }, 20 }, -- { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe424a6ab, 0xb05c0275, 0xe424a6ab, 0xff217cac, 0xdd28f52b, 0xdd28f52b, 0xcd83646c, 0xcd83646c, 0xcd83646c, 0xecbf9d88, 0xecbf9d88, 0xecbf9d88, 0x91075604, 0x91075604, 0x91075604, 0xdd28f52b, 0xff217cac, 0xff217cac, 0xdd28f52b, }, 20 }, -- { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4a7dff41, 0xe1ec28fc, 0x4a7dff41, 0xb5c2e4c1, 0x43d1f34, 0x43d1f34, 0xb200c08a, 0xb200c08a, 0xb200c08a, 0xcd0a6922, 0xcd0a6922, 0xcd0a6922, 0x545b6ca4, 0x545b6ca4, 0x545b6ca4, 0x43d1f34, 0xb5c2e4c1, 0xb5c2e4c1, 0x43d1f34, }, 20 }, -- { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd3d3e4a2, 0x9c635046, 0xd3d3e4a2, 0x902529e5, 0x59c36f00, 0x59c36f00, 0x85e713, 0x85e713, 0x85e713, 0x7e058a75, 0x7e058a75, 0x7e058a75, 0x1cf39fa7, 0x1cf39fa7, 0x1cf39fa7, 0x59c36f00, 0x902529e5, 0x902529e5, 0x59c36f00, }, 20 }, -- { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd61c80f5, 0xdf78b496, 0xd61c80f5, 0xf819058a, 0xaa4593fe, 0xaa4593fe, 0xefc0f7e7, 0xefc0f7e7, 0xefc0f7e7, 0x4935fa80, 0x4935fa80, 0x4935fa80, 0x640d51f8, 0x640d51f8, 0x640d51f8, 0xaa4593fe, 0xf819058a, 0xf819058a, 0xaa4593fe, }, 20 }, -- { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x936bc89d, 0x523a3e80, 0x936bc89d, 0xce7ca519, 0xc9cbf769, 0xc9cbf769, 0xaa99ffb1, 0xaa99ffb1, 0xaa99ffb1, 0x54413e7d, 0x54413e7d, 0x54413e7d, 0xbd0b8175, 0xbd0b8175, 0xbd0b8175, 0xc9cbf769, 0xce7ca519, 0xce7ca519, 0xc9cbf769, }, 20 }, -- { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4fdd0291, 0x133fa83d, 0x4fdd0291, 0xe18b4b49, 0x9813a416, 0x9813a416, 0x74c38e90, 0x74c38e90, 0x74c38e90, 0xe51808a3, 0xe51808a3, 0xe51808a3, 0xfca23573, 0xfca23573, 0xfca23573, 0x9813a416, 0xe18b4b49, 0xe18b4b49, 0x9813a416, }, 20 }, -- { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x538203b0, 0x2a92e789, 0x538203b0, 0x25243603, 0x5fcf013d, 0x5fcf013d, 0x5e4d3dd8, 0x5e4d3dd8, 0x5e4d3dd8, 0x8c5d25ae, 0x8c5d25ae, 0x8c5d25ae, 0x9a2e1a31, 0x9a2e1a31, 0x9a2e1a31, 0x5fcf013d, 0x25243603, 0x25243603, 0x5fcf013d, }, 20 }, -- { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xcfc85125, 0xa5b0e11b, 0xcfc85125, 0xd4cd8b22, 0xdd28f52b, 0xdd28f52b, 0x1af8cddc, 0x1af8cddc, 0x1af8cddc, 0x3bc43438, 0x3bc43438, 0x3bc43438, 0x467cffb4, 0x467cffb4, 0x467cffb4, 0xdd28f52b, 0xd4cd8b22, 0xd4cd8b22, 0xdd28f52b, }, 20 }, -- { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf2469ffb, 0x1d0c1d2, 0xf2469ffb, 0xdf9847b, 0x43d1f34, 0x43d1f34, 0xa2837c7a, 0xa2837c7a, 0xa2837c7a, 0xdd89d5d2, 0xdd89d5d2, 0xdd89d5d2, 0x44d8d054, 0x44d8d054, 0x44d8d054, 0x43d1f34, 0xdf9847b, 0xdf9847b, 0x43d1f34, }, 20 }, -- { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x27851cc1, 0x15f731b5, 0x27851cc1, 0x6473d186, 0x59c36f00, 0x59c36f00, 0x125bcddf, 0x125bcddf, 0x125bcddf, 0x6cdba0b9, 0x6cdba0b9, 0x6cdba0b9, 0xe2db56b, 0xe2db56b, 0xe2db56b, 0x59c36f00, 0x6473d186, 0x6473d186, 0x59c36f00, }, 20 }, -- { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xfcb223c, 0x2c2e18b9, 0xfcb223c, 0x21cea743, 0xaa4593fe, 0xaa4593fe, 0xd700be1a, 0xd700be1a, 0xd700be1a, 0x71f5b37d, 0x71f5b37d, 0x71f5b37d, 0x5ccd1805, 0x5ccd1805, 0x5ccd1805, 0xaa4593fe, 0x21cea743, 0x21cea743, 0xaa4593fe, }, 20 }, -- { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x807efaa5, 0xb673036a, 0x807efaa5, 0xdd699721, 0xc9cbf769, 0xc9cbf769, 0xdca3ed4b, 0xdca3ed4b, 0xdca3ed4b, 0x227b2c87, 0x227b2c87, 0x227b2c87, 0xcb31938f, 0xcb31938f, 0xcb31938f, 0xc9cbf769, 0xdd699721, 0xdd699721, 0xc9cbf769, }, 20 }, -- { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x651d0d50, 0xf0dc38fc, 0x651d0d50, 0xcb4b4488, 0x9813a416, 0x9813a416, 0x80d03ee8, 0x80d03ee8, 0x80d03ee8, 0x110bb8db, 0x110bb8db, 0x110bb8db, 0x8b1850b, 0x8b1850b, 0x8b1850b, 0x9813a416, 0xcb4b4488, 0xcb4b4488, 0x9813a416, }, 20 }, -- { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xb9b068f, 0xdc68ac3c, 0xb9b068f, 0x7d3d333c, 0x5fcf013d, 0x5fcf013d, 0xa1f0a6e4, 0xa1f0a6e4, 0xa1f0a6e4, 0x73e0be92, 0x73e0be92, 0x73e0be92, 0x6593810d, 0x6593810d, 0x6593810d, 0x5fcf013d, 0x7d3d333c, 0x7d3d333c, 0x5fcf013d, }, 20 }, -- { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf0789d7e, 0x6f2f2b61, 0xf0789d7e, 0xeb7d4779, 0xdd28f52b, 0xdd28f52b, 0xb995630, 0xb995630, 0xb995630, 0x2aa5afd4, 0x2aa5afd4, 0x2aa5afd4, 0x571d6458, 0x571d6458, 0x571d6458, 0xdd28f52b, 0xeb7d4779, 0xeb7d4779, 0xdd28f52b, }, 20 }, -- { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x819821ff, 0xdd19128c, 0x819821ff, 0x7e273a7f, 0x43d1f34, 0x43d1f34, 0xf35981d3, 0xf35981d3, 0xf35981d3, 0x8c53287b, 0x8c53287b, 0x8c53287b, 0x15022dfd, 0x15022dfd, 0x15022dfd, 0x43d1f34, 0x7e273a7f, 0x7e273a7f, 0x43d1f34, }, 20 }, -- { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa99604d1, 0xcf59e852, 0xa99604d1, 0xfebbba0f, 0x59c36f00, 0x59c36f00, 0x53767ce3, 0x53767ce3, 0x53767ce3, 0x2df61185, 0x2df61185, 0x2df61185, 0x4f000457, 0x4f000457, 0x4f000457, 0x59c36f00, 0xfebbba0f, 0xfebbba0f, 0x59c36f00, }, 20 }, -- { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x7d0a218, 0xa3fa25a0, 0x7d0a218, 0xb777784e, 0xaa4593fe, 0xaa4593fe, 0x35db26e1, 0x35db26e1, 0x35db26e1, 0x932e2b86, 0x932e2b86, 0x932e2b86, 0xbe1680fe, 0xbe1680fe, 0xbe1680fe, 0xaa4593fe, 0xb777784e, 0xb777784e, 0xaa4593fe, }, 20 }, -- { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x63be90f4, 0xd932cf2c, 0x63be90f4, 0x739b8e5a, 0xc9cbf769, 0xc9cbf769, 0x70a00efe, 0x70a00efe, 0x70a00efe, 0x8e78cf32, 0x8e78cf32, 0x8e78cf32, 0x6732703a, 0x6732703a, 0x6732703a, 0xc9cbf769, 0x739b8e5a, 0x739b8e5a, 0xc9cbf769, }, 20 }, -- { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x53460c90, 0xe0e605a7, 0x53460c90, 0x6337f0bf, 0x9813a416, 0x9813a416, 0x4161864c, 0x4161864c, 0x4161864c, 0xd0ba007f, 0xd0ba007f, 0xd0ba007f, 0xc9003daf, 0xc9003daf, 0xc9003daf, 0x9813a416, 0x6337f0bf, 0x6337f0bf, 0x9813a416, }, 20 }, -- { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf54761a0, 0xe5b17ac1, 0xf54761a0, 0x5b408e55, 0x5fcf013d, 0x5fcf013d, 0x580fda0e, 0x580fda0e, 0x580fda0e, 0x8a1fc278, 0x8a1fc278, 0x8a1fc278, 0x9c6cfde7, 0x9c6cfde7, 0x9c6cfde7, 0x5fcf013d, 0x5b408e55, 0x5b408e55, 0x5fcf013d, }, 20 }, -- { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xec78b0c1, 0xb800141f, 0xec78b0c1, 0x621c7b1b, 0xdd28f52b, 0xdd28f52b, 0x8f60179, 0x8f60179, 0x8f60179, 0x29caf89d, 0x29caf89d, 0x29caf89d, 0x54723311, 0x54723311, 0x54723311, 0xdd28f52b, 0x621c7b1b, 0x621c7b1b, 0xdd28f52b, }, 20 }, -- { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf209411b, 0x599896a6, 0xf209411b, 0x6551c7bb, 0x43d1f34, 0x43d1f34, 0x5ac6bb4a, 0x5ac6bb4a, 0x5ac6bb4a, 0x25cc12e2, 0x25cc12e2, 0x25cc12e2, 0xbc9d1764, 0xbc9d1764, 0xbc9d1764, 0x43d1f34, 0x6551c7bb, 0x6551c7bb, 0x43d1f34, }, 20 }, -- { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x93b4fcd8, 0xf57b105b, 0x93b4fcd8, 0x2bfe5312, 0x59c36f00, 0x59c36f00, 0x3ad73295, 0x3ad73295, 0x3ad73295, 0x44575ff3, 0x44575ff3, 0x44575ff3, 0x26a14a21, 0x26a14a21, 0x26a14a21, 0x59c36f00, 0x2bfe5312, 0x2bfe5312, 0x59c36f00, }, 20 }, -- { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x656c9044, 0xc14617fc, 0x656c9044, 0xa6ea58cb, 0xaa4593fe, 0xaa4593fe, 0xbec19c1b, 0xbec19c1b, 0xbec19c1b, 0x1834917c, 0x1834917c, 0x1834917c, 0x350c3a04, 0x350c3a04, 0x350c3a04, 0xaa4593fe, 0xa6ea58cb, 0xa6ea58cb, 0xaa4593fe, }, 20 }, -- { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa11479ed, 0x1b982635, 0xa11479ed, 0xe37185d0, 0xc9cbf769, 0xc9cbf769, 0xe4861949, 0xe4861949, 0xe4861949, 0x1a5ed885, 0x1a5ed885, 0x1a5ed885, 0xf314678d, 0xf314678d, 0xf314678d, 0xc9cbf769, 0xe37185d0, 0xe37185d0, 0xc9cbf769, }, 20 }, -- { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x244770a7, 0x97e77990, 0x244770a7, 0x6a54d2ee, 0x9813a416, 0x9813a416, 0xb5e8801c, 0xb5e8801c, 0xb5e8801c, 0x2433062f, 0x2433062f, 0x2433062f, 0x3d893bff, 0x3d893bff, 0x3d893bff, 0x9813a416, 0x6a54d2ee, 0x6a54d2ee, 0x9813a416, }, 20 }, -- { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x8ca34476, 0x9c555f17, 0x8ca34476, 0x1fc54b41, 0x5fcf013d, 0x5fcf013d, 0x819b5c4e, 0x819b5c4e, 0x819b5c4e, 0x538b4438, 0x538b4438, 0x538b4438, 0x45f87ba7, 0x45f87ba7, 0x45f87ba7, 0x5fcf013d, 0x1fc54b41, 0x1fc54b41, 0x5fcf013d, }, 20 }, -- { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf19f6af8, 0xa5e7ce26, 0xf19f6af8, 0x1619aea6, 0xdd28f52b, 0xdd28f52b, 0xcd83646c, 0xcd83646c, 0xcd83646c, 0xecbf9d88, 0xecbf9d88, 0xecbf9d88, 0x91075604, 0x91075604, 0x91075604, 0xdd28f52b, 0x1619aea6, 0x1619aea6, 0xdd28f52b, }, 20 }, -- { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x5f75414f, 0xf4e496f2, 0x5f75414f, 0x27fd1fe0, 0x43d1f34, 0x43d1f34, 0xb200c08a, 0xb200c08a, 0xb200c08a, 0xcd0a6922, 0xcd0a6922, 0xcd0a6922, 0x545b6ca4, 0x545b6ca4, 0x545b6ca4, 0x43d1f34, 0x27fd1fe0, 0x27fd1fe0, 0x43d1f34, }, 20 }, -- { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, }, 5 }, -- { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, }, 5 }, -- { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, }, 5 }, -- { "videotest", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x4c2cef83, 0x1b215a88, 0xe2378595, 0xb53a309e, 0x15f64d5e, }, 5 }, -- { "videotest", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x758f388c, 0xd4442397, 0x33f5784b, 0x923e6350, 0xf97bb902, }, 5 }, -- { "videotest", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xb9f6f52a, 0x4e24e8b7, 0x53beb8e1, 0xa46ca57c, 0x688a184d, }, 5 }, -- { "videotest", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x5bd98ce3, 0x15df7962, 0xc7d467e1, 0x89d29260, 0x662e2c16, }, 5 }, -- { "videotest", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0xf9847b65, 0xf9847b65, 0xf9847b65, 0xf9847b65, 0xf9847b65, }, 5 }, -- { "videotest", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xc421716d, 0xc421716d, 0xc421716d, 0xc421716d, 0xc421716d, }, 5 }, -- { "videotest", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, }, 5 }, -- { "videotest", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x25690db2, 0x25690db2, 0x25690db2, 0x25690db2, 0x25690db2, }, 5 }, -- { "videotest", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0x7333f220, 0x7333f220, 0x7333f220, 0x7333f220, 0x7333f220, }, 5 }, -- { "videotest", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0xac52d537, 0xac52d537, 0xac52d537, 0xac52d537, 0xac52d537, }, 5 }, -- { "videotest", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, }, 5 }, -- { "videotest", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, }, 5 }, -- { "videotest", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x89acbf88, 0x89acbf88, 0x89acbf88, 0x89acbf88, 0x89acbf88, }, 5 }, -- { "videotest", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x335fadcb, 0x1f517b5c, 0x6b4200e5, 0x474cd672, 0x8364f797, }, 5 }, -- { "videotest", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0xcf9985f8, 0x1d92c7fc, 0x6e637701, 0xbc683505, 0x898016fb, }, 5 }, -- { "videotest", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0xdb824190, 0x378d05dc, 0x670bff9, 0xea7ffbb5, 0x658bcbb3, }, 5 }, -- { "videotest", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x18ed532e, 0x18ed532e, 0x18ed532e, 0x18ed532e, 0x18ed532e, }, 5 }, -- { "videotest", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, }, 5 }, -- { "videotest", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, }, 5 }, -- { "videotest", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0xc07dde33, 0xc07dde33, 0xc07dde33, 0xc07dde33, 0xc07dde33, }, 5 }, -- { "videotest", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, }, 5 }, -- { "videotest", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x700255dd, 0x700255dd, 0x700255dd, 0x700255dd, 0x700255dd, }, 5 }, -- { "videotest", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x157232bd, 0x5e6bdacd, 0x8341e25d, 0xc8580a2d, 0x3cf9e58c, }, 5 }, -- { "videotest", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0xbfafd7cd, 0x51650951, 0x67d61c04, 0x891cc298, 0xab036ae, }, 5 }, -- { "videotest", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x760580c9, 0xdc6d8205, 0x2739f3a0, 0x8d51f16c, 0xd47d661b, }, 5 }, -- { "videotest", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0xada3b5f, 0x24cd61a6, 0x56f48ead, 0x78e3d454, 0xb28750bb, }, 5 }, -- { "videotest", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x827694e2, 0x9d97c3dd, 0xbdb43a9c, 0xa2556da3, 0xfdf3c81e, }, 5 }, -- { "videotest", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0x664534a5, 0xcd0979a0, 0x3531d85e, 0x9e7d955b, 0xc0aced53, }, 5 }, -+ { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xc69be699, 0xc69be699, 0xe17fc97c, 0xe17fc97c, 0xc2512486, 0xc2512486, 0x20260761, 0x20260761, 0xe3485349, 0xe3485349, 0x6020b4d9, 0x6020b4d9, 0x1605db98, 0x1605db98, 0xdca51b58, 0xdca51b58, 0xf3d66441, 0xf3d66441, 0x18cb7ce2, 0x18cb7ce2, 0x23b616d9, 0x23b616d9, 0xa1bf5dbf, 0xa1bf5dbf, 0x5e4a8b3d, 0x5e4a8b3d, 0x9933b3d8, 0x9933b3d8, 0xce7be2de, 0xce7be2de, 0x62531729, 0x62531729, 0xc39d3788, 0xc39d3788, 0xf7aee2fe, 0xf7aee2fe, 0xc66f4903, 0xc66f4903, 0x536c922f, 0x536c922f, 0xcb231652, 0x4ae07b67, 0x146816d5, 0x146816d5, }, 45 }, -+ { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x29d0cfb7, 0x29d0cfb7, 0x4d57ad88, 0x4d57ad88, 0xaf7591cb, 0xaf7591cb, 0xb88e3c0, 0xb88e3c0, 0x5d55a031, 0x5d55a031, 0x4363bcff, 0x4363bcff, 0xe1142833, 0xe1142833, 0x9578c80d, 0x9578c80d, 0xff1f5174, 0xff1f5174, 0x6828d47, 0x6828d47, 0x2a849ae3, 0x2a849ae3, 0x27a811d9, 0x27a811d9, 0x6c42e1cb, 0x6c42e1cb, 0x5bba61f5, 0x5bba61f5, 0xc02ab705, 0xc02ab705, 0xeb3e0e05, 0xeb3e0e05, 0x6f4ce3c, 0x6f4ce3c, 0x2075c50e, 0x2075c50e, 0x54ac7fba, 0x54ac7fba, 0x335d1c21, 0x335d1c21, 0xf923fbd1, 0x1b489d4d, 0x1253eb5e, 0x1253eb5e, }, 45 }, -+ { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6ff92a98, 0x6ff92a98, 0xbd8264b3, 0xbd8264b3, 0x5c50282c, 0x5c50282c, 0xd18d6a5a, 0xd18d6a5a, 0x99cea139, 0x99cea139, 0x2590c545, 0x2590c545, 0x55c86045, 0x55c86045, 0xad53ef1e, 0xad53ef1e, 0x5b44a23a, 0x5b44a23a, 0xa255f863, 0xa255f863, 0x85b0bdca, 0x85b0bdca, 0x4220ee1f, 0x4220ee1f, 0xeb991a9f, 0xeb991a9f, 0x86f366dd, 0x86f366dd, 0xfa176b7d, 0xfa176b7d, 0xd7384ca9, 0xd7384ca9, 0xceebf5c1, 0xceebf5c1, 0xae62b268, 0xae62b268, 0x6e89bbd6, 0x6e89bbd6, 0x3fe07c8e, 0x3fe07c8e, 0xee5358fe, 0x162d1a8a, 0x876f8d10, 0x876f8d10, }, 45 }, -+ { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb96afaea, 0xb96afaea, 0xaa16ab1e, 0xaa16ab1e, 0x51ff382, 0x51ff382, 0xec74f127, 0xec74f127, 0xde4bca99, 0xde4bca99, 0x8ef3e8a5, 0x8ef3e8a5, 0x2daeb0b4, 0x2daeb0b4, 0x7cf5e243, 0x7cf5e243, 0x11fd57c6, 0x11fd57c6, 0x140723af, 0x140723af, 0x2bd93833, 0x2bd93833, 0xd731f4ac, 0xd731f4ac, 0x5fcd7114, 0x5fcd7114, 0xd1fea24a, 0xd1fea24a, 0x4083d53a, 0x4083d53a, 0x2e372605, 0x2e372605, 0x8e6316a7, 0x8e6316a7, 0x283ef6cc, 0x283ef6cc, 0x20cee9de, 0x20cee9de, 0xad6fa187, 0xad6fa187, 0xd691f438, 0xf3257e63, 0x4786ba7, 0x4786ba7, }, 45 }, -+ { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x48acf1bf, 0x48acf1bf, 0xb8777469, 0xb8777469, 0xad2fad44, 0xad2fad44, 0xa415ac59, 0xa415ac59, 0x5a7bfb26, 0x5a7bfb26, 0xccb6016, 0xccb6016, 0x77a80cb3, 0x77a80cb3, 0x2034c102, 0x2034c102, 0x444b4ccd, 0x444b4ccd, 0xe6c31bea, 0xe6c31bea, 0x8408036e, 0x8408036e, 0x9e7c556f, 0x9e7c556f, 0x445dc388, 0x445dc388, 0x94b3f850, 0x94b3f850, 0xf6f15341, 0xf6f15341, 0xcb939b5f, 0xcb939b5f, 0xbe88067d, 0xbe88067d, 0x1efc4734, 0x1efc4734, 0x7f5dfca8, 0x7f5dfca8, 0xb7b10eb9, 0xb7b10eb9, 0xb94cb441, 0x9571329, 0x8a26912b, 0x8a26912b, }, 45 }, -+ { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc508d04e, 0xc508d04e, 0x6dbccbfe, 0x6dbccbfe, 0xbf06ff60, 0xbf06ff60, 0xbc5ab06, 0xbc5ab06, 0x97eeab3c, 0x97eeab3c, 0x62663589, 0x62663589, 0xb03e21e2, 0xb03e21e2, 0xea196bb6, 0xea196bb6, 0x672c16c4, 0x672c16c4, 0xefbca2cd, 0xefbca2cd, 0x1af5b410, 0x1af5b410, 0xc7a80569, 0xc7a80569, 0x4926a16, 0x4926a16, 0xee29c99c, 0xee29c99c, 0xffb15985, 0xffb15985, 0x4f608e46, 0x4f608e46, 0x3e450fd2, 0x3e450fd2, 0xac45215f, 0xac45215f, 0x789b0ce7, 0x789b0ce7, 0x4cedfe22, 0x4cedfe22, 0xa005588c, 0x701da05c, 0x6f25cec1, 0x6f25cec1, }, 45 }, -+ { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x29e7a7f, 0x29e7a7f, 0xbd221052, 0xbd221052, 0x3b18b64, 0x3b18b64, 0x7f1e8462, 0x7f1e8462, 0xf28d5124, 0xf28d5124, 0xc336f170, 0xc336f170, 0xfe3bf988, 0xfe3bf988, 0x7bf89e05, 0x7bf89e05, 0x7857a3f8, 0x7857a3f8, 0x272c1a36, 0x272c1a36, 0xe8adb445, 0xe8adb445, 0x70cfe280, 0x70cfe280, 0x4f2b6120, 0x4f2b6120, 0xbaf5caa5, 0xbaf5caa5, 0x4b6bcab2, 0x4b6bcab2, 0x2bef7b92, 0x2bef7b92, 0x17b381dc, 0x17b381dc, 0x884c9c35, 0x884c9c35, 0x2f9eb909, 0x2f9eb909, 0xa811b3af, 0xa811b3af, 0x4c39478f, 0x5a72c3ab, 0x8071678a, 0x8071678a, }, 45 }, -+ { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd9f04953, 0xbf3fa5d0, 0xd9f04953, 0x9a068414, 0x59c36f00, 0x59c36f00, 0x620c0067, 0x620c0067, 0x620c0067, 0x1c8c6d01, 0x1c8c6d01, 0x1c8c6d01, 0xc3269013, 0xc3269013, 0xc3269013, 0x59c36f00, 0x9a068414, 0x9a068414, 0x59c36f00, }, 20 }, -+ { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x9254157f, 0x367e92c7, 0x9254157f, 0xbc519000, 0xaa4593fe, 0xaa4593fe, 0xa8a596c8, 0xa8a596c8, 0xa8a596c8, 0xe509baf, 0xe509baf, 0xe509baf, 0x16f0dc06, 0x16f0dc06, 0x16f0dc06, 0xaa4593fe, 0xbc519000, 0xbc519000, 0xaa4593fe, }, 20 }, -+ { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x354b1976, 0x8fc746ae, 0x354b1976, 0x685c74f2, 0xc9cbf769, 0xc9cbf769, 0x3ce35e1d, 0x3ce35e1d, 0x3ce35e1d, 0xc23b9fd1, 0xc23b9fd1, 0xc23b9fd1, 0x5b18528e, 0x5b18528e, 0x5b18528e, 0xc9cbf769, 0x685c74f2, 0x685c74f2, 0xc9cbf769, }, 20 }, -+ { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1c9ec014, 0xaf3ec923, 0x1c9ec014, 0x43f5296, 0x9813a416, 0x9813a416, 0x43fda3fa, 0x43fda3fa, 0x43fda3fa, 0xd22625c9, 0xd22625c9, 0xd22625c9, 0x76a62c0a, 0x76a62c0a, 0x76a62c0a, 0x9813a416, 0x43f5296, 0x43f5296, 0x9813a416, }, 20 }, -+ { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa704f7ea, 0xb7f2ec8b, 0xa704f7ea, 0xb279bf59, 0x5fcf013d, 0x5fcf013d, 0xf3582c48, 0xf3582c48, 0xf3582c48, 0x2148343e, 0x2148343e, 0x2148343e, 0x9c719024, 0x9c719024, 0x9c719024, 0x5fcf013d, 0xb279bf59, 0xb279bf59, 0x5fcf013d, }, 20 }, -+ { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xf293ce36, 0xa6eb6ae8, 0xf293ce36, 0xcd87647e, 0xdd28f52b, 0xdd28f52b, 0xb3c7ef80, 0xb3c7ef80, 0xb3c7ef80, 0x92fb1664, 0x92fb1664, 0x92fb1664, 0xd15b5e2e, 0xd15b5e2e, 0xd15b5e2e, 0xdd28f52b, 0xcd87647e, 0xcd87647e, 0xdd28f52b, }, 20 }, -+ { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x31e75bd7, 0x9a768c6a, 0x31e75bd7, 0xa8fc31a6, 0x43d1f34, 0x43d1f34, 0xa0717008, 0xa0717008, 0xa0717008, 0xdf7bd9a0, 0xdf7bd9a0, 0xdf7bd9a0, 0x8e5a9312, 0x8e5a9312, 0x8e5a9312, 0x43d1f34, 0xa8fc31a6, 0xa8fc31a6, 0x43d1f34, }, 20 }, -+ { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1ce7bd78, 0x682580f5, 0x1ce7bd78, 0x490ad6fe, 0x9a2e0d26, 0x64eb71ba, 0x64eb71ba, 0x64eb71ba, 0x3833877a, 0x3833877a, 0x3833877a, 0xcfc14f0a, 0xcfc14f0a, 0xcfc14f0a, 0x59c36f00, 0x490ad6fe, 0x490ad6fe, }, 18 }, -+ { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2b6ff87d, 0x63ce2ca2, 0x2b6ff87d, 0xf00f044e, 0xa9d58ccd, 0xe2c46577, 0xe2c46577, 0xe2c46577, 0xb79bcf7d, 0xb79bcf7d, 0xb79bcf7d, 0xbc30ed71, 0xbc30ed71, 0xbc30ed71, 0xaa4593fe, 0xf00f044e, 0xf00f044e, }, 18 }, -+ { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe61cadba, 0x9880b727, 0xe61cadba, 0xdf5f2fc0, 0x5411be8b, 0x4449774e, 0x4449774e, 0x4449774e, 0x3bf7d1da, 0x3bf7d1da, 0x3bf7d1da, 0xd2ddee01, 0xd2ddee01, 0xd2ddee01, 0xc9cbf769, 0xdf5f2fc0, 0xdf5f2fc0, }, 18 }, -+ { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xbe54acf7, 0x9b4ce770, 0xbe54acf7, 0x3111489, 0x740d78cf, 0x314c4c59, 0x314c4c59, 0x314c4c59, 0xdae9a625, 0xdae9a625, 0xdae9a625, 0xcbf8af57, 0xcbf8af57, 0xcbf8af57, 0x1c3742c9, 0x3111489, 0x3111489, }, 18 }, -+ { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0xee571de5, 0x568aaeff, 0xee571de5, 0xe328b7a7, 0xbcda144c, 0xf56e1b60, 0xf56e1b60, 0xf56e1b60, 0x9a27c771, 0x9a27c771, 0x9a27c771, 0xd6d05397, 0xd6d05397, 0xd6d05397, 0xcc5a7bed, 0xe328b7a7, 0xe328b7a7, }, 18 }, -+ { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0x1db9877c, 0x7e1afeae, 0x1db9877c, 0x8fc0c430, 0x5d55a141, 0x96f335c6, 0x96f335c6, 0x96f335c6, 0x504171d8, 0x504171d8, 0x504171d8, 0x69f71c0, 0x69f71c0, 0x69f71c0, 0xef4a3312, 0x8fc0c430, 0x8fc0c430, }, 18 }, -+ { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0x151819bd, 0xea8d4865, 0x151819bd, 0x11d75fd2, 0x6d6bb4bc, 0x650ccd09, 0x650ccd09, 0x650ccd09, 0xe4ff3bd8, 0xe4ff3bd8, 0xe4ff3bd8, 0xc5308b73, 0xc5308b73, 0xc5308b73, 0x54e48d80, 0x11d75fd2, 0x11d75fd2, }, 18 }, -+ { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd0b06c3d, 0xde50d1a5, 0xd0b06c3d, 0x9346a17a, 0x59c36f00, 0x59c36f00, 0xacff5d47, 0xacff5d47, 0xacff5d47, 0xd27f3021, 0xd27f3021, 0xd27f3021, 0xdd5cd33, 0xdd5cd33, 0xdd5cd33, 0x59c36f00, 0x9346a17a, 0x9346a17a, 0x59c36f00, }, 20 }, -+ { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf32d50c1, 0x730a7ed, 0xf32d50c1, 0xdd28d5be, 0xaa4593fe, 0xaa4593fe, 0xba8a2d4c, 0xba8a2d4c, 0xba8a2d4c, 0x1c7f202b, 0x1c7f202b, 0x1c7f202b, 0x4df6782, 0x4df6782, 0x4df6782, 0xaa4593fe, 0xdd28d5be, 0xdd28d5be, 0xaa4593fe, }, 20 }, -+ { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x711a4ac1, 0x6396f14c, 0x711a4ac1, 0x2c0d2745, 0xc9cbf769, 0xc9cbf769, 0x6b6ccbb0, 0x6b6ccbb0, 0x6b6ccbb0, 0x95b40a7c, 0x95b40a7c, 0x95b40a7c, 0xc97c723, 0xc97c723, 0xc97c723, 0xc9cbf769, 0x2c0d2745, 0x2c0d2745, 0xc9cbf769, }, 20 }, -+ { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x29baad6a, 0x348b1f2b, 0x29baad6a, 0x311b3fe8, 0x9813a416, 0x9813a416, 0xe8e982cc, 0xe8e982cc, 0xe8e982cc, 0x793204ff, 0x793204ff, 0x793204ff, 0xddb20d3c, 0xddb20d3c, 0xddb20d3c, 0x9813a416, 0x311b3fe8, 0x311b3fe8, 0x9813a416, }, 20 }, -+ { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf834b3bb, 0x3951bd1a, 0xf834b3bb, 0xed49fb08, 0x5fcf013d, 0x5fcf013d, 0x5aefa2a7, 0x5aefa2a7, 0x5aefa2a7, 0x88ffbad1, 0x88ffbad1, 0x88ffbad1, 0x35c61ecb, 0x35c61ecb, 0x35c61ecb, 0x5fcf013d, 0xed49fb08, 0xed49fb08, 0x5fcf013d, }, 20 }, -+ { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7e9a7a47, 0xb1651b5a, 0x7e9a7a47, 0x418ed00f, 0xdd28f52b, 0xdd28f52b, 0x83f9db69, 0x83f9db69, 0x83f9db69, 0xa2c5228d, 0xa2c5228d, 0xa2c5228d, 0xe1656ac7, 0xe1656ac7, 0xe1656ac7, 0xdd28f52b, 0x418ed00f, 0x418ed00f, 0xdd28f52b, }, 20 }, -+ { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc6a0340, 0x7dd5855c, 0xc6a0340, 0x95716931, 0x43d1f34, 0x43d1f34, 0x5f1c24c0, 0x5f1c24c0, 0x5f1c24c0, 0x20168d68, 0x20168d68, 0x20168d68, 0x7137c7da, 0x7137c7da, 0x7137c7da, 0x43d1f34, 0x95716931, 0x95716931, 0x43d1f34, }, 20 }, -+ { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd3798aaa, 0xab48784c, 0xd3798aaa, 0x908f47ed, 0x59c36f00, 0x59c36f00, 0x1688ec7c, 0x1688ec7c, 0x1688ec7c, 0x6808811a, 0x6808811a, 0x6808811a, 0xb7a27c08, 0xb7a27c08, 0xb7a27c08, 0x59c36f00, 0x908f47ed, 0x908f47ed, 0x59c36f00, }, 20 }, -+ { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xc30d9d2a, 0x60b9ed26, 0xc30d9d2a, 0xed081855, 0xaa4593fe, 0xaa4593fe, 0x3eba2192, 0x3eba2192, 0x3eba2192, 0x984f2cf5, 0x984f2cf5, 0x984f2cf5, 0x80ef6b5c, 0x80ef6b5c, 0x80ef6b5c, 0xaa4593fe, 0xed081855, 0xed081855, 0xaa4593fe, }, 20 }, -+ { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe469e6af, 0x46ac2012, 0xe469e6af, 0xb97e8b2b, 0xc9cbf769, 0xc9cbf769, 0x60f0d993, 0x60f0d993, 0x60f0d993, 0x9e28185f, 0x9e28185f, 0x9e28185f, 0x70bd500, 0x70bd500, 0x70bd500, 0xc9cbf769, 0xb97e8b2b, 0xb97e8b2b, 0xc9cbf769, }, 20 }, -+ { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x8538d2ef, 0xab143284, 0x8538d2ef, 0x9d99406d, 0x9813a416, 0x9813a416, 0x7e8326ec, 0x7e8326ec, 0x7e8326ec, 0xef58a0df, 0xef58a0df, 0xef58a0df, 0x4bd8a91c, 0x4bd8a91c, 0x4bd8a91c, 0x9813a416, 0x9d99406d, 0x9d99406d, 0x9813a416, }, 20 }, -+ { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x8115198c, 0x1abdaee1, 0x8115198c, 0x9468513f, 0x5fcf013d, 0x5fcf013d, 0xa5e86484, 0xa5e86484, 0xa5e86484, 0x77f87cf2, 0x77f87cf2, 0x77f87cf2, 0xcac1d8e8, 0xcac1d8e8, 0xcac1d8e8, 0x5fcf013d, 0x9468513f, 0x9468513f, 0x5fcf013d, }, 20 }, -+ { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xea03b805, 0x74148290, 0xea03b805, 0xd517124d, 0xdd28f52b, 0xdd28f52b, 0x8f6eee40, 0x8f6eee40, 0x8f6eee40, 0xae5217a4, 0xae5217a4, 0xae5217a4, 0xedf25fee, 0xedf25fee, 0xedf25fee, 0xdd28f52b, 0xd517124d, 0xd517124d, 0xdd28f52b, }, 20 }, -+ { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa044490f, 0xe23458db, 0xa044490f, 0x395f237e, 0x43d1f34, 0x43d1f34, 0xe1ca82c2, 0xe1ca82c2, 0xe1ca82c2, 0x9ec02b6a, 0x9ec02b6a, 0x9ec02b6a, 0xcfe161d8, 0xcfe161d8, 0xcfe161d8, 0x43d1f34, 0x395f237e, 0x395f237e, 0x43d1f34, }, 20 }, -+ { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xf3259b30, 0xf1f01411, 0xf3259b30, 0xb0d35677, 0x59c36f00, 0x59c36f00, 0x97895f8e, 0x97895f8e, 0x97895f8e, 0xe90932e8, 0xe90932e8, 0xe90932e8, 0x36a3cffa, 0x36a3cffa, 0x36a3cffa, 0x59c36f00, 0xb0d35677, 0xb0d35677, 0x59c36f00, }, 20 }, -+ { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x53a43759, 0xe0f26bfa, 0x53a43759, 0x7da1b226, 0xaa4593fe, 0xaa4593fe, 0xbf482a4e, 0xbf482a4e, 0xbf482a4e, 0x19bd2729, 0x19bd2729, 0x19bd2729, 0x11d6080, 0x11d6080, 0x11d6080, 0xaa4593fe, 0x7da1b226, 0x7da1b226, 0xaa4593fe, }, 20 }, -+ { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xd7ff8d53, 0x665b2728, 0xd7ff8d53, 0x8ae8e0d7, 0xc9cbf769, 0xc9cbf769, 0x5a693e73, 0x5a693e73, 0x5a693e73, 0xa4b1ffbf, 0xa4b1ffbf, 0xa4b1ffbf, 0x3d9232e0, 0x3d9232e0, 0x3d9232e0, 0xc9cbf769, 0x8ae8e0d7, 0x8ae8e0d7, 0xc9cbf769, }, 20 }, -+ { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x99fddcbe, 0x6d5c8895, 0x99fddcbe, 0x815c4e3c, 0x9813a416, 0x9813a416, 0x9bcf9821, 0x9bcf9821, 0x9bcf9821, 0xa141e12, 0xa141e12, 0xa141e12, 0xae9417d1, 0xae9417d1, 0xae9417d1, 0x9813a416, 0x815c4e3c, 0x815c4e3c, 0x9813a416, }, 20 }, -+ { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x5797846, 0x25a6ad40, 0x5797846, 0x100430f5, 0x5fcf013d, 0x5fcf013d, 0xddc86daf, 0xddc86daf, 0xddc86daf, 0xfd875d9, 0xfd875d9, 0xfd875d9, 0xb2e1d1c3, 0xb2e1d1c3, 0xb2e1d1c3, 0x5fcf013d, 0x100430f5, 0x100430f5, 0x5fcf013d, }, 20 }, -+ { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x30653ae8, 0x7fcd187, 0x30653ae8, 0xf7190a0, 0xdd28f52b, 0xdd28f52b, 0x24c3d325, 0x24c3d325, 0x24c3d325, 0x5ff2ac1, 0x5ff2ac1, 0x5ff2ac1, 0x465f628b, 0x465f628b, 0x465f628b, 0xdd28f52b, 0xf7190a0, 0xf7190a0, 0xdd28f52b, }, 20 }, -+ { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x3bd91638, 0x1d74dd4a, 0x3bd91638, 0xa2c27c49, 0x43d1f34, 0x43d1f34, 0x53d1ad3d, 0x53d1ad3d, 0x53d1ad3d, 0x2cdb0495, 0x2cdb0495, 0x2cdb0495, 0x7dfa4e27, 0x7dfa4e27, 0x7dfa4e27, 0x43d1f34, 0xa2c27c49, 0xa2c27c49, 0x43d1f34, }, 20 }, -+ { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xbe2c351a, 0x2692720, 0xbe2c351a, 0xfddaf85d, 0x59c36f00, 0x59c36f00, 0x1b2e2301, 0x1b2e2301, 0x1b2e2301, 0x65ae4e67, 0x65ae4e67, 0x65ae4e67, 0xba04b375, 0xba04b375, 0xba04b375, 0x59c36f00, 0xfddaf85d, 0xfddaf85d, 0x59c36f00, }, 20 }, -+ { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x1eca82e1, 0xe8fa59cc, 0x1eca82e1, 0x30cf079e, 0xaa4593fe, 0xaa4593fe, 0xaf27ddc5, 0xaf27ddc5, 0xaf27ddc5, 0x9d2d0a2, 0x9d2d0a2, 0x9d2d0a2, 0x1172970b, 0x1172970b, 0x1172970b, 0xaa4593fe, 0x30cf079e, 0x30cf079e, 0xaa4593fe, }, 20 }, -+ { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa9ccd435, 0x1ac646eb, 0xa9ccd435, 0xf4dbb9b1, 0xc9cbf769, 0xc9cbf769, 0x86d69aa0, 0x86d69aa0, 0x86d69aa0, 0x780e5b6c, 0x780e5b6c, 0x780e5b6c, 0xe12d9633, 0xe12d9633, 0xe12d9633, 0xc9cbf769, 0xf4dbb9b1, 0xf4dbb9b1, 0xc9cbf769, }, 20 }, -+ { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xf96d568, 0x7ad05c1b, 0xf96d568, 0x173747ea, 0x9813a416, 0x9813a416, 0xacf9792a, 0xacf9792a, 0xacf9792a, 0x3d22ff19, 0x3d22ff19, 0x3d22ff19, 0x99a2f6da, 0x99a2f6da, 0x99a2f6da, 0x9813a416, 0x173747ea, 0x173747ea, 0x9813a416, }, 20 }, -+ { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa0dc6b9c, 0xc2761148, 0xa0dc6b9c, 0xb5a1232f, 0x5fcf013d, 0x5fcf013d, 0x4e05748b, 0x4e05748b, 0x4e05748b, 0x9c156cfd, 0x9c156cfd, 0x9c156cfd, 0x212cc8e7, 0x212cc8e7, 0x212cc8e7, 0x5fcf013d, 0xb5a1232f, 0xb5a1232f, 0x5fcf013d, }, 20 }, -+ { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xcd722f7d, 0xe4df8d6b, 0xcd722f7d, 0xf2668535, 0xdd28f52b, 0xdd28f52b, 0xbdbb8019, 0xbdbb8019, 0xbdbb8019, 0x9c8779fd, 0x9c8779fd, 0x9c8779fd, 0xdf2731b7, 0xdf2731b7, 0xdf2731b7, 0xdd28f52b, 0xf2668535, 0xf2668535, 0xdd28f52b, }, 20 }, -+ { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa6c99d2f, 0x1de04317, 0xa6c99d2f, 0x3fd2f75e, 0x43d1f34, 0x43d1f34, 0x3f85b7d3, 0x3f85b7d3, 0x3f85b7d3, 0x408f1e7b, 0x408f1e7b, 0x408f1e7b, 0x11ae54c9, 0x11ae54c9, 0x11ae54c9, 0x43d1f34, 0x3fd2f75e, 0x3fd2f75e, 0x43d1f34, }, 20 }, -+ { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x1e35b709, 0x2683bf92, 0x1e35b709, 0x5dc37a4e, 0x59c36f00, 0x59c36f00, 0xd697967f, 0xd697967f, 0xd697967f, 0xa817fb19, 0xa817fb19, 0xa817fb19, 0x77bd060b, 0x77bd060b, 0x77bd060b, 0x59c36f00, 0x5dc37a4e, 0x5dc37a4e, 0x59c36f00, }, 20 }, -+ { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x53ff7735, 0x8cbf197c, 0x53ff7735, 0x7dfaf24a, 0xaa4593fe, 0xaa4593fe, 0x389a922, 0x389a922, 0x389a922, 0xa57ca445, 0xa57ca445, 0xa57ca445, 0xbddce3ec, 0xbddce3ec, 0xbddce3ec, 0xaa4593fe, 0x7dfaf24a, 0x7dfaf24a, 0xaa4593fe, }, 20 }, -+ { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5217c47d, 0x7c8ae63e, 0x5217c47d, 0xf00a9f9, 0xc9cbf769, 0xc9cbf769, 0x3995409, 0x3995409, 0x3995409, 0xfd4195c5, 0xfd4195c5, 0xfd4195c5, 0x6462589a, 0x6462589a, 0x6462589a, 0xc9cbf769, 0xf00a9f9, 0xf00a9f9, 0xc9cbf769, }, 20 }, -+ { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x45b67706, 0x375fb5db, 0x45b67706, 0x5d17e584, 0x9813a416, 0x9813a416, 0x8195719b, 0x8195719b, 0x8195719b, 0x104ef7a8, 0x104ef7a8, 0x104ef7a8, 0xb4cefe6b, 0xb4cefe6b, 0xb4cefe6b, 0x9813a416, 0x5d17e584, 0x5d17e584, 0x9813a416, }, 20 }, -+ { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xfc209a25, 0xd5c20779, 0xfc209a25, 0xe95dd296, 0x5fcf013d, 0x5fcf013d, 0xe5699efe, 0xe5699efe, 0xe5699efe, 0x37798688, 0x37798688, 0x37798688, 0x8a402292, 0x8a402292, 0x8a402292, 0x5fcf013d, 0xe95dd296, 0xe95dd296, 0x5fcf013d, }, 20 }, -+ { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x77f956f0, 0xfb0cc079, 0x77f956f0, 0x48edfcb8, 0xdd28f52b, 0xdd28f52b, 0xd51b1dc9, 0xd51b1dc9, 0xd51b1dc9, 0xf427e42d, 0xf427e42d, 0xf427e42d, 0xb787ac67, 0xb787ac67, 0xb787ac67, 0xdd28f52b, 0x48edfcb8, 0x48edfcb8, 0xdd28f52b, }, 20 }, -+ { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x1d9ac82a, 0xa254aa53, 0x1d9ac82a, 0x8481a25b, 0x43d1f34, 0x43d1f34, 0xc304df68, 0xc304df68, 0xc304df68, 0xbc0e76c0, 0xbc0e76c0, 0xbc0e76c0, 0xed2f3c72, 0xed2f3c72, 0xed2f3c72, 0x43d1f34, 0x8481a25b, 0x8481a25b, 0x43d1f34, }, 20 }, -+ { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa6239a89, 0x8dc4bfbb, 0xa6239a89, 0xe5d557ce, 0x59c36f00, 0x59c36f00, 0x244cf807, 0x244cf807, 0x244cf807, 0x5acc9561, 0x5acc9561, 0x5acc9561, 0x85666873, 0x85666873, 0x85666873, 0x59c36f00, 0xe5d557ce, 0xe5d557ce, 0x59c36f00, }, 20 }, -+ { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x742cede9, 0x83bb7a50, 0x742cede9, 0x5a296896, 0xaa4593fe, 0xaa4593fe, 0xd83f8aeb, 0xd83f8aeb, 0xd83f8aeb, 0x7eca878c, 0x7eca878c, 0x7eca878c, 0x666ac025, 0x666ac025, 0x666ac025, 0xaa4593fe, 0x5a296896, 0x5a296896, 0xaa4593fe, }, 20 }, -+ { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe20a98b0, 0x7e8cedef, 0xe20a98b0, 0xbf1df534, 0xc9cbf769, 0xc9cbf769, 0x2748b88c, 0x2748b88c, 0x2748b88c, 0xd9907940, 0xd9907940, 0xd9907940, 0x40b3b41f, 0x40b3b41f, 0x40b3b41f, 0xc9cbf769, 0xbf1df534, 0xbf1df534, 0xc9cbf769, }, 20 }, -+ { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x8f911ca4, 0xcbf1d895, 0x8f911ca4, 0x97308e26, 0x9813a416, 0x9813a416, 0x5b359bf4, 0x5b359bf4, 0x5b359bf4, 0xcaee1dc7, 0xcaee1dc7, 0xcaee1dc7, 0x6e6e1404, 0x6e6e1404, 0x6e6e1404, 0x9813a416, 0x97308e26, 0x97308e26, 0x9813a416, }, 20 }, -+ { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x1bf82c82, 0xc7b39627, 0x1bf82c82, 0xe856431, 0x5fcf013d, 0x5fcf013d, 0xa9dbae99, 0xa9dbae99, 0xa9dbae99, 0x7bcbb6ef, 0x7bcbb6ef, 0x7bcbb6ef, 0xc6f212f5, 0xc6f212f5, 0xc6f212f5, 0x5fcf013d, 0xe856431, 0xe856431, 0x5fcf013d, }, 20 }, -+ { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xfae19a5c, 0xd1e8fabb, 0xfae19a5c, 0xc5f53014, 0xdd28f52b, 0xdd28f52b, 0xfa2c5565, 0xfa2c5565, 0xfa2c5565, 0xdb10ac81, 0xdb10ac81, 0xdb10ac81, 0x98b0e4cb, 0x98b0e4cb, 0x98b0e4cb, 0xdd28f52b, 0xc5f53014, 0xc5f53014, 0xdd28f52b, }, 20 }, -+ { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x9a18f7bc, 0x5fcecc43, 0x9a18f7bc, 0x3039dcd, 0x43d1f34, 0x43d1f34, 0x287a2b96, 0x287a2b96, 0x287a2b96, 0x5770823e, 0x5770823e, 0x5770823e, 0x651c88c, 0x651c88c, 0x651c88c, 0x43d1f34, 0x3039dcd, 0x3039dcd, 0x43d1f34, }, 20 }, -+ { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x65112dfc, 0x3dec17f, 0x65112dfc, 0x26e7e0bb, 0x59c36f00, 0x59c36f00, 0x620c0067, 0x620c0067, 0x620c0067, 0x1c8c6d01, 0x1c8c6d01, 0x1c8c6d01, 0xc3269013, 0xc3269013, 0xc3269013, 0x59c36f00, 0x26e7e0bb, 0x26e7e0bb, 0x59c36f00, }, 20 }, -+ { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2b3430fb, 0x8f1eb743, 0x2b3430fb, 0x531b584, 0xaa4593fe, 0xaa4593fe, 0xa8a596c8, 0xa8a596c8, 0xa8a596c8, 0xe509baf, 0xe509baf, 0xe509baf, 0x16f0dc06, 0x16f0dc06, 0x16f0dc06, 0xaa4593fe, 0x531b584, 0x531b584, 0xaa4593fe, }, 20 }, -+ { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb523e920, 0xfafb6f8, 0xb523e920, 0xe83484a4, 0xc9cbf769, 0xc9cbf769, 0x3ce35e1d, 0x3ce35e1d, 0x3ce35e1d, 0xc23b9fd1, 0xc23b9fd1, 0xc23b9fd1, 0x5b18528e, 0x5b18528e, 0x5b18528e, 0xc9cbf769, 0xe83484a4, 0xe83484a4, 0xc9cbf769, }, 20 }, -+ { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xa9bf7336, 0x1a1f7a01, 0xa9bf7336, 0xb11ee1b4, 0x9813a416, 0x9813a416, 0x43fda3fa, 0x43fda3fa, 0x43fda3fa, 0xd22625c9, 0xd22625c9, 0xd22625c9, 0x76a62c0a, 0x76a62c0a, 0x76a62c0a, 0x9813a416, 0xb11ee1b4, 0xb11ee1b4, 0x9813a416, }, 20 }, -+ { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xe5271912, 0xf5d10273, 0xe5271912, 0xf05a51a1, 0x5fcf013d, 0x5fcf013d, 0xf3582c48, 0xf3582c48, 0xf3582c48, 0x2148343e, 0x2148343e, 0x2148343e, 0x9c719024, 0x9c719024, 0x9c719024, 0x5fcf013d, 0xf05a51a1, 0xf05a51a1, 0x5fcf013d, }, 20 }, -+ { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x66a34f49, 0x32dbeb97, 0x66a34f49, 0x59b7e501, 0xdd28f52b, 0xdd28f52b, 0xb3c7ef80, 0xb3c7ef80, 0xb3c7ef80, 0x92fb1664, 0x92fb1664, 0x92fb1664, 0xd15b5e2e, 0xd15b5e2e, 0xd15b5e2e, 0xdd28f52b, 0x59b7e501, 0x59b7e501, 0xdd28f52b, }, 20 }, -+ { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x7c2f19da, 0xd7bece67, 0x7c2f19da, 0xe53473ab, 0x43d1f34, 0x43d1f34, 0xa0717008, 0xa0717008, 0xa0717008, 0xdf7bd9a0, 0xdf7bd9a0, 0xdf7bd9a0, 0x8e5a9312, 0x8e5a9312, 0x8e5a9312, 0x43d1f34, 0xe53473ab, 0xe53473ab, 0x43d1f34, }, 20 }, -+ { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x37943894, 0x78248c70, 0x37943894, 0x7462f5d3, 0x59c36f00, 0x59c36f00, 0xf4be229a, 0xf4be229a, 0xf4be229a, 0x8a3e4ffc, 0x8a3e4ffc, 0x8a3e4ffc, 0x5594b2ee, 0x5594b2ee, 0x5594b2ee, 0x59c36f00, 0x7462f5d3, 0x7462f5d3, 0x59c36f00, }, 20 }, -+ { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd5158e6c, 0xdc71ba0f, 0xd5158e6c, 0xfb100b13, 0xaa4593fe, 0xaa4593fe, 0xd3ed72a3, 0xd3ed72a3, 0xd3ed72a3, 0x75187fc4, 0x75187fc4, 0x75187fc4, 0x6db8386d, 0x6db8386d, 0x6db8386d, 0xaa4593fe, 0xfb100b13, 0xfb100b13, 0xaa4593fe, }, 20 }, -+ { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6277a9e6, 0xa3265ffb, 0x6277a9e6, 0x3f60c462, 0xc9cbf769, 0xc9cbf769, 0x2dcf8a8d, 0x2dcf8a8d, 0x2dcf8a8d, 0xd3174b41, 0xd3174b41, 0xd3174b41, 0x4a34861e, 0x4a34861e, 0x4a34861e, 0xc9cbf769, 0x3f60c462, 0x3f60c462, 0xc9cbf769, }, 20 }, -+ { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x81115dc4, 0xddf3f768, 0x81115dc4, 0x99b0cf46, 0x9813a416, 0x9813a416, 0x9b9d96df, 0x9b9d96df, 0x9b9d96df, 0xa4610ec, 0xa4610ec, 0xa4610ec, 0xaec6192f, 0xaec6192f, 0xaec6192f, 0x9813a416, 0x99b0cf46, 0x99b0cf46, 0x9813a416, }, 20 }, -+ { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x5e96a904, 0x27864d3d, 0x5e96a904, 0x4bebe1b7, 0x5fcf013d, 0x5fcf013d, 0x18cae7f4, 0x18cae7f4, 0x18cae7f4, 0xcadaff82, 0xcadaff82, 0xcadaff82, 0x77e35b98, 0x77e35b98, 0x77e35b98, 0x5fcf013d, 0x4bebe1b7, 0x4bebe1b7, 0x5fcf013d, }, 20 }, -+ { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd00b19f8, 0xba73a9c6, 0xd00b19f8, 0xef1fb3b0, 0xdd28f52b, 0xdd28f52b, 0xb660046d, 0xb660046d, 0xb660046d, 0x975cfd89, 0x975cfd89, 0x975cfd89, 0xd4fcb5c3, 0xd4fcb5c3, 0xd4fcb5c3, 0xdd28f52b, 0xef1fb3b0, 0xef1fb3b0, 0xdd28f52b, }, 20 }, -+ { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x8b4b98cd, 0x78ddc6e4, 0x8b4b98cd, 0x1250f2bc, 0x43d1f34, 0x43d1f34, 0x4889d3fd, 0x4889d3fd, 0x4889d3fd, 0x37837a55, 0x37837a55, 0x37837a55, 0x66a230e7, 0x66a230e7, 0x66a230e7, 0x43d1f34, 0x1250f2bc, 0x1250f2bc, 0x43d1f34, }, 20 }, -+ { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xfecb570e, 0xccb97a7a, 0xfecb570e, 0xbd3d9a49, 0x59c36f00, 0x59c36f00, 0x40281258, 0x40281258, 0x40281258, 0x3ea87f3e, 0x3ea87f3e, 0x3ea87f3e, 0xe102822c, 0xe102822c, 0xe102822c, 0x59c36f00, 0xbd3d9a49, 0xbd3d9a49, 0x59c36f00, }, 20 }, -+ { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x897d1fac, 0xaa982529, 0x897d1fac, 0xa7789ad3, 0xaa4593fe, 0xaa4593fe, 0xa482510, 0xa482510, 0xa482510, 0xacbd2877, 0xacbd2877, 0xacbd2877, 0xb41d6fde, 0xb41d6fde, 0xb41d6fde, 0xaa4593fe, 0xa7789ad3, 0xa7789ad3, 0xaa4593fe, }, 20 }, -+ { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xd02a5297, 0xe627ab58, 0xd02a5297, 0x8d3d3f13, 0xc9cbf769, 0xc9cbf769, 0xbf0a8b7f, 0xbf0a8b7f, 0xbf0a8b7f, 0x41d24ab3, 0x41d24ab3, 0x41d24ab3, 0xd8f187ec, 0xd8f187ec, 0xd8f187ec, 0xc9cbf769, 0x8d3d3f13, 0x8d3d3f13, 0xc9cbf769, }, 20 }, -+ { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xa653dcda, 0x3392e976, 0xa653dcda, 0xbef24e58, 0x9813a416, 0x9813a416, 0x4f2bc106, 0x4f2bc106, 0x4f2bc106, 0xdef04735, 0xdef04735, 0xdef04735, 0x7a704ef6, 0x7a704ef6, 0x7a704ef6, 0x9813a416, 0xbef24e58, 0xbef24e58, 0x9813a416, }, 20 }, -+ { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xe2d7b585, 0x35241f36, 0xe2d7b585, 0xf7aafd36, 0x5fcf013d, 0x5fcf013d, 0xf2bd04db, 0xf2bd04db, 0xf2bd04db, 0x20ad1cad, 0x20ad1cad, 0x20ad1cad, 0x9d94b8b7, 0x9d94b8b7, 0x9d94b8b7, 0x5fcf013d, 0xf7aafd36, 0xf7aafd36, 0x5fcf013d, }, 20 }, -+ { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x72ff749c, 0xeda8c283, 0x72ff749c, 0x4debded4, 0xdd28f52b, 0xdd28f52b, 0xb8c9cc22, 0xb8c9cc22, 0xb8c9cc22, 0x99f535c6, 0x99f535c6, 0x99f535c6, 0xda557d8c, 0xda557d8c, 0xda557d8c, 0xdd28f52b, 0x4debded4, 0x4debded4, 0xdd28f52b, }, 20 }, -+ { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xb7cac764, 0xeb4bf417, 0xb7cac764, 0x2ed1ad15, 0x43d1f34, 0x43d1f34, 0xce718801, 0xce718801, 0xce718801, 0xb17b21a9, 0xb17b21a9, 0xb17b21a9, 0xe05a6b1b, 0xe05a6b1b, 0xe05a6b1b, 0x43d1f34, 0x2ed1ad15, 0x2ed1ad15, 0x43d1f34, }, 20 }, -+ { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x930e8e13, 0xf5c16290, 0x930e8e13, 0x27f5f1c0, 0x59c36f00, 0x59c36f00, 0xbad4e11, 0xbad4e11, 0xbad4e11, 0x752d2377, 0x752d2377, 0x752d2377, 0xaa87de65, 0xaa87de65, 0xaa87de65, 0x59c36f00, 0x27f5f1c0, 0x27f5f1c0, 0x59c36f00, }, 20 }, -+ { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xff9301f2, 0x5bb9864a, 0xff9301f2, 0x31c145de, 0xaa4593fe, 0xaa4593fe, 0x23bf2c32, 0x23bf2c32, 0x23bf2c32, 0x854a2155, 0x854a2155, 0x854a2155, 0x9dea66fc, 0x9dea66fc, 0x9dea66fc, 0xaa4593fe, 0x31c145de, 0x31c145de, 0xaa4593fe, }, 20 }, -+ { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xfc5938ef, 0x46d56737, 0xfc5938ef, 0x23cf2668, 0xc9cbf769, 0xc9cbf769, 0xa8c549aa, 0xa8c549aa, 0xa8c549aa, 0x561d8866, 0x561d8866, 0x561d8866, 0xcf3e4539, 0xcf3e4539, 0xcf3e4539, 0xc9cbf769, 0x23cf2668, 0x23cf2668, 0xc9cbf769, }, 20 }, -+ { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xe7160822, 0x54b60115, 0xe7160822, 0x168efa6f, 0x9813a416, 0x9813a416, 0xb774a5aa, 0xb774a5aa, 0xb774a5aa, 0x26af2399, 0x26af2399, 0x26af2399, 0x822f2a5a, 0x822f2a5a, 0x822f2a5a, 0x9813a416, 0x168efa6f, 0x168efa6f, 0x9813a416, }, 20 }, -+ { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf655f9b2, 0xe6a3e2d3, 0xf655f9b2, 0xd1d7405f, 0x5fcf013d, 0x5fcf013d, 0x2accaa08, 0x2accaa08, 0x2accaa08, 0xf8dcb27e, 0xf8dcb27e, 0xf8dcb27e, 0x45e51664, 0x45e51664, 0x45e51664, 0x5fcf013d, 0xd1d7405f, 0xd1d7405f, 0x5fcf013d, }, 20 }, -+ { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x2d85ebdc, 0x79fd4f02, 0x2d85ebdc, 0xc48ae2b6, 0xdd28f52b, 0xdd28f52b, 0x76b28a95, 0x76b28a95, 0x76b28a95, 0x578e7371, 0x578e7371, 0x578e7371, 0x142e3b3b, 0x142e3b3b, 0x142e3b3b, 0xdd28f52b, 0xc48ae2b6, 0xc48ae2b6, 0xdd28f52b, }, 20 }, -+ { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x29c00f98, 0x8251d825, 0x29c00f98, 0x35a750d1, 0x43d1f34, 0x43d1f34, 0x48b70bc8, 0x48b70bc8, 0x48b70bc8, 0x37bda260, 0x37bda260, 0x37bda260, 0x669ce8d2, 0x669ce8d2, 0x669ce8d2, 0x43d1f34, 0x35a750d1, 0x35a750d1, 0x43d1f34, }, 20 }, -+ { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4afab717, 0x2c355b94, 0x4afab717, 0x1166d9d0, 0x59c36f00, 0x59c36f00, 0x620c0067, 0x620c0067, 0x620c0067, 0x1c8c6d01, 0x1c8c6d01, 0x1c8c6d01, 0xc3269013, 0xc3269013, 0xc3269013, 0x59c36f00, 0x1166d9d0, 0x1166d9d0, 0x59c36f00, }, 20 }, -+ { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe3daadd4, 0x47f02a6c, 0xe3daadd4, 0x5ea9fb21, 0xaa4593fe, 0xaa4593fe, 0xa8a596c8, 0xa8a596c8, 0xa8a596c8, 0xe509baf, 0xe509baf, 0xe509baf, 0x16f0dc06, 0x16f0dc06, 0x16f0dc06, 0xaa4593fe, 0x5ea9fb21, 0x5ea9fb21, 0xaa4593fe, }, 20 }, -+ { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf140d1df, 0x4bcc8e07, 0xf140d1df, 0x7c962dcb, 0xc9cbf769, 0xc9cbf769, 0x3ce35e1d, 0x3ce35e1d, 0x3ce35e1d, 0xc23b9fd1, 0xc23b9fd1, 0xc23b9fd1, 0x5b18528e, 0x5b18528e, 0x5b18528e, 0xc9cbf769, 0x7c962dcb, 0x7c962dcb, 0xc9cbf769, }, 20 }, -+ { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xe709a12d, 0x54a9a81a, 0xe709a12d, 0xde04d65c, 0x9813a416, 0x9813a416, 0x43fda3fa, 0x43fda3fa, 0x43fda3fa, 0xd22625c9, 0xd22625c9, 0xd22625c9, 0x76a62c0a, 0x76a62c0a, 0x76a62c0a, 0x9813a416, 0xde04d65c, 0xde04d65c, 0x9813a416, }, 20 }, -+ { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x65eff77c, 0x7519ec1d, 0x65eff77c, 0x1cd7d353, 0x5fcf013d, 0x5fcf013d, 0xf3582c48, 0xf3582c48, 0xf3582c48, 0x2148343e, 0x2148343e, 0x2148343e, 0x9c719024, 0x9c719024, 0x9c719024, 0x5fcf013d, 0x1cd7d353, 0x1cd7d353, 0x5fcf013d, }, 20 }, -+ { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7318831a, 0x276027c4, 0x7318831a, 0xd7e4f5bb, 0xdd28f52b, 0xdd28f52b, 0xb3c7ef80, 0xb3c7ef80, 0xb3c7ef80, 0x92fb1664, 0x92fb1664, 0x92fb1664, 0xd15b5e2e, 0xd15b5e2e, 0xd15b5e2e, 0xdd28f52b, 0xd7e4f5bb, 0xd7e4f5bb, 0xdd28f52b, }, 20 }, -+ { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x6927a7d4, 0xc2b67069, 0x6927a7d4, 0xfc345163, 0x43d1f34, 0x43d1f34, 0xa0717008, 0xa0717008, 0xa0717008, 0xdf7bd9a0, 0xdf7bd9a0, 0xdf7bd9a0, 0x8e5a9312, 0x8e5a9312, 0x8e5a9312, 0x43d1f34, 0xfc345163, 0xfc345163, 0x43d1f34, }, 20 }, -+ { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0xe6012f70, 0xe6012f70, 0xe6012f70, 0xe6012f70, 0xe6012f70, }, 5 }, -+ { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xfb6be77b, 0xfb6be77b, 0xfb6be77b, 0xfb6be77b, 0xfb6be77b, }, 5 }, -+ { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0x67c0629f, 0x67c0629f, 0x67c0629f, 0x67c0629f, 0x67c0629f, }, 5 }, -+ { "videotest", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x8f20afbb, 0xd8f7abc, 0x8f937344, 0xd3ca643, 0x8e471645, }, 5 }, -+ { "videotest", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xdca764da, 0x9f76da9a, 0x5b04185a, 0x18d5a61a, 0xd60deb2b, }, 5 }, -+ { "videotest", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0x7b87af36, 0x7cb96093, 0x75fa307c, 0x72c4ffd9, 0x677c91a2, }, 5 }, -+ { "videotest", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x72981c65, 0x50120635, 0x378c28c5, 0x15063295, 0xf8b07525, }, 5 }, -+ { "videotest", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0xc8f64b58, 0xc8f64b58, 0xc8f64b58, 0xc8f64b58, 0xc8f64b58, }, 5 }, -+ { "videotest", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0x2b499dfa, 0x2b499dfa, 0x2b499dfa, 0x2b499dfa, 0x2b499dfa, }, 5 }, -+ { "videotest", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0x6156b420, 0x6156b420, 0x6156b420, 0x6156b420, 0x6156b420, }, 5 }, -+ { "videotest", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x363285ca, 0x363285ca, 0x363285ca, 0x363285ca, 0x363285ca, }, 5 }, -+ { "videotest", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0x25bb37f4, 0x25bb37f4, 0x25bb37f4, 0x25bb37f4, 0x25bb37f4, }, 5 }, -+ { "videotest", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0xeeab9e91, 0xeeab9e91, 0xeeab9e91, 0xeeab9e91, 0xeeab9e91, }, 5 }, -+ { "videotest", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x26a9a50b, 0x26a9a50b, 0x26a9a50b, 0x26a9a50b, 0x26a9a50b, }, 5 }, -+ { "videotest", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0x2c0f4fe7, 0x2c0f4fe7, 0x2c0f4fe7, 0x2c0f4fe7, 0x2c0f4fe7, }, 5 }, -+ { "videotest", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x46c11052, 0x46c11052, 0x46c11052, 0x46c11052, 0x46c11052, }, 5 }, -+ { "videotest", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0xe56cf615, 0xcd2be572, 0xb5e2d0db, 0x9da5c3bc, 0x4470bb89, }, 5 }, -+ { "videotest", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x2a25b871, 0x4bf85361, 0xe99e6e51, 0x88438541, 0xa8be62c0, }, 5 }, -+ { "videotest", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x81523037, 0xd8c0bfd3, 0x32772fff, 0x6be5a01b, 0xe2f47956, }, 5 }, -+ { "videotest", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x1833bb41, 0x1833bb41, 0x1833bb41, 0x1833bb41, 0x1833bb41, }, 5 }, -+ { "videotest", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0x2c39a0e8, 0x2c39a0e8, 0x2c39a0e8, 0x2c39a0e8, 0x2c39a0e8, }, 5 }, -+ { "videotest", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0xf0d4c23, 0xf0d4c23, 0xf0d4c23, 0xf0d4c23, 0xf0d4c23, }, 5 }, -+ { "videotest", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x456d063c, 0x456d063c, 0x456d063c, 0x456d063c, 0x456d063c, }, 5 }, -+ { "videotest", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0x47e15a2e, 0x47e15a2e, 0x47e15a2e, 0x47e15a2e, 0x47e15a2e, }, 5 }, -+ { "videotest", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x54d7300d, 0x54d7300d, 0x54d7300d, 0x54d7300d, 0x54d7300d, }, 5 }, -+ { "videotest", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x770da211, 0x8ef2528e, 0x811e35de, 0x78e1c541, 0x9ec6fb7e, }, 5 }, -+ { "videotest", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0xeb181fbc, 0xae648cc1, 0x61e13946, 0x249daa3b, 0xfb0624b9, }, 5 }, -+ { "videotest", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x2b6f64dc, 0xc25f8431, 0xfce2d3f7, 0x15d2331a, 0x81987c7b, }, 5 }, -+ { "videotest", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0xa260f7dd, 0x3e2f4980, 0x9f13fd96, 0x35c43cb, 0xd886e34b, }, 5 }, -+ { "videotest", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x41a9bff8, 0xa0d3f7c3, 0x86b1597f, 0x67cb1144, 0xca740407, }, 5 }, -+ { "videotest", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0x8f7a3b6d, 0xcb84c6e3, 0x687c071, 0x42793dff, 0x996dbba4, }, 5 }, -diff --git a/include/grub/aout.h b/include/grub/aout.h -index 10d7dde61ececf0e980c6ad62420764fcefd5e67..c8c1d94eca518042992a6fc5e3777f81a39b431d 100644 ---- a/include/grub/aout.h -+++ b/include/grub/aout.h -@@ -52,6 +52,7 @@ - #define GRUB_AOUT_HEADER 1 - - #include -+#include - - struct grub_aout32_header - { -diff --git a/include/grub/arc/arc.h b/include/grub/arc/arc.h -index 7615a49a92cac0ac16326c188e438b789b09acec..999de7196753b58781a02c5311c9bc3834408021 100644 ---- a/include/grub/arc/arc.h -+++ b/include/grub/arc/arc.h -@@ -53,7 +53,7 @@ enum grub_arc_memory_type - #ifndef GRUB_CPU_WORDS_BIGENDIAN - GRUB_ARC_MEMORY_FREE_CONTIGUOUS, - #endif -- } grub_arc_memory_type_t; -+ }; - - struct grub_arc_timeinfo - { -diff --git a/include/grub/arm/coreboot/console.h b/include/grub/arm/coreboot/console.h -new file mode 100644 -index 0000000000000000000000000000000000000000..13a14b783839a6cae96845973ae3087bcaef670e ---- /dev/null -+++ b/include/grub/arm/coreboot/console.h -@@ -0,0 +1,29 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2009 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#ifndef GRUB_MACHINE_CONSOLE_HEADER -+#define GRUB_MACHINE_CONSOLE_HEADER 1 -+ -+void grub_video_coreboot_fb_init (void); -+void grub_video_coreboot_fb_early_init (void); -+void grub_video_coreboot_fb_late_init (void); -+void grub_video_coreboot_fb_fini (void); -+ -+extern struct grub_linuxbios_table_framebuffer *grub_video_coreboot_fbtable; -+ -+#endif /* ! GRUB_MACHINE_CONSOLE_HEADER */ -diff --git a/include/grub/arm/coreboot/kernel.h b/include/grub/arm/coreboot/kernel.h -new file mode 100644 -index 0000000000000000000000000000000000000000..2695053427050f306b8ca86ba066df90c519e8e0 ---- /dev/null -+++ b/include/grub/arm/coreboot/kernel.h -@@ -0,0 +1,44 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2013 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#ifndef GRUB_KERNEL_MACHINE_HEADER -+#define GRUB_KERNEL_MACHINE_HEADER 1 -+ -+#ifndef ASM_FILE -+ -+#include -+#include -+ -+struct grub_fdt_board -+{ -+ const char *vendor, *part; -+ const grub_uint8_t *dtb; -+ grub_size_t dtb_size; -+}; -+ -+extern struct grub_fdt_board grub_fdt_boards[]; -+void grub_machine_timer_init (void); -+void grub_pl050_init (void); -+void grub_cros_init (void); -+void grub_rk3288_spi_init (void); -+extern grub_addr_t EXPORT_VAR (start_of_ram); -+#endif /* ! ASM_FILE */ -+ -+#define GRUB_KERNEL_MACHINE_STACK_SIZE GRUB_KERNEL_ARM_STACK_SIZE -+ -+#endif /* ! GRUB_KERNEL_MACHINE_HEADER */ -diff --git a/include/grub/arm/cros_ec.h b/include/grub/arm/cros_ec.h -new file mode 100644 -index 0000000000000000000000000000000000000000..45a372572a5c3c411c9b2b7f328135f5cbe551c8 ---- /dev/null -+++ b/include/grub/arm/cros_ec.h -@@ -0,0 +1,21 @@ -+#ifndef GRUB_ARM_CROS_EC_H -+#define GRUB_ARM_CROS_EC_H 1 -+ -+#include -+#include -+ -+#define GRUB_CROS_EC_KEYSCAN_COLS 13 -+#define GRUB_CROS_EC_KEYSCAN_ROWS 8 -+ -+struct grub_cros_ec_keyscan { -+ grub_uint8_t data[GRUB_CROS_EC_KEYSCAN_COLS]; -+}; -+ -+int -+grub_cros_ec_scan_keyboard (const struct grub_fdtbus_dev *dev, -+ struct grub_cros_ec_keyscan *scan); -+ -+int -+grub_cros_ec_validate (const struct grub_fdtbus_dev *dev); -+ -+#endif -diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h -index a66caad13db8c5c3b0da10f624d01a81640eab44..712ba17b9ba30cf850b6a9011d08a04d57816227 100644 ---- a/include/grub/arm/linux.h -+++ b/include/grub/arm/linux.h -@@ -17,14 +17,28 @@ - * along with GRUB. If not, see . - */ - --#ifndef GRUB_LINUX_CPU_HEADER --#define GRUB_LINUX_CPU_HEADER 1 -- --#define LINUX_ZIMAGE_OFFSET 0x24 --#define LINUX_ZIMAGE_MAGIC 0x016f2818 -+#ifndef GRUB_ARM_LINUX_HEADER -+#define GRUB_ARM_LINUX_HEADER 1 - - #include "system.h" - -+#define GRUB_LINUX_ARM_MAGIC_SIGNATURE 0x016f2818 -+ -+struct linux_arm_kernel_header { -+ grub_uint32_t code0; -+ grub_uint32_t reserved1[8]; -+ grub_uint32_t magic; -+ grub_uint32_t start; /* _start */ -+ grub_uint32_t end; /* _edata */ -+ grub_uint32_t reserved2[4]; -+ grub_uint32_t hdr_offset; -+}; -+ -+#if defined(__arm__) -+# define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM_MAGIC_SIGNATURE -+# define linux_armxx_kernel_header linux_arm_kernel_header -+#endif -+ - #if defined GRUB_MACHINE_UBOOT - # include - # define LINUX_ADDRESS (start_of_ram + 0x8000) -@@ -32,15 +46,17 @@ - # define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000) - # define grub_arm_firmware_get_boot_data grub_uboot_get_boot_data - # define grub_arm_firmware_get_machine_type grub_uboot_get_machine_type --#elif defined GRUB_MACHINE_EFI --# include --# include --/* On UEFI platforms - load the images at the lowest available address not -- less than *_PHYS_OFFSET from the first available memory location. */ --# define LINUX_PHYS_OFFSET (0x00008000) --# define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000) --# define LINUX_FDT_PHYS_OFFSET (LINUX_INITRD_PHYS_OFFSET - 0x10000) --# define grub_arm_firmware_get_boot_data (grub_addr_t)grub_efi_get_firmware_fdt -+#elif defined (GRUB_MACHINE_COREBOOT) -+#include -+#include -+# define LINUX_ADDRESS (start_of_ram + 0x8000) -+# define LINUX_INITRD_ADDRESS (start_of_ram + 0x02000000) -+# define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000) -+static inline const void * -+grub_arm_firmware_get_boot_data (void) -+{ -+ return grub_fdtbus_get_fdt (); -+} - static inline grub_uint32_t - grub_arm_firmware_get_machine_type (void) - { -@@ -48,6 +64,4 @@ grub_arm_firmware_get_machine_type (void) - } - #endif - --#define FDT_ADDITIONAL_ENTRIES_SIZE 0x300 -- --#endif /* ! GRUB_LINUX_CPU_HEADER */ -+#endif /* ! GRUB_ARM_LINUX_HEADER */ -diff --git a/include/grub/arm/startup.h b/include/grub/arm/startup.h -new file mode 100644 -index 0000000000000000000000000000000000000000..9afb6c57c0bc4c53e96f711bf545d94a8ed07aa5 ---- /dev/null -+++ b/include/grub/arm/startup.h -@@ -0,0 +1,16 @@ -+#ifndef GRUB_STARTUP_CPU_HEADER -+#define GRUB_STARTUP_CPU_HEADER -+ -+struct grub_arm_startup_registers -+{ -+ /* registers 0-11 */ -+ /* for U-boot r[1] is machine type */ -+ /* for U-boot r[2] is boot data */ -+ grub_uint32_t r[12]; -+ grub_uint32_t sp; -+ grub_uint32_t lr; -+}; -+ -+extern struct grub_arm_startup_registers grub_arm_saved_registers; -+ -+#endif -diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h -index 1ea23696e7a096e53075af2314da11ecce91f8d7..8655067e03924793293ba86cb1bae2e44efa5fee 100644 ---- a/include/grub/arm64/linux.h -+++ b/include/grub/arm64/linux.h -@@ -16,17 +16,13 @@ - * along with GRUB. If not, see . - */ - --#ifndef GRUB_LINUX_CPU_HEADER --#define GRUB_LINUX_CPU_HEADER 1 -+#ifndef GRUB_ARM64_LINUX_HEADER -+#define GRUB_ARM64_LINUX_HEADER 1 - --#include -- --#define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */ -- --#define GRUB_EFI_PE_MAGIC 0x5A4D -+#define GRUB_LINUX_ARM64_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */ - - /* From linux/Documentation/arm64/booting.txt */ --struct grub_arm64_linux_kernel_header -+struct linux_arm64_kernel_header - { - grub_uint32_t code0; /* Executable code */ - grub_uint32_t code1; /* Executable code */ -@@ -40,9 +36,9 @@ struct grub_arm64_linux_kernel_header - grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ - }; - --grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header -- *lh); --grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, -- char *args); -+#if defined(__aarch64__) -+# define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM64_MAGIC_SIGNATURE -+# define linux_armxx_kernel_header linux_arm64_kernel_header -+#endif - --#endif /* ! GRUB_LINUX_CPU_HEADER */ -+#endif /* ! GRUB_ARM64_LINUX_HEADER */ -diff --git a/include/grub/at_keyboard.h b/include/grub/at_keyboard.h -index b4f8ff0a06117756a770129683796edf0050b867..bcb4d9ba78f1376bdaa82249418f847eb4e543a6 100644 ---- a/include/grub/at_keyboard.h -+++ b/include/grub/at_keyboard.h -@@ -23,13 +23,11 @@ - #define KEYBOARD_COMMAND_ISREADY(x) !((x) & 0x02) - #define KEYBOARD_COMMAND_READ 0x20 - #define KEYBOARD_COMMAND_WRITE 0x60 -+#define KEYBOARD_COMMAND_ENABLE 0xf4 - #define KEYBOARD_COMMAND_REBOOT 0xfe - - #define KEYBOARD_AT_TRANSLATE 0x40 -- --#define GRUB_AT_ACK 0xfa --#define GRUB_AT_NACK 0xfe --#define GRUB_AT_TRIES 5 -+#define KEYBOARD_AT_DISABLE 0x10 - - #define KEYBOARD_ISMAKE(x) !((x) & 0x80) - #define KEYBOARD_ISREADY(x) ((x) & 0x01) -diff --git a/include/grub/autoefi.h b/include/grub/autoefi.h -index b75591176eb9d785de3f2867e32edc1b9a626280..b7a252e079e2137b4d27639b5c981e9085cb8a82 100644 ---- a/include/grub/autoefi.h -+++ b/include/grub/autoefi.h -@@ -55,7 +55,7 @@ static inline grub_err_t grub_autoefi_prepare (void) - # define SYSTEM_TABLE_PTR GRUB_EFIEMU_SYSTEM_TABLE_PTR - # define SIZEOF_OF_UINTN GRUB_EFIEMU_SIZEOF_OF_UINTN - # define SYSTEM_TABLE GRUB_EFIEMU_SYSTEM_TABLE --# define grub_efi_allocate_pages(x,y) (x) -+# define grub_efi_allocate_fixed(x,y) (x) - # define grub_efi_free_pages(x,y) GRUB_EFI_SUCCESS - # define grub_autoefi_finish_boot_services grub_efiemu_finish_boot_services - # define EFI_PRESENT 1 -diff --git a/include/grub/cache.h b/include/grub/cache.h -index fc669dfd1892c14bb43c6230e48067a0ff8e7c23..ccfa717e669625e0db96df0692c65f5a4c5ff916 100644 ---- a/include/grub/cache.h -+++ b/include/grub/cache.h -@@ -34,15 +34,16 @@ void EXPORT_FUNC(grub_arch_sync_caches) (void *address, grub_size_t len); - #endif - - #ifndef GRUB_MACHINE_EMU --#ifdef _mips --void EXPORT_FUNC(grub_arch_sync_dma_caches) (volatile void *address, -- grub_size_t len); --#else -+#if defined (__aarch64__) || defined (__powerpc__) || defined (__sparc__) -+ -+#elif defined (__i386__) || defined (__x86_64__) - static inline void - grub_arch_sync_dma_caches (volatile void *address __attribute__ ((unused)), - grub_size_t len __attribute__ ((unused))) - { - } -+#else -+void EXPORT_FUNC(grub_arch_sync_dma_caches) (volatile void *address, grub_size_t len); - #endif - #endif - -diff --git a/include/grub/i386/coreboot/lbio.h b/include/grub/coreboot/lbio.h -similarity index 93% -rename from include/grub/i386/coreboot/lbio.h -rename to include/grub/coreboot/lbio.h -index 1c3fa6f1953c3a6b41ea3644c30f000c98524224..5076d36c71ba32e5c55a6242287e5fe159e09b4f 100644 ---- a/include/grub/i386/coreboot/lbio.h -+++ b/include/grub/coreboot/lbio.h -@@ -20,6 +20,9 @@ - #ifndef _GRUB_MACHINE_LBIO_HEADER - #define _GRUB_MACHINE_LBIO_HEADER 1 - -+#include -+#include -+ - struct grub_linuxbios_table_header - { - grub_uint8_t signature[4]; -@@ -102,4 +105,10 @@ EXPORT_FUNC(grub_linuxbios_table_iterate) (int (*hook) (grub_linuxbios_table_ite - void *), - void *hook_data); - -+grub_linuxbios_table_header_t -+grub_linuxbios_get_tables (void); -+ -+int -+grub_linuxbios_check_signature (grub_linuxbios_table_header_t tbl_header); -+ - #endif -diff --git a/include/grub/dma.h b/include/grub/dma.h -new file mode 100644 -index 0000000000000000000000000000000000000000..19992ebc131d4fc93a45f31992ad3c03b9de2821 ---- /dev/null -+++ b/include/grub/dma.h -@@ -0,0 +1,44 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2008,2009 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#ifndef GRUB_DMA_H -+#define GRUB_DMA_H 1 -+ -+struct grub_pci_dma_chunk; -+ -+struct grub_pci_dma_chunk *EXPORT_FUNC(grub_memalign_dma32) (grub_size_t align, -+ grub_size_t size); -+void EXPORT_FUNC(grub_dma_free) (struct grub_pci_dma_chunk *ch); -+volatile void *EXPORT_FUNC(grub_dma_get_virt) (struct grub_pci_dma_chunk *ch); -+grub_uint32_t EXPORT_FUNC(grub_dma_get_phys) (struct grub_pci_dma_chunk *ch); -+ -+static inline void * -+grub_dma_phys2virt (grub_uint32_t phys, struct grub_pci_dma_chunk *chunk) -+{ -+ return ((grub_uint8_t *) grub_dma_get_virt (chunk) -+ + (phys - grub_dma_get_phys (chunk))); -+} -+ -+static inline grub_uint32_t -+grub_dma_virt2phys (volatile void *virt, struct grub_pci_dma_chunk *chunk) -+{ -+ return (((grub_uint8_t *) virt - (grub_uint8_t *) grub_dma_get_virt (chunk)) -+ + grub_dma_get_phys (chunk)); -+} -+ -+#endif -diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index e9c601f34103ae1a4ced7e93be8204970bfef193..2c6648d46fc1a377312c81220c38470d9d1cc99a 100644 ---- a/include/grub/efi/efi.h -+++ b/include/grub/efi/efi.h -@@ -38,16 +38,25 @@ void *EXPORT_FUNC(grub_efi_open_protocol) (grub_efi_handle_t handle, - int EXPORT_FUNC(grub_efi_set_text_mode) (int on); - void EXPORT_FUNC(grub_efi_stall) (grub_efi_uintn_t microseconds); - void * --EXPORT_FUNC(grub_efi_allocate_pages) (grub_efi_physical_address_t address, -+EXPORT_FUNC(grub_efi_allocate_pages_real) (grub_efi_physical_address_t address, -+ grub_efi_uintn_t pages, -+ grub_efi_allocate_type_t alloctype, -+ grub_efi_memory_type_t memtype); -+void * -+EXPORT_FUNC(grub_efi_allocate_fixed) (grub_efi_physical_address_t address, - grub_efi_uintn_t pages); -+void * -+EXPORT_FUNC(grub_efi_allocate_any_pages) (grub_efi_uintn_t pages); - void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address, - grub_efi_uintn_t pages); -+grub_efi_uintn_t EXPORT_FUNC(grub_efi_find_mmap_size) (void); - int - EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size, - grub_efi_memory_descriptor_t *memory_map, - grub_efi_uintn_t *map_key, - grub_efi_uintn_t *descriptor_size, - grub_efi_uint32_t *descriptor_version); -+void grub_efi_memory_fini (void); - grub_efi_loaded_image_t *EXPORT_FUNC(grub_efi_get_loaded_image) (grub_efi_handle_t image_handle); - void EXPORT_FUNC(grub_efi_print_device_path) (grub_efi_device_path_t *dp); - char *EXPORT_FUNC(grub_efi_get_filename) (grub_efi_device_path_t *dp); -@@ -83,6 +92,11 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, - - #if defined(__arm__) || defined(__aarch64__) - void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void); -+grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); -+#include -+grub_err_t grub_armxx_efi_linux_check_image(struct linux_armxx_kernel_header *lh); -+grub_err_t grub_armxx_efi_linux_boot_image(grub_addr_t addr, grub_size_t size, -+ char *args); - #endif - - grub_addr_t grub_efi_modules_addr (void); -diff --git a/include/grub/arm64/fdtload.h b/include/grub/efi/fdtload.h -similarity index 89% -rename from include/grub/arm64/fdtload.h -rename to include/grub/efi/fdtload.h -index 7b9ddba916d9980fbad51e7b02d99f0737ebc3fa..713c9424d0a9ebe47b1923a247e691566842b2d0 100644 ---- a/include/grub/arm64/fdtload.h -+++ b/include/grub/efi/fdtload.h -@@ -29,7 +29,4 @@ grub_fdt_unload (void); - grub_err_t - grub_fdt_install (void); - --#define GRUB_EFI_PAGE_SHIFT 12 --#define GRUB_EFI_BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) -- - #endif -diff --git a/include/grub/efi/memory.h b/include/grub/efi/memory.h -index 20526b14676de9295d17968f5ddc837a06bc56b6..08fe62277839dde3434e506cde78174f1977e9c9 100644 ---- a/include/grub/efi/memory.h -+++ b/include/grub/efi/memory.h -@@ -22,6 +22,13 @@ - #include - #include - -+/* The term "page" in UEFI refers only to a 4 KiB-aligned 4 KiB size region of -+ memory. It is not concerned with underlying translation management concepts, -+ but only used as the granule for memory allocations. */ -+#define GRUB_EFI_PAGE_SHIFT 12 -+#define GRUB_EFI_PAGE_SIZE (1 << GRUB_EFI_PAGE_SHIFT) -+#define GRUB_EFI_BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) -+ - #define GRUB_MMAP_REGISTER_BY_FIRMWARE 1 - - grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size, -diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h -index f79c36c026e0a518b3f9edaca36251d6d4943757..7d44732d2c353b74271262a1cf094d4aafd8dd10 100644 ---- a/include/grub/efi/pe32.h -+++ b/include/grub/efi/pe32.h -@@ -45,6 +45,8 @@ - - #define GRUB_PE32_MSDOS_STUB_SIZE 0x80 - -+#define GRUB_PE32_MAGIC 0x5a4d -+ - /* According to the spec, the minimal alignment is 512 bytes... - But some examples (such as EFI drivers in the Intel - Sample Implementation) use 32 bytes (0x20) instead, and it seems -diff --git a/include/grub/efiemu/runtime.h b/include/grub/efiemu/runtime.h -index 9b6b729f4ccde7274678b1324c16c9f6854477a2..36d2dedf47e4346b86f17882dc554207201b6401 100644 ---- a/include/grub/efiemu/runtime.h -+++ b/include/grub/efiemu/runtime.h -@@ -29,7 +29,7 @@ struct grub_efiemu_ptv_rel - - struct efi_variable - { -- grub_efi_guid_t guid; -+ grub_efi_packed_guid_t guid; - grub_uint32_t namelen; - grub_uint32_t size; - grub_efi_uint32_t attributes; -diff --git a/include/grub/fat.h b/include/grub/fat.h -index 4a5aab7934652cfde20c6fb291e00c29170b8753..8d7e4a1e54d644e6d70bb249802c699d5092728e 100644 ---- a/include/grub/fat.h -+++ b/include/grub/fat.h -@@ -28,20 +28,15 @@ struct grub_fat_bpb - grub_uint16_t bytes_per_sector; - grub_uint8_t sectors_per_cluster; - grub_uint16_t num_reserved_sectors; -- grub_uint8_t num_fats; -- /* 0x10 */ -+ grub_uint8_t num_fats; /* 0x10 */ - grub_uint16_t num_root_entries; - grub_uint16_t num_total_sectors_16; -- grub_uint8_t media; -- /*0 x15 */ -+ grub_uint8_t media; /* 0x15 */ - grub_uint16_t sectors_per_fat_16; -- grub_uint16_t sectors_per_track; -- /*0 x19 */ -- grub_uint16_t num_heads; -- /*0 x1b */ -- grub_uint32_t num_hidden_sectors; -- /* 0x1f */ -- grub_uint32_t num_total_sectors_32; -+ grub_uint16_t sectors_per_track; /* 0x18 */ -+ grub_uint16_t num_heads; /* 0x1A */ -+ grub_uint32_t num_hidden_sectors; /* 0x1C */ -+ grub_uint32_t num_total_sectors_32; /* 0x20 */ - union - { - struct -diff --git a/include/grub/fdt.h b/include/grub/fdt.h -index fdfca75bf487f17e8621fee5d1642f4874a2bf16..158b1bc4b3ad8bac60860e298b816781d6c57090 100644 ---- a/include/grub/fdt.h -+++ b/include/grub/fdt.h -@@ -20,6 +20,7 @@ - #define GRUB_FDT_HEADER 1 - - #include -+#include - - #define FDT_MAGIC 0xD00DFEED - -@@ -49,6 +50,11 @@ struct grub_fdt_empty_tree { - - #define GRUB_FDT_EMPTY_TREE_SZ sizeof (struct grub_fdt_empty_tree) - -+/* Size needed by a property entry: 1 token (FDT_PROPERTY), plus len and nameoff -+ fields, plus the property value, plus padding if needed. */ -+#define grub_fdt_prop_entry_size(prop_len) \ -+ (3 * sizeof(grub_uint32_t) + ALIGN_UP(prop_len, sizeof(grub_uint32_t))) -+ - #define grub_fdt_get_header(fdt, field) \ - grub_be_to_cpu32(((const grub_fdt_header_t *)(fdt))->field) - #define grub_fdt_set_header(fdt, field, value) \ -@@ -95,16 +101,22 @@ struct grub_fdt_empty_tree { - #define grub_fdt_set_size_dt_struct(fdt, value) \ - grub_fdt_set_header(fdt, size_dt_struct, value) - --int grub_fdt_create_empty_tree (void *fdt, unsigned int size); --int grub_fdt_check_header (void *fdt, unsigned int size); --int grub_fdt_check_header_nosize (void *fdt); --int grub_fdt_find_subnode (const void *fdt, unsigned int parentoffset, -- const char *name); --int grub_fdt_add_subnode (void *fdt, unsigned int parentoffset, -+int EXPORT_FUNC(grub_fdt_create_empty_tree) (void *fdt, unsigned int size); -+int EXPORT_FUNC(grub_fdt_check_header) (const void *fdt, unsigned int size); -+int EXPORT_FUNC(grub_fdt_check_header_nosize) (const void *fdt); -+int EXPORT_FUNC(grub_fdt_find_subnode) (const void *fdt, unsigned int parentoffset, -+ const char *name); -+int EXPORT_FUNC(grub_fdt_first_node) (const void *fdt, unsigned int parentoffset); -+int EXPORT_FUNC(grub_fdt_next_node) (const void *fdt, unsigned int currentoffset); -+int EXPORT_FUNC(grub_fdt_add_subnode) (void *fdt, unsigned int parentoffset, - const char *name); -+const char * -+EXPORT_FUNC(grub_fdt_get_nodename) (const void *fdt, unsigned int nodeoffset); -+const void *EXPORT_FUNC(grub_fdt_get_prop) (const void *fdt, unsigned int nodeoffset, const char *name, -+ grub_uint32_t *len); - --int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, -- const void *val, grub_uint32_t len); -+int EXPORT_FUNC(grub_fdt_set_prop) (void *fdt, unsigned int nodeoffset, const char *name, -+ const void *val, grub_uint32_t len); - #define grub_fdt_set_prop32(fdt, nodeoffset, name, val) \ - ({ \ - grub_uint32_t _val = grub_cpu_to_be32(val); \ -diff --git a/include/grub/fdtbus.h b/include/grub/fdtbus.h -new file mode 100644 -index 0000000000000000000000000000000000000000..f519c40ec35faea9aeedca055164012d9d9b3fb5 ---- /dev/null -+++ b/include/grub/fdtbus.h -@@ -0,0 +1,89 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2016 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#ifndef GRUB_FDTBUS_HEADER -+#define GRUB_FDTBUS_HEADER 1 -+ -+#include -+#include -+ -+struct grub_fdtbus_dev -+{ -+ struct grub_fdtbus_dev *next; -+ struct grub_fdtbus_dev *parent; -+ int node; -+ struct grub_fdtbus_driver *driver; -+}; -+ -+struct grub_fdtbus_driver -+{ -+ struct grub_fdtbus_driver *next; -+ struct grub_fdtbus_driver **prev; -+ -+ const char *compatible; -+ -+ grub_err_t (*attach) (const struct grub_fdtbus_dev *dev); -+ void (*detach) (const struct grub_fdtbus_dev *dev); -+ -+ /* Message bus operations. */ -+ grub_err_t (*send) (const struct grub_fdtbus_dev *dev, const void *data, grub_size_t sz); -+ grub_err_t (*receive) (const struct grub_fdtbus_dev *dev, void *data, grub_size_t sz); -+ grub_err_t (*start) (const struct grub_fdtbus_dev *dev); -+ void (*stop) (const struct grub_fdtbus_dev *dev); -+}; -+ -+extern char EXPORT_VAR(grub_fdtbus_invalid_mapping)[1]; -+ -+static inline int -+grub_fdtbus_is_mapping_valid (volatile void *m) -+{ -+ return m != grub_fdtbus_invalid_mapping; -+} -+ -+volatile void * -+EXPORT_FUNC(grub_fdtbus_map_reg) (const struct grub_fdtbus_dev *dev, int reg, grub_size_t *size); -+ -+const void * -+EXPORT_FUNC(grub_fdtbus_get_fdt) (void); -+ -+const char * -+EXPORT_FUNC(grub_fdtbus_get_name) (const struct grub_fdtbus_dev *dev); -+ -+const void * -+EXPORT_FUNC(grub_fdtbus_get_prop) (const struct grub_fdtbus_dev *dev, -+ const char *name, -+ grub_uint32_t *len); -+ -+void -+EXPORT_FUNC(grub_fdtbus_register) (struct grub_fdtbus_driver *driver); -+ -+void -+EXPORT_FUNC(grub_fdtbus_unregister) (struct grub_fdtbus_driver *driver); -+ -+int -+EXPORT_FUNC(grub_fdtbus_is_compatible) (const char *compat_string, -+ const struct grub_fdtbus_dev *dev); -+ -+/* Must be called before any register(). */ -+/* dtb is assumed to be unfreeable and must remain -+ valid for lifetime of GRUB. -+ */ -+void -+grub_fdtbus_init (const void *dtb, grub_size_t size); -+ -+#endif -diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h -index 1b32f6725a498f16941991771efe6a7a04ed6f5e..7a93f43291cce490cbaecc140ef2e5e0577ae274 100644 ---- a/include/grub/gpt_partition.h -+++ b/include/grub/gpt_partition.h -@@ -22,14 +22,14 @@ - #include - #include - --struct grub_gpt_part_type -+struct grub_gpt_part_guid - { - grub_uint32_t data1; - grub_uint16_t data2; - grub_uint16_t data3; - grub_uint8_t data4[8]; --} __attribute__ ((aligned(8))); --typedef struct grub_gpt_part_type grub_gpt_part_type_t; -+} GRUB_PACKED; -+typedef struct grub_gpt_part_guid grub_gpt_part_guid_t; - - #define GRUB_GPT_PARTITION_TYPE_EMPTY \ - { 0x0, 0x0, 0x0, \ -@@ -70,8 +70,8 @@ struct grub_gpt_header - - struct grub_gpt_partentry - { -- grub_gpt_part_type_t type; -- grub_uint8_t guid[16]; -+ grub_gpt_part_guid_t type; -+ grub_gpt_part_guid_t guid; - grub_uint64_t start; - grub_uint64_t end; - grub_uint64_t attrib; -diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h -index da0ca3b83cdc7355fc5b9815415ad7fc8732d153..60c7c3b5e660276dc11d23f4a53ccc2f1e5536a5 100644 ---- a/include/grub/i386/linux.h -+++ b/include/grub/i386/linux.h -@@ -16,10 +16,10 @@ - * along with GRUB. If not, see . - */ - --#ifndef GRUB_LINUX_MACHINE_HEADER --#define GRUB_LINUX_MACHINE_HEADER 1 -+#ifndef GRUB_I386_LINUX_HEADER -+#define GRUB_I386_LINUX_HEADER 1 - --#define GRUB_LINUX_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */ -+#define GRUB_LINUX_I386_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */ - #define GRUB_LINUX_DEFAULT_SETUP_SECTS 4 - #define GRUB_LINUX_INITRD_MAX_ADDRESS 0x37FFFFFF - #define GRUB_LINUX_MAX_SETUP_SECTS 64 -@@ -43,6 +43,9 @@ - - #define GRUB_LINUX_CL_MAGIC 0xA33F - -+#define VIDEO_CAPABILITY_SKIP_QUIRKS (1 << 0) -+#define VIDEO_CAPABILITY_64BIT_BASE (1 << 1) /* Frame buffer base is 64-bit. */ -+ - #ifdef __x86_64__ - - #define GRUB_LINUX_EFI_SIGNATURE \ -@@ -85,7 +88,7 @@ enum - }; - - /* For the Linux/i386 boot protocol version 2.10. */ --struct linux_kernel_header -+struct linux_i386_kernel_header - { - grub_uint8_t code1[0x0020]; - grub_uint16_t cl_magic; /* Magic number 0xA33F */ -@@ -188,8 +191,9 @@ struct linux_kernel_params - grub_uint16_t lfb_pages; /* 32 */ - grub_uint16_t vesa_attrib; /* 34 */ - grub_uint32_t capabilities; /* 36 */ -+ grub_uint32_t ext_lfb_base; /* 3a */ - -- grub_uint8_t padding3[0x40 - 0x3a]; -+ grub_uint8_t padding3[0x40 - 0x3e]; - - grub_uint16_t apm_version; /* 40 */ - grub_uint16_t apm_code_segment; /* 42 */ -@@ -312,4 +316,4 @@ struct linux_kernel_params - } GRUB_PACKED; - #endif /* ! ASM_FILE */ - --#endif /* ! GRUB_LINUX_MACHINE_HEADER */ -+#endif /* ! GRUB_I386_LINUX_HEADER */ -diff --git a/include/grub/i386/multiboot.h b/include/grub/i386/multiboot.h -index 807a1de27f900c8393476736051e20ee1af6717c..0b596fc2060a63f2fd9e1c67cb002279454aebe5 100644 ---- a/include/grub/i386/multiboot.h -+++ b/include/grub/i386/multiboot.h -@@ -19,6 +19,13 @@ - #ifndef GRUB_MULTIBOOT_CPU_HEADER - #define GRUB_MULTIBOOT_CPU_HEADER 1 - -+#define MULTIBOOT2_INITIAL_STATE { .eax = MULTIBOOT2_BOOTLOADER_MAGIC, \ -+ .ecx = 0, \ -+ .edx = 0, \ -+ /* Set esp to some random location in low memory to avoid breaking */ \ -+ /* non-compliant kernels. */ \ -+ .esp = 0x7ff00 \ -+ } - #define MULTIBOOT_INITIAL_STATE { .eax = MULTIBOOT_BOOTLOADER_MAGIC, \ - .ecx = 0, \ - .edx = 0, \ -@@ -28,7 +35,7 @@ - } - #define MULTIBOOT_ENTRY_REGISTER eip - #define MULTIBOOT_MBI_REGISTER ebx --#define MULTIBOOT_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_I386 -+#define MULTIBOOT2_ARCHITECTURE_CURRENT MULTIBOOT2_ARCHITECTURE_I386 - - #ifdef GRUB_MACHINE_EFI - #ifdef __x86_64__ -@@ -36,6 +43,10 @@ - .rcx = 0, \ - .rdx = 0, \ - } -+#define MULTIBOOT2_EFI_INITIAL_STATE { .rax = MULTIBOOT2_BOOTLOADER_MAGIC, \ -+ .rcx = 0, \ -+ .rdx = 0, \ -+ } - #define MULTIBOOT_EFI_ENTRY_REGISTER rip - #define MULTIBOOT_EFI_MBI_REGISTER rbx - #endif -diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h -index 8e425130327e193af1c1e34760e7255c9d6e6223..8868f3a756fe57b90188e25aaba2b203edacde13 100644 ---- a/include/grub/ieee1275/ieee1275.h -+++ b/include/grub/ieee1275/ieee1275.h -@@ -210,7 +210,25 @@ int EXPORT_FUNC(grub_ieee1275_set_property) (grub_ieee1275_phandle_t phandle, - int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle, - int index, int r, int g, int b); - int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs); -- -+int EXPORT_FUNC(grub_ieee1275_set_address) (grub_ieee1275_ihandle_t ihandle, -+ grub_uint32_t target, -+ grub_uint32_t lun); -+int EXPORT_FUNC(grub_ieee1275_no_data_command) (grub_ieee1275_ihandle_t ihandle, -+ const void *cmd_addr, -+ grub_ssize_t *result); -+int EXPORT_FUNC(grub_ieee1275_decode_unit4) (grub_ieee1275_ihandle_t ihandle, -+ void *addr, grub_size_t size, -+ grub_uint32_t *phy_lo, -+ grub_uint32_t *phy_hi, -+ grub_uint32_t *lun_lo, -+ grub_uint32_t *lun_hi); -+char *EXPORT_FUNC(grub_ieee1275_encode_uint4) (grub_ieee1275_ihandle_t ihandle, -+ grub_uint32_t phy_lo, -+ grub_uint32_t phy_hi, -+ grub_uint32_t lun_lo, -+ grub_uint32_t lun_hi, -+ grub_size_t *size); -+int EXPORT_FUNC(grub_ieee1275_get_block_size) (grub_ieee1275_ihandle_t ihandle); - - grub_err_t EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size); - -@@ -235,6 +253,8 @@ void EXPORT_FUNC(grub_ieee1275_children_peer) (struct grub_ieee1275_devalias *al - void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath, - struct grub_ieee1275_devalias *alias); - -+char *EXPORT_FUNC(grub_ieee1275_get_boot_dev) (void); -+ - #define FOR_IEEE1275_DEVALIASES(alias) for (grub_ieee1275_devalias_init_iterator (&(alias)); grub_ieee1275_devalias_next (&(alias));) - - #define FOR_IEEE1275_DEVCHILDREN(devpath, alias) for (grub_ieee1275_children_first ((devpath), &(alias)); \ -diff --git a/include/grub/kernel.h b/include/grub/kernel.h -index 20ddf2da297d5c883ed5b5542f2cfd99ee9c18da..ecd88ca72c6dea39be9f046463e7c51c874cb351 100644 ---- a/include/grub/kernel.h -+++ b/include/grub/kernel.h -@@ -28,7 +28,8 @@ enum - OBJ_TYPE_MEMDISK, - OBJ_TYPE_CONFIG, - OBJ_TYPE_PREFIX, -- OBJ_TYPE_PUBKEY -+ OBJ_TYPE_PUBKEY, -+ OBJ_TYPE_DTB - }; - - /* The module header. */ -diff --git a/include/grub/mips/multiboot.h b/include/grub/mips/multiboot.h -index 4aebf29e73240b575bb90c699fd02e8185ab5171..cdfb41e315af4aa22d549f76fb0131835abd957e 100644 ---- a/include/grub/mips/multiboot.h -+++ b/include/grub/mips/multiboot.h -@@ -19,11 +19,11 @@ - #ifndef GRUB_MULTIBOOT_CPU_HEADER - #define GRUB_MULTIBOOT_CPU_HEADER 1 - --#define MULTIBOOT_INITIAL_STATE { .gpr[4] = MULTIBOOT_BOOTLOADER_MAGIC, \ -+#define MULTIBOOT2_INITIAL_STATE { .gpr[4] = MULTIBOOT2_BOOTLOADER_MAGIC, \ - .jumpreg = 1 } - #define MULTIBOOT_ENTRY_REGISTER gpr[1] - #define MULTIBOOT_MBI_REGISTER gpr[5] --#define MULTIBOOT_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_MIPS32 -+#define MULTIBOOT2_ARCHITECTURE_CURRENT MULTIBOOT2_ARCHITECTURE_MIPS32 - - #define MULTIBOOT_ELF32_MACHINE EM_MIPS - #define MULTIBOOT_ELF64_MACHINE EM_MIPS -diff --git a/include/grub/misc.h b/include/grub/misc.h -index 2a9f87cc255eda94476733513807ec757c6d9cd9..372f009e84f12a58c3185dda63216bab7325be8f 100644 ---- a/include/grub/misc.h -+++ b/include/grub/misc.h -@@ -396,7 +396,8 @@ grub_abs (int x) - } - - /* Reboot the machine. */ --#if defined (GRUB_MACHINE_EMU) || defined (GRUB_MACHINE_QEMU_MIPS) -+#if defined (GRUB_MACHINE_EMU) || defined (GRUB_MACHINE_QEMU_MIPS) || \ -+ defined (GRUB_MACHINE_EFI) - void EXPORT_FUNC(grub_reboot) (void) __attribute__ ((noreturn)); - #else - void grub_reboot (void) __attribute__ ((noreturn)); -diff --git a/include/grub/multiboot.h b/include/grub/multiboot.h -index c96492bb5fa771831a62d4ab1bac3798328093f0..bd0a9873e6c158f77190c38546007c544cb0d6c9 100644 ---- a/include/grub/multiboot.h -+++ b/include/grub/multiboot.h -@@ -22,19 +22,11 @@ - - #include - --#ifdef GRUB_USE_MULTIBOOT2 --#include --/* Same thing as far as our loader is concerned. */ --#define MULTIBOOT_BOOTLOADER_MAGIC MULTIBOOT2_BOOTLOADER_MAGIC --#define MULTIBOOT_HEADER_MAGIC MULTIBOOT2_HEADER_MAGIC --#else - #include --#endif - - #include - #include - --#ifndef GRUB_USE_MULTIBOOT2 - typedef enum - { - GRUB_MULTIBOOT_QUIRKS_NONE = 0, -@@ -42,7 +34,6 @@ typedef enum - GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL = 2 - } grub_multiboot_quirks_t; - extern grub_multiboot_quirks_t grub_multiboot_quirks; --#endif - - extern struct grub_relocator *grub_multiboot_relocator; - -@@ -60,7 +51,7 @@ void - grub_multiboot_add_elfsyms (grub_size_t num, grub_size_t entsize, - unsigned shndx, void *data); - --grub_uint32_t grub_get_multiboot_mmap_count (void); -+grub_uint32_t grub_multiboot_get_mmap_count (void); - grub_err_t grub_multiboot_set_video_mode (void); - - /* FIXME: support coreboot as well. */ -diff --git a/include/grub/multiboot2.h b/include/grub/multiboot2.h -new file mode 100644 -index 0000000000000000000000000000000000000000..502d34ef18045e898680f2198522139c3066b587 ---- /dev/null -+++ b/include/grub/multiboot2.h -@@ -0,0 +1,104 @@ -+/* multiboot.h - multiboot header file with grub definitions. */ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2003,2007,2008,2010 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#ifndef GRUB_MULTIBOOT2_HEADER -+#define GRUB_MULTIBOOT2_HEADER 1 -+ -+#include -+ -+#include -+ -+#include -+#include -+ -+extern struct grub_relocator *grub_multiboot2_relocator; -+ -+void grub_multiboot2 (int argc, char *argv[]); -+void grub_module2 (int argc, char *argv[]); -+ -+void grub_multiboot2_set_accepts_video (int val); -+grub_err_t grub_multiboot2_make_mbi (grub_uint32_t *target); -+void grub_multiboot2_free_mbi (void); -+grub_err_t grub_multiboot2_init_mbi (int argc, char *argv[]); -+grub_err_t grub_multiboot2_add_module (grub_addr_t start, grub_size_t size, -+ int argc, char *argv[]); -+void grub_multiboot2_set_bootdev (void); -+void -+grub_multiboot2_add_elfsyms (grub_size_t num, grub_size_t entsize, -+ unsigned shndx, void *data); -+ -+grub_uint32_t grub_multiboot2_get_mmap_count (void); -+grub_err_t grub_multiboot2_set_video_mode (void); -+ -+/* FIXME: support coreboot as well. */ -+#if defined (GRUB_MACHINE_PCBIOS) -+#define GRUB_MACHINE_HAS_VBE 1 -+#else -+#define GRUB_MACHINE_HAS_VBE 0 -+#endif -+ -+#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU) -+#define GRUB_MACHINE_HAS_VGA_TEXT 1 -+#else -+#define GRUB_MACHINE_HAS_VGA_TEXT 0 -+#endif -+ -+#if defined (GRUB_MACHINE_EFI) || defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT) -+#define GRUB_MACHINE_HAS_ACPI 1 -+#else -+#define GRUB_MACHINE_HAS_ACPI 0 -+#endif -+ -+#define GRUB_MULTIBOOT2_CONSOLE_EGA_TEXT 1 -+#define GRUB_MULTIBOOT2_CONSOLE_FRAMEBUFFER 2 -+ -+grub_err_t -+grub_multiboot2_set_console (int console_type, int accepted_consoles, -+ int width, int height, int depth, -+ int console_required); -+grub_err_t -+grub_multiboot2_load (grub_file_t file, const char *filename); -+ -+struct mbi_load_data -+{ -+ grub_file_t file; -+ const char *filename; -+ void *buffer; -+ unsigned int mbi_ver; -+ int relocatable; -+ grub_uint32_t min_addr; -+ grub_uint32_t max_addr; -+ grub_size_t align; -+ grub_uint32_t preference; -+ grub_uint32_t link_base_addr; -+ grub_uint32_t load_base_addr; -+ int avoid_efi_boot_services; -+}; -+typedef struct mbi_load_data mbi_load_data_t; -+ -+/* Load ELF32 or ELF64. */ -+grub_err_t -+grub_multiboot2_load_elf (mbi_load_data_t *mld); -+ -+extern grub_size_t grub_multiboot2_pure_size; -+extern grub_size_t grub_multiboot2_alloc_mbi; -+extern grub_uint32_t grub_multiboot2_payload_eip; -+ -+ -+#endif /* ! GRUB_MULTIBOOT_HEADER */ -diff --git a/include/grub/net.h b/include/grub/net.h -index 2192fa18628862e8e3a6046d854b12613e914ff9..1096b24322eb1ba36e8c996872fce2a255e6bccc 100644 ---- a/include/grub/net.h -+++ b/include/grub/net.h -@@ -291,6 +291,7 @@ struct grub_net_network_level_interface - grub_net_interface_flags_t flags; - struct grub_net_bootp_packet *dhcp_ack; - grub_size_t dhcp_acklen; -+ grub_uint16_t vlantag; - void *data; - }; - -@@ -561,4 +562,6 @@ extern char *grub_net_default_server; - #define GRUB_NET_INTERVAL 400 - #define GRUB_NET_INTERVAL_ADDITION 20 - -+#define VLANTAG_IDENTIFIER 0x8100 -+ - #endif /* ! GRUB_NET_HEADER */ -diff --git a/include/grub/net/arp.h b/include/grub/net/arp.h -index bb1703622e1529479618e7f71b0d5e88adb631d1..8d9d081134f52e2d33c23928baae7f6b4c08470f 100644 ---- a/include/grub/net/arp.h -+++ b/include/grub/net/arp.h -@@ -22,10 +22,11 @@ - #include - - extern grub_err_t grub_net_arp_receive (struct grub_net_buff *nb, -- struct grub_net_card *card); -+ struct grub_net_card *card, -+ grub_uint16_t *vlantag); - - grub_err_t - grub_net_arp_send_request (struct grub_net_network_level_interface *inf, -- const grub_net_network_level_address_t *proto_addr); -+ const grub_net_network_level_address_t *proto_addr); - - #endif -diff --git a/include/grub/net/ip.h b/include/grub/net/ip.h -index dcceaa56894605a39f87858964da7af11951ff11..ab9d68f98252b9772853a712ff1e8556162002ee 100644 ---- a/include/grub/net/ip.h -+++ b/include/grub/net/ip.h -@@ -48,7 +48,8 @@ grub_err_t - grub_net_recv_ip_packets (struct grub_net_buff *nb, - struct grub_net_card *card, - const grub_net_link_level_address_t *hwaddress, -- const grub_net_link_level_address_t *src_hwaddress); -+ const grub_net_link_level_address_t *src_hwaddress, -+ grub_uint16_t *vlantag); - - grub_err_t - grub_net_send_ip_packet (struct grub_net_network_level_interface *inf, -diff --git a/include/grub/offsets.h b/include/grub/offsets.h -index c88c86d4d2ebddddb23f25c50ad2c29b52e54ccb..330e4c70738abcacc3c1d53fb16ae1ec8896d9e3 100644 ---- a/include/grub/offsets.h -+++ b/include/grub/offsets.h -@@ -50,7 +50,7 @@ - /* The offset of GRUB_CORE_ENTRY_ADDR. */ - #define GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR 0x8 - --#define GRUB_KERNEL_I386_QEMU_LINK_ADDR 0x8200 -+#define GRUB_KERNEL_I386_QEMU_LINK_ADDR 0x9000 - - /* The offset of GRUB_TOTAL_MODULE_SIZE. */ - #define GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE 0x8 -@@ -91,7 +91,7 @@ - - #define GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE 0x08 - --#define GRUB_KERNEL_I386_COREBOOT_LINK_ADDR 0x8200 -+#define GRUB_KERNEL_I386_COREBOOT_LINK_ADDR 0x9000 - #define GRUB_KERNEL_I386_COREBOOT_MODULES_ADDR 0x100000 - - #define GRUB_KERNEL_I386_IEEE1275_LINK_ADDR 0x10000 -@@ -122,6 +122,12 @@ - #define GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN 0x8 - #define GRUB_KERNEL_ARM_UBOOT_TOTAL_MODULE_SIZE 0x4 - -+#define GRUB_KERNEL_ARM_COREBOOT_MOD_ALIGN 0x8 -+#define GRUB_KERNEL_ARM_COREBOOT_TOTAL_MODULE_SIZE 0x4 -+ -+#define GRUB_KERNEL_ARM_STACK_SIZE 0x40000 -+#define GRUB_KERNEL_ARM_COREBOOT_MOD_GAP (GRUB_KERNEL_ARM_STACK_SIZE + 1024) -+ - /* Minimal gap between _end and the start of the modules. It's a hack - for PowerMac to prevent "CLAIM failed" error. The real fix is to - rewrite grub-mkimage to generate valid ELF files. */ -diff --git a/include/grub/pci.h b/include/grub/pci.h -index 70d9a05131b240bbe3c7fe12df899c8e3de237ce..262c89b748bbfccc98ffa27912ce7e2a5005f545 100644 ---- a/include/grub/pci.h -+++ b/include/grub/pci.h -@@ -142,27 +142,7 @@ grub_pci_address_t EXPORT_FUNC(grub_pci_make_address) (grub_pci_device_t dev, - void EXPORT_FUNC(grub_pci_iterate) (grub_pci_iteratefunc_t hook, - void *hook_data); - --struct grub_pci_dma_chunk; -- --struct grub_pci_dma_chunk *EXPORT_FUNC(grub_memalign_dma32) (grub_size_t align, -- grub_size_t size); --void EXPORT_FUNC(grub_dma_free) (struct grub_pci_dma_chunk *ch); --volatile void *EXPORT_FUNC(grub_dma_get_virt) (struct grub_pci_dma_chunk *ch); --grub_uint32_t EXPORT_FUNC(grub_dma_get_phys) (struct grub_pci_dma_chunk *ch); -- --static inline void * --grub_dma_phys2virt (grub_uint32_t phys, struct grub_pci_dma_chunk *chunk) --{ -- return ((grub_uint8_t *) grub_dma_get_virt (chunk) -- + (phys - grub_dma_get_phys (chunk))); --} -- --static inline grub_uint32_t --grub_dma_virt2phys (volatile void *virt, struct grub_pci_dma_chunk *chunk) --{ -- return (((grub_uint8_t *) virt - (grub_uint8_t *) grub_dma_get_virt (chunk)) -- + grub_dma_get_phys (chunk)); --} -+#include - - grub_uint8_t - EXPORT_FUNC (grub_pci_find_capability) (grub_pci_device_t dev, grub_uint8_t cap); -diff --git a/include/grub/ps2.h b/include/grub/ps2.h -new file mode 100644 -index 0000000000000000000000000000000000000000..4f2e527e49767c297646f1ea3d0e09bdc2855892 ---- /dev/null -+++ b/include/grub/ps2.h -@@ -0,0 +1,43 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2007,2008,2009 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#ifndef GRUB_PS2_HEADER -+#define GRUB_PS2_HEADER 1 -+ -+#include -+ -+#define GRUB_AT_ACK 0xfa -+#define GRUB_AT_NACK 0xfe -+#define GRUB_AT_TRIES 5 -+ -+/* Make sure it's zeroed-out and set current_set at init. */ -+struct grub_ps2_state -+{ -+ int e0_received; -+ int f0_received; -+ grub_uint8_t led_status; -+ short at_keyboard_status; -+ grub_uint8_t current_set; -+}; -+ -+/* If there is a key pending, return it; otherwise return GRUB_TERM_NO_KEY. */ -+int -+grub_ps2_process_incoming_byte (struct grub_ps2_state *ps2_state, -+ grub_uint8_t data); -+ -+#endif -diff --git a/include/grub/sparc64/ieee1275/ieee1275.h b/include/grub/sparc64/ieee1275/ieee1275.h -index 32c77f80f1a136c0127aecb6d5643ebd64cb5e88..4b18468d8d654bb3fe62050e7a4f439e1544889c 100644 ---- a/include/grub/sparc64/ieee1275/ieee1275.h -+++ b/include/grub/sparc64/ieee1275/ieee1275.h -@@ -42,6 +42,8 @@ extern int EXPORT_FUNC(grub_ieee1275_claim_vaddr) (grub_addr_t vaddr, - extern int EXPORT_FUNC(grub_ieee1275_alloc_physmem) (grub_addr_t *paddr, - grub_size_t size, - grub_uint32_t align); -+extern grub_uint64_t EXPORT_FUNC(grub_ieee1275_num_blocks) (grub_uint32_t ihandle); -+extern grub_uint64_t EXPORT_FUNC(grub_ieee1275_num_blocks64) (grub_uint32_t ihandle); - - extern grub_addr_t EXPORT_VAR (grub_ieee1275_original_stack); - -diff --git a/include/grub/term.h b/include/grub/term.h -index 5ffb38f69aaa8911a66bdc6f417a72666b19e514..8117e2a24dac3f270d05408f1897fae9f0fa1593 100644 ---- a/include/grub/term.h -+++ b/include/grub/term.h -@@ -55,7 +55,8 @@ - #define GRUB_TERM_KEY_INSERT (GRUB_TERM_EXTENDED | 0x52) - #define GRUB_TERM_KEY_CENTER (GRUB_TERM_EXTENDED | 0x4c) - --#define GRUB_TERM_ESC '\e' -+/* Hex value is used for ESC, since '\e' is nonstandard */ -+#define GRUB_TERM_ESC 0x1b - #define GRUB_TERM_TAB '\t' - #define GRUB_TERM_BACKSPACE '\b' - -diff --git a/include/grub/usb.h b/include/grub/usb.h -index 11d96481ff6b58cc43f468bcb2020475663fa098..512ae1dd0e64931c852847c9d52efdbd6b2caccb 100644 ---- a/include/grub/usb.h -+++ b/include/grub/usb.h -@@ -321,5 +321,9 @@ grub_usb_err_t - grub_usb_check_transfer (grub_usb_transfer_t trans, grub_size_t *actual); - void - grub_usb_cancel_transfer (grub_usb_transfer_t trans); -+void -+grub_ehci_init_device (volatile void *regs); -+void -+grub_ehci_pci_scan (void); - - #endif /* GRUB_USB_H */ -diff --git a/include/grub/util/install.h b/include/grub/util/install.h -index 5ca4811cd130f6810f07e6fbce89af1de36827c7..0dba8b67f93d44f875f2d1065ed5bf745f7813a5 100644 ---- a/include/grub/util/install.h -+++ b/include/grub/util/install.h -@@ -29,6 +29,8 @@ - #define GRUB_INSTALL_OPTIONS \ - { "modules", GRUB_INSTALL_OPTIONS_MODULES, N_("MODULES"), \ - 0, N_("pre-load specified modules MODULES"), 1 }, \ -+ { "dtb", GRUB_INSTALL_OPTIONS_DTB, N_("FILE"), \ -+ 0, N_("embed a specific DTB"), 1 }, \ - { "install-modules", GRUB_INSTALL_OPTIONS_INSTALL_MODULES, \ - N_("MODULES"), 0, \ - N_("install only MODULES and their dependencies [default=all]"), 1 }, \ -@@ -99,6 +101,7 @@ enum grub_install_plat - GRUB_INSTALL_PLATFORM_I386_XEN, - GRUB_INSTALL_PLATFORM_X86_64_XEN, - GRUB_INSTALL_PLATFORM_ARM64_EFI, -+ GRUB_INSTALL_PLATFORM_ARM_COREBOOT, - GRUB_INSTALL_PLATFORM_MAX - }; - -@@ -115,7 +118,8 @@ enum grub_install_options { - GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY, - GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY, - GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE, -- GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS -+ GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS, -+ GRUB_INSTALL_OPTIONS_DTB - }; - - extern char *grub_install_source_directory; -@@ -176,7 +180,7 @@ grub_install_generate_image (const char *dir, const char *prefix, - char *config_path, - const struct grub_install_image_target_desc *image_target, - int note, -- grub_compression_t comp); -+ grub_compression_t comp, const char *dtb_file); - - const struct grub_install_image_target_desc * - grub_install_get_image_target (const char *arg); -@@ -206,7 +210,7 @@ grub_install_create_envblk_file (const char *name); - const char * - grub_install_get_default_x86_platform (void); - --void -+int - grub_install_register_efi (grub_device_t efidir_grub_dev, - const char *efifile_path, - const char *efi_distributor); -diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h -index 1a18708a89c6e5503dd29b0b76f5098cef3ac893..b3a5ca132bc4d336f8d85158726bcce77fd7cd37 100644 ---- a/include/grub/util/mkimage.h -+++ b/include/grub/util/mkimage.h -@@ -51,13 +51,13 @@ grub_mkimage_load_image64 (const char *kernel_path, - void - grub_mkimage_generate_elf32 (const struct grub_install_image_target_desc *image_target, - int note, char **core_img, size_t *core_size, -- Elf32_Addr target_addr, grub_size_t align, -- size_t kernel_size, size_t bss_size); -+ Elf32_Addr target_addr, -+ struct grub_mkimage_layout *layout); - void - grub_mkimage_generate_elf64 (const struct grub_install_image_target_desc *image_target, - int note, char **core_img, size_t *core_size, -- Elf64_Addr target_addr, grub_size_t align, -- size_t kernel_size, size_t bss_size); -+ Elf64_Addr target_addr, -+ struct grub_mkimage_layout *layout); - - struct grub_install_image_target_desc - { -diff --git a/include/multiboot2.h b/include/multiboot2.h -index 5a3db5a7cae38c26be516dc76a4fa6a9ad4ed354..5693923c014f2fa9e855dcc89c7328a19e0e6408 100644 ---- a/include/multiboot2.h -+++ b/include/multiboot2.h -@@ -75,8 +75,8 @@ - #define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9 - #define MULTIBOOT_HEADER_TAG_RELOCATABLE 10 - --#define MULTIBOOT_ARCHITECTURE_I386 0 --#define MULTIBOOT_ARCHITECTURE_MIPS32 4 -+#define MULTIBOOT2_ARCHITECTURE_I386 0 -+#define MULTIBOOT2_ARCHITECTURE_MIPS32 4 - #define MULTIBOOT_HEADER_TAG_OPTIONAL 1 - - #define MULTIBOOT_LOAD_PREFERENCE_NONE 0 -diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S -index 1ee4cf5b2e0fd03ba177e953fafdaf5e0ca457a6..c1addc0df29bc78009238690a9514ea301bf3a29 100644 ---- a/grub-core/boot/i386/pc/diskboot.S -+++ b/grub-core/boot/i386/pc/diskboot.S -@@ -37,8 +37,8 @@ - start: - _start: - /* -- * _start is loaded at 0x2000 and is jumped to with -- * CS:IP 0:0x2000 in kernel. -+ * _start is loaded at 0x8000 and is jumped to with -+ * CS:IP 0:0x8000 in kernel. - */ - - /* -diff --git a/grub-core/boot/sparc64/ieee1275/boot.S b/grub-core/boot/sparc64/ieee1275/boot.S -index 586efb4014e8648e560fb43eee8eea8b09da669b..9ea9b4e06627bbd8b7da422ffba3357b4fba0a6a 100644 ---- a/grub-core/boot/sparc64/ieee1275/boot.S -+++ b/grub-core/boot/sparc64/ieee1275/boot.S -@@ -69,6 +69,10 @@ prom_seek_name: .asciz "seek" - prom_read_name: .asciz "read" - prom_exit_name: .asciz "exit" - grub_name: .asciz "GRUB " -+#ifdef CDBOOT -+prom_close_name: .asciz "close" -+#endif -+ - #define GRUB_NAME_LEN 5 - - .align 4 -@@ -213,6 +217,12 @@ bootpath_known: - call prom_call_3_1_o1 - #ifdef CDBOOT - LDUW_ABS(kernel_size, 0x00, %o3) -+ -+ GET_ABS(prom_close_name, %o0) -+ mov 1, %g1 -+ mov 0, %o5 -+ call prom_call -+ mov BOOTDEV_REG, %o1 - #else - mov 512, %o3 - #endif -diff --git a/grub-core/kern/arm/cache_armv7.S b/grub-core/kern/arm/cache_armv7.S -index 1ef2754af8a7612c35c26011fab442dbba074dfd..5ae76a3d819c002676f54db3311f517791e0c4e8 100644 ---- a/grub-core/kern/arm/cache_armv7.S -+++ b/grub-core/kern/arm/cache_armv7.S -@@ -33,6 +33,18 @@ - # define ISB isb - #define ARMV7 1 - -+FUNCTION(grub_arm_clean_dcache_range_poc_armv7) -+ DSB -+ @ Clean data cache for range to point-of-coherence -+1: cmp r0, r1 -+ bge 2f -+ mcr p15, 0, r0, c7, c14, 1 @ DCCMVAC -+ add r0, r0, r2 @ Next line -+ b 1b -+2: DSB -+ bx lr -+ -+ - @ r0 - CLIDR - @ r1 - LoC - @ r2 - current level -diff --git a/include/grub/arm/efi/loader.h b/grub-core/kern/arm/coreboot/coreboot.S -similarity index 62% -rename from include/grub/arm/efi/loader.h -rename to grub-core/kern/arm/coreboot/coreboot.S -index 4bab18e83ee833d6932fea917d839fe7dcc212d1..a1104526c154bd5a9dfd9e3680d8bb787c1088ef 100644 ---- a/include/grub/arm/efi/loader.h -+++ b/grub-core/kern/arm/coreboot/coreboot.S -@@ -1,6 +1,6 @@ - /* - * GRUB -- GRand Unified Bootloader -- * Copyright (C) 2013 Free Software Foundation, Inc. -+ * Copyright (C) 2016 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by -@@ -16,11 +16,29 @@ - * along with GRUB. If not, see . - */ - --#ifndef GRUB_LOADER_MACHINE_HEADER --#define GRUB_LOADER_MACHINE_HEADER 1 -+#include - --grub_err_t EXPORT_FUNC (grub_efi_prepare_platform) (void); --void * EXPORT_FUNC (grub_efi_allocate_loader_memory) (grub_uint32_t min_offset, -- grub_uint32_t size); -+ .file "coreboot.S" -+ .text -+ .syntax unified -+#if !defined (__thumb2__) -+ .arch armv7a -+ .arm -+#else -+ .arch armv7 -+ .thumb -+#endif -+ -+FUNCTION(grub_arm_pfr1) -+ mrc p15, 0, r0, c0, c1, 1 -+ bx lr -+ -+FUNCTION(grub_armv7_get_timer_value) -+ isb -+ mrrc p15, 1, r0, r1, c14 -+ bx lr -+ -+FUNCTION(grub_armv7_get_timer_frequency) -+ mrc p15, 0, r0, c14, c0, 0 -+ bx lr - --#endif /* ! GRUB_LOADER_MACHINE_HEADER */ -diff --git a/grub-core/kern/arm/uboot/startup.S b/grub-core/kern/arm/startup.S -similarity index 77% -rename from grub-core/kern/arm/uboot/startup.S -rename to grub-core/kern/arm/startup.S -index 5efaae16e838b48dd4d9a5debfc2937a558c65ba..3946fe8e183023f80e3a90ae4ee7b942f02f204d 100644 ---- a/grub-core/kern/arm/uboot/startup.S -+++ b/grub-core/kern/arm/startup.S -@@ -24,6 +24,7 @@ - * GRUB is called from U-Boot as a Linux Kernel type image, which - * means among other things that it always enters in ARM state. - * -+ * coreboot starts in ARM mode as well. - * - * Overview of GRUB image layout: - * -@@ -86,7 +87,7 @@ FUNCTION(codestart) - @ Stack pointer used as start address for signature probing - mov r12, sp - adr sp, entry_state -- push {r1-r12,lr} @ store U-Boot context (sp in r12) -+ push {r0-r12,lr} @ store U-Boot context (sp in r12) - - adr r1, _start - ldr r0, bss_start_ptr @ src -@@ -127,6 +128,8 @@ reloc_done: - - str r1, EXT_C(grub_modbase) - -+ /* Coreboot already places modules at right place. */ -+#ifndef GRUB_MACHINE_COREBOOT - add r1, r1, r2 - add r0, r0, r2 - sub r1, r1, #4 -@@ -136,6 +139,7 @@ reloc_done: - str r3, [r1], #-4 @ *dst-- = r3 - subs r2, #4 @ remaining -= 4 - bne 1b @ while remaining != 0 -+#endif - - @ Since we _are_ the C run-time, we need to manually zero the BSS - @ region before continuing -@@ -153,69 +157,21 @@ reloc_done: - - b EXT_C(grub_main) - -- /* -- * uboot_syscall(): -- * This function is effectively a veneer, so it cannot -- * modify the stack or corrupt any registers other than -- * r12 (ip). Furthermore it needs to restore r8 for -- * U-Boot (Global Data Pointer) and preserve it for Grub. -- */ --FUNCTION(grub_uboot_syscall) -- str r8, transition_space -- str lr, transition_space + 4 -- str r9, transition_space + 8 -- -- ldr r8, gd_backup -- ldr r9, gd_backup + 4 -- -- bl do_syscall -- -- ldr r8, transition_space -- ldr lr, transition_space + 4 -- ldr r9, transition_space + 8 -- -- bx lr --do_syscall: -- -- ldr ip, grub_uboot_syscall_ptr -- bx ip -- --FUNCTION(grub_uboot_return) -- adr sp, entry_state_end -- pop {r4-r12, lr} -- mov sp, r12 -- bx lr -- -- - .align 3 --@ U-boot context stack space --entry_state_end: --VARIABLE(grub_uboot_machine_type) -+@ U-boot/coreboot context stack space -+VARIABLE(grub_arm_saved_registers) -+ .long 0 @ r0 - .long 0 @ r1 --VARIABLE(grub_uboot_boot_data) - .long 0 @ r2 - .long 0 @ r3 - .long 0 @ r4 - .long 0 @ r5 - .long 0 @ r6 - .long 0 @ r7 --gd_backup: -- .long 0 @ r8 - U-Boot global data pointer up to 2013-09-21 -- .long 0 @ r9 - U-Boot global data pointer 2013-09-21 onwards -- .long 0 @ r10 -- .long 0 @ r11 --VARIABLE(grub_uboot_search_hint)@ U-Boot stack pointer - -- .long 0 @ also API signature address hint. -- .long 0 @ lr --entry_state: @ backup for U-Boot context -- --@ GRUB context stack space --transition_space: - .long 0 @ r8 -- .long 0 @ lr - .long 0 @ r9 -- --VARIABLE(grub_uboot_syscall_ptr) -- .long 0 @ -- -- END -+ .long 0 @ r10 -+ .long 0 @ r11 -+ .long 0 @ sp -+ .long 0 @ lr -+entry_state: -diff --git a/grub-core/kern/arm/uboot/uboot.S b/grub-core/kern/arm/uboot/uboot.S -new file mode 100644 -index 0000000000000000000000000000000000000000..d128775f19ea1f862b46bc82b05b453be577d741 ---- /dev/null -+++ b/grub-core/kern/arm/uboot/uboot.S -@@ -0,0 +1,73 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2013 Free Software Foundation, Inc. -+ * -+ * GRUB is free software: you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation, either version 3 of the License, or -+ * (at your option) any later version. -+ * -+ * GRUB is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with GRUB. If not, see . -+ */ -+ -+#include -+#include -+#include -+ -+ /* -+ * uboot_syscall(): -+ * This function is effectively a veneer, so it cannot -+ * modify the stack or corrupt any registers other than -+ * r12 (ip). Furthermore it needs to restore r8 for -+ * U-Boot (Global Data Pointer) and preserve it for Grub. -+ */ -+FUNCTION(grub_uboot_syscall) -+ str r8, transition_space -+ str lr, transition_space + 4 -+ str r9, transition_space + 8 -+ -+ ldr ip, saved_registers_ptr -+ ldr r8, [ip, #4 * 8] -+ ldr r9, [ip, #4 * 9] -+ -+ bl do_syscall -+ -+ ldr r8, transition_space -+ ldr lr, transition_space + 4 -+ ldr r9, transition_space + 8 -+ -+ bx lr -+do_syscall: -+ -+ ldr ip, grub_uboot_syscall_ptr -+ bx ip -+ -+FUNCTION(grub_uboot_return) -+ ldr ip, saved_registers_ptr -+ ldr sp, [ip, #4 * 4] -+ pop {r4-r12, lr} -+ mov sp, r12 -+ bx lr -+ -+ -+ .align 3 -+ -+@ GRUB context stack space -+transition_space: -+ .long 0 @ r8 -+ .long 0 @ lr -+ .long 0 @ r9 -+ -+saved_registers_ptr: -+ .long EXT_C(grub_arm_saved_registers) -+ -+VARIABLE(grub_uboot_syscall_ptr) -+ .long 0 @ -+ -+ END -diff --git a/conf/Makefile.common b/conf/Makefile.common -index 11296b550a7cd40ded498613620f556d78c67d84..311da61c6c59fed3de8cba06c2c581b217d8273f 100644 ---- a/conf/Makefile.common -+++ b/conf/Makefile.common -@@ -86,9 +86,11 @@ CPPFLAGS_TERMINAL_LIST += '-Dgrub_term_register_output(...)=OUTPUT_TERMINAL_LIST - CPPFLAGS_COMMAND_LIST = '-Dgrub_register_command(...)=COMMAND_LIST_MARKER(__VA_ARGS__)' - CPPFLAGS_COMMAND_LIST += '-Dgrub_register_extcmd(...)=EXTCOMMAND_LIST_MARKER(__VA_ARGS__)' - CPPFLAGS_COMMAND_LIST += '-Dgrub_register_command_p1(...)=P1COMMAND_LIST_MARKER(__VA_ARGS__)' -+CPPFLAGS_FDT_LIST := '-Dgrub_fdtbus_register(...)=FDT_DRIVER_LIST_MARKER(__VA_ARGS__)' - CPPFLAGS_MARKER = $(CPPFLAGS_FS_LIST) $(CPPFLAGS_VIDEO_LIST) \ - $(CPPFLAGS_PARTTOOL_LIST) $(CPPFLAGS_PARTMAP_LIST) \ -- $(CPPFLAGS_TERMINAL_LIST) $(CPPFLAGS_COMMAND_LIST) -+ $(CPPFLAGS_TERMINAL_LIST) $(CPPFLAGS_COMMAND_LIST) \ -+ $(CPPFLAGS_FDT_LIST) - - # Define these variables to calm down automake - -diff --git a/docs/grub.texi b/docs/grub.texi -index e935af33ea5e24d832e588d1345e3721b826d5a0..2adfa97bee8f8b2dcd53ead368dfd6f115b8cb82 100644 ---- a/docs/grub.texi -+++ b/docs/grub.texi -@@ -360,8 +360,9 @@ blocklist notation. The currently supported filesystem types are @dfn{Amiga - Fast FileSystem (AFFS)}, @dfn{AtheOS fs}, @dfn{BeFS}, - @dfn{BtrFS} (including raid0, raid1, raid10, gzip and lzo), - @dfn{cpio} (little- and big-endian bin, odc and newc variants), --@dfn{Linux ext2/ext3/ext4}, @dfn{DOS FAT12/FAT16/FAT32}, @dfn{exFAT}, @dfn{HFS}, --@dfn{HFS+}, @dfn{ISO9660} (including Joliet, Rock-ridge and multi-chunk files), -+@dfn{Linux ext2/ext3/ext4}, @dfn{DOS FAT12/FAT16/FAT32}, -+@dfn{exFAT}, @dfn{F2FS}, @dfn{HFS}, @dfn{HFS+}, -+@dfn{ISO9660} (including Joliet, Rock-ridge and multi-chunk files), - @dfn{JFS}, @dfn{Minix fs} (versions 1, 2 and 3), @dfn{nilfs2}, - @dfn{NTFS} (including compression), @dfn{ReiserFS}, @dfn{ROMFS}, - @dfn{Amiga Smart FileSystem (SFS)}, @dfn{Squash4}, @dfn{tar}, @dfn{UDF}, -@@ -1213,10 +1214,11 @@ GRUB is configured using @file{grub.cfg}, usually located under - need to write the whole thing by hand. - - @menu --* Simple configuration:: Recommended for most users --* Shell-like scripting:: For power users and developers --* Multi-boot manual config:: For non-standard multi-OS scenarios --* Embedded configuration:: Embedding a configuration file into GRUB -+* Simple configuration:: Recommended for most users -+* Root Identifcation Heuristics:: Summary on how the root file system is identified. -+* Shell-like scripting:: For power users and developers -+* Multi-boot manual config:: For non-standard multi-OS scenarios -+* Embedded configuration:: Embedding a configuration file into GRUB - @end menu - - -@@ -1398,6 +1400,25 @@ for all respectively normal entries. - The values of these options replace the values of @samp{GRUB_CMDLINE_LINUX} - and @samp{GRUB_CMDLINE_LINUX_DEFAULT} for Linux and Xen menu entries. - -+@item GRUB_EARLY_INITRD_LINUX_CUSTOM -+@itemx GRUB_EARLY_INITRD_LINUX_STOCK -+List of space-separated early initrd images to be loaded from @samp{/boot}. -+This is for loading things like CPU microcode, firmware, ACPI tables, crypto -+keys, and so on. These early images will be loaded in the order declared, -+and all will be loaded before the actual functional initrd image. -+ -+@samp{GRUB_EARLY_INITRD_LINUX_STOCK} is for your distribution to declare -+images that are provided by the distribution. It should not be modified -+without understanding the consequences. They will be loaded first. -+ -+@samp{GRUB_EARLY_INITRD_LINUX_CUSTOM} is for your custom created images. -+ -+The default stock images are as follows, though they may be overridden by -+your distribution: -+@example -+intel-uc.img intel-ucode.img amd-uc.img amd-ucode.img early_ucode.cpio microcode.cpio -+@end example -+ - @item GRUB_DISABLE_LINUX_UUID - Normally, @command{grub-mkconfig} will generate menu entries that use - universally-unique identifiers (UUIDs) to identify the root filesystem to -@@ -1405,6 +1426,17 @@ the Linux kernel, using a @samp{root=UUID=...} kernel parameter. This is - usually more reliable, but in some cases it may not be appropriate. To - disable the use of UUIDs, set this option to @samp{true}. - -+@item GRUB_DISABLE_LINUX_PARTUUID -+If @command{grub-mkconfig} cannot identify the root filesystem via its -+universally-unique indentifier (UUID), @command{grub-mkconfig} can use the UUID -+of the partition containing the filesystem to identify the root filesystem to -+the Linux kernel via a @samp{root=PARTUUID=...} kernel parameter. This is not -+as reliable as using the filesystem UUID, but is more reliable than using the -+Linux device names. When @samp{GRUB_DISABLE_LINUX_PARTUUID} is set to -+@samp{false}, the Linux kernel version must be 2.6.37 (3.10 for systems using -+the MSDOS partition scheme) or newer. This option defaults to @samp{true}. To -+enable the use of partition UUIDs, set this option to @samp{false}. -+ - @item GRUB_DISABLE_RECOVERY - If this option is set to @samp{true}, disable the generation of recovery - mode menu entries. -@@ -1536,6 +1568,53 @@ edit the scripts in @file{/etc/grub.d} directly. - menu entries; simply type the menu entries you want to add at the end of - that file, making sure to leave at least the first two lines intact. - -+@node Root Identifcation Heuristics -+@section Root Identifcation Heuristics -+If the target operating system uses the Linux kernel, @command{grub-mkconfig} -+attempts to identify the root file system via a heuristic algoirthm. This -+algorithm selects the identification method of the root file system by -+considering three factors. The first is if an initrd for the target operating -+system is also present. The second is @samp{GRUB_DISABLE_LINUX_UUID} and if set -+to @samp{true}, prevents @command{grub-mkconfig} from identifying the root file -+system by its UUID. The third is @samp{GRUB_DISABLE_LINUX_PARTUUID} and if set -+to @samp{true}, prevents @command{grub-mkconfig} from identifying the root file -+system via the UUID of its enclosing partition. If the variables are assigned -+any other value, that value is considered equivalent to @samp{false}. The -+variables are also considered to be set to @samp{false} if they are not set. -+ -+When booting, the Linux kernel will delegate the task of mounting the root -+filesystem to the initrd. Most initrd images determine the root file system by -+checking the Linux kernel's command-line for the @samp{root} key and use its -+value as the identification method of the root file system. To improve the -+reliability of booting, most initrd images also allow the root file system to be -+identified by its UUID. Because of this behavior, the @command{grub-mkconfig} -+command will set @samp{root} to @samp{root=UUID=...} to provide the initrd with -+the filesystem UUID of the root file system. -+ -+If no initrd is detected or @samp{GRUB_DISABLE_LINUX_UUID} is set to @samp{true} -+then @command{grub-command} will identify the root filesystem by setting the -+kernel command-line variable @samp{root} to @samp{root=PARTUUID=...} unless -+@samp{GRUB_DISABLE_LINUX_PARTUUID} is also set to @samp{true}. If -+@samp{GRUB_DISABLE_LINUX_PARTUUID} is also set to @samp{true}, -+@command{grub-command} will identify by its Linux device name. -+ -+The following table summarizes the behavior of the @command{grub-mkconfig} -+command. -+ -+@multitable {detected} {GRUB_DISABLE_LINUX_PARTUUID} {GRUB_DISABLE_LINUX_UUID} {Linux Root} -+@headitem Initrd detected @tab GRUB_DISABLE_LINUX_PARTUUID Set To @tab GRUB_DISABLE_LINUX_UUID Set To @tab Linux Root ID Method -+@item false @tab false @tab false @tab part UUID -+@item false @tab false @tab true @tab part UUID -+@item false @tab true @tab false @tab dev name -+@item false @tab true @tab true @tab dev name -+@item true @tab false @tab false @tab fs UUID -+@item true @tab false @tab true @tab part UUID -+@item true @tab true @tab false @tab fs UUID -+@item true @tab true @tab true @tab dev name -+@end multitable -+ -+Remember, @samp{GRUB_DISABLE_LINUX_PARTUUID} and @samp{GRUB_DISABLE_LINUX_UUID} -+are also considered to be set to @samp{false} when they are unset. - - @node Shell-like scripting - @section Writing full configuration files directly -@@ -3873,11 +3952,9 @@ you forget a command, you can run the command @command{help} - @comment * vbeinfo:: List available video modes - * verify_detached:: Verify detached digital signature - * videoinfo:: List available video modes --@comment * xen_*:: Xen boot commands --* xen_hypervisor:: Load xen hypervisor binary --* xen_linux:: Load dom0 kernel for xen hypervisor --* xen_initrd:: Load dom0 initrd for dom0 kernel --* xen_xsm:: Load xen security module for xen hypervisor -+@comment * xen_*:: Xen boot commands for AArch64 -+* xen_hypervisor:: Load xen hypervisor binary (only on AArch64) -+* xen_module:: Load xen modules for xen hypervisor (only on AArch64) - @end menu - - -@@ -4645,7 +4722,7 @@ range 0-0xFF (prefix with @samp{0x} to enter it in hexadecimal). - When enabled, this hides the selected partition by setting the @dfn{hidden} - bit in its partition type code; when disabled, unhides the selected - partition by clearing this bit. This is useful only when booting DOS or --Wwindows and multiple primary FAT partitions exist in one disk. See also -+Windows and multiple primary FAT partitions exist in one disk. See also - @ref{DOS/Windows}. - @end table - @end deffn -@@ -5153,32 +5230,22 @@ List available video modes. If resolution is given, show only matching modes. - Load a Xen hypervisor binary from @var{file}. The rest of the line is passed - verbatim as the @dfn{kernel command-line}. Any other binaries must be - reloaded after using this command. -+This command is only available on AArch64 systems. - @end deffn - --@node xen_linux --@subsection xen_linux -+@node xen_module -+@subsection xen_module - --@deffn Command xen_linux file [arguments] --Load a dom0 kernel image for xen hypervisor at the booting process of xen. -+@deffn Command xen_module [--nounzip] file [arguments] -+Load a module for xen hypervisor at the booting process of xen. - The rest of the line is passed verbatim as the module command line. -+Modules should be loaded in the following order: -+ - dom0 kernel image -+ - dom0 ramdisk if present -+ - XSM policy if present -+This command is only available on AArch64 systems. - @end deffn - --@node xen_initrd --@subsection xen_initrd -- --@deffn Command xen_initrd file --Load a initrd image for dom0 kernel at the booting process of xen. --@end deffn -- --@node xen_xsm --@subsection xen_xsm -- --@deffn Command xen_xsm file --Load a xen security module for xen hypervisor at the booting process of xen. --See @uref{http://wiki.xen.org/wiki/XSM} for more detail. --@end deffn -- -- - @node Networking commands - @section The list of networking commands - -@@ -5368,7 +5435,7 @@ NTFS, JFS, UDF, HFS+, exFAT, long filenames in FAT, Joliet part of - ISO9660 are treated as UTF-16 as per specification. AFS and BFS are read - as UTF-8, again according to specification. BtrFS, cpio, tar, squash4, minix, - minix2, minix3, ROMFS, ReiserFS, XFS, ext2, ext3, ext4, FAT (short names), --RockRidge part of ISO9660, nilfs2, UFS1, UFS2 and ZFS are assumed -+F2FS, RockRidge part of ISO9660, nilfs2, UFS1, UFS2 and ZFS are assumed - to be UTF-8. This might be false on systems configured with legacy charset - but as long as the charset used is superset of ASCII you should be able to - access ASCII-named files. And it's recommended to configure your system to use -diff --git a/gentpl.py b/gentpl.py -index f08bcc404f6a8bd8c3b13a6d5bb041ee32422776..da67965a41a40cde7c987b719fea39cd02ba10e5 100644 ---- a/gentpl.py -+++ b/gentpl.py -@@ -31,7 +31,8 @@ GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", - "i386_xen", "x86_64_xen", - "mips_loongson", "sparc64_ieee1275", - "powerpc_ieee1275", "mips_arc", "ia64_efi", -- "mips_qemu_mips", "arm_uboot", "arm_efi", "arm64_efi" ] -+ "mips_qemu_mips", "arm_uboot", "arm_efi", "arm64_efi", -+ "arm_coreboot"] - - GROUPS = {} - -@@ -44,7 +45,7 @@ GROUPS["x86"] = GROUPS["i386"] + GROUPS["x86_64"] - GROUPS["mips"] = [ "mips_loongson", "mips_qemu_mips", "mips_arc" ] - GROUPS["sparc64"] = [ "sparc64_ieee1275" ] - GROUPS["powerpc"] = [ "powerpc_ieee1275" ] --GROUPS["arm"] = [ "arm_uboot", "arm_efi" ] -+GROUPS["arm"] = [ "arm_uboot", "arm_efi", "arm_coreboot" ] - GROUPS["arm64"] = [ "arm64_efi" ] - - # Groups based on firmware -@@ -52,6 +53,7 @@ GROUPS["efi"] = [ "i386_efi", "x86_64_efi", "ia64_efi", "arm_efi", "arm64_efi" - GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ] - GROUPS["uboot"] = [ "arm_uboot" ] - GROUPS["xen"] = [ "i386_xen", "x86_64_xen" ] -+GROUPS["coreboot"] = [ "i386_coreboot", "arm_coreboot" ] - - # emu is a special case so many core functionality isn't needed on this platform - GROUPS["noemu"] = GRUB_PLATFORMS[:]; GROUPS["noemu"].remove("emu") -@@ -61,10 +63,10 @@ GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_loongson", "mips_qemu_mips", - "sparc64_ieee1275", "powerpc_ieee1275"] - GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi"); - GROUPS["pci"] = GROUPS["x86"] + ["mips_loongson"] --GROUPS["usb"] = GROUPS["pci"] -+GROUPS["usb"] = GROUPS["pci"] + ["arm_coreboot"] - - # If gfxterm is main output console integrate it into kernel --GROUPS["videoinkernel"] = ["mips_loongson", "i386_coreboot" ] -+GROUPS["videoinkernel"] = ["mips_loongson", "i386_coreboot", "arm_coreboot" ] - GROUPS["videomodules"] = GRUB_PLATFORMS[:]; - for i in GROUPS["videoinkernel"]: GROUPS["videomodules"].remove(i) - -diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am -index 04e9395fd949460672c1113c3d49c90a5d4471ec..f4ff62b769ae99f1d9b2fadf51378966c93d835c 100644 ---- a/grub-core/Makefile.am -+++ b/grub-core/Makefile.am -@@ -112,7 +112,7 @@ endif - - if COND_i386_coreboot - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h --KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/coreboot/lbio.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/coreboot/lbio.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h -@@ -239,8 +239,21 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h - endif - -+if COND_arm_coreboot -+KERNEL_HEADER_FILES += $(top_builddir)/include/grub/keyboard_layouts.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdt.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/dma.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/coreboot/kernel.h -+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/fdtbus.h -+endif -+ - if COND_arm_efi --KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h - KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h -@@ -278,7 +291,7 @@ BUILT_SOURCES += symlist.h - - symlist.c: symlist.h gensymlist.sh - $(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) -DGRUB_SYMBOL_GENERATOR=1 symlist.h > symlist.p || (rm -f symlist.p; exit 1) -- cat symlist.p | /bin/sh $(srcdir)/gensymlist.sh $(top_builddir)/config.h $(KERNEL_HEADER_FILES) >$@ || (rm -f $@; exit 1) -+ cat symlist.p | $(SHELL) $(srcdir)/gensymlist.sh $(top_builddir)/config.h $(KERNEL_HEADER_FILES) >$@ || (rm -f $@; exit 1) - rm -f symlist.p - CLEANFILES += symlist.c - BUILT_SOURCES += symlist.c -@@ -358,6 +371,16 @@ terminal.lst: $(MARKER_FILES) - platform_DATA += terminal.lst - CLEANFILES += terminal.lst - -+fdt.lst: $(MARKER_FILES) -+ (for pp in $^; do \ -+ b=`basename $$pp .marker`; \ -+ sed -n \ -+ -e "/FDT_DRIVER_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/i\1: $$b/;p;}" \ -+ -e "/FDT_DRIVER_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/o\1: $$b/;p;}" $$pp; \ -+ done) | sort -u > $@ -+platform_DATA += fdt.lst -+CLEANFILES += fdt.lst -+ - parttool.lst: $(MARKER_FILES) - (for pp in $^; do \ - b=`basename $$pp .marker`; \ -diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in -index 03cc3b7f69ed3cfb69b744f8114895fd0e14fde7..1250589b3f5f88b52d7ea6de361427339fe7e578 100644 ---- a/grub-core/genmod.sh.in -+++ b/grub-core/genmod.sh.in -@@ -1,4 +1,4 @@ --#! /bin/sh -+#! @BUILD_SHEBANG@ - set -e - - # Copyright (C) 2010 Free Software Foundation, Inc. -@@ -58,6 +58,10 @@ if test x@TARGET_APPLE_LINKER@ != x1; then - -K grub_mod_init -K grub_mod_fini \ - -K _grub_mod_init -K _grub_mod_fini \ - -R .note.gnu.gold-version -R .note.GNU-stack \ -+ -R .gnu.build.attributes \ -+ -R .rel.gnu.build.attributes \ -+ -R .rela.gnu.build.attributes \ -+ -R .eh_frame -R .rela.eh_frame -R .rel.eh_frame \ - -R .note -R .comment -R .ARM.exidx $tmpfile || exit 1 - fi - if ! test -z "${TARGET_OBJ2ELF}"; then -diff --git a/grub-core/genmoddep.awk b/grub-core/genmoddep.awk -index bd98d84cdd7427eef2f3651f455377d469955250..04c2863e5abfa4d950df2c41d579dea03a361927 100644 ---- a/grub-core/genmoddep.awk -+++ b/grub-core/genmoddep.awk -@@ -18,6 +18,10 @@ BEGIN { - - { - if ($1 == "defined") { -+ if ($3 !~ /^\.refptr\./ && $3 in symtab) { -+ printf "%s in %s is duplicated in %s\n", $3, $2, symtab[$3] >"/dev/stderr"; -+ error++; -+ } - symtab[$3] = $2; - modtab[$2] = "" modtab[$2] - } else if ($1 == "undefined") { -diff --git a/grub-core/gensyminfo.sh.in b/grub-core/gensyminfo.sh.in -index 2e8716b425cb04d9379ef5e2c629283d0f346c90..9bc7675327a6d9229492548671dd004054282434 100644 ---- a/grub-core/gensyminfo.sh.in -+++ b/grub-core/gensyminfo.sh.in -@@ -1,4 +1,4 @@ --#! /bin/sh -+#! @BUILD_SHEBANG@ - set -e - - # Copyright (C) 2010 Free Software Foundation, Inc. -diff --git a/grub-core/modinfo.sh.in b/grub-core/modinfo.sh.in -index faf0ad30edbe878270a185add45aa70e245d8b3a..f6cd657ce0f8307547fc5d011efa35622c318e63 100644 ---- a/grub-core/modinfo.sh.in -+++ b/grub-core/modinfo.sh.in -@@ -1,4 +1,4 @@ --#!/bin/sh -+#!@BUILD_SHEBANG@ - - # User-controllable options - grub_modinfo_target_cpu=@target_cpu@ -diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l -index 95b2191705ac826833e0951fa323242a9f8859d1..7b44c37b76ffa87f24b6f04260b9519f0c8654c0 100644 ---- a/grub-core/script/yylex.l -+++ b/grub-core/script/yylex.l -@@ -91,7 +91,7 @@ typedef size_t yy_size_t; - #define stdin 0 - #define stdout 0 - --#define fprintf(...) 0 -+#define fprintf(...) (void)0 - #define exit(...) grub_fatal("fatal error in lexer") - #endif - -diff --git a/po/Makefile.in.in b/po/Makefile.in.in -index 3619458e85f2bed3f92a76a9d919c26a30116dee..e68e9da843d927bfb6bbd519f4b3923c733abd7c 100644 ---- a/po/Makefile.in.in -+++ b/po/Makefile.in.in -@@ -15,7 +15,7 @@ PACKAGE = @PACKAGE@ - VERSION = @VERSION@ - PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ - --SHELL = /bin/sh -+SHELL = @SHELL@ - @SET_MAKE@ - - srcdir = @srcdir@ -diff --git a/po/exclude.pot b/po/exclude.pot -index 0a9b215eaf1971bf2a2af8a36e9605043de38e36..816089c30cbd36939b2a72724b3d591a0ac8a290 100644 -GIT binary patch -delta 49 -zcmaEUhNJl`#|G_WNh^i)qS7SY?UJ|KB{OOs -F1^~&~5lR36 - -delta 27 -jcmZoZ%klgS#|G`>=`Ng%LX#(mur$XeZ;wr8R67g+m_Q0B - -diff --git a/tests/ahci_test.in b/tests/ahci_test.in -index 1d01d1f59a0aac8911ff7ca3e62565f2dee5954d..7df56046201e4c2e4a55bdcdd403853cde902268 100644 ---- a/tests/ahci_test.in -+++ b/tests/ahci_test.in -@@ -1,4 +1,4 @@ --#! /bin/sh -+#! @BUILD_SHEBANG@ - # Copyright (C) 2013 Free Software Foundation, Inc. - # - # GRUB is free software: you can redistribute it and/or modify -diff --git a/tests/btrfs_test.in b/tests/btrfs_test.in -index c55d9477f78e01b6556bc0da9695f038523936f4..2b37ddd3324cc77f1edeb03feb369c22d03204a2 100644 ---- a/tests/btrfs_test.in -+++ b/tests/btrfs_test.in -@@ -1,4 +1,4 @@ --#!/bin/sh -+#!@BUILD_SHEBANG@ - - set -e - -diff --git a/tests/cdboot_test.in b/tests/cdboot_test.in -index 1cc901977c229dcf839bf58bede2b34f04252d57..75acdfedb7fe4a634d4122e44b3cd01778ed6f35 100644 ---- a/tests/cdboot_test.in -+++ b/tests/cdboot_test.in -@@ -1,4 +1,4 @@ --#! /bin/sh -+#! @BUILD_SHEBANG@ - # Copyright (C) 2013 Free Software Foundation, Inc. - # - # GRUB is free software: you can redistribute it and/or modify -diff --git a/tests/core_compress_test.in b/tests/core_compress_test.in -index 1003587ccca65616b0c7e3c1b90353ef7f459299..9d216ebcff60bfce04e3be4dbd1f8834800a6948 100644 ---- a/tests/core_compress_test.in -+++ b/tests/core_compress_test.in -@@ -1,4 +1,4 @@ --#! /bin/sh -+#! @BUILD_SHEBANG@ - # Copyright (C) 2013 Free Software Foundation, Inc. - # - # GRUB is free software: you can redistribute it and/or modify -diff --git a/tests/cpio_test.in b/tests/cpio_test.in -index 0b09db549f07868a524376f0eb25fd6a2cac9e40..5742cf17b9d8f587d00590d481f0a00aaf6cada8 100644 ---- a/tests/cpio_test.in -+++ b/tests/cpio_test.in -@@ -1,4 +1,4 @@ --#!/bin/sh -+#!@BUILD_SHEBANG@ - - set -e - -diff --git a/tests/ehci_test.in b/tests/ehci_test.in -index 7dd8d3e8fbd4a76b8efb88d69ecd8989546dc543..b197f8cdc922628ed35863dfa384eeef4cc4cc09 100644 ---- a/tests/ehci_test.in -+++ b/tests/ehci_test.in -@@ -1,4 +1,4 @@ --#! /bin/sh -+#! @BUILD_SHEBANG@ - # Copyright (C) 2013 Free Software Foundation, Inc. - # - # GRUB is free software: you can redistribute it and/or modify -diff --git a/tests/example_scripted_test.in b/tests/example_scripted_test.in -index 09633e89341e079a05fda7461d867e1541df4287..783b7f13853f39f9ec63b8da1da6e8a1b3a887a5 100644 ---- a/tests/example_scripted_test.in -+++ b/tests/example_scripted_test.in -@@ -1,4 +1,4 @@ --#!/bin/sh -+#!@BUILD_SHEBANG@ - set -e - - true -diff --git a/tests/exfat_test.in b/tests/exfat_test.in -index fc1a0fe5ec0306434434f0b49b20c44a1736dca1..cd3cd4cb2f70bb99df7edbfa8b5697f4316548ac 100644 ---- a/tests/exfat_test.in -+++ b/tests/exfat_test.in -@@ -1,4 +1,4 @@ --#!/bin/sh -+#!@BUILD_SHEBANG@ - - set -e - -diff --git a/tests/ext234_test.in b/tests/ext234_test.in -index c986960a8bec696deb37a55cba00915219d77215..4f1eb527eb2ed41095266dba6d5013ead77d9be3 100644 ---- a/tests/ext234_test.in -+++ b/tests/ext234_test.in -@@ -1,4 +1,4 @@ --#!/bin/sh -+#!@BUILD_SHEBANG@ - - set -e - -@@ -30,3 +30,4 @@ fi - "@builddir@/grub-fs-tester" ext3 - "@builddir@/grub-fs-tester" ext4 - "@builddir@/grub-fs-tester" ext4_metabg -+"@builddir@/grub-fs-tester" ext4_encrypt -diff --git a/tests/f2fs_test.in b/tests/f2fs_test.in -new file mode 100644 -index 0000000000000000000000000000000000000000..1ea77c826d32bd01e33d13ea7ad6639eb1cb77b0 ---- /dev/null -+++ b/tests/f2fs_test.in -@@ -0,0 +1,19 @@ -+#!/bin/sh -+ -+set -e -+ -+if [ "x$EUID" = "x" ] ; then -+ EUID=`id -u` -+fi -+ -+if [ "$EUID" != 0 ] ; then -+ exit 77 -+fi -+ -+if ! which mkfs.f2fs >/dev/null 2>&1; then -+ echo "mkfs.f2fs not installed; cannot test f2fs." -+ exit 77 -+fi -+ -+ -+"@builddir@/grub-fs-tester" f2fs -diff --git a/tests/fat_test.in b/tests/fat_test.in -index 1d132b51703c43e269d5500ca1740fa1e6b9a42c..b6b4748ca694b59337441a2f3111863e01799884 100644 ---- a/tests/fat_test.in -+++ b/tests/fat_test.in -@@ -1,4 +1,4 @@ --#!/bin/sh -+#!@BUILD_SHEBANG@ - - set -e - -diff --git a/tests/fddboot_test.in b/tests/fddboot_test.in -index a59645b7f873872490ac2474a30420c2df7a5caf..2d7dfc8891f6d7fdf42f88dea1213428e23b6f2e 100644 ---- a/tests/fddboot_test.in -+++ b/tests/fddboot_test.in -@@ -1,4 +1,4 @@ --#! /bin/sh -+#! @BUILD_SHEBANG@ - # Copyright (C) 2013 Free Software Foundation, Inc. - # - # GRUB is free software: you can redistribute it and/or modify -diff --git a/tests/file_filter_test.in b/tests/file_filter_test.in -index 8909e4021fb1d507cd5bf3b63319824fdc005dd5..bfb6382274e48d409d6cf6f918fc252f993f717f 100644 ---- a/tests/file_filter_test.in -+++ b/tests/file_filter_test.in -@@ -1,4 +1,4 @@ --#! /bin/sh -+#! @BUILD_SHEBANG@ - # Copyright (C) 2014 Free Software Foundation, Inc. - # - # GRUB is free software: you can redistribute it and/or modify -diff --git a/tests/gettext_strings_test.in b/tests/gettext_strings_test.in -index 5c305e75b7e9583f6be8a23d389051cf1fe2c243..813999ebe6ea5ee35796669e58baa57d0a2ace95 100644 ---- a/tests/gettext_strings_test.in -+++ b/tests/gettext_strings_test.in -@@ -1,4 +1,4 @@ --#!/bin/sh -+#!@BUILD_SHEBANG@ - - cd '@srcdir@' - -diff --git a/tests/grub_cmd_date.in b/tests/grub_cmd_date.in -index a459353e8a51c22fb966a842af532cff904de2a3..f7c9ca00432fa3307a2fb53ac88ca11115d7f73f 100644 ---- a/tests/grub_cmd_date.in -+++ b/tests/grub_cmd_date.in -@@ -1,4 +1,4 @@ --#! /bin/bash -+#! @BUILD_SHEBANG@ - set -e - - . "@builddir@/grub-core/modinfo.sh" -@@ -9,7 +9,7 @@ if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = sparc64-ieee1275 ]; - fi - - pdt="$(date -u +%s)" --dt=`echo date | @builddir@/grub-shell` -+dt=`echo date | @builddir@/grub-shell | sed 's, [A-Z][a-z]*$,,'` - dtg="$(date -u -d "$dt" +%s)" - ndt="$(date -u +%s)" - -diff --git a/tests/grub_cmd_regexp.in b/tests/grub_cmd_regexp.in -index e7e6257011525ee42ca6945485208155fe717d24..6520bd6d79acc0c8f5bfddc443912d74e826a0c8 100644 ---- a/tests/grub_cmd_regexp.in -+++ b/tests/grub_cmd_regexp.in -@@ -1,4 +1,4 @@ --#! /bin/bash -+#! @BUILD_SHEBANG@ - set -e - - # Run GRUB script in a Qemu instance -diff --git a/tests/grub_cmd_set_date.in b/tests/grub_cmd_set_date.in -index c594ae3fc14ebf7a6be86b90f4d048747383a69f..aac120a6c52731649678549d34372af14fef52d9 100644 ---- a/tests/grub_cmd_set_date.in -+++ b/tests/grub_cmd_set_date.in -@@ -1,4 +1,4 @@ --#! /bin/bash -+#! @BUILD_SHEBANG@ - set -e - - . "@builddir@/grub-core/modinfo.sh" -diff --git a/tests/grub_cmd_sleep.in b/tests/grub_cmd_sleep.in -index eb362aa2439d713bf4246e2c56932bbc6200d710..8797f6632845f5a76ac22b813c223897ceddd672 100644 ---- a/tests/grub_cmd_sleep.in -+++ b/tests/grub_cmd_sleep.in -@@ -1,4 +1,4 @@ --#! /bin/bash -+#! @BUILD_SHEBANG@ - set -e - - . "@builddir@/grub-core/modinfo.sh" -@@ -11,8 +11,8 @@ fi - # Compare RTC with interval timer. - # Not 100% proper but should check that timer is running ok - dt=`echo 'date; sleep 10; date' | @builddir@/grub-shell` --dt1="$(date -u -d "$(echo "$dt" | head -n 1)" +%s)" --dt2="$(date -u -d "$(echo "$dt" | tail -n 1)" +%s)" -+dt1="$(date -u -d "$(echo "$dt" | head -n 1 | sed 's, [A-Z][a-z]*$,,')" +%s)" -+dt2="$(date -u -d "$(echo "$dt" | tail -n 1 | sed 's, [A-Z][a-z]*$,,')" +%s)" - - # Ignore QEMU bug - if [ "${grub_modinfo_target_cpu}" = arm ] && [ $((dt2 - dt1)) -ge 15 ] && [ $((dt2 - dt1)) -le 17 ]; then -diff --git a/tests/grub_cmd_test.in b/tests/grub_cmd_test.in -index 6269891c9eeddb70f42da372e5636089e666818d..3399eb2929408570e9dad99db8dbc7215b41aea4 100644 ---- a/tests/grub_cmd_test.in -+++ b/tests/grub_cmd_test.in -@@ -1,4 +1,4 @@ --#! /bin/bash -+#! @BUILD_SHEBANG@ - - # create a randome file - empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 -diff --git a/tests/grub_cmd_tr.in b/tests/grub_cmd_tr.in -index 3fb15e35c8ac3ac218abf580f8ff5cdcaa2925ca..bed469c03ddc9a762112896d75af399678af711e 100644 ---- a/tests/grub_cmd_tr.in -+++ b/tests/grub_cmd_tr.in -@@ -1,4 +1,4 @@ --#! /bin/bash -e -+#! @BUILD_SHEBANG@ -e - - # Run GRUB script in a Qemu instance - # Copyright (C) 2010 Free Software Foundation, Inc. -diff --git a/tests/grub_func_test.in b/tests/grub_func_test.in -index c8cc263763377fd23d6c7f1eca49c1edafe530a7..c67f9e422534a402614eb280fe67d165fd0bb906 100644 ---- a/tests/grub_func_test.in -+++ b/tests/grub_func_test.in -@@ -1,4 +1,4 @@ --#! /bin/bash -+#! @BUILD_SHEBANG@ - set -e - - . "@builddir@/grub-core/modinfo.sh" -diff --git a/tests/grub_script_blanklines.in b/tests/grub_script_blanklines.in -index 89ed763d3f4e0bb2a3ac3a61de9e0ec49b2eaccf..bd8735491be3b947c72fffbf5767d7ab6bcf91ae 100644 ---- a/tests/grub_script_blanklines.in -+++ b/tests/grub_script_blanklines.in -@@ -1,4 +1,4 @@ --#! /bin/sh -+#! @BUILD_SHEBANG@ - set -e - - @builddir@/grub-script-check < 4096 - MAXBLKSIZE=4096;; -@@ -169,7 +196,12 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - MINBLKSIZE=1024 - MAXBLKSIZE=4096;; - esac -- for ((BLKSIZE=MINBLKSIZE;BLKSIZE<=MAXBLKSIZE;BLKSIZE=BLKSTEP?BLKSIZE+BLKSTEP:2*BLKSIZE)); do -+ if test "$BLKSTEP" -eq 0; then -+ blksizes="$(powrange "$MINBLKSIZE" "$MAXBLKSIZE")" -+ else -+ blksizes="$(range "$MINBLKSIZE" "$MAXBLKSIZE" "$BLKSTEP")" -+ fi -+ for BLKSIZE in $blksizes; do - MAXDEVICES=1 - MINDEVICES=1 - export fs -@@ -199,13 +231,11 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - MAXDEVICES=7;; - esac - -- for ((NDEVICES=MINDEVICES; NDEVICES <= MAXDEVICES; NDEVICES++)); do -+ for NDEVICES in $(range "$MINDEVICES" "$MAXDEVICES" 1); do - export NDEVICES -- unset FSIMAGES -- for ((i=0; i < NDEVICES; i++)); do -- FSIMAGES[i]="${tempdir}/${fs}_${SECSIZE}_${BLKSIZE}_${NDEVICES}_$i.img" -- done -- export FSIMAGES -+ unset FSIMAGEP -+ FSIMAGEP="${tempdir}/${fs}_${SECSIZE}_${BLKSIZE}_${NDEVICES}_" -+ export FSIMAGEP - unset NEED_IMAGES; - - case x$fs in -@@ -226,11 +256,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - *) - NEED_IMAGES_N=$NDEVICES;; - esac -- for ((i=0;i < NEED_IMAGES_N; i++)); do -- NEED_IMAGES[i]="${FSIMAGES[i]}"; -- done - export NEED_IMAGES_N -- export NEED_IMAGES - - MNTPOINTRO="${tempdir}/${fs}_ro" - MNTPOINTRW="${tempdir}/${fs}_rw" -@@ -238,20 +264,25 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - MOUNTFS="$fs" - MASTER="${tempdir}/master" - FSLABEL="grub_;/testé莭莽茝😁киритi urewfceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoirefoireoifoijfoirereoireoivoioirevoinvoinreoinvnoieoinreoinveoinveoinreoinvoineoinoinoineoinernoiveoinvreoiioewdioewoirvnoireoivfoirewfewoifoijewoijfoijewfoijfewoijoijoijoijoijoijoijfewceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoirefoireoifoijfoirereoireoivoioirevoinvoinreoinvnoieoinreoinveoinveoinreoinvoineoinoinoineoinernoiveoinvreoiioewdioewoirvnoireoivfoirewfewoifoijewoijfoijewfoijfewoijoijoijoijoijoijoijfewrewfceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoirefoireoifoijfoirereoireoivoioirevoinvoinreoinvnoieoinreoinveoinveoinreoinvoineoinoinoineoinernoiveoinvreoiioewdioewoirvnoireoivfoirewfewoifoijewoijfoijewfoijfewoijoijoijoijoijoijoijfewceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoirefoireoifoijfoirereoireoivoioirevoinvoinreoinvnoieoinreoinveoinveoinreoinvoineoinoinoineoinernoiveoinvreoiioewdioewoirvnoireoivfoirewfewoifoijewoijfoijewfoijfewoijoijoijoijoijoijoijfew" -- CFILESN=1 -- if test -f /usr/share/dict/american-english; then -- CFILESSRC[0]="/usr/share/dict/american-english" -- else -- CFILESSRC[0]="/usr/share/dict/linux.words" -+ CFILESRC= -+ for cand in /usr/share/dict/american-english /usr/share/dict/linux.words /data/data/com.termux/files/usr/share/hunspell/en_US.dic; do -+ if test -f "$cand" ; then -+ CFILESRC="$cand" -+ break -+ fi -+ done -+ if test "$CFILESRC" = "" ; then -+ echo "Couldn't find compressible file" >&2 -+ exit 1 - fi - case x"$fs" in - # FS LIMITATION: 8.3 names - xmsdos*) -- CFILES[0]="american.eng";; -+ CFILE="american.eng";; - xiso9660) -- CFILES[0]="american_english";; -+ CFILE="american_english";; - *) -- CFILES[0]="american-english";; -+ CFILE="american-english";; - esac - # OS LIMITATION: Limited by NAME_MAX (usually 255) in GNU/Linux - LONGNAME="qwertzuiopasdfghjklyxcvbnm1234567890qwertzuiopasdfghjklyxcvbnm1234567890oiewqfiewioqoiqoiurqruewqoiuwoieoiiuewqroreqiufieiuwrnureweriuvceoiroiewqoiricdsalkcndsakfirefoiwqeoircorejwoijfreoijojoiewjfwnfcoirenfoirefnreoifenoiwfnoi" -@@ -268,6 +299,10 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - x"btrfs"*) - FSLABEL="grub_;/testé莭莽😁киритi urewfceniuewruevrewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoi";; - -+ # FS LIMITATION: f2fs label is at most 512 UTF-16 chars -+ x"f2fs") -+ FSLABEL="grub_;/testé䏌䐓䏕киритiurewfceniuewruewnuuireurevueurnievrewfnerfcnevirivinrewvnirewnivrewiuvcrewvnuewvrrrewniuerwreiuviurewiuviurewnuvewnvrenurnunuvrevuurerejiremvreijnvvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoirvcreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoircreivire nverivnreivrevnureiorfnfrvoeoiroireoireoifrefoieroifoireoifoiq";; -+ - # FS LIMITATION: exfat is at most 15 UTF-16 chars - x"exfat") - FSLABEL="géт ;/莭莽😁кир";; -@@ -388,8 +423,8 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - ;; - x"vfat16" | xmsdos16) - BIGBLOCKCNT=$((25000 * BLKSIZE)) -- if [ $BIGBLOCKCNT -gt $((16#ffffffff)) ]; then -- BIGBLOCKCNT=$((16#ffffffff)) -+ if [ $BIGBLOCKCNT -gt 4294967295 ]; then -+ BIGBLOCKCNT=4294967295 - fi - ;; - x"minix") -@@ -410,7 +445,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - BIGBLOCKCNT=$((4000 * 1048576));; - # FS LIMITATION: These FS have uint32 as file size field - x"vfat"* | xmsdos* | x"cpio_crc" | x"cpio_newc" | x"cpio_bin" | x"cpio_hpbin" | xsfs*) -- BIGBLOCKCNT=$((16#ffffffff));; -+ BIGBLOCKCNT=4294967295;; - # FS LIMITATION: These FS have int32 as file size field - # FIXME: not so sure about AFFS - # OS LIMITATION: minix2/minix3 could be formatted in a way to permit more. -@@ -477,7 +512,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - # FIXME: Not sure about BtrFS, NTFS, JFS, AFS, UDF and SFS. Check it. - # FS LIMITATION: as far as I know those FS don't store their last modification date. - x"jfs_caseins" | x"jfs" | x"xfs" | x"xfs_crc" | x"btrfs"* | x"reiserfs_old" | x"reiserfs" \ -- | x"bfs" | x"afs" \ -+ | x"bfs" | x"afs" | x"f2fs" \ - | x"tarfs" | x"cpio_"* | x"minix" | x"minix2" \ - | x"minix3" | x"ntfs"* | x"udf" | x"sfs"*) - NOFSTIME=y;; -@@ -543,18 +578,18 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - - PDIR="" - # OS LIMITATION: Limited by PATH_MAX (usually 1024) -- for ((i=0;i /dev/null -- LODEVICES[i]=`losetup -f` -- losetup "${LODEVICES[i]}" "${FSIMAGES[i]}" -+ for i in $(range 0 $((NDEVICES-1)) 1); do -+ dd if=/dev/zero of="$FSIMAGEP${i}.img" count=1 bs=1 seek=$((DISKSIZE-1)) &> /dev/null -+ LODEVICE=$(losetup --find --show "$FSIMAGEP${i}.img") -+ LODEVICES="$LODEVICES $LODEVICE" -+ if test "$i" = 0; then -+ MOUNTDEVICE="$LODEVICE" -+ fi - done ;; - esac - -- MOUNTDEVICE="${LODEVICES[0]}" - case x"$fs" in - x"afs") - ;; - x"btrfs") -- "mkfs.btrfs" -s $SECSIZE -L "$FSLABEL" "${LODEVICES[0]}" ;; -+ "mkfs.btrfs" -s $SECSIZE -L "$FSLABEL" "${MOUNTDEVICE}" ;; - x"btrfs_zlib" | x"btrfs_lzo") -- "mkfs.btrfs" -s $SECSIZE -L "$FSLABEL" "${LODEVICES[0]}" -+ "mkfs.btrfs" -s $SECSIZE -L "$FSLABEL" "${MOUNTDEVICE}" - MOUNTOPTS="compress=${fs/btrfs_/}," - MOUNTFS="btrfs" - ;; - x"btrfs_raid0") -- "mkfs.btrfs" -s $SECSIZE -d raid0 -m raid0 -L "$FSLABEL" "${LODEVICES[@]}" -+ "mkfs.btrfs" -s $SECSIZE -d raid0 -m raid0 -L "$FSLABEL" $LODEVICES - MOUNTFS="btrfs" - ;; - x"btrfs_raid1") -- "mkfs.btrfs" -s $SECSIZE -d raid1 -m raid1 -L "$FSLABEL" "${LODEVICES[@]}" -+ "mkfs.btrfs" -s $SECSIZE -d raid1 -m raid1 -L "$FSLABEL" $LODEVICES - MOUNTFS="btrfs" - ;; - x"btrfs_raid10") -- "mkfs.btrfs" -s $SECSIZE -d raid10 -m raid10 -L "$FSLABEL" "${LODEVICES[@]}" -+ "mkfs.btrfs" -s $SECSIZE -d raid10 -m raid10 -L "$FSLABEL" $LODEVICES - MOUNTFS="btrfs" - ;; - x"btrfs_single") -- "mkfs.btrfs" -s $SECSIZE -d single -L "$FSLABEL" "${LODEVICES[@]}" -+ "mkfs.btrfs" -s $SECSIZE -d single -L "$FSLABEL" $LODEVICES - MOUNTFS="btrfs" - ;; - x"exfat") -- "mkfs.$fs" -s $((BLKSIZE/512)) -n "$FSLABEL" "${LODEVICES[0]}" -+ "mkfs.$fs" -s $((BLKSIZE/512)) -n "$FSLABEL" "${MOUNTDEVICE}" - MOUNTOPTS="iocharset=utf8," - MOUNTFS="exfat-fuse";; - x"minix") -- "mkfs.minix" "${LODEVICES[0]}" -+ "mkfs.minix" "${MOUNTDEVICE}" - ;; - # mkfs.hfs and mkfs.hfsplus don't fill UUID. - x"hfsplus") -- "mkfs.hfsplus" -b $BLKSIZE -v "$FSLABEL" "${LODEVICES[0]}" -- dd if=/dev/urandom of="${LODEVICES[0]}" bs=1 seek=$((16#468)) conv=notrunc count=8 ;; -+ "mkfs.hfsplus" -b $BLKSIZE -v "$FSLABEL" "${MOUNTDEVICE}" -+ dd if=/dev/urandom of="${MOUNTDEVICE}" bs=1 seek=$((16#468)) conv=notrunc count=8 ;; - x"hfsplus_wrap") -- "mkfs.hfsplus" -w -b $BLKSIZE -v "$FSLABEL" "${LODEVICES[0]}" -- dd if=/dev/urandom of="${LODEVICES[0]}" bs=1 seek=$((16#468)) conv=notrunc count=8 -+ "mkfs.hfsplus" -w -b $BLKSIZE -v "$FSLABEL" "${MOUNTDEVICE}" -+ dd if=/dev/urandom of="${MOUNTDEVICE}" bs=1 seek=$((16#468)) conv=notrunc count=8 - MOUNTFS="hfsplus";; - x"hfsplus_casesens") -- "mkfs.hfsplus" -s -b $BLKSIZE -v "$FSLABEL" "${LODEVICES[0]}" -- dd if=/dev/urandom of="${LODEVICES[0]}" bs=1 seek=$((16#468)) conv=notrunc count=8 -+ "mkfs.hfsplus" -s -b $BLKSIZE -v "$FSLABEL" "${MOUNTDEVICE}" -+ dd if=/dev/urandom of="${MOUNTDEVICE}" bs=1 seek=$((16#468)) conv=notrunc count=8 - MOUNTFS="hfsplus";; - x"hfs") -- "mkfs.hfs" -b $BLKSIZE -v "`echo $FSLABEL |recode utf8..macroman`" -h "${LODEVICES[0]}" -- dd if=/dev/urandom of="${LODEVICES[0]}" bs=1 seek=$((16#474)) conv=notrunc count=8 -+ "mkfs.hfs" -b $BLKSIZE -v "`echo $FSLABEL |recode utf8..macroman`" -h "${MOUNTDEVICE}" -+ dd if=/dev/urandom of="${MOUNTDEVICE}" bs=1 seek=$((16#474)) conv=notrunc count=8 - MOUNTOPTS="iocharset=utf8,codepage=macroman," - ;; - x"vfat"*|xmsdos*) -@@ -643,98 +682,98 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - else - A= - fi -- "mkfs.vfat" -a $A -S $SECSIZE -s $((BLKSIZE/SECSIZE)) -F "${BITS:0:2}" -n "$FSLABEL" "${FSIMAGES[0]}" -+ "mkfs.vfat" -a $A -S $SECSIZE -s $((BLKSIZE/SECSIZE)) -F "${BITS:0:2}" -n "$FSLABEL" "${MOUNTDEVICE}" - MOUNTOPTS="iocharset=utf8,codepage=437," - MOUNTFS="$(echo "$fs"|sed 's,[0-9]*a\?$,,')";; - x"minix2") -- "mkfs.minix" -v "${LODEVICES[0]}" -+ "mkfs.minix" -v "${MOUNTDEVICE}" - MOUNTFS="minix";; - x"minix3") -- "mkfs.minix" -B $BLKSIZE -3 "${LODEVICES[0]}" -+ "mkfs.minix" -B $BLKSIZE -3 "${MOUNTDEVICE}" - MOUNTFS="minix";; - x"ntfs"*) -- "mkfs.ntfs" -s "$SECSIZE" -c "$BLKSIZE" -L "$FSLABEL" -Q -q "${LODEVICES[0]}" -+ "mkfs.ntfs" -s "$SECSIZE" -c "$BLKSIZE" -L "$FSLABEL" -Q -q "${MOUNTDEVICE}" - MOUNTOPTS="iocharset=utf8,compression," - MOUNTFS="ntfs-3g";; - x"udf") -- "mkudffs" --utf8 -b $BLKSIZE --lvid="$FSLABEL" "${LODEVICES[0]}" -+ "mkudffs" --utf8 -b $BLKSIZE --lvid="$FSLABEL" "${MOUNTDEVICE}" - MOUNTOPTS="iocharset=utf8,bs=$BLKSIZE,";; - x"ufs2") -- "mkfs.ufs" -b $BLKSIZE -L "$FSLABEL" -O 2 "${LODEVICES[0]}" -+ "mkfs.ufs" -b $BLKSIZE -L "$FSLABEL" -O 2 "${MOUNTDEVICE}" - MOUNTOPTS="ufstype=ufs2," - MOUNTFS="ufs";; - x"ufs1") -- "mkfs.ufs" -b $BLKSIZE -L "$FSLABEL" -O 1 "${LODEVICES[0]}" -+ "mkfs.ufs" -b $BLKSIZE -L "$FSLABEL" -O 1 "${MOUNTDEVICE}" - MOUNTOPTS="ufstype=44bsd," - MOUNTFS="ufs";; - x"ufs1_sun") -- "mkfs.ufs" -b $BLKSIZE -L "$FSLABEL" -O 1 "${LODEVICES[0]}" -+ "mkfs.ufs" -b $BLKSIZE -L "$FSLABEL" -O 1 "${MOUNTDEVICE}" - MOUNTOPTS="ufstype=sun," - MOUNTFS="ufs";; - x"zfs") -- "zpool" create -R "$MNTPOINTRW" "$FSLABEL" "${LODEVICES[0]}" -+ "zpool" create -R "$MNTPOINTRW" "$FSLABEL" "${MOUNTDEVICE}" - sleep 1 - "zfs" create "$FSLABEL"/"grub fs" - sleep 1;; - x"zfs_caseins") -- "zpool" create -R "$MNTPOINTRW" "$FSLABEL" "${LODEVICES[0]}" -+ "zpool" create -R "$MNTPOINTRW" "$FSLABEL" "${MOUNTDEVICE}" - sleep 1 - "zfs" create -o casesensitivity=insensitive "$FSLABEL"/"grub fs" - sleep 1;; - x"zfs_lzjb" | xzfs_gzip | xzfs_zle) -- "zpool" create -O compression=${fs/zfs_/} -R "$MNTPOINTRW" "$FSLABEL" "${LODEVICES[0]}" -+ "zpool" create -O compression=${fs/zfs_/} -R "$MNTPOINTRW" "$FSLABEL" "${MOUNTDEVICE}" - sleep 1 - "zfs" create -o compression=${fs/zfs_/} "$FSLABEL"/"grub fs" - sleep 1;; - x"zfs_raidz") -- "zpool" create -R "$MNTPOINTRW" "$FSLABEL" raidz1 "${LODEVICES[@]}" -+ "zpool" create -R "$MNTPOINTRW" "$FSLABEL" raidz1 $LODEVICES - sleep 1 - "zfs" create "$FSLABEL"/"grub fs" - sleep 1;; - x"zfs_raidz2") -- "zpool" create -R "$MNTPOINTRW" "$FSLABEL" raidz2 "${LODEVICES[@]}" -+ "zpool" create -R "$MNTPOINTRW" "$FSLABEL" raidz2 $LODEVICES - sleep 1 - "zfs" create "$FSLABEL"/"grub fs" - sleep 1;; - x"zfs_raidz3") -- "zpool" create -R "$MNTPOINTRW" "$FSLABEL" raidz3 "${LODEVICES[@]}" -+ "zpool" create -R "$MNTPOINTRW" "$FSLABEL" raidz3 $LODEVICES - sleep 1 - "zfs" create "$FSLABEL"/"grub fs" - sleep 1;; - x"zfs_mirror") -- "zpool" create -R "$MNTPOINTRW" "$FSLABEL" mirror "${LODEVICES[@]}" -+ "zpool" create -R "$MNTPOINTRW" "$FSLABEL" mirror $LODEVICES - sleep 1 - "zfs" create "$FSLABEL"/"grub fs" - sleep 1;; - x"zfs_stripe") -- "zpool" create -R "$MNTPOINTRW" "$FSLABEL" "${LODEVICES[@]}" -+ "zpool" create -R "$MNTPOINTRW" "$FSLABEL" $LODEVICES - sleep 1 - "zfs" create "$FSLABEL"/"grub fs" - sleep 1;; - x"tarfs" | x"cpio_"* | x"iso9660" | xjoliet | xrockridge | xrockridge_joliet | x"iso9660_1999" | xjoliet_1999 | xrockridge_1999 | xrockridge_joliet_1999 | x"ziso9660" | x"romfs" | x"squash4_"*) - INSTDEVICE=/dev/null;; - x"reiserfs") -- "mkfs.reiserfs" --format=3.6 -b $BLKSIZE -l "$FSLABEL" -q "${LODEVICES[0]}" ;; -+ "mkfs.reiserfs" --format=3.6 -b $BLKSIZE -l "$FSLABEL" -q "${MOUNTDEVICE}" ;; - x"reiserfs_old") -- "mkfs.reiserfs" --format=3.5 -b $BLKSIZE -l "$FSLABEL" -q "${LODEVICES[0]}" -+ "mkfs.reiserfs" --format=3.5 -b $BLKSIZE -l "$FSLABEL" -q "${MOUNTDEVICE}" - MOUNTFS=reiserfs;; - x"jfs") -- "mkfs.jfs" -L "$FSLABEL" -q "${LODEVICES[0]}" -+ "mkfs.jfs" -L "$FSLABEL" -q "${MOUNTDEVICE}" - MOUNTOPTS="iocharset=utf8,";; - x"jfs_caseins") -- "mkfs.jfs" -O -L "$FSLABEL" -q "${LODEVICES[0]}" -+ "mkfs.jfs" -O -L "$FSLABEL" -q "${MOUNTDEVICE}" - MOUNTFS=jfs - MOUNTOPTS="iocharset=utf8,";; - x"mdraid"*) -- mdadm -C --chunk=$((BLKSIZE/1024)) --force -e "${fs:6:1}.${fs:7:1}" "/dev/md/${fs}_${NDEVICES}" --level="${fs:13}" --raid-devices="$NDEVICES" "${LODEVICES[@]}" -+ mdadm -C --chunk=$((BLKSIZE/1024)) --force -e "${fs:6:1}.${fs:7:1}" "/dev/md/${fs}_${NDEVICES}" --level="${fs:13}" --raid-devices="$NDEVICES" $LODEVICES - MOUNTDEVICE="/dev/md/${fs}_${NDEVICES}" - MOUNTFS=ext2 - "mkfs.ext2" -L "$FSLABEL" -q "${MOUNTDEVICE}" ;; - x"lvm"*) -- for ((i=0;i /dev/null; -+ cp "${CFILESRC}" "$MNTPOINTRW/$OSDIR/${CFILE}" &> /dev/null; - else -- for ((i=0;i<$CFILESN;i++)); do -- cp "${CFILESSRC[i]}" "$MNTPOINTRW/$OSDIR/${CFILES[i]}"; -- done -+ -+ cp "${CFILESRC}" "$MNTPOINTRW/$OSDIR/${CFILE}"; -+ - fi - - if [ x$NOSYMLINK != xy ]; then -@@ -968,48 +1015,48 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - sleep 2 - ;; - x"tarfs") -- (cd "$MASTER"; tar cf "${FSIMAGES[0]}" .) ;; -+ (cd "$MASTER"; tar cf "${FSIMAGEP}0.img" .) ;; - x"cpio_"*) -- (cd "$MASTER"; find . | cpio -o -H "${fs/cpio_/}" > "${FSIMAGES[0]}" ) ;; -+ (cd "$MASTER"; find . | cpio -o -H "$(echo ${fs} | sed 's@^cpio_@@')" > "${FSIMAGEP}0.img" ) ;; - x"ziso9660") - FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); -- xorriso -compliance rec_mtime -set_filter_r --zisofs -- -zisofs default -as mkisofs -iso-level 3 -graft-points -R -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" -- -set_filter_r --zisofs -- -zisofs default -add /="$MASTER" ;; -+ xorriso -compliance rec_mtime -set_filter_r --zisofs -- -zisofs default -as mkisofs -iso-level 3 -graft-points -R -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" -- -set_filter_r --zisofs -- -zisofs default -add /="$MASTER" ;; - x"iso9660") - FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); -- xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; -+ xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; - x"joliet") - FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); -- xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; -+ xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; - x"rockridge") - FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); -- xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; -+ xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; - x"rockridge_joliet") - FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); -- xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; -+ xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 3 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; - x"iso9660_1999") - FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); -- xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; -+ xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; - x"joliet_1999") - FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); -- xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; -+ xorriso --rockridge off -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; - x"rockridge_1999") - FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); -- xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; -+ xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; - x"rockridge_joliet_1999") - FSUUID=$(date -u +%Y-%m-%d-%H-%M-%S-00); -- xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGES[0]}" /="$MASTER" ;; -+ xorriso --rockridge on -compliance rec_mtime -as mkisofs -iso-level 4 -graft-points -J -joliet-long -V "$FSLABEL" --modification-date=$(echo ${FSUUID} | sed 's/-//g;') -o "${FSIMAGEP}0.img" /="$MASTER" ;; - x"romfs") -- genromfs -V "$FSLABEL" -f "${FSIMAGES[0]}" -d "$MASTER" ;; -+ genromfs -V "$FSLABEL" -f "${FSIMAGEP}0.img" -d "$MASTER" ;; - xsquash4_*) -- echo mksquashfs "$MASTER" "${FSIMAGES[0]}" -always-use-fragments -comp "${fs/squash4_/}" -b $BLKSIZE -- mksquashfs "$MASTER" "${FSIMAGES[0]}" -always-use-fragments -comp "${fs/squash4_/}" -b $BLKSIZE ;; -+ echo mksquashfs "$MASTER" "${FSIMAGEP}0.img" -always-use-fragments -comp "${fs/squash4_/}" -b $BLKSIZE -+ mksquashfs "$MASTER" "${FSIMAGEP}0.img" -always-use-fragments -comp "${fs/squash4_/}" -b $BLKSIZE ;; - x"bfs") - sleep 1 - fusermount -u "$MNTPOINTRW" - ;; - xlvm*) - sleep 1 -- for ((try=0;try < 20; try++)); do -+ for try in $(range 0 20 1); do - if umount "$MNTPOINTRW" ; then - break; - fi -@@ -1021,7 +1068,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - ;; - xmdraid*) - sleep 1 -- for ((try=0;try < 20; try++)); do -+ for try in $(range 0 20 1); do - if umount "$MNTPOINTRW" ; then - break; - fi -@@ -1033,7 +1080,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - ;; - *) - sleep 1 -- for ((try=0;try < 20; try++)); do -+ for try in $(range 0 20 1); do - if umount "$MNTPOINTRW" ; then - break; - fi -@@ -1066,7 +1113,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - sleep 1 - mount -t "$MOUNTFS" "${MOUNTDEVICE}" "$MNTPOINTRO" -o ${MOUNTOPTS}${SELINUXOPTS}ro ;; - xmdraid*) -- mdadm --assemble /dev/md/"${fs}_$NDEVICES" "${LODEVICES[@]}" -+ mdadm --assemble /dev/md/"${fs}_$NDEVICES" $LODEVICES - sleep 1 - mount -t "$MOUNTFS" "${MOUNTDEVICE}" "$MNTPOINTRO" -o ${MOUNTOPTS}${SELINUXOPTS}ro ;; - *) -@@ -1085,7 +1132,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - else - echo LIST FAIL - echo "$LSROUT" -- TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" -+ TZ=UTC ls -l "$MNTPOINTRO" - exit 1 - fi - -@@ -1094,7 +1141,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - else - echo NLIST FAIL - echo "$LSROUT" -- TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -lA "$MNTPOINTRO" -+ TZ=UTC ls -lA "$MNTPOINTRO" - exit 1 - fi - -@@ -1103,7 +1150,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - else - echo ILIST FAIL - echo "$LSROUT" -- TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" -+ TZ=UTC ls -l "$MNTPOINTRO" - exit 1 - fi - -@@ -1112,7 +1159,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - else - echo LONG LIST FAIL - echo "$LSROUT" -- TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" -+ TZ=UTC ls -l "$MNTPOINTRO" - exit 1 - fi - -@@ -1123,7 +1170,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - else - echo TIME FAIL - echo "$LSROUT" -- TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" -+ TZ=UTC ls -l "$MNTPOINTRO" - exit 1 - fi - -@@ -1133,7 +1180,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - else - echo LONG TIME FAIL - echo "$LSROUT" -- TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" -+ TZ=UTC ls -l "$MNTPOINTRO" - exit 1 - fi - fi -@@ -1149,7 +1196,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - else - echo DOT IN ROOTDIR FAIL - echo "$LSROUT" -- TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" -+ TZ=UTC ls -l "$MNTPOINTRO" - exit 1 - fi - -@@ -1163,7 +1210,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - else - echo DOTDOT IN ROOTDIR FAIL - echo "$LSROUT" -- TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" -+ TZ=UTC ls -l "$MNTPOINTRO" - exit 1 - fi - ;; -@@ -1180,7 +1227,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - else - echo SLIST FAIL - echo "$LSROUT" -- TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO/sdir" -+ TZ=UTC ls -l "$MNTPOINTRO/sdir" - exit 1 - fi - -@@ -1195,7 +1242,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - else - echo PLIST FAIL - echo "$LSROUT" -- TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO/$PDIR" -+ TZ=UTC ls -l "$MNTPOINTRO/$PDIR" - exit 1 - fi - -@@ -1210,7 +1257,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - else - echo DOT IN SUBDIR FAIL - echo "$LSROUT" -- TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO/$OSDIR/sdir" -+ TZ=UTC ls -l "$MNTPOINTRO/$OSDIR/sdir" - exit 1 - fi - -@@ -1225,7 +1272,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - else - echo DOTDOT IN SUBDIR FAIL - echo "$LSROUT" -- TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO/$OSDIR/ssdir" -+ TZ=UTC ls -l "$MNTPOINTRO/$OSDIR/ssdir" - exit 1 - fi - -@@ -1245,8 +1292,8 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - case x"$fs" in - x"iso9660" | x"ziso9660" | xrockridge | xjoliet | xrockridge_joliet | x"iso9660_1999" | xrockridge_1999 | xjoliet_1999 | xrockridge_joliet_1999) ;; - x"zfs"*) -- for ((i=0;i /dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM1" > /dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM2" || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM3" > /dev/null; then -- : -- else -- echo FSTIME FAIL -- echo "$FSTIME" -- echo "$LSOUT" -- exit 1 -+ if echo "$LSOUT" | grep -F 'Last modification time '"$FSTIME" > /dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM1" > /dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM2" || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM3" > /dev/null; then -+ : -+ else -+ echo FSTIME FAIL -+ echo "$FSTIME" -+ echo "$LSOUT" -+ exit 1 -+ fi - fi - - if [ x$NOHARDLINK != xy ]; then -@@ -1410,11 +1457,9 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - exit 1 - fi - ok=true -- for ((i=0;i<$CFILESN;i++)); do -- if ! run_grubfstest cmp "$GRUBDIR/${CFILES[i]}" "$MNTPOINTRO/$OSDIR/${CFILES[i]}" ; then -- ok=false; -- fi -- done -+ if ! run_grubfstest cmp "$GRUBDIR/${CFILE}" "$MNTPOINTRO/$OSDIR/${CFILE}" ; then -+ ok=false; -+ fi - if test x$ok = xtrue; then - : - else -@@ -1503,15 +1548,17 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + - sleep 1 - ;; - esac -- for ((i=0; i < NDEVICES; i++)); do -- case x"$fs" in -- x"tarfs" | x"cpio_"* | x"iso9660" | xrockridge | xjoliet | xrockridge_joliet | x"ziso9660" | x"romfs" | x"squash4_"* | x"iso9660_1999" | xrockridge_1999 | xjoliet_1999 | xrockridge_joliet_1999) ;; -- *) -- while ! losetup -d "${LODEVICES[i]}"; do -+ case x"$fs" in -+ x"tarfs" | x"cpio_"* | x"iso9660" | xrockridge | xjoliet | xrockridge_joliet | x"ziso9660" | x"romfs" | x"squash4_"* | x"iso9660_1999" | xrockridge_1999 | xjoliet_1999 | xrockridge_joliet_1999) ;; -+ *) -+ for lodev in $LODEVICES; do -+ while ! losetup -d "$lodev"; do - sleep 1 -- done;; -- esac -- rm "${FSIMAGES[i]}" -+ done -+ done;; -+ esac -+ for i in $(range 0 $((NDEVICES-1)) 1); do -+ rm "$FSIMAGEP${i}.img" - done - if [ x"$fs" = x"zfs" ]; then - rmdir "$MNTPOINTRW"/"grub fs" || true -diff --git a/tests/util/grub-shell-tester.in b/tests/util/grub-shell-tester.in -index 5adce0a47fe3208e14bbbf4820685d67b43ef9bb..8a87109b15240de9d61f2ac02becfcb5300582f1 100644 ---- a/tests/util/grub-shell-tester.in -+++ b/tests/util/grub-shell-tester.in -@@ -1,4 +1,4 @@ --#! /bin/sh -+#! @BUILD_SHEBANG@ - set -e - - # Compares GRUB script output with BASH output. -diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in -index 814f36c6bd2438b7f9c59f5f4a9777e95b9e38db..d690d6734efb82109f7635c4688b6fc7417a5751 100644 ---- a/tests/util/grub-shell.in -+++ b/tests/util/grub-shell.in -@@ -1,4 +1,4 @@ --#! /bin/sh -+#! @BUILD_SHEBANG@ - set -e - - # Run GRUB script in a Qemu instance -diff --git a/tests/xfs_test.in b/tests/xfs_test.in -index 3807e2e5c77e244f8b2f0d43ec28b86b3f2f9e9b..03a3513595dc719cd72b4d9b7198f22b338cb588 100644 ---- a/tests/xfs_test.in -+++ b/tests/xfs_test.in -@@ -1,4 +1,4 @@ --#!/bin/sh -+#!@BUILD_SHEBANG@ - - set -e - -diff --git a/tests/xzcompress_test.in b/tests/xzcompress_test.in -index b2bd999ec071c24205533e50cf51f46ec59a2218..03bfb5e951dd8dfb7ccb15fb6a31dd4aea639df9 100644 ---- a/tests/xzcompress_test.in -+++ b/tests/xzcompress_test.in -@@ -1,4 +1,4 @@ --#! /bin/sh -+#! @BUILD_SHEBANG@ - # Copyright (C) 2013 Free Software Foundation, Inc. - # - # GRUB is free software: you can redistribute it and/or modify -diff --git a/tests/zfs_test.in b/tests/zfs_test.in -index 047120e47a0e042f0540d6762666edf4cb0b37fb..eee62c10d704ec42b090eba5ac16b4966ff760ad 100644 ---- a/tests/zfs_test.in -+++ b/tests/zfs_test.in -@@ -1,4 +1,4 @@ --#!/bin/sh -+#!@BUILD_SHEBANG@ - - set -e - -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index f8496d28bdf7f4bcbc2413888330834c1e252a64..33332360eecf954fc2952df944fe171006fc4143 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -134,6 +134,7 @@ fi - # Device containing our userland. Typically used for root= parameter. - GRUB_DEVICE="`${grub_probe} --target=device /`" - GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true -+GRUB_DEVICE_PARTUUID="`${grub_probe} --device ${GRUB_DEVICE} --target=partuuid 2> /dev/null`" || true - - # Device containing our /boot partition. Usually the same as GRUB_DEVICE. - GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`" -@@ -147,6 +148,12 @@ if [ x"$GRUB_FS" = xunknown ]; then - GRUB_FS="$(stat -f --printf=%T / || echo unknown)" - fi - -+# Provide a default set of stock linux early initrd images. -+# Define here so the list can be modified in the sourced config file. -+if [ "x${GRUB_EARLY_INITRD_LINUX_STOCK}" = "x" ]; then -+ GRUB_EARLY_INITRD_LINUX_STOCK="intel-uc.img intel-ucode.img amd-uc.img amd-ucode.img early_ucode.cpio microcode.cpio" -+fi -+ - if test -f ${sysconfdir}/default/grub ; then - . ${sysconfdir}/default/grub - fi -@@ -182,6 +189,7 @@ if [ "x${GRUB_ACTUAL_DEFAULT}" = "xsaved" ] ; then GRUB_ACTUAL_DEFAULT="`"${grub - # override them. - export GRUB_DEVICE \ - GRUB_DEVICE_UUID \ -+ GRUB_DEVICE_PARTUUID \ - GRUB_DEVICE_BOOT \ - GRUB_DEVICE_BOOT_UUID \ - GRUB_FS \ -@@ -211,10 +219,13 @@ export GRUB_DEFAULT \ - GRUB_CMDLINE_NETBSD \ - GRUB_CMDLINE_NETBSD_DEFAULT \ - GRUB_CMDLINE_GNUMACH \ -+ GRUB_EARLY_INITRD_LINUX_CUSTOM \ -+ GRUB_EARLY_INITRD_LINUX_STOCK \ - GRUB_TERMINAL_INPUT \ - GRUB_TERMINAL_OUTPUT \ - GRUB_SERIAL_COMMAND \ - GRUB_DISABLE_LINUX_UUID \ -+ GRUB_DISABLE_LINUX_PARTUUID \ - GRUB_DISABLE_RECOVERY \ - GRUB_VIDEO_BACKEND \ - GRUB_GFXMODE \ -diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in -index 60b31caddeb42b5db338897dc18acdc156dd2c22..0f801cab3e4d05efface62c7fcb9b787c69995c3 100644 ---- a/util/grub-mkconfig_lib.in -+++ b/util/grub-mkconfig_lib.in -@@ -188,6 +188,7 @@ grub_file_is_not_garbage () - *.dpkg-*) return 1 ;; # debian dpkg - *.rpmsave|*.rpmnew) return 1 ;; - README*|*/README*) return 1 ;; # documentation -+ *.sig) return 1 ;; # signatures - esac - else - return 1 -diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index de9044c7f28611d56358f581ac52ca2d2b7fc982..61ebd7dc714e87aedb167345729f574426d69b77 100644 ---- a/util/grub.d/10_linux.in -+++ b/util/grub.d/10_linux.in -@@ -43,12 +43,22 @@ case ${GRUB_DEVICE} in - ;; - esac - -+# Default to disabling partition uuid support to maintian compatibility with -+# older kernels. -+GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true} -+ - # btrfs may reside on multiple devices. We cannot pass them as value of root= parameter - # and mounting btrfs requires user space scanning, so force UUID in this case. --if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ -- || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ -+if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] ) \ -+ || ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ -+ && [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \ -+ || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ -+ && ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \ - || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then - LINUX_ROOT_DEVICE=${GRUB_DEVICE} -+elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \ -+ || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then -+ LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID} - else - LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} - fi -@@ -136,9 +146,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)' -- initrd ${rel_dirname}/${initrd} -+ initrd $(echo $initrd_path) - EOF - fi - sed "s/^/$submenu_indentation/" << EOF -@@ -188,7 +202,15 @@ while [ "x$list" != "x" ] ; do - alt_version=`echo $version | sed -e "s,\.old$,,g"` - linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" - -- initrd= -+ initrd_early= -+ for i in ${GRUB_EARLY_INITRD_LINUX_STOCK} \ -+ ${GRUB_EARLY_INITRD_LINUX_CUSTOM}; do -+ if test -e "${dirname}/${i}" ; then -+ initrd_early="${initrd_early} ${i}" -+ fi -+ done -+ -+ 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" \ -@@ -198,11 +220,22 @@ while [ "x$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 - -+ 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 -+ - config= - for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do - if test -e "${i}" ; then -@@ -216,12 +249,16 @@ while [ "x$list" != "x" ] ; do - initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${config}" | cut -f2 -d= | tr -d \"` - fi - -- if test -n "${initrd}" ; then -- gettext_printf "Found initrd image: %s\n" "${dirname}/${initrd}" >&2 -- elif test -z "${initramfs}" ; then -+ if test -z "${initramfs}" && test -z "${initrd_real}" ; then - # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs. Since there's - # no initrd or builtin initramfs, it can't work here. -- linux_root_device_thisversion=${GRUB_DEVICE} -+ if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \ -+ || [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then -+ -+ linux_root_device_thisversion=${GRUB_DEVICE} -+ else -+ linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID} -+ fi - fi - - if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then -diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in -index c48af948d6ecdf672aa341f713912ba15de8f27d..e8143b079dc8bcdf21ec8a763b19a356c863a5e3 100644 ---- a/util/grub.d/20_linux_xen.in -+++ b/util/grub.d/20_linux_xen.in -@@ -43,12 +43,22 @@ case ${GRUB_DEVICE} in - ;; - esac - -+# Default to disabling partition uuid support to maintian compatibility with -+# older kernels. -+GRUB_DISABLE_LINUX_PARTUUID=${GRUB_DISABLE_LINUX_PARTUUID-true} -+ - # btrfs may reside on multiple devices. We cannot pass them as value of root= parameter - # and mounting btrfs requires user space scanning, so force UUID in this case. --if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ -- || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ -+if ( [ "x${GRUB_DEVICE_UUID}" = "x" ] && [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] ) \ -+ || ( [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ -+ && [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ] ) \ -+ || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ -+ && ! test -e "/dev/disk/by-partuuid/${GRUB_DEVICE_PARTUUID}" ) \ - || ( test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm ); then - LINUX_ROOT_DEVICE=${GRUB_DEVICE} -+elif [ "x${GRUB_DEVICE_UUID}" = "x" ] \ -+ || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ]; then -+ LINUX_ROOT_DEVICE=PARTUUID=${GRUB_DEVICE_PARTUUID} - else - LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} - fi -@@ -122,16 +132,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 +216,18 @@ 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 -+ if ($grub_file --is-arm64-efi $current_xen); then -+ xen_loader="xen_hypervisor" -+ module_loader="xen_module" -+ else -+ 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` - gettext_printf "Found linux image: %s\n" "$linux" >&2 -@@ -234,7 +256,13 @@ while [ "x${xen_list}" != "x" ] ; do - gettext_printf "Found initrd image: %s\n" "${dirname}/${initrd}" >&2 - else - # "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here. -- linux_root_device_thisversion=${GRUB_DEVICE} -+ if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \ -+ || [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then -+ -+ linux_root_device_thisversion=${GRUB_DEVICE} -+ else -+ linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID} -+ fi - fi - - if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then diff --git a/revert-0067-Be-more-aggro.patch b/revert-0067-Be-more-aggro.patch deleted file mode 100644 index e6085bc08cb61dc8d1e80ba6b0388d0271b89cd2..0000000000000000000000000000000000000000 --- a/revert-0067-Be-more-aggro.patch +++ /dev/null @@ -1,216 +0,0 @@ -From 5494d47944aad4608df08e2d5f73a9569f81b0e1 Mon Sep 17 00:00:00 2001 -From: Fedora Ninjas -Date: Sat, 13 Jul 2019 10:41:34 +0000 -Subject: [PATCH] huawei-revert-0067-Be-more-aggro.patch - ---- - grub-core/net/drivers/efi/efinet.c | 125 ++++++----------------------- - include/grub/efi/api.h | 4 - - 2 files changed, 26 insertions(+), 103 deletions(-) - -diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 56305f4..2076aeb 100644 ---- a/grub-core/net/drivers/efi/efinet.c -+++ b/grub-core/net/drivers/efi/efinet.c -@@ -247,85 +247,46 @@ grub_efinet_get_device_handle (struct grub_net_card *card) - return card->efi_handle; - } - --static int --grub_efinet_find_snp_cards (int preferred_only, grub_efi_handle_t preferred, -- int *i) -+static void -+grub_efinet_findcards (void) - { -- grub_efi_uintn_t num_handles = 0; -- grub_efi_handle_t *handles = NULL; -+ grub_efi_uintn_t num_handles; -+ grub_efi_handle_t *handles; - grub_efi_handle_t *handle; -- grub_efi_device_path_t *pdp = NULL, *pp = NULL, *pc = NULL; -- int ret = 0; -- -- if (preferred) -- { -- grub_efi_device_path_t *pdpc; -- pdpc = pdp = grub_efi_get_device_path (preferred); -- if (pdp == NULL) -- { -- grub_print_error (); -- return -1; -- } -- -- for (; ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (pdpc); -- pdpc = GRUB_EFI_NEXT_DEVICE_PATH (pdpc)) -- { -- pp = pc; -- pc = pdpc; -- } -- } -+ int i = 0; - -- /* Find handles which support the SNP interface. */ -+ /* Find handles which support the disk io interface. */ - handles = grub_efi_locate_handle (GRUB_EFI_BY_PROTOCOL, &net_io_guid, - 0, &num_handles); -- -- for (handle = handles; handle && num_handles--; handle++) -+ if (! handles) -+ return; -+ for (handle = handles; num_handles--; handle++) - { - grub_efi_simple_network_t *net; - struct grub_net_card *card; - grub_efi_device_path_t *dp, *parent = NULL, *child = NULL; - -- /* if we're looking for only the preferred handle, skip anything that -- isn't it. */ -- if (preferred_only && preferred != NULL && *handle != preferred) -- continue; -- -- /* if we're not looking for the preferred handle, skip it if it's -- found. */ -- if (!preferred_only && *handle == preferred) -- continue; -- -+ /* EDK2 UEFI PXE driver creates IPv4 and IPv6 messaging devices as -+ children of main MAC messaging device. We only need one device with -+ bound SNP per physical card, otherwise they compete with each other -+ when polling for incoming packets. -+ */ - dp = grub_efi_get_device_path (*handle); - if (!dp) - continue; -- -- for (; ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp); -- dp = GRUB_EFI_NEXT_DEVICE_PATH (dp)) -+ for (; ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp); dp = GRUB_EFI_NEXT_DEVICE_PATH (dp)) - { - parent = child; - child = dp; - } -- -- if (!preferred_only) -- { -- if (pp && pc -- && grub_efi_compare_device_paths (pp, parent) == 0 -- && grub_efi_compare_device_paths (pc, child) == 0) -- continue; -- -- if (child -- && (GRUB_EFI_DEVICE_PATH_IS_TYPE(child, -- GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE, -- GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE) || -- GRUB_EFI_DEVICE_PATH_IS_TYPE(child, -- GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE, -- GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE)) -- && parent -- && (GRUB_EFI_DEVICE_PATH_IS_TYPE(parent, -- GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE, -- GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE))) -- continue; -- } -+ if (child -+ && GRUB_EFI_DEVICE_PATH_TYPE (child) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE -+ && (GRUB_EFI_DEVICE_PATH_SUBTYPE (child) == GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE -+ || GRUB_EFI_DEVICE_PATH_SUBTYPE (child) == GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE) -+ && parent -+ && GRUB_EFI_DEVICE_PATH_TYPE (parent) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE -+ && GRUB_EFI_DEVICE_PATH_SUBTYPE (parent) == GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE) -+ continue; - - net = grub_efi_open_protocol (*handle, &net_io_guid, - GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); -@@ -352,7 +313,7 @@ grub_efinet_find_snp_cards (int preferred_only, grub_efi_handle_t preferred, - { - grub_print_error (); - grub_free (handles); -- return -1; -+ return; - } - - card->mtu = net->mode->max_packet_size; -@@ -363,14 +324,13 @@ grub_efinet_find_snp_cards (int preferred_only, grub_efi_handle_t preferred, - grub_print_error (); - grub_free (handles); - grub_free (card); -- return -1; -+ return; - } - card->txbusy = 0; - - card->rcvbufsize = ALIGN_UP (card->mtu, 64) + 256; - -- card->name = grub_xasprintf ("efinet%d", *i); -- *i = (*i)+1; -+ card->name = grub_xasprintf ("efinet%d", i++); - card->driver = &efidriver; - card->flags = 0; - card->default_address.type = net->mode->if_type; -@@ -382,38 +342,8 @@ grub_efinet_find_snp_cards (int preferred_only, grub_efi_handle_t preferred, - card->efi_handle = *handle; - - grub_net_card_register (card); -- ret++; - } - grub_free (handles); -- -- return ret; --} -- --static void --grub_efinet_findcards (void) --{ -- grub_efi_loaded_image_t *image = NULL; -- int rc; -- int efinet_number = 0; -- -- image = grub_efi_get_loaded_image (grub_efi_image_handle); -- -- if (image && image->device_handle) -- { -- rc = grub_efinet_find_snp_cards (1, image->device_handle, &efinet_number); -- if (rc < 0) -- return; -- -- rc = grub_efinet_find_snp_cards (0, image->device_handle, &efinet_number); -- if (rc < 0) -- return; -- } -- else -- { -- rc = grub_efinet_find_snp_cards (0, NULL, &efinet_number); -- if (rc < 0) -- return; -- } - } - - static grub_efi_handle_t -@@ -833,9 +763,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, - if (card->driver != &efidriver) - continue; - -- if (hnd != card->efi_handle) -- continue; -- - cdp = grub_efi_get_device_path (card->efi_handle); - if (! cdp) - continue; -diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 5f62a2d..b337e1a 100644 ---- a/include/grub/efi/api.h -+++ b/include/grub/efi/api.h -@@ -663,10 +663,6 @@ typedef struct grub_efi_device_path grub_efi_device_path_t; - It seems to be identical to EFI_DEVICE_PATH. */ - typedef struct grub_efi_device_path grub_efi_device_path_protocol_t; - --#define GRUB_EFI_DEVICE_PATH_IS_TYPE(dp, type, subtype) \ -- ((GRUB_EFI_DEVICE_PATH_TYPE(dp) == (type)) && \ -- (GRUB_EFI_DEVICE_PATH_SUBTYPE(dp) == (subtype))) -- - #define GRUB_EFI_DEVICE_PATH_TYPE(dp) ((dp)->type & 0x7f) - #define GRUB_EFI_DEVICE_PATH_SUBTYPE(dp) ((dp)->subtype) - #define GRUB_EFI_DEVICE_PATH_LENGTH(dp) ((dp)->length) --- -2.19.1 - diff --git a/support-TPM2.0-in-grub2-both-legacy-and-efi.patch b/support-TPM2.0-in-grub2-both-legacy-and-efi.patch deleted file mode 100644 index c9c9bef17f7e5e2cd72689a8bfa0d59c1616d406..0000000000000000000000000000000000000000 --- a/support-TPM2.0-in-grub2-both-legacy-and-efi.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 57f962bb2234c989b21497af3a4f0ea088589cd2 Mon Sep 17 00:00:00 2001 -From: linyanly -Date: Fri, 3 Nov 2017 15:53:29 +0800 -Subject: [PATCH] backport 'support TPM2.0 in grub2, both legacy and efi' - ---- - grub-core/Makefile.am | 1 + - grub-core/Makefile.core.def | 3 + - grub-core/boot/i386/pc/boot.S | 31 ++++ - grub-core/boot/i386/pc/diskboot.S | 44 ++++++ - grub-core/kern/dl.c | 4 + - grub-core/kern/efi/tpm.c | 282 ++++++++++++++++++++++++++++++++++ - grub-core/kern/emu/mm.c | 3 +- - grub-core/kern/i386/pc/tpm.c | 144 +++++++++++++++++ - grub-core/kern/tpm.c | 19 +++ - grub-core/lib/cmdline.c | 7 +- - grub-core/loader/i386/efi/linux.c | 6 + - grub-core/loader/i386/linux.c | 4 + - grub-core/loader/i386/multiboot_mbi.c | 4 + - grub-core/loader/i386/pc/linux.c | 4 + - grub-core/loader/linux.c | 2 + - grub-core/loader/multiboot.c | 4 + - grub-core/loader/multiboot_mbi2.c | 3 + - grub-core/script/execute.c | 28 +++- - include/grub/efi/tpm.h | 153 ++++++++++++++++++ - include/grub/tpm.h | 89 +++++++++++ - 20 files changed, 831 insertions(+), 4 deletions(-) - create mode 100644 grub-core/kern/efi/tpm.c - create mode 100644 grub-core/kern/i386/pc/tpm.c - create mode 100644 grub-core/kern/tpm.c - create mode 100644 include/grub/efi/tpm.h - create mode 100644 include/grub/tpm.h - -diff --git a/grub-core/kern/emu/mm.c b/grub-core/kern/emu/mm.c -index f262e95..43b31fa 100644 ---- a/grub-core/kern/emu/mm.c -+++ b/grub-core/kern/emu/mm.c -@@ -50,7 +50,8 @@ - void - grub_free (void *ptr) - { -- free (ptr); -+ if (ptr) -+ free (ptr); - } - - void * --- -1.8.3.1 diff --git a/unix-platform-Initialize-variable-to-fix-grub-instal.patch b/unix-platform-Initialize-variable-to-fix-grub-instal.patch deleted file mode 100644 index 2c4dc5291ac8f5185088f4d766f25e8e7544f4fc..0000000000000000000000000000000000000000 --- a/unix-platform-Initialize-variable-to-fix-grub-instal.patch +++ /dev/null @@ -1,69 +0,0 @@ -From b71ac53751877dac18cfc091db2e22b805462278 Mon Sep 17 00:00:00 2001 -From: Paul Menzel -Date: Tue, 23 Oct 2018 15:00:13 +0200 -Subject: [PATCH 200/270] unix/platform: Initialize variable to fix - grub-install on UEFI system -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -On a UEFI system, were no boot entry *grub* is present, currently, -`grub-install` fails with an error. - - $ efibootmgr - BootCurrent: 0000 - Timeout: 0 seconds - BootOrder: 0001,0006,0003,0004,0005 - Boot0001 Diskette Drive - Boot0003* USB Storage Device - Boot0004* CD/DVD/CD-RW Drive - Boot0005 Onboard NIC - Boot0006* WDC WD2500AAKX-75U6AA0 - $ sudo grub-install /dev/sda - Installing for x86_64-efi platform. - grub-install: error: efibootmgr failed to register the boot entry: Unknown error 22020. - -The error code is always different, and the error message (incorrectly) -points to efibootmgr. - -But, the error is in GRUB’s function -`grub_install_remove_efi_entries_by_distributor()`, where the variable -`rc` for the return value, is uninitialized and never set, when no boot -entry for the distributor is found. - -The content of that uninitialized variable is then returned as the error -code of efibootmgr. - -Set the variable to 0, so that success is returned, when no entry needs -to be deleted. - -Tested on Dell OptiPlex 7010 with firmware A28. - - $ sudo ./grub-install /dev/sda - Installing for x86_64-efi platform. - Installation finished. No error reported. - -[1]: https://github.com/rhboot/efibootmgr/issues/100 - -Signed-off-by: Paul Menzel -Reviewed-by: Daniel Kiper ---- - grub-core/osdep/unix/platform.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c -index ca448bc..55b8f40 100644 ---- a/grub-core/osdep/unix/platform.c -+++ b/grub-core/osdep/unix/platform.c -@@ -85,7 +85,7 @@ grub_install_remove_efi_entries_by_distributor (const char *efi_distributor) - pid_t pid = grub_util_exec_pipe ((const char * []){ "efibootmgr", NULL }, &fd); - char *line = NULL; - size_t len = 0; -- int rc; -+ int rc = 0; - - if (!pid) - { --- -1.8.3.1 -