From d5c5bf4a6399195b99aa1390a1e308faac9a42f7 Mon Sep 17 00:00:00 2001 From: Troy Dawson Date: Tue, 29 Oct 2024 08:28:59 -0700 Subject: [PATCH 1/2] Bump release for October 2024 mass rebuild: Resolves: RHEL-64018 --- grub2.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grub2.spec b/grub2.spec index f8e8ff7..2ed1c13 100644 --- a/grub2.spec +++ b/grub2.spec @@ -17,7 +17,7 @@ Name: grub2 Epoch: 1 Version: 2.06 -Release: 133%{?dist} +Release: 134%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPL-3.0-or-later URL: http://www.gnu.org/software/grub/ @@ -583,6 +583,10 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog +* Tue Oct 29 2024 Troy Dawson +- Bump release for October 2024 mass rebuild: + Resolves: RHEL-64018 + * Mon Sep 23 2024 Leo Sandoval - 2.06-133 - posttrans: condition EFI_HOME/grub.cfg cmds if stub is present - Resolves: #RHEL-59796 From f9ffaac36ed6a828d6508c393921e1ee6f2213ed Mon Sep 17 00:00:00 2001 From: Leo Sandoval Date: Fri, 18 Oct 2024 12:18:00 -0600 Subject: [PATCH 2/2] Rebased to release grub-2.12 Resolves: #RHEL-15032 Signed-off-by: Leo Sandoval --- ...-Fix-user-facing-typo-with-an-incorr.patch | 2 +- ...-Properly-disable-the-os-prober-by-d.patch | 6 +- ...tes-Disable-the-os-prober-by-default.patch | 8 +- ...d.patch => 0004-Rework-linux-command.patch | 16 +- ...patch => 0005-Rework-linux16-command.patch | 2 +- ...re.patch => 0006-re-write-.gitignore.patch | 16 +- ...ient-architecture-CAS-reboot-support.patch | 10 +- ...nsole-display-attr-when-clear-screen.patch | 2 +- ...video-support-for-IBM-power-machines.patch | 18 +- ...0-Move-bash-completion-script-922997.patch | 8 +- ...o-include-entries-by-title-not-just-.patch | 2 +- ...=> 0012-Make-exit-take-a-return-code.patch | 67 +- ...es-load-an-env-block-from-a-variable.patch | 33 +- ...014-Migrate-PPC-from-Yaboot-to-Grub2.patch | 8 +- ...=> 0015-Add-fw_path-variable-revised.patch | 4 +- ...-hex-hex-straight-through-unmolested.patch | 6 +- ...g-module-to-parse-Boot-Loader-Specif.patch | 24 +- ...patch => 0018-Add-devicetree-loading.patch | 10 +- ...0019-Enable-pager-by-default.-985860.patch | 2 +- ...n-t-say-GNU-Linux-in-generated-menus.patch | 18 +- ...rame-to-list-of-relocations-stripped.patch | 11 +- ...password-to-boot-entries-generated-b.patch | 2 +- ...ix-when-fallback-searching-for-grub-.patch | 2 +- ...-before-grub.cfg-on-tftp-config-file.patch | 2 +- ...CLASS-in-10_linux-from-etc-os-releas.patch | 2 +- ...6-Try-prefix-if-fw_path-doesn-t-work.patch | 51 +- ...fig-construct-titles-that-look-like-.patch | 6 +- ...ly-grub2-password-config-tool-985962.patch | 20 +- ... 0029-tcp-add-window-scaling-support.patch | 6 +- ...net-and-bootp-add-support-for-dhcpv6.patch | 127 +- ...=> 0031-bootp-New-net_bootp6-command.patch | 54 +- ...rnel-settings-and-use-it-in-10_linux.patch | 32 +- ... 0033-Make-grub_fatal-also-backtrace.patch | 31 +- ...fo-pages-say-grub2-where-appropriate.patch | 314 +-- ...-chainloader-entries-don-t-try-any-x.patch | 4 +- ...-Add-ability-to-boot-from-subvolumes.patch | 43 +- 0037-btrfs-fix-a-bad-null-check.patch | 40 + ...1374141-fix-incorrect-mask-for-ppc64.patch | 48 - ...port-btrfs_subvol-and-btrfs_subvolid.patch | 4 +- ...> 0039-grub2-btrfs-03-follow_default.patch | 20 +- ...=> 0040-grub2-btrfs-04-grub2-install.patch | 33 +- ...> 0041-grub2-btrfs-05-grub2-mkconfig.patch | 16 +- ... => 0042-grub2-btrfs-06-subvol-mount.patch | 32 +- ...subvol-name-scheme-to-support-old-sn.patch | 4 +- ...-correctly-with-btrfs-snapshots-bsc-.patch | 8 +- ...ocate_pool-and-grub_efi_free_pool-wr.patch | 18 +- ...fi_.-memory-helpers-where-reasonable.patch | 36 + 0047-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch | 33 + ...=> 0048-don-t-use-int-for-efi-status.patch | 4 +- ...INIT-declare-its-function-prototypes.patch | 2 +- ...-efi-as-HFS-on-ppc-machines-in-grub-.patch | 4 +- ...fi_.-memory-helpers-where-reasonable.patch | 106 -- ...d-xen-or-multiboot-2-modules-as-need.patch | 14 +- 0051-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch | 48 - ...052-align-struct-efi_variable-better.patch | 6 +- ...053-Add-BLS-support-to-grub-mkconfig.patch | 20 +- ...-backtrace-on-grub_abort-for-grub-em.patch | 4 +- ...h => 0055-Add-grub2-switch-to-blscfg.patch | 14 +- ...-calibration-not-take-51-seconds-to-.patch | 211 --- ...w-our-startup-message-if-debug-is-se.patch | 4 +- ...-some-minor-include-path-weirdnesses.patch | 8 +- ...it-possible-to-enabled-build-id-sha1.patch | 6 +- ...patch => 0059-make-better-backtraces.patch | 84 +- 0060-Fixup-for-newer-compiler.patch | 22 + ...-export-the-start-and-_start-symbols.patch | 2 +- ...tch => 0062-Fixup-for-newer-compiler.patch | 10 +- ...pport-for-non-Ethernet-network-cards.patch | 128 +- ...=> 0064-efinet-UEFI-IPv6-PXE-support.patch | 14 +- ...065-grub.texi-Add-net_bootp6-doument.patch | 6 +- ...dprintf-that-tells-us-load-addresses.patch | 178 -- ...essing-DHCPACK-packet-from-HTTP-Boot.patch | 8 +- ...ar-pointers-in-grub-core-net-bootp.c.patch | 4 +- 0067-Fixup-for-newer-compiler.patch | 36 - ...etting-network-from-UEFI-device-path.patch | 61 +- ...etting-DNS-server-from-UEFI-protocol.patch | 79 +- ...70-Support-UEFI-networking-protocols.patch | 331 ++-- ...> 0071-AUDIT-0-http-boot-tracker-bug.patch | 25 +- ...racketed-ipv6-addrs-and-port-numbers.patch | 270 --- ...-incr-command-to-increment-integer-v.patch | 2 +- ...h => 0073-Add-auto-hide-menu-support.patch | 20 +- ...> 0074-Add-grub-set-bootflag-utility.patch | 14 +- ...b-boot-indeterminate.service-example.patch | 2 +- ...h => 0076-gentpl-add-disable-support.patch | 6 +- ... => 0077-gentpl-add-pc-firmware-type.patch | 8 +- ...e-the-firmware-acceleration-for-http.patch | 2 +- ...ot_url-reflect-the-protocol-hostname.patch | 4 +- ...n-tell-configure-which-cflags-utils-.patch | 24 +- ...81-Rework-how-the-fdt-command-builds.patch | 28 +- ...able-non-wordsize-allocations-on-arm.patch | 4 +- ...nd-prefix-when-HTTP-path-is-relative.patch | 6 +- ...=> 0084-Make-grub_error-more-verbose.patch | 6 +- ...eset-an-alias-for-the-reboot-command.patch | 2 +- ....patch => 0086-Add-a-version-command.patch | 22 +- ...dprintf-and-nerf-dprintf-in-script.c.patch | 12 +- ...p-all-the-places-Wsign-compare-error.patch | 56 +- ...gn-compare-Wno-conversion-Wno-error-.patch | 38 +- ...make-it-possible-to-run-checkers-on-.patch | 58 - ... => 0090-Fix-getroot.c-s-trampolines.patch | 4 +- ...not-allow-stack-trampolines-anywhere.patch | 12 +- ...tch => 0092-Reimplement-boot_counter.patch | 12 +- ...ntry-selection-based-on-ID-and-title.patch | 2 +- ...try-users-option-argument-to-be-opti.patch | 2 +- ...export-env-and-efi-load-env-commands.patch | 30 +- ...bles-from-the-initial-context-when-c.patch | 4 +- ...-boot-success-reset-from-menu-auto-h.patch | 12 +- ...t-boot-commands-will-only-return-on-.patch | 2 +- ...g-Update-comment-about-running-as-ro.patch | 2 +- ...g-Write-new-env-to-tmpfile-and-then-.patch | 2 +- ...indeterminate-getting-set-on-boot_su.patch | 2 +- ... => 0102-Add-start-symbol-for-RISC-V.patch | 2 +- ...conf-Force-autogen.sh-to-use-python3.patch | 4 +- ...fw-http-_path-variables-to-make-them.patch | 4 +- ...-literal-IPv6-addresses-in-square-br.patch | 8 +- ...o-specify-a-port-number-in-addresses.patch | 2 +- ...mprove-check-to-detect-literal-IPv6-.patch | 2 +- ...debug-message-if-parsing-the-address.patch | 2 +- ...so-accept-F8-as-a-user-interrupt-key.patch | 2 +- ...fix-when-the-HTTP-path-is-relative-a.patch | 4 +- ...turn-in-efi-export-env-and-efi-load-.patch | 2 +- ...le-to-subtract-conditions-from-debug.patch | 45 - ...p-fix-some-allocation-error-checking.patch | 6 +- ...p-fix-some-allocation-error-checking.patch | 6 +- ...g.c-fix-some-potential-allocation-ov.patch | 4 +- ...ointers-in-grub-core-net-efi-ip4_con.patch | 2 +- ...ointers-in-grub-core-net-efi-ip6_con.patch | 2 +- ...-pointers-in-grub-core-net-efi-net.c.patch | 2 +- ...-pointers-in-grub-core-net-efi-pxe.c.patch | 2 +- ...gration-scripts-to-make-systemctl-re.patch | 28 +- ...ion.sh-Also-set-old-menu_show_once-g.patch | 2 +- ...set-1-when-keyboard-is-in-Translate-.patch | 12 +- ...ll-disable-support-for-EFI-platforms.patch | 24 +- ...imestamps-configure-flag-to-prepend-.patch | 30 +- ...ements-to-grub_disk_open-and-grub_di.patch | 17 +- ...on-grub_debug_is_enabled-void-return.patch | 8 +- ...ear-screen-when-debugging-is-enabled.patch | 12 +- ..._-instrumentation-new-file-debug-tag.patch | 12 +- ...ate-TPM-measurement-errors-to-the-ve.patch | 62 - ...-Avoiding-many-unecessary-open-close.patch | 8 +- ...-implements-fibre-channel-discovery-.patch | 2 +- ...erpc-enables-device-mapper-discovery.patch | 2 +- ...fallback_set-var-to-force-the-set-ma.patch | 20 +- ...igning-grub-with-an-appended-signatu.patch | 68 +- ...rub-Document-signing-grub-under-UEFI.patch | 8 +- ...nt-signing-grub-with-an-appended-sig.patch | 4 +- ...e-grub_dl_set_persistent-for-the-emu.patch | 4 +- ...patch => 0136-pgp-factor-out-rsa_pad.patch | 10 +- ...rage-for-grub_crypto_pk_-to-crypto.c.patch | 4 +- ...p-tweaks-in-preparation-for-libtasn1.patch | 14 +- ...0139-libtasn1-import-libtasn1-4.16.0.patch | 30 +- ...asn1-disable-code-not-needed-in-grub.patch | 12 +- ...tasn1-changes-for-grub-compatibility.patch | 12 +- ...42-libtasn1-compile-into-asn1-module.patch | 10 +- ...3-test_asn1-test-module-for-libtasn1.patch | 47 +- ...-support-embedding-x509-certificates.patch | 42 +- ...res-import-GNUTLS-s-ASN.1-descriptio.patch | 4 +- ...res-parse-PKCS-7-signedData-and-X.50.patch | 8 +- ...res-support-verifying-appended-signa.patch | 10 +- ...pended-signatures-verification-tests.patch | 10 +- ...49-appended-signatures-documentation.patch | 42 +- ...Fix-error-handling-in-grub_file_open.patch | 34 - ...er-lockdown-based-on-ibm-secure-boot.patch | 26 +- ...275-drop-HEAP_MAX_ADDR-HEAP_MIN_SIZE.patch | 46 + ...-Also-handle-the-Extended-Key-Usage-.patch | 6 +- ...eee1275-ofdisk-retry-on-open-failure.patch | 10 +- ...> 0154-efinet-Add-DHCP-proxy-support.patch | 24 +- ...-cmdline-when-generating-legacy-menu.patch | 4 +- ... 0156-Suppress-gettext-error-message.patch | 2 +- ...d-Always-use-boot-grub2-user.cfg-as-.patch | 2 +- ...over-the-device-to-read-the-config-f.patch | 2 +- ...etting-of-prefix-for-signed-binary-c.patch | 12 +- ...pc-ieee1275-load-grub-at-4MB-not-2MB.patch | 6 +- ...-Fedora-location-of-DejaVu-SANS-font.patch | 30 + ...h => 0162-efi-new-connectefi-command.patch | 34 +- ...etection-support-device-names-with-c.patch | 2 +- ...=> 0164-make-ofdisk_retries-optional.patch | 2 +- ...grub_min-and-grub_max-more-resilient.patch | 8 +- ...FS-switch-to-using-grub_min-grub_max.patch | 2 +- ...oot_time-also-call-grub_dprintf-boot.patch | 16 +- ...dules-make-.module_license-read-only.patch | 2 +- ...p-.llvm_addrsig-sections-and-similar.patch | 2 +- ...locate-space-for-non-allocable-secti.patch | 4 +- ...ule-sections-at-page-aligned-address.patch | 50 +- ...-nx-add-memory-attribute-get-set-API.patch | 44 +- ...-page-permissions-for-loaded-modules.patch | 61 +- ...275-drop-HEAP_MAX_ADDR-HEAP_MIN_SIZE.patch | 75 - ...x-compatible-flag-in-EFI-grub-images.patch | 28 +- ...probe-dprint-errors-from-filesystems.patch | 6 +- ...file-show-which-file-filters-get-run.patch | 2 +- ...e-etc-kernel-cmdline-during-mkconfig.patch | 4 +- ...sh-don-t-dup-rhgb-quiet-check-mtimes.patch | 4 +- ...gnore-checksum-seed-incompat-feature.patch | 54 - ...=> 0179-squish-give-up-on-rhgb-quiet.patch | 4 +- ...write-etc-kernel-cmdline-if-writable.patch | 4 +- ...scfg-Don-t-root-device-in-emu-builds.patch | 2 +- ...82-ppc64le-signed-boot-media-changes.patch | 20 +- ...veral-implicit-function-declarations.patch | 6 +- ...for-EFI-at-runtime-instead-of-config.patch | 63 - ...or-if-boot-to-firmware-setup-is-not-.patch | 92 - ...-memory-with-ibm-client-architecture.patch | 109 ++ ...-work-around-proc-not-reporting-size.patch | 8 +- ...blscfg-check-for-mounted-boot-in-emu.patch | 2 +- ...b_dl_set_mem_attrs-fix-format-string.patch | 2 +- ...adable-filesystem-with-v4-superblock.patch | 118 -- ...attrs-add-self-check-for-the-tramp-G.patch | 2 +- ...module-name-on-license-check-failure.patch | 48 - ...ments-page-align-the-tramp-GOT-areas.patch | 16 +- ...0190-emu-Add-switch-root-to-grub-emu.patch | 10 +- ...-mkconfig-restore-umask-for-grub.cfg.patch | 40 - ...il-Enable-default-kernel-for-updates.patch | 2 +- ...-efi-http-change-uint32_t-to-uintn_t.patch | 2 +- ...btrfs-Use-full-btrfs-bootloader-area.patch | 160 -- ...-Fedora-location-of-DejaVu-SANS-font.patch | 30 - ...Install-section-to-aux-systemd-units.patch | 6 +- ...0194-Fix-missing-include-in-ofdisk.c.patch | 2 +- ...t-show-Booting-s-msg-when-auto-booti.patch | 90 - ...-Welcome-to-GRUB-message-in-EFI-buil.patch | 41 - ...195-add-flag-to-only-search-root-dev.patch | 24 +- ...ot-set-colorstate-until-the-first-te.patch | 51 - ...ptdisk-fix-incorrect-sign-comparison.patch | 28 + ...ot-set-cursor-until-the-first-text-o.patch | 71 - ...-install-fix-a-sign-comparison-error.patch | 25 + ...se-visual-indentation-in-config.h.in.patch | 93 - ...t-work-around-bad-integer-comparison.patch | 50 + ...sure-config-util.h-precedes-config.h.patch | 275 --- ...-use-after-free-in-get_slave_from_dm.patch | 32 + 0200-Drop-gnulib-fix-base64.patch.patch | 140 -- 0200-Fix-some-sign-comparison-errors.patch | 37 + 0201-Drop-gnulib-no-abort.patch.patch | 97 - 0201-normal-Fix-a-discarded-const.patch | 23 + ...version-and-drop-most-gnulib-patches.patch | 832 -------- ...-grub_keyboard_controller_write-unus.patch | 35 + ...-another-minor-sign-comparison-error.patch | 23 + ...Fix-bug-stopping-iteration-when-no-f.patch | 33 - ...odule-dependencies-in-Makefile.core..patch | 124 ++ ...w-efidisk-only-option-on-EFI-systems.patch | 168 -- ...-that-we-preserve-header-vs-region-a.patch | 75 + ...U-variety-of-build-flags-for-PROGRAM.patch | 38 + 0207-Work-around-extra_deps.lst-issue.patch | 24 + ...-arm64-linux.c-do-not-validate-kerne.patch | 58 - ...ttribute-for-an-EFI-API-call-definit.patch | 42 + 0209-cast-grub_error-status-parameter.patch | 67 + 0210-remove-unused-varible.patch | 31 + 0211-cast-grub_net_bootp_packet-pointer.patch | 42 + ...libtasn1-fix-string-overflow-warning.patch | 56 + ...d-support-for-Linux-EFI-stub-loading.patch | 486 +---- ...ot-Add-API-to-pass-context-to-loader.patch | 158 -- 0214-fix-i386_pc-on-legacycfg-module.patch | 21 + ...ecureboot-support-on-efi-chainloader.patch | 269 ++- ...loaders-that-link-in-efi-mode-honor-.patch | 151 +- ...t-ordering-for-.debug-and-rescue-ker.patch | 4 +- ...f-grub_dprintf-without-the-file-line.patch | 12 +- ...dprintf-that-tells-us-load-addresses.patch | 83 + ...ct-non-kernel-files-in-the-shim_lock.patch | 101 - ...rch-64-on-32-boot-in-linuxefi-loader.patch | 56 +- ...-leak-device_name-on-error-in-grub_f.patch | 39 - ...tter-locations-for-kernel-and-initrd.patch | 22 +- ...g-Abort-sooner-if-a-read-operation-f.patch | 198 -- ...g-Refuse-to-handle-multiple-image-he.patch | 28 - ...ce-buffers-for-reading-to-addresses-.patch | 4 +- ...g-Drop-greyscale-support-to-fix-heap.patch | 170 -- ...-arrange-grub_cmd_linux-a-little-bit.patch | 4 +- ...g-Avoid-heap-OOB-R-W-inserting-huff-.patch | 40 - ...e-our-own-allocator-for-kernel-stuff.patch | 33 +- ...-png-Sanity-check-some-huffman-codes.patch | 40 - ...itrd-params-cmdline-allocations-abov.patch | 20 +- ...se-address-before-jumping-to-the-PE-.patch | 16 +- ...eg-Abort-sooner-if-a-read-operation-.patch | 255 --- ...eg-Do-not-reallocate-a-given-huff-ta.patch | 29 - ...maximum-bounce-buffer-size-to-16-MiB.patch | 2 +- ...integer-overflows-in-grub_cmd_initrd.patch | 2 +- ...eg-Refuse-to-handle-multiple-start-o.patch | 44 - ...rnel-validation-without-shim-protoco.patch | 49 +- ...eg-Block-int-underflow-wild-pointer-.patch | 53 - ...ainloading-EFI-apps-from-loop-mounts.patch | 37 +- ...ix-array-out-of-bounds-formatting-un.patch | 34 - ...-i386-efi-linux.c-do-not-validate-ke.patch | 2 +- ...ff-Block-overly-large-netbuff-allocs.patch | 46 - ...-efi-chainloader.c-do-not-validate-c.patch | 18 +- 0232-net-ip-Do-IP-fragment-maths-safely.patch | 44 - ...-efi-linux.c-drop-now-unused-grub_li.patch | 24 +- ...le-free-addresses-on-corrupt-DNS-res.patch | 56 - ...loader-grub_load_and_start_image-doe.patch | 10 +- ...ad-past-the-end-of-the-string-we-re-.patch | 71 - ...hainloader-simplify-the-loader-state.patch | 126 +- ...-a-UAF-and-double-free-from-a-failed.patch | 112 -- ...i-chainloader-Use-grub_loader_set_ex.patch | 39 +- 0236-net-tftp-Avoid-a-trivial-UAF.patch | 35 - ...linux-Avoid-a-use-after-free-in-the-.patch | 6 +- ...tear-down-socket-if-it-s-already-bee.patch | 42 - ...386-efi-linux-Use-grub_loader_set_ex.patch | 19 +- ...Fix-OOB-write-for-split-http-headers.patch | 46 - ...linux-Fix-a-memory-leak-in-the-initr.patch | 2 +- ...or-out-on-headers-with-LF-without-CR.patch | 48 - ...nel-in-EFI_RUNTIME_SERVICES_CODE-ins.patch | 2 +- ...ead-past-the-end-of-nat-journal-entr.patch | 72 - ...ed-array-positions-for-our-allocatio.patch | 6 +- ...-not-read-past-the-end-of-nat-bitmap.patch | 132 -- ...tion-policy-for-kernel-vs-initrd-mem.patch | 10 +- ...ot-copy-file-names-that-are-too-long.patch | 38 - ...-initrd-within-the-bounds-expressed-.patch | 8 +- ...eral-fuzz-issues-with-invalid-dir-it.patch | 79 - ...ER_-CODE-DATA-for-kernel-and-initrd-.patch | 10 +- ...e-ASAN-and-SEGV-issues-found-with-fu.patch | 134 -- ...x-more-fuzz-issues-related-to-chunks.patch | 75 - ...ncorrect-array-size-in-kernel-alloca.patch | 2 +- ...> 0246-grub-install-on-EFI-if-forced.patch | 47 +- ...stall-section-from-aux-systemd-units.patch | 4 +- ...der-remove-device-path-debug-message.patch | 7 +- ...g-Conservative-partial-fix-for-CVE-2.patch | 2 +- ...g-More-complete-fix-for-CVE-2024-104.patch | 2 +- ...g-Exit-calmly-when-not-running-as-ro.patch | 2 +- 0252-Makefile.core.def-fix-linux-module.patch | 61 + ...Linux-EFI-stub-loading-on-arm-archit.patch | 270 +++ ...-Better-memory-allocation-and-error-.patch | 112 +- ...x-EFI-loader-kernel-image-allocation.patch | 165 +- ...eader-struct-and-fix-some-bad-naming.patch | 36 +- ... 0257-Correct-BSS-zeroing-on-aarch64.patch | 38 +- ...er-memory-type-for-kernel-allocation.patch | 18 +- ...-document-the-behavior-of-multiple-v.patch | 25 - ...ub_env_set-prefix-in-grub_try_normal.patch | 2 +- ...n-continuous-data-blocks-in-director.patch | 54 + ...nore-warnings-for-incompatible-types.patch | 4 +- 0261-fs-fat-don-t-error-when-mtime-is-0.patch | 64 - ...d-search-Rework-of-CVE-2023-4001-fix.patch | 12 +- ....c-read-the-kernel-image-before-head.patch | 69 + ...4-nx-set-attrs-in-our-kernel-loaders.patch | 261 +-- ...-wrappers-for-load_image-start_image.patch | 183 ++ ...lback-to-legacy-Linux-loader-when-sh.patch | 66 + ...le-stack-sections-on-EFI-assembly-fi.patch | 47 + ...fig.in-turn-off-executable-owner-bit.patch | 14 +- ...it-Add-IEEE-1275-Radix-support-for-K.patch | 119 ++ ...nsure-grub-cfg-stub-is-not-overwritt.patch | 4 +- ...-mkconfig-Simplify-os_name-detection.patch | 9 +- ...move-check-for-mount-point-for-grub-.patch | 4 +- ...ux-Remove-magic-number-header-field-.patch | 43 - ...e-missing-__grub_efi_api-macros-on-E.patch | 495 +++++ ...rub-core-net-arp.c-fix-variable-name.patch | 23 + ...EFI-commands-inside-test-expressions.patch | 44 + ...i-tpm-Refine-the-status-of-log-event.patch | 42 - ...-if-NX-is-required-in-grub_efi_linux.patch | 25 + ...om-always-printing-dynamic_load_symb.patch | 80 + ...-Use-grub_strcpy-instead-of-grub_mem.patch | 37 - ...-EFI_CC_MEASUREMENT_PROTOCOL-support.patch | 258 --- ...ate-i-cache-before-starting-the-kern.patch | 12 +- ...hs-exceeds-font-max_glyph_width-or-f.patch | 31 - ...dont-overwrite-BLS-cmdline-if-BLSCFG.patch | 8 +- ...erflow-in-grub_font_get_glyph_intern.patch | 110 -- ...ass-all-boot-params-when-used-by-ana.patch | 4 +- ...-integer-overflows-in-grub_font_cons.patch | 79 - 0282-font-Remove-grub_font_dup_glyph.patch | 40 - ...nteger-overflow-in-ensure_comb_space.patch | 46 - ...nt-Fix-integer-overflow-in-BMP-index.patch | 63 - ...-underflow-in-binary-search-of-char-.patch | 83 - ...b-Enforce-verification-of-font-files.patch | 52 - 0287-fbutil-Fix-integer-overflow.patch | 83 - ...ix-an-integer-underflow-in-blit_comb.patch | 89 - ..._font_blit_glyph-and-grub_font_blit_.patch | 73 - ...l_font-to-glyphs-in-ascii_font_glyph.patch | 34 - ...ix-an-integer-overflow-in-grub_unico.patch | 53 - ...ening-fonts-from-the-bundled-memdisk.patch | 78 - 0293-mm-Clarify-grub_real_malloc.patch | 183 -- ...loc-Make-small-allocs-comment-match-.patch | 32 - 0295-mm-Document-grub_free.patch | 120 -- 0296-mm-Document-grub_mm_init_region.patch | 73 - ...-internal-memory-management-structur.patch | 78 - ...e-preserve-header-vs-region-alignmen.patch | 56 - ...-region-merge-with-region-after-as-w.patch | 203 -- ...-Debug-support-for-region-operations.patch | 71 - ...p-unused-unloading-of-modules-on-OOM.patch | 80 - ...ally-requesting-additional-memory-re.patch | 130 -- ...ys-request-a-fixed-number-of-pages-o.patch | 103 - ...tract-function-to-add-memory-regions.patch | 85 - ...ss-up-errors-from-add_memory_regions.patch | 87 - ...-Implement-runtime-addition-of-pages.patch | 75 - ...-default-memory-allocation-to-32-MiB.patch | 31 - ...e-disk-caches-last-when-out-of-memor.patch | 57 - ...rt-for-grub-emu-to-kexec-Linux-menu-.patch | 431 ----- ...n-Hack-Ware-remove-GRUB_IEEE1275_FLA.patch | 111 -- ...-memory-with-ibm-client-architecture.patch | 308 --- ...ee1275-drop-len-1-quirk-in-heap_init.patch | 36 - ...1275-support-runtime-memory-claiming.patch | 435 ----- ...5-implement-vec5-for-cas-negotiation.patch | 74 - ...ort-for-trusted-boot-using-a-vTPM-2..patch | 246 --- 0318-powerpc-Drop-Open-Hack-Ware.patch | 69 - ...disk-Modify-sector-by-sysfs-as-disk-.patch | 70 - ...gion-size-to-take-management-overhea.patch | 145 -- ...e-some-space-when-adding-new-regions.patch | 53 - ...complex-heap-growth-math-in-hot-path.patch | 72 - ...ork-around-systemctl-kexec-returning.patch | 41 - ...it-Convert-plain-numbers-to-constant.patch | 48 - ...ee1275-init-Extended-support-in-Vec5.patch | 127 -- ...tpm-verifier-if-the-TPM-device-is-no.patch | 156 -- ...it-ppc64-Restrict-high-memory-in-pre.patch | 226 --- 0341-fs-Remove-trailing-whitespaces.patch | 1681 ----------------- ...s-xfs-Fix-memory-leaks-in-XFS-module.patch | 47 - ...s-found-while-fuzzing-the-XFS-filesy.patch | 106 -- ...-short-form-directory-data-boundary-.patch | 47 - ...-extent-counters-incompat-feature-su.patch | 115 -- ...xfs-Fix-XFS-directory-extent-parsing.patch | 168 -- ...OB-write-when-parsing-the-ATTRIBUTE_.patch | 90 - ...OB-read-when-reading-data-from-the-r.patch | 55 - ...OB-read-when-parsing-directory-entri.patch | 70 - ...OB-read-when-parsing-bitmaps-for-ind.patch | 48 - ...OOB-read-when-parsing-a-volume-label.patch | 58 - 0364-fs-ntfs-Make-code-more-readable.patch | 156 -- bootstrap | 319 ++-- bootstrap.conf | 26 +- gitignore | 4 + grub.patches | 640 +++---- grub2.spec | 10 +- sources | 2 +- 411 files changed, 5798 insertions(+), 17542 deletions(-) rename 0005-Rework-linux-command.patch => 0004-Rework-linux-command.patch (86%) rename 0006-Rework-linux16-command.patch => 0005-Rework-linux16-command.patch (98%) rename 0010-re-write-.gitignore.patch => 0006-re-write-.gitignore.patch (94%) rename 0011-IBM-client-architecture-CAS-reboot-support.patch => 0007-IBM-client-architecture-CAS-reboot-support.patch (96%) rename 0012-for-ppc-reset-console-display-attr-when-clear-screen.patch => 0008-for-ppc-reset-console-display-attr-when-clear-screen.patch (97%) rename 0013-Disable-GRUB-video-support-for-IBM-power-machines.patch => 0009-Disable-GRUB-video-support-for-IBM-power-machines.patch (85%) rename 0014-Move-bash-completion-script-922997.patch => 0010-Move-bash-completion-script-922997.patch (89%) rename 0015-Allow-fallback-to-include-entries-by-title-not-just-.patch => 0011-Allow-fallback-to-include-entries-by-title-not-just-.patch (98%) rename 0016-Make-exit-take-a-return-code.patch => 0012-Make-exit-take-a-return-code.patch (82%) rename 0017-Make-efi-machines-load-an-env-block-from-a-variable.patch => 0013-Make-efi-machines-load-an-env-block-from-a-variable.patch (71%) rename 0018-Migrate-PPC-from-Yaboot-to-Grub2.patch => 0014-Migrate-PPC-from-Yaboot-to-Grub2.patch (96%) rename 0019-Add-fw_path-variable-revised.patch => 0015-Add-fw_path-variable-revised.patch (96%) rename 0020-Pass-x-hex-hex-straight-through-unmolested.patch => 0016-Pass-x-hex-hex-straight-through-unmolested.patch (97%) rename 0021-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch => 0017-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch (98%) rename 0022-Add-devicetree-loading.patch => 0018-Add-devicetree-loading.patch (90%) rename 0023-Enable-pager-by-default.-985860.patch => 0019-Enable-pager-by-default.-985860.patch (94%) rename 0024-Don-t-say-GNU-Linux-in-generated-menus.patch => 0020-Don-t-say-GNU-Linux-in-generated-menus.patch (91%) rename 0025-Add-.eh_frame-to-list-of-relocations-stripped.patch => 0021-Add-.eh_frame-to-list-of-relocations-stripped.patch (76%) rename 0026-Don-t-require-a-password-to-boot-entries-generated-b.patch => 0022-Don-t-require-a-password-to-boot-entries-generated-b.patch (96%) rename 0027-use-fw_path-prefix-when-fallback-searching-for-grub-.patch => 0023-use-fw_path-prefix-when-fallback-searching-for-grub-.patch (97%) rename 0028-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch => 0024-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch (99%) rename 0029-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch => 0025-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch (96%) rename 0031-Try-prefix-if-fw_path-doesn-t-work.patch => 0026-Try-prefix-if-fw_path-doesn-t-work.patch (93%) rename 0032-Make-grub2-mkconfig-construct-titles-that-look-like-.patch => 0027-Make-grub2-mkconfig-construct-titles-that-look-like-.patch (95%) rename 0033-Add-friendly-grub2-password-config-tool-985962.patch => 0028-Add-friendly-grub2-password-config-tool-985962.patch (94%) rename 0034-tcp-add-window-scaling-support.patch => 0029-tcp-add-window-scaling-support.patch (95%) rename 0035-efinet-and-bootp-add-support-for-dhcpv6.patch => 0030-efinet-and-bootp-add-support-for-dhcpv6.patch (84%) rename 0072-bootp-New-net_bootp6-command.patch => 0031-bootp-New-net_bootp6-command.patch (96%) rename 0036-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch => 0032-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch (92%) rename 0038-Make-grub_fatal-also-backtrace.patch => 0033-Make-grub_fatal-also-backtrace.patch (89%) rename 0039-Make-our-info-pages-say-grub2-where-appropriate.patch => 0034-Make-our-info-pages-say-grub2-where-appropriate.patch (80%) rename 0040-macos-just-build-chainloader-entries-don-t-try-any-x.patch => 0035-macos-just-build-chainloader-entries-don-t-try-any-x.patch (98%) rename 0041-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch => 0036-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch (94%) create mode 100644 0037-btrfs-fix-a-bad-null-check.patch delete mode 100644 0037-bz1374141-fix-incorrect-mask-for-ppc64.patch rename 0042-export-btrfs_subvol-and-btrfs_subvolid.patch => 0038-export-btrfs_subvol-and-btrfs_subvolid.patch (91%) rename 0043-grub2-btrfs-03-follow_default.patch => 0039-grub2-btrfs-03-follow_default.patch (90%) rename 0044-grub2-btrfs-04-grub2-install.patch => 0040-grub2-btrfs-04-grub2-install.patch (87%) rename 0045-grub2-btrfs-05-grub2-mkconfig.patch => 0041-grub2-btrfs-05-grub2-mkconfig.patch (93%) rename 0046-grub2-btrfs-06-subvol-mount.patch => 0042-grub2-btrfs-06-subvol-mount.patch (94%) rename 0047-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch => 0043-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch (94%) rename 0048-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch => 0044-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch (97%) rename 0049-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch => 0045-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch (82%) create mode 100644 0046-Use-grub_efi_.-memory-helpers-where-reasonable.patch create mode 100644 0047-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch rename 0052-don-t-use-int-for-efi-status.patch => 0048-don-t-use-int-for-efi-status.patch (88%) rename 0053-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch => 0049-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch (96%) rename 0054-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch => 0050-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch (92%) delete mode 100644 0050-Use-grub_efi_.-memory-helpers-where-reasonable.patch rename 0055-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch => 0051-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch (85%) delete mode 100644 0051-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch rename 0057-align-struct-efi_variable-better.patch => 0052-align-struct-efi_variable-better.patch (91%) rename 0058-Add-BLS-support-to-grub-mkconfig.patch => 0053-Add-BLS-support-to-grub-mkconfig.patch (96%) rename 0059-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch => 0054-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch (89%) rename 0060-Add-grub2-switch-to-blscfg.patch => 0055-Add-grub2-switch-to-blscfg.patch (97%) delete mode 100644 0056-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch rename 0062-normal-don-t-draw-our-startup-message-if-debug-is-se.patch => 0056-normal-don-t-draw-our-startup-message-if-debug-is-se.patch (87%) rename 0063-Work-around-some-minor-include-path-weirdnesses.patch => 0057-Work-around-some-minor-include-path-weirdnesses.patch (97%) rename 0064-Make-it-possible-to-enabled-build-id-sha1.patch => 0058-Make-it-possible-to-enabled-build-id-sha1.patch (93%) rename 0061-make-better-backtraces.patch => 0059-make-better-backtraces.patch (93%) create mode 100644 0060-Fixup-for-newer-compiler.patch rename 0068-Don-t-attempt-to-export-the-start-and-_start-symbols.patch => 0061-Don-t-attempt-to-export-the-start-and-_start-symbols.patch (97%) rename 0069-Fixup-for-newer-compiler.patch => 0062-Fixup-for-newer-compiler.patch (79%) rename 0070-Add-support-for-non-Ethernet-network-cards.patch => 0063-Add-support-for-non-Ethernet-network-cards.patch (90%) rename 0073-efinet-UEFI-IPv6-PXE-support.patch => 0064-efinet-UEFI-IPv6-PXE-support.patch (92%) rename 0074-grub.texi-Add-net_bootp6-doument.patch => 0065-grub.texi-Add-net_bootp6-doument.patch (88%) delete mode 100644 0066-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch rename 0075-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch => 0066-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch (95%) rename 0136-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch => 0067-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch (93%) delete mode 100644 0067-Fixup-for-newer-compiler.patch rename 0076-efinet-Setting-network-from-UEFI-device-path.patch => 0068-efinet-Setting-network-from-UEFI-device-path.patch (89%) rename 0077-efinet-Setting-DNS-server-from-UEFI-protocol.patch => 0069-efinet-Setting-DNS-server-from-UEFI-protocol.patch (84%) rename 0078-Support-UEFI-networking-protocols.patch => 0070-Support-UEFI-networking-protocols.patch (94%) rename 0079-AUDIT-0-http-boot-tracker-bug.patch => 0071-AUDIT-0-http-boot-tracker-bug.patch (82%) delete mode 100644 0071-net-read-bracketed-ipv6-addrs-and-port-numbers.patch rename 0080-grub-editenv-Add-incr-command-to-increment-integer-v.patch => 0072-grub-editenv-Add-incr-command-to-increment-integer-v.patch (98%) rename 0081-Add-auto-hide-menu-support.patch => 0073-Add-auto-hide-menu-support.patch (94%) rename 0082-Add-grub-set-bootflag-utility.patch => 0074-Add-grub-set-bootflag-utility.patch (97%) rename 0083-docs-Add-grub-boot-indeterminate.service-example.patch => 0075-docs-Add-grub-boot-indeterminate.service-example.patch (97%) rename 0084-gentpl-add-disable-support.patch => 0076-gentpl-add-disable-support.patch (89%) rename 0085-gentpl-add-pc-firmware-type.patch => 0077-gentpl-add-pc-firmware-type.patch (74%) rename 0086-efinet-also-use-the-firmware-acceleration-for-http.patch => 0078-efinet-also-use-the-firmware-acceleration-for-http.patch (96%) rename 0087-efi-http-Make-root_url-reflect-the-protocol-hostname.patch => 0079-efi-http-Make-root_url-reflect-the-protocol-hostname.patch (93%) rename 0088-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch => 0080-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch (87%) rename 0090-Rework-how-the-fdt-command-builds.patch => 0081-Rework-how-the-fdt-command-builds.patch (85%) rename 0091-Disable-non-wordsize-allocations-on-arm.patch => 0082-Disable-non-wordsize-allocations-on-arm.patch (93%) rename 0092-Prepend-prefix-when-HTTP-path-is-relative.patch => 0083-Prepend-prefix-when-HTTP-path-is-relative.patch (97%) rename 0093-Make-grub_error-more-verbose.patch => 0084-Make-grub_error-more-verbose.patch (94%) rename 0094-Make-reset-an-alias-for-the-reboot-command.patch => 0085-Make-reset-an-alias-for-the-reboot-command.patch (97%) rename 0095-Add-a-version-command.patch => 0086-Add-a-version-command.patch (89%) rename 0096-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch => 0087-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch (89%) rename 0099-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch => 0088-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch (77%) rename 0100-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch => 0089-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch (55%) delete mode 100644 0089-module-verifier-make-it-possible-to-run-checkers-on-.patch rename 0105-Fix-getroot.c-s-trampolines.patch => 0090-Fix-getroot.c-s-trampolines.patch (92%) rename 0106-Do-not-allow-stack-trampolines-anywhere.patch => 0091-Do-not-allow-stack-trampolines-anywhere.patch (65%) rename 0107-Reimplement-boot_counter.patch => 0092-Reimplement-boot_counter.patch (96%) rename 0108-Fix-menu-entry-selection-based-on-ID-and-title.patch => 0093-Fix-menu-entry-selection-based-on-ID-and-title.patch (99%) rename 0109-Make-the-menu-entry-users-option-argument-to-be-opti.patch => 0094-Make-the-menu-entry-users-option-argument-to-be-opti.patch (97%) rename 0110-Add-efi-export-env-and-efi-load-env-commands.patch => 0095-Add-efi-export-env-and-efi-load-env-commands.patch (93%) rename 0112-Export-all-variables-from-the-initial-context-when-c.patch => 0096-Export-all-variables-from-the-initial-context-when-c.patch (95%) rename 0113-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch => 0097-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch (96%) rename 0114-Don-t-assume-that-boot-commands-will-only-return-on-.patch => 0098-Don-t-assume-that-boot-commands-will-only-return-on-.patch (98%) rename 0115-grub-set-bootflag-Update-comment-about-running-as-ro.patch => 0099-grub-set-bootflag-Update-comment-about-running-as-ro.patch (96%) rename 0116-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch => 0100-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch (99%) rename 0117-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch => 0101-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch (98%) rename 0118-Add-start-symbol-for-RISC-V.patch => 0102-Add-start-symbol-for-RISC-V.patch (95%) rename 0119-bootstrap.conf-Force-autogen.sh-to-use-python3.patch => 0103-bootstrap.conf-Force-autogen.sh-to-use-python3.patch (92%) rename 0120-efi-http-Export-fw-http-_path-variables-to-make-them.patch => 0104-efi-http-Export-fw-http-_path-variables-to-make-them.patch (95%) rename 0121-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch => 0105-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch (94%) rename 0122-efi-net-Allow-to-specify-a-port-number-in-addresses.patch => 0106-efi-net-Allow-to-specify-a-port-number-in-addresses.patch (97%) rename 0123-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch => 0107-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch (97%) rename 0124-efi-net-Print-a-debug-message-if-parsing-the-address.patch => 0108-efi-net-Print-a-debug-message-if-parsing-the-address.patch (98%) rename 0125-kern-term-Also-accept-F8-as-a-user-interrupt-key.patch => 0109-kern-term-Also-accept-F8-as-a-user-interrupt-key.patch (96%) rename 0129-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch => 0110-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch (93%) rename 0130-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch => 0111-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch (95%) delete mode 100644 0111-Make-it-possible-to-subtract-conditions-from-debug.patch rename 0131-efi-dhcp-fix-some-allocation-error-checking.patch => 0112-efi-dhcp-fix-some-allocation-error-checking.patch (83%) rename 0132-efi-http-fix-some-allocation-error-checking.patch => 0113-efi-http-fix-some-allocation-error-checking.patch (84%) rename 0133-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch => 0114-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch (98%) rename 0137-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch => 0115-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch (97%) rename 0138-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch => 0116-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch (96%) rename 0139-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch => 0117-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch (97%) rename 0140-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch => 0118-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch (97%) rename 0141-Add-systemd-integration-scripts-to-make-systemctl-re.patch => 0119-Add-systemd-integration-scripts-to-make-systemctl-re.patch (91%) rename 0142-systemd-integration.sh-Also-set-old-menu_show_once-g.patch => 0120-systemd-integration.sh-Also-set-old-menu_show_once-g.patch (97%) rename 0143-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch => 0121-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch (93%) rename 0144-grub-install-disable-support-for-EFI-platforms.patch => 0122-grub-install-disable-support-for-EFI-platforms.patch (81%) rename 0145-New-with-debug-timestamps-configure-flag-to-prepend-.patch => 0123-New-with-debug-timestamps-configure-flag-to-prepend-.patch (84%) rename 0146-Added-debug-statements-to-grub_disk_open-and-grub_di.patch => 0124-Added-debug-statements-to-grub_disk_open-and-grub_di.patch (67%) rename 0147-Introduce-function-grub_debug_is_enabled-void-return.patch => 0125-Introduce-function-grub_debug_is_enabled-void-return.patch (87%) rename 0148-Don-t-clear-screen-when-debugging-is-enabled.patch => 0126-Don-t-clear-screen-when-debugging-is-enabled.patch (80%) rename 0150-grub_file_-instrumentation-new-file-debug-tag.patch => 0127-grub_file_-instrumentation-new-file-debug-tag.patch (83%) delete mode 100644 0127-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch rename 0151-ieee1275-Avoiding-many-unecessary-open-close.patch => 0128-ieee1275-Avoiding-many-unecessary-open-close.patch (94%) rename 0152-ieee1275-powerpc-implements-fibre-channel-discovery-.patch => 0129-ieee1275-powerpc-implements-fibre-channel-discovery-.patch (98%) rename 0153-ieee1275-powerpc-enables-device-mapper-discovery.patch => 0130-ieee1275-powerpc-enables-device-mapper-discovery.patch (98%) rename 0154-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch => 0131-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch (94%) rename 0155-Add-suport-for-signing-grub-with-an-appended-signatu.patch => 0132-Add-suport-for-signing-grub-with-an-appended-signatu.patch (86%) rename 0156-docs-grub-Document-signing-grub-under-UEFI.patch => 0133-docs-grub-Document-signing-grub-under-UEFI.patch (92%) rename 0157-docs-grub-Document-signing-grub-with-an-appended-sig.patch => 0134-docs-grub-Document-signing-grub-with-an-appended-sig.patch (95%) rename 0158-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch => 0135-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch (92%) rename 0159-pgp-factor-out-rsa_pad.patch => 0136-pgp-factor-out-rsa_pad.patch (97%) rename 0160-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch => 0137-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch (96%) rename 0161-posix_wrap-tweaks-in-preparation-for-libtasn1.patch => 0138-posix_wrap-tweaks-in-preparation-for-libtasn1.patch (89%) rename 0162-libtasn1-import-libtasn1-4.16.0.patch => 0139-libtasn1-import-libtasn1-4.16.0.patch (99%) rename 0163-libtasn1-disable-code-not-needed-in-grub.patch => 0140-libtasn1-disable-code-not-needed-in-grub.patch (97%) rename 0164-libtasn1-changes-for-grub-compatibility.patch => 0141-libtasn1-changes-for-grub-compatibility.patch (96%) rename 0165-libtasn1-compile-into-asn1-module.patch => 0142-libtasn1-compile-into-asn1-module.patch (94%) rename 0166-test_asn1-test-module-for-libtasn1.patch => 0143-test_asn1-test-module-for-libtasn1.patch (99%) rename 0167-grub-install-support-embedding-x509-certificates.patch => 0144-grub-install-support-embedding-x509-certificates.patch (90%) rename 0168-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch => 0145-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch (99%) rename 0169-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch => 0146-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch (99%) rename 0170-appended-signatures-support-verifying-appended-signa.patch => 0147-appended-signatures-support-verifying-appended-signa.patch (98%) rename 0171-appended-signatures-verification-tests.patch => 0148-appended-signatures-verification-tests.patch (99%) rename 0172-appended-signatures-documentation.patch => 0149-appended-signatures-documentation.patch (91%) delete mode 100644 0149-kern-file-Fix-error-handling-in-grub_file_open.patch rename 0173-ieee1275-enter-lockdown-based-on-ibm-secure-boot.patch => 0150-ieee1275-enter-lockdown-based-on-ibm-secure-boot.patch (84%) create mode 100644 0151-ieee1275-drop-HEAP_MAX_ADDR-HEAP_MIN_SIZE.patch rename 0175-appendedsig-x509-Also-handle-the-Extended-Key-Usage-.patch => 0152-appendedsig-x509-Also-handle-the-Extended-Key-Usage-.patch (99%) rename 0176-ieee1275-ofdisk-retry-on-open-failure.patch => 0153-ieee1275-ofdisk-retry-on-open-failure.patch (93%) rename 0178-efinet-Add-DHCP-proxy-support.patch => 0154-efinet-Add-DHCP-proxy-support.patch (80%) rename 0180-Don-t-update-the-cmdline-when-generating-legacy-menu.patch => 0155-Don-t-update-the-cmdline-when-generating-legacy-menu.patch (92%) rename 0181-Suppress-gettext-error-message.patch => 0156-Suppress-gettext-error-message.patch (96%) rename 0182-grub-set-password-Always-use-boot-grub2-user.cfg-as-.patch => 0157-grub-set-password-Always-use-boot-grub2-user.cfg-as-.patch (97%) rename 0186-normal-main-Discover-the-device-to-read-the-config-f.patch => 0158-normal-main-Discover-the-device-to-read-the-config-f.patch (98%) rename 0187-powerpc-adjust-setting-of-prefix-for-signed-binary-c.patch => 0159-powerpc-adjust-setting-of-prefix-for-signed-binary-c.patch (92%) rename 0190-powerpc-ieee1275-load-grub-at-4MB-not-2MB.patch => 0160-powerpc-ieee1275-load-grub-at-4MB-not-2MB.patch (97%) create mode 100644 0161-Add-Fedora-location-of-DejaVu-SANS-font.patch rename 0205-efi-new-connectefi-command.patch => 0162-efi-new-connectefi-command.patch (94%) rename 0210-powerpc-prefix-detection-support-device-names-with-c.patch => 0163-powerpc-prefix-detection-support-device-names-with-c.patch (98%) rename 0211-make-ofdisk_retries-optional.patch => 0164-make-ofdisk_retries-optional.patch (98%) rename 0246-misc-Make-grub_min-and-grub_max-more-resilient.patch => 0165-misc-Make-grub_min-and-grub_max-more-resilient.patch (94%) rename 0247-ReiserFS-switch-to-using-grub_min-grub_max.patch => 0166-ReiserFS-switch-to-using-grub_min-grub_max.patch (99%) rename 0248-misc-make-grub_boot_time-also-call-grub_dprintf-boot.patch => 0167-misc-make-grub_boot_time-also-call-grub_dprintf-boot.patch (76%) rename 0249-modules-make-.module_license-read-only.patch => 0168-modules-make-.module_license-read-only.patch (97%) rename 0250-modules-strip-.llvm_addrsig-sections-and-similar.patch => 0169-modules-strip-.llvm_addrsig-sections-and-similar.patch (97%) rename 0251-modules-Don-t-allocate-space-for-non-allocable-secti.patch => 0170-modules-Don-t-allocate-space-for-non-allocable-secti.patch (92%) rename 0254-modules-load-module-sections-at-page-aligned-address.patch => 0171-modules-load-module-sections-at-page-aligned-address.patch (90%) rename 0255-nx-add-memory-attribute-get-set-API.patch => 0172-nx-add-memory-attribute-get-set-API.patch (89%) rename 0256-nx-set-page-permissions-for-loaded-modules.patch => 0173-nx-set-page-permissions-for-loaded-modules.patch (81%) delete mode 100644 0174-ieee1275-drop-HEAP_MAX_ADDR-HEAP_MIN_SIZE.patch rename 0258-nx-set-the-nx-compatible-flag-in-EFI-grub-images.patch => 0174-nx-set-the-nx-compatible-flag-in-EFI-grub-images.patch (63%) rename 0260-grub_fs_probe-dprint-errors-from-filesystems.patch => 0175-grub_fs_probe-dprint-errors-from-filesystems.patch (89%) rename 0262-Make-debug-file-show-which-file-filters-get-run.patch => 0176-Make-debug-file-show-which-file-filters-get-run.patch (97%) rename 0267-BLS-create-etc-kernel-cmdline-during-mkconfig.patch => 0177-BLS-create-etc-kernel-cmdline-during-mkconfig.patch (92%) rename 0268-squish-don-t-dup-rhgb-quiet-check-mtimes.patch => 0178-squish-don-t-dup-rhgb-quiet-check-mtimes.patch (94%) delete mode 100644 0179-fs-ext2-Ignore-checksum-seed-incompat-feature.patch rename 0269-squish-give-up-on-rhgb-quiet.patch => 0179-squish-give-up-on-rhgb-quiet.patch (91%) rename 0270-squish-BLS-only-write-etc-kernel-cmdline-if-writable.patch => 0180-squish-BLS-only-write-etc-kernel-cmdline-if-writable.patch (96%) rename 0271-blscfg-Don-t-root-device-in-emu-builds.patch => 0181-blscfg-Don-t-root-device-in-emu-builds.patch (95%) rename 0309-ppc64le-signed-boot-media-changes.patch => 0182-ppc64le-signed-boot-media-changes.patch (92%) rename 0310-core-Fix-several-implicit-function-declarations.patch => 0183-core-Fix-several-implicit-function-declarations.patch (93%) delete mode 100644 0183-templates-Check-for-EFI-at-runtime-instead-of-config.patch delete mode 100644 0184-efi-Print-an-error-if-boot-to-firmware-setup-is-not-.patch create mode 100644 0184-ieee1275-request-memory-with-ibm-client-architecture.patch rename 0323-hostdisk-work-around-proc-not-reporting-size.patch => 0185-hostdisk-work-around-proc-not-reporting-size.patch (93%) rename 0324-blscfg-check-for-mounted-boot-in-emu.patch => 0186-blscfg-check-for-mounted-boot-in-emu.patch (99%) rename 0329-grub_dl_set_mem_attrs-fix-format-string.patch => 0187-grub_dl_set_mem_attrs-fix-format-string.patch (97%) delete mode 100644 0188-fs-xfs-Fix-unreadable-filesystem-with-v4-superblock.patch rename 0330-grub_dl_set_mem_attrs-add-self-check-for-the-tramp-G.patch => 0188-grub_dl_set_mem_attrs-add-self-check-for-the-tramp-G.patch (99%) delete mode 100644 0189-Print-module-name-on-license-check-failure.patch rename 0331-grub_dl_load_segments-page-align-the-tramp-GOT-areas.patch => 0189-grub_dl_load_segments-page-align-the-tramp-GOT-areas.patch (88%) rename 0332-emu-Add-switch-root-to-grub-emu.patch => 0190-emu-Add-switch-root-to-grub-emu.patch (98%) delete mode 100644 0191-grub-mkconfig-restore-umask-for-grub.cfg.patch rename 0333-util-Enable-default-kernel-for-updates.patch => 0191-util-Enable-default-kernel-for-updates.patch (97%) rename 0334-efi-http-change-uint32_t-to-uintn_t.patch => 0192-efi-http-change-uint32_t-to-uintn_t.patch (95%) delete mode 100644 0192-fs-btrfs-Use-full-btrfs-bootloader-area.patch delete mode 100644 0193-Add-Fedora-location-of-DejaVu-SANS-font.patch rename 0335-Add-Install-section-to-aux-systemd-units.patch => 0193-Add-Install-section-to-aux-systemd-units.patch (93%) rename 0337-Fix-missing-include-in-ofdisk.c.patch => 0194-Fix-missing-include-in-ofdisk.c.patch (95%) delete mode 100644 0194-normal-menu-Don-t-show-Booting-s-msg-when-auto-booti.patch delete mode 100644 0195-EFI-suppress-the-Welcome-to-GRUB-message-in-EFI-buil.patch rename 0348-add-flag-to-only-search-root-dev.patch => 0195-add-flag-to-only-search-root-dev.patch (88%) delete mode 100644 0196-EFI-console-Do-not-set-colorstate-until-the-first-te.patch create mode 100644 0196-cryptdisk-fix-incorrect-sign-comparison.patch delete mode 100644 0197-EFI-console-Do-not-set-cursor-until-the-first-text-o.patch create mode 100644 0197-grub-install-fix-a-sign-comparison-error.patch delete mode 100644 0198-Use-visual-indentation-in-config.h.in.patch create mode 100644 0198-grub-mount-work-around-bad-integer-comparison.patch delete mode 100644 0199-Where-present-ensure-config-util.h-precedes-config.h.patch create mode 100644 0199-power-Fix-use-after-free-in-get_slave_from_dm.patch delete mode 100644 0200-Drop-gnulib-fix-base64.patch.patch create mode 100644 0200-Fix-some-sign-comparison-errors.patch delete mode 100644 0201-Drop-gnulib-no-abort.patch.patch create mode 100644 0201-normal-Fix-a-discarded-const.patch delete mode 100644 0202-Update-gnulib-version-and-drop-most-gnulib-patches.patch create mode 100644 0202-at_keyboard-mark-grub_keyboard_controller_write-unus.patch create mode 100644 0203-Fix-another-minor-sign-comparison-error.patch delete mode 100644 0203-commands-search-Fix-bug-stopping-iteration-when-no-f.patch create mode 100644 0204-Track-explicit-module-dependencies-in-Makefile.core..patch delete mode 100644 0204-search-new-efidisk-only-option-on-EFI-systems.patch create mode 100644 0205-Revert-mm-Assert-that-we-preserve-header-vs-region-a.patch create mode 100644 0206-make-use-the-_CPU-variety-of-build-flags-for-PROGRAM.patch create mode 100644 0207-Work-around-extra_deps.lst-issue.patch delete mode 100644 0207-grub-core-loader-arm64-linux.c-do-not-validate-kerne.patch create mode 100644 0208-include-proper-attribute-for-an-EFI-API-call-definit.patch create mode 100644 0209-cast-grub_error-status-parameter.patch create mode 100644 0210-remove-unused-varible.patch create mode 100644 0211-cast-grub_net_bootp_packet-pointer.patch create mode 100644 0212-libtasn1-fix-string-overflow-warning.patch rename 0004-Add-support-for-Linux-EFI-stub-loading.patch => 0213-Add-support-for-Linux-EFI-stub-loading.patch (55%) delete mode 100644 0214-commands-boot-Add-API-to-pass-context-to-loader.patch create mode 100644 0214-fix-i386_pc-on-legacycfg-module.patch rename 0007-Add-secureboot-support-on-efi-chainloader.patch => 0215-Add-secureboot-support-on-efi-chainloader.patch (88%) rename 0008-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch => 0216-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch (66%) rename 0030-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch => 0217-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch (93%) rename 0065-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch => 0218-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch (79%) create mode 100644 0219-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch delete mode 100644 0219-kern-efi-sb-Reject-non-kernel-files-in-the-shim_lock.patch rename 0009-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch => 0220-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch (84%) delete mode 100644 0220-kern-file-Do-not-leak-device_name-on-error-in-grub_f.patch rename 0098-Try-to-pick-better-locations-for-kernel-and-initrd.patch => 0221-Try-to-pick-better-locations-for-kernel-and-initrd.patch (94%) delete mode 100644 0221-video-readers-png-Abort-sooner-if-a-read-operation-f.patch delete mode 100644 0222-video-readers-png-Refuse-to-handle-multiple-image-he.patch rename 0101-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch => 0222-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch (97%) delete mode 100644 0223-video-readers-png-Drop-greyscale-support-to-fix-heap.patch rename 0102-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch => 0223-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch (98%) delete mode 100644 0224-video-readers-png-Avoid-heap-OOB-R-W-inserting-huff-.patch rename 0103-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch => 0224-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch (90%) delete mode 100644 0225-video-readers-png-Sanity-check-some-huffman-codes.patch rename 0104-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch => 0225-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch (92%) rename 0126-efi-Set-image-base-address-before-jumping-to-the-PE-.patch => 0226-efi-Set-image-base-address-before-jumping-to-the-PE-.patch (78%) delete mode 100644 0226-video-readers-jpeg-Abort-sooner-if-a-read-operation-.patch delete mode 100644 0227-video-readers-jpeg-Do-not-reallocate-a-given-huff-ta.patch rename 0128-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch => 0227-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch (97%) rename 0134-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch => 0228-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch (97%) delete mode 100644 0228-video-readers-jpeg-Refuse-to-handle-multiple-start-o.patch rename 0135-linuxefi-fail-kernel-validation-without-shim-protoco.patch => 0229-linuxefi-fail-kernel-validation-without-shim-protoco.patch (69%) delete mode 100644 0229-video-readers-jpeg-Block-int-underflow-wild-pointer-.patch rename 0177-Allow-chainloading-EFI-apps-from-loop-mounts.patch => 0230-Allow-chainloading-EFI-apps-from-loop-mounts.patch (81%) delete mode 100644 0230-normal-charset-Fix-array-out-of-bounds-formatting-un.patch rename 0206-grub-core-loader-i386-efi-linux.c-do-not-validate-ke.patch => 0231-grub-core-loader-i386-efi-linux.c-do-not-validate-ke.patch (98%) delete mode 100644 0231-net-netbuff-Block-overly-large-netbuff-allocs.patch rename 0208-grub-core-loader-efi-chainloader.c-do-not-validate-c.patch => 0232-grub-core-loader-efi-chainloader.c-do-not-validate-c.patch (86%) delete mode 100644 0232-net-ip-Do-IP-fragment-maths-safely.patch rename 0209-grub-core-loader-efi-linux.c-drop-now-unused-grub_li.patch => 0233-grub-core-loader-efi-linux.c-drop-now-unused-grub_li.patch (83%) delete mode 100644 0233-net-dns-Fix-double-free-addresses-on-corrupt-DNS-res.patch rename 0212-loader-efi-chainloader-grub_load_and_start_image-doe.patch => 0234-loader-efi-chainloader-grub_load_and_start_image-doe.patch (87%) delete mode 100644 0234-net-dns-Don-t-read-past-the-end-of-the-string-we-re-.patch rename 0213-loader-efi-chainloader-simplify-the-loader-state.patch => 0235-loader-efi-chainloader-simplify-the-loader-state.patch (76%) delete mode 100644 0235-net-tftp-Prevent-a-UAF-and-double-free-from-a-failed.patch rename 0215-loader-efi-chainloader-Use-grub_loader_set_ex.patch => 0236-loader-efi-chainloader-Use-grub_loader_set_ex.patch (79%) delete mode 100644 0236-net-tftp-Avoid-a-trivial-UAF.patch rename 0216-loader-i386-efi-linux-Avoid-a-use-after-free-in-the-.patch => 0237-loader-i386-efi-linux-Avoid-a-use-after-free-in-the-.patch (93%) delete mode 100644 0237-net-http-Do-not-tear-down-socket-if-it-s-already-bee.patch rename 0217-loader-i386-efi-linux-Use-grub_loader_set_ex.patch => 0238-loader-i386-efi-linux-Use-grub_loader_set_ex.patch (94%) delete mode 100644 0238-net-http-Fix-OOB-write-for-split-http-headers.patch rename 0218-loader-i386-efi-linux-Fix-a-memory-leak-in-the-initr.patch => 0239-loader-i386-efi-linux-Fix-a-memory-leak-in-the-initr.patch (98%) delete mode 100644 0239-net-http-Error-out-on-headers-with-LF-without-CR.patch rename 0253-EFI-allocate-kernel-in-EFI_RUNTIME_SERVICES_CODE-ins.patch => 0240-EFI-allocate-kernel-in-EFI_RUNTIME_SERVICES_CODE-ins.patch (98%) delete mode 100644 0240-fs-f2fs-Do-not-read-past-the-end-of-nat-journal-entr.patch rename 0263-efi-use-enumerated-array-positions-for-our-allocatio.patch => 0241-efi-use-enumerated-array-positions-for-our-allocatio.patch (95%) delete mode 100644 0241-fs-f2fs-Do-not-read-past-the-end-of-nat-bitmap.patch rename 0264-efi-split-allocation-policy-for-kernel-vs-initrd-mem.patch => 0242-efi-split-allocation-policy-for-kernel-vs-initrd-mem.patch (94%) delete mode 100644 0242-fs-f2fs-Do-not-copy-file-names-that-are-too-long.patch rename 0265-efi-allocate-the-initrd-within-the-bounds-expressed-.patch => 0243-efi-allocate-the-initrd-within-the-bounds-expressed-.patch (90%) delete mode 100644 0243-fs-btrfs-Fix-several-fuzz-issues-with-invalid-dir-it.patch rename 0266-efi-use-EFI_LOADER_-CODE-DATA-for-kernel-and-initrd-.patch => 0244-efi-use-EFI_LOADER_-CODE-DATA-for-kernel-and-initrd-.patch (87%) delete mode 100644 0244-fs-btrfs-Fix-more-ASAN-and-SEGV-issues-found-with-fu.patch delete mode 100644 0245-fs-btrfs-Fix-more-fuzz-issues-related-to-chunks.patch rename 0275-x86-efi-Fix-an-incorrect-array-size-in-kernel-alloca.patch => 0245-x86-efi-Fix-an-incorrect-array-size-in-kernel-alloca.patch (97%) rename 0339-grub-install-on-EFI-if-forced.patch => 0246-grub-install-on-EFI-if-forced.patch (73%) rename 0340-Remove-Install-section-from-aux-systemd-units.patch => 0247-Remove-Install-section-from-aux-systemd-units.patch (93%) rename 0346-chainloader-remove-device-path-debug-message.patch => 0248-chainloader-remove-device-path-debug-message.patch (89%) rename 0356-grub-set-bootflag-Conservative-partial-fix-for-CVE-2.patch => 0249-grub-set-bootflag-Conservative-partial-fix-for-CVE-2.patch (99%) rename 0357-grub-set-bootflag-More-complete-fix-for-CVE-2024-104.patch => 0250-grub-set-bootflag-More-complete-fix-for-CVE-2024-104.patch (99%) rename 0358-grub-set-bootflag-Exit-calmly-when-not-running-as-ro.patch => 0251-grub-set-bootflag-Exit-calmly-when-not-running-as-ro.patch (96%) create mode 100644 0252-Makefile.core.def-fix-linux-module.patch create mode 100644 0253-Add-support-for-Linux-EFI-stub-loading-on-arm-archit.patch rename 0097-arm-arm64-loader-Better-memory-allocation-and-error-.patch => 0254-arm-arm64-loader-Better-memory-allocation-and-error-.patch (80%) rename 0185-arm64-Fix-EFI-loader-kernel-image-allocation.patch => 0255-arm64-Fix-EFI-loader-kernel-image-allocation.patch (67%) rename 0252-pe-add-the-DOS-header-struct-and-fix-some-bad-naming.patch => 0256-pe-add-the-DOS-header-struct-and-fix-some-bad-naming.patch (68%) rename 0273-Correct-BSS-zeroing-on-aarch64.patch => 0257-Correct-BSS-zeroing-on-aarch64.patch (76%) rename 0336-arm64-Use-proper-memory-type-for-kernel-allocation.patch => 0258-arm64-Use-proper-memory-type-for-kernel-allocation.patch (77%) delete mode 100644 0259-grub-probe-document-the-behavior-of-multiple-v.patch rename 0347-normal-Remove-grub_env_set-prefix-in-grub_try_normal.patch => 0259-normal-Remove-grub_env_set-prefix-in-grub_try_normal.patch (96%) create mode 100644 0260-fs-xfs-Handle-non-continuous-data-blocks-in-director.patch rename 0349-Ignore-warnings-for-incompatible-types.patch => 0261-Ignore-warnings-for-incompatible-types.patch (90%) delete mode 100644 0261-fs-fat-don-t-error-when-mtime-is-0.patch rename 0365-cmd-search-Rework-of-CVE-2023-4001-fix.patch => 0262-cmd-search-Rework-of-CVE-2023-4001-fix.patch (92%) create mode 100644 0263-loader-efi-linux.c-read-the-kernel-image-before-head.patch rename 0257-nx-set-attrs-in-our-kernel-loaders.patch => 0264-nx-set-attrs-in-our-kernel-loaders.patch (77%) create mode 100644 0265-efi-Provide-wrappers-for-load_image-start_image.patch create mode 100644 0266-efi-Disallow-fallback-to-legacy-Linux-loader-when-sh.patch create mode 100644 0267-Set-non-executable-stack-sections-on-EFI-assembly-fi.patch rename 0366-grub-mkconfig.in-turn-off-executable-owner-bit.patch => 0268-grub-mkconfig.in-turn-off-executable-owner-bit.patch (76%) create mode 100644 0269-kern-ieee1275-init-Add-IEEE-1275-Radix-support-for-K.patch rename 0351-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch => 0270-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch (95%) rename 0352-grub2-mkconfig-Simplify-os_name-detection.patch => 0271-grub2-mkconfig-Simplify-os_name-detection.patch (86%) rename 0353-grub-mkconfig-Remove-check-for-mount-point-for-grub-.patch => 0272-grub-mkconfig-Remove-check-for-mount-point-for-grub-.patch (95%) delete mode 100644 0272-loader-arm64-linux-Remove-magic-number-header-field-.patch create mode 100644 0273-efi-api.h-include-missing-__grub_efi_api-macros-on-E.patch create mode 100644 0274-grub-core-net-arp.c-fix-variable-name.patch create mode 100644 0275-load-EFI-commands-inside-test-expressions.patch delete mode 100644 0276-commands-efi-tpm-Refine-the-status-of-log-event.patch create mode 100644 0276-efi-loader-Check-if-NX-is-required-in-grub_efi_linux.patch create mode 100644 0277-Stop-grub.efi-from-always-printing-dynamic_load_symb.patch delete mode 100644 0277-commands-efi-tpm-Use-grub_strcpy-instead-of-grub_mem.patch delete mode 100644 0278-efi-tpm-Add-EFI_CC_MEASUREMENT_PROTOCOL-support.patch rename 0274-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch => 0278-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch (78%) delete mode 100644 0279-font-Reject-glyphs-exceeds-font-max_glyph_width-or-f.patch rename 0354-grub-mkconfig-dont-overwrite-BLS-cmdline-if-BLSCFG.patch => 0279-grub-mkconfig-dont-overwrite-BLS-cmdline-if-BLSCFG.patch (93%) delete mode 100644 0280-font-Fix-size-overflow-in-grub_font_get_glyph_intern.patch rename 0355-grub2-mkconfig-Pass-all-boot-params-when-used-by-ana.patch => 0280-grub2-mkconfig-Pass-all-boot-params-when-used-by-ana.patch (92%) delete mode 100644 0281-font-Fix-several-integer-overflows-in-grub_font_cons.patch delete mode 100644 0282-font-Remove-grub_font_dup_glyph.patch delete mode 100644 0283-font-Fix-integer-overflow-in-ensure_comb_space.patch delete mode 100644 0284-font-Fix-integer-overflow-in-BMP-index.patch delete mode 100644 0285-font-Fix-integer-underflow-in-binary-search-of-char-.patch delete mode 100644 0286-kern-efi-sb-Enforce-verification-of-font-files.patch delete mode 100644 0287-fbutil-Fix-integer-overflow.patch delete mode 100644 0288-font-Fix-an-integer-underflow-in-blit_comb.patch delete mode 100644 0289-font-Harden-grub_font_blit_glyph-and-grub_font_blit_.patch delete mode 100644 0290-font-Assign-null_font-to-glyphs-in-ascii_font_glyph.patch delete mode 100644 0291-normal-charset-Fix-an-integer-overflow-in-grub_unico.patch delete mode 100644 0292-font-Try-opening-fonts-from-the-bundled-memdisk.patch delete mode 100644 0293-mm-Clarify-grub_real_malloc.patch delete mode 100644 0294-mm-grub_real_malloc-Make-small-allocs-comment-match-.patch delete mode 100644 0295-mm-Document-grub_free.patch delete mode 100644 0296-mm-Document-grub_mm_init_region.patch delete mode 100644 0297-mm-Document-GRUB-internal-memory-management-structur.patch delete mode 100644 0298-mm-Assert-that-we-preserve-header-vs-region-alignmen.patch delete mode 100644 0299-mm-When-adding-a-region-merge-with-region-after-as-w.patch delete mode 100644 0300-mm-Debug-support-for-region-operations.patch delete mode 100644 0301-mm-Drop-unused-unloading-of-modules-on-OOM.patch delete mode 100644 0302-mm-Allow-dynamically-requesting-additional-memory-re.patch delete mode 100644 0303-kern-efi-mm-Always-request-a-fixed-number-of-pages-o.patch delete mode 100644 0304-kern-efi-mm-Extract-function-to-add-memory-regions.patch delete mode 100644 0305-kern-efi-mm-Pass-up-errors-from-add_memory_regions.patch delete mode 100644 0306-kern-efi-mm-Implement-runtime-addition-of-pages.patch delete mode 100644 0307-efi-Increase-default-memory-allocation-to-32-MiB.patch delete mode 100644 0308-mm-Try-invalidate-disk-caches-last-when-out-of-memor.patch delete mode 100644 0311-loader-Add-support-for-grub-emu-to-kexec-Linux-menu-.patch delete mode 100644 0312-powerpc-Drop-Open-Hack-Ware-remove-GRUB_IEEE1275_FLA.patch delete mode 100644 0313-ieee1275-request-memory-with-ibm-client-architecture.patch delete mode 100644 0314-ieee1275-drop-len-1-quirk-in-heap_init.patch delete mode 100644 0315-ieee1275-support-runtime-memory-claiming.patch delete mode 100644 0316-ieee1275-implement-vec5-for-cas-negotiation.patch delete mode 100644 0317-ibmvtpm-Add-support-for-trusted-boot-using-a-vTPM-2..patch delete mode 100644 0318-powerpc-Drop-Open-Hack-Ware.patch delete mode 100644 0319-osdep-linux-hostdisk-Modify-sector-by-sysfs-as-disk-.patch delete mode 100644 0320-mm-Adjust-new-region-size-to-take-management-overhea.patch delete mode 100644 0321-mm-Preallocate-some-space-when-adding-new-regions.patch delete mode 100644 0322-mm-Avoid-complex-heap-growth-math-in-hot-path.patch delete mode 100644 0325-emu-linux-work-around-systemctl-kexec-returning.patch delete mode 100644 0326-kern-ieee1275-init-Convert-plain-numbers-to-constant.patch delete mode 100644 0327-kern-ieee1275-init-Extended-support-in-Vec5.patch delete mode 100644 0328-tpm-Disable-the-tpm-verifier-if-the-TPM-device-is-no.patch delete mode 100644 0338-kern-ieee1275-init-ppc64-Restrict-high-memory-in-pre.patch delete mode 100644 0341-fs-Remove-trailing-whitespaces.patch delete mode 100644 0342-fs-xfs-Fix-memory-leaks-in-XFS-module.patch delete mode 100644 0343-fs-xfs-Fix-issues-found-while-fuzzing-the-XFS-filesy.patch delete mode 100644 0344-fs-xfs-Incorrect-short-form-directory-data-boundary-.patch delete mode 100644 0345-fs-xfs-Add-large-extent-counters-incompat-feature-su.patch delete mode 100644 0350-fs-xfs-Fix-XFS-directory-extent-parsing.patch delete mode 100644 0359-fs-ntfs-Fix-an-OOB-write-when-parsing-the-ATTRIBUTE_.patch delete mode 100644 0360-fs-ntfs-Fix-an-OOB-read-when-reading-data-from-the-r.patch delete mode 100644 0361-fs-ntfs-Fix-an-OOB-read-when-parsing-directory-entri.patch delete mode 100644 0362-fs-ntfs-Fix-an-OOB-read-when-parsing-bitmaps-for-ind.patch delete mode 100644 0363-fs-ntfs-Fix-an-OOB-read-when-parsing-a-volume-label.patch delete mode 100644 0364-fs-ntfs-Make-code-more-readable.patch diff --git a/0001-Revert-templates-Fix-user-facing-typo-with-an-incorr.patch b/0001-Revert-templates-Fix-user-facing-typo-with-an-incorr.patch index 4824aa1..5162165 100644 --- a/0001-Revert-templates-Fix-user-facing-typo-with-an-incorr.patch +++ b/0001-Revert-templates-Fix-user-facing-typo-with-an-incorr.patch @@ -10,7 +10,7 @@ This reverts commit 722737630889607c3b5761f1f5a48f1674cd2821. 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in -index 5984e92d29..9462248128 100644 +index 656301eaf22..376ca47efe4 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -36,7 +36,7 @@ if ! command -v os-prober > /dev/null || ! command -v linux-boot-prober > /dev/n diff --git a/0002-Revert-templates-Properly-disable-the-os-prober-by-d.patch b/0002-Revert-templates-Properly-disable-the-os-prober-by-d.patch index 05ac0f8..aa5a326 100644 --- a/0002-Revert-templates-Properly-disable-the-os-prober-by-d.patch +++ b/0002-Revert-templates-Properly-disable-the-os-prober-by-d.patch @@ -10,7 +10,7 @@ This reverts commit 54e0a1bbf1e9106901a557195bb35e5e20fb3925. 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index f8cbb8d7a2..d3e879b8e5 100644 +index 32c480daeb2..7516a015be0 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -140,9 +140,6 @@ GRUB_DEVICE_PARTUUID="`${grub_probe} --device ${GRUB_DEVICE} --target=partuuid 2 @@ -31,7 +31,7 @@ index f8cbb8d7a2..d3e879b8e5 100644 GRUB_FS \ GRUB_FONT \ GRUB_PRELOAD_MODULES \ -@@ -246,6 +242,7 @@ export GRUB_DEFAULT \ +@@ -250,6 +246,7 @@ export GRUB_DEFAULT \ GRUB_BACKGROUND \ GRUB_THEME \ GRUB_GFXPAYLOAD_LINUX \ @@ -40,7 +40,7 @@ index f8cbb8d7a2..d3e879b8e5 100644 GRUB_SAVEDEFAULT \ GRUB_ENABLE_CRYPTODISK \ diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in -index 9462248128..80685b15f4 100644 +index 376ca47efe4..30f27f15b83 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -26,8 +26,8 @@ export TEXTDOMAINDIR="@localedir@" diff --git a/0003-Revert-templates-Disable-the-os-prober-by-default.patch b/0003-Revert-templates-Disable-the-os-prober-by-default.patch index 9492795..a51779d 100644 --- a/0003-Revert-templates-Disable-the-os-prober-by-default.patch +++ b/0003-Revert-templates-Disable-the-os-prober-by-default.patch @@ -10,10 +10,10 @@ This reverts commit e346414725a70e5c74ee87ca14e580c66f517666. 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi -index f8b4b3b21a..69f08d289f 100644 +index a225f9a88d2..974bc0ddb07 100644 --- a/docs/grub.texi +++ b/docs/grub.texi -@@ -1519,13 +1519,10 @@ boot sequence. If you have problems, set this option to @samp{text} and +@@ -1552,13 +1552,10 @@ boot sequence. If you have problems, set this option to @samp{text} and GRUB will tell Linux to boot in normal text mode. @item GRUB_DISABLE_OS_PROBER @@ -31,7 +31,7 @@ index f8b4b3b21a..69f08d289f 100644 @item GRUB_OS_PROBER_SKIP_LIST List of space-separated FS UUIDs of filesystems to be ignored from os-prober -@@ -1853,9 +1850,10 @@ than zero; otherwise 0. +@@ -1889,9 +1886,10 @@ than zero; otherwise 0. @section Multi-boot manual config Currently autogenerating config files for multi-boot environments depends on @@ -46,7 +46,7 @@ index f8b4b3b21a..69f08d289f 100644 First create a separate GRUB partition, big enough to hold GRUB. Some of the following entries show how to load OS installer images from this same partition, diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in -index 80685b15f4..1b91c102f3 100644 +index 30f27f15b83..f300e46fc6a 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -26,8 +26,7 @@ export TEXTDOMAINDIR="@localedir@" diff --git a/0005-Rework-linux-command.patch b/0004-Rework-linux-command.patch similarity index 86% rename from 0005-Rework-linux-command.patch rename to 0004-Rework-linux-command.patch index 694e423..26d10ac 100644 --- a/0005-Rework-linux-command.patch +++ b/0004-Rework-linux-command.patch @@ -13,10 +13,10 @@ Signed-off-by: Matthew Garrett 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index 9f74a96b19..dccf3bb300 100644 +index 977757f2cc9..10f967f2563 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c -@@ -649,13 +649,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -661,13 +661,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), { grub_file_t file = 0; struct linux_i386_kernel_header lh; @@ -33,7 +33,7 @@ index 9f74a96b19..dccf3bb300 100644 grub_dl_ref (my_mod); -@@ -669,7 +671,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -681,7 +683,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (! file) goto fail; @@ -50,7 +50,7 @@ index 9f74a96b19..dccf3bb300 100644 { if (!grub_errno) grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -@@ -677,6 +687,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -689,6 +699,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } @@ -60,7 +60,7 @@ index 9f74a96b19..dccf3bb300 100644 if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) { grub_error (GRUB_ERR_BAD_OS, "invalid magic number"); -@@ -784,13 +797,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -796,13 +809,11 @@ 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); @@ -78,7 +78,7 @@ index 9f74a96b19..dccf3bb300 100644 } linux_params.code32_start = prot_mode_target + lh.code32_start - GRUB_LINUX_BZIMAGE_ADDR; -@@ -853,7 +864,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -865,7 +876,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), /* The other parameters are filled when booting. */ @@ -87,7 +87,7 @@ index 9f74a96b19..dccf3bb300 100644 grub_dprintf ("linux", "bzImage, setup=0x%x, size=0x%x\n", (unsigned) real_size, (unsigned) prot_size); -@@ -1007,9 +1018,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -1019,9 +1030,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), } len = prot_file_size; @@ -98,7 +98,7 @@ index 9f74a96b19..dccf3bb300 100644 if (grub_errno == GRUB_ERR_NONE) { -@@ -1020,6 +1029,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -1032,6 +1041,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), fail: diff --git a/0006-Rework-linux16-command.patch b/0005-Rework-linux16-command.patch similarity index 98% rename from 0006-Rework-linux16-command.patch rename to 0005-Rework-linux16-command.patch index 5adaaba..50a648c 100644 --- a/0006-Rework-linux16-command.patch +++ b/0005-Rework-linux16-command.patch @@ -13,7 +13,7 @@ Signed-off-by: Matthew Garrett 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 8be4c3b3f4..4b1750e360 100644 +index 4adeee9ae00..600530a742b 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -124,13 +124,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), diff --git a/0010-re-write-.gitignore.patch b/0006-re-write-.gitignore.patch similarity index 94% rename from 0010-re-write-.gitignore.patch rename to 0006-re-write-.gitignore.patch index b6fa0be..36b0efd 100644 --- a/0010-re-write-.gitignore.patch +++ b/0006-re-write-.gitignore.patch @@ -20,10 +20,10 @@ Subject: [PATCH] re-write .gitignore create mode 100644 util/bash-completion.d/.gitignore diff --git a/.gitignore b/.gitignore -index f6a1bd0517..208d1d2325 100644 +index 4d0dfb700e4..a18787dcfe6 100644 --- a/.gitignore +++ b/.gitignore -@@ -275,3 +275,153 @@ widthspec.bin +@@ -279,3 +279,153 @@ widthspec.bin /xfs_test /xzcompress_test /zfs_test @@ -179,7 +179,7 @@ index f6a1bd0517..208d1d2325 100644 +/widthspec.h diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 -index 0000000000..e1d849ef95 +index 00000000000..e1d849ef95b --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,5 @@ @@ -190,7 +190,7 @@ index 0000000000..e1d849ef95 +/version*.texi diff --git a/grub-core/.gitignore b/grub-core/.gitignore new file mode 100644 -index 0000000000..2acce28115 +index 00000000000..2acce281159 --- /dev/null +++ b/grub-core/.gitignore @@ -0,0 +1,16 @@ @@ -212,14 +212,14 @@ index 0000000000..2acce28115 +/trigtables.c diff --git a/grub-core/lib/.gitignore b/grub-core/lib/.gitignore new file mode 100644 -index 0000000000..6815459140 +index 00000000000..68154591404 --- /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 0000000000..8fbf564624 +index 00000000000..8fbf5646246 --- /dev/null +++ b/include/grub/gcrypt/.gitignore @@ -0,0 +1,2 @@ @@ -227,7 +227,7 @@ index 0000000000..8fbf564624 +gcrypt.h diff --git a/po/.gitignore b/po/.gitignore new file mode 100644 -index 0000000000..f507e7741e +index 00000000000..f507e7741e3 --- /dev/null +++ b/po/.gitignore @@ -0,0 +1,5 @@ @@ -238,7 +238,7 @@ index 0000000000..f507e7741e +/stamp-po diff --git a/util/bash-completion.d/.gitignore b/util/bash-completion.d/.gitignore new file mode 100644 -index 0000000000..6813a527ad +index 00000000000..6813a527ad3 --- /dev/null +++ b/util/bash-completion.d/.gitignore @@ -0,0 +1,2 @@ diff --git a/0011-IBM-client-architecture-CAS-reboot-support.patch b/0007-IBM-client-architecture-CAS-reboot-support.patch similarity index 96% rename from 0011-IBM-client-architecture-CAS-reboot-support.patch rename to 0007-IBM-client-architecture-CAS-reboot-support.patch index 316b9eb..4475534 100644 --- a/0011-IBM-client-architecture-CAS-reboot-support.patch +++ b/0007-IBM-client-architecture-CAS-reboot-support.patch @@ -29,7 +29,7 @@ Signed-off-by: Robbie Harwood 4 files changed, 91 insertions(+) diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c -index 4d493ab766..3a6689abb1 100644 +index 11b2beb2ff2..e2ecc65d2d8 100644 --- a/grub-core/kern/ieee1275/openfw.c +++ b/grub-core/kern/ieee1275/openfw.c @@ -591,3 +591,66 @@ grub_ieee1275_get_boot_dev (void) @@ -100,7 +100,7 @@ index 4d493ab766..3a6689abb1 100644 + return 0; +} diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index c4ebe9e22a..70614de156 100644 +index bd44310005d..d3f53d93d87 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -34,6 +34,9 @@ @@ -137,7 +137,7 @@ index c4ebe9e22a..70614de156 100644 grub_errno = GRUB_ERR_NONE; } diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index 25158407dd..ad80399246 100644 +index 14ff09094f0..dab8fd2aeb0 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c @@ -28,6 +28,9 @@ @@ -162,10 +162,10 @@ index 25158407dd..ad80399246 100644 { char *line; diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h -index 73e2f46447..0a599607f3 100644 +index dddb385149e..4f6e6aaa098 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h -@@ -254,6 +254,8 @@ int EXPORT_FUNC(grub_ieee1275_devalias_next) (struct grub_ieee1275_devalias *ali +@@ -251,6 +251,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); diff --git a/0012-for-ppc-reset-console-display-attr-when-clear-screen.patch b/0008-for-ppc-reset-console-display-attr-when-clear-screen.patch similarity index 97% rename from 0012-for-ppc-reset-console-display-attr-when-clear-screen.patch rename to 0008-for-ppc-reset-console-display-attr-when-clear-screen.patch index 121af84..6335939 100644 --- a/0012-for-ppc-reset-console-display-attr-when-clear-screen.patch +++ b/0008-for-ppc-reset-console-display-attr-when-clear-screen.patch @@ -17,7 +17,7 @@ Signed-off-by: Robbie Harwood 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c -index 85ecf06b4d..05c88dcf49 100644 +index 4e534c683eb..3dbe88e8933 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, diff --git a/0013-Disable-GRUB-video-support-for-IBM-power-machines.patch b/0009-Disable-GRUB-video-support-for-IBM-power-machines.patch similarity index 85% rename from 0013-Disable-GRUB-video-support-for-IBM-power-machines.patch rename to 0009-Disable-GRUB-video-support-for-IBM-power-machines.patch index 917943f..d55e7d0 100644 --- a/0013-Disable-GRUB-video-support-for-IBM-power-machines.patch +++ b/0009-Disable-GRUB-video-support-for-IBM-power-machines.patch @@ -15,10 +15,10 @@ Signed-off-by: Robbie Harwood 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c -index 20cbbd761e..04df9d2c66 100644 +index e74de32483f..810a089a934 100644 --- a/grub-core/kern/ieee1275/cmain.c +++ b/grub-core/kern/ieee1275/cmain.c -@@ -90,7 +90,10 @@ grub_ieee1275_find_options (void) +@@ -89,7 +89,10 @@ grub_ieee1275_find_options (void) } if (rc >= 0 && grub_strncmp (tmp, "IBM", 3) == 0) @@ -31,10 +31,10 @@ index 20cbbd761e..04df9d2c66 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 17a3dbbb57..b8e4b3feb3 100644 +index ca3d3c3b2c8..5592e4bb7c9 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 = +@@ -351,9 +351,12 @@ static struct grub_video_adapter grub_video_ieee1275_adapter = GRUB_MOD_INIT(ieee1275_fb) { @@ -51,14 +51,14 @@ index 17a3dbbb57..b8e4b3feb3 100644 GRUB_MOD_FINI(ieee1275_fb) diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h -index 0a599607f3..b5a1d49bbc 100644 +index 4f6e6aaa098..db0ec5f4c68 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h -@@ -148,6 +148,8 @@ enum grub_ieee1275_flag - GRUB_IEEE1275_FLAG_CURSORONOFF_ANSI_BROKEN, +@@ -145,6 +145,8 @@ enum grub_ieee1275_flag + GRUB_IEEE1275_FLAG_POWER_VM, - GRUB_IEEE1275_FLAG_RAW_DEVNAMES, -+ + GRUB_IEEE1275_FLAG_POWER_KVM, ++ + GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT }; diff --git a/0014-Move-bash-completion-script-922997.patch b/0010-Move-bash-completion-script-922997.patch similarity index 89% rename from 0014-Move-bash-completion-script-922997.patch rename to 0010-Move-bash-completion-script-922997.patch index a84d66e..113f8b0 100644 --- a/0014-Move-bash-completion-script-922997.patch +++ b/0010-Move-bash-completion-script-922997.patch @@ -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 7517fc49d9..8331f95b64 100644 +index cd667a2eb75..ae3a49321ad 100644 --- a/configure.ac +++ b/configure.ac -@@ -314,6 +314,14 @@ AC_SUBST(grubdirname) +@@ -319,6 +319,14 @@ AC_SUBST(grubdirname) AC_DEFINE_UNQUOTED(GRUB_DIR_NAME, "$grubdirname", [Default grub directory name]) @@ -28,7 +28,7 @@ index 7517fc49d9..8331f95b64 100644 # # Checks for build programs. # -@@ -525,6 +533,9 @@ HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags" +@@ -534,6 +542,9 @@ HOST_CFLAGS="$HOST_CFLAGS $grub_cv_cc_w_extra_flags" # Check for target programs. # @@ -39,7 +39,7 @@ index 7517fc49d9..8331f95b64 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 136287cf1b..61108f0542 100644 +index 136287cf1bf..61108f05429 100644 --- a/util/bash-completion.d/Makefile.am +++ b/util/bash-completion.d/Makefile.am @@ -6,7 +6,6 @@ EXTRA_DIST = $(bash_completion_source) diff --git a/0015-Allow-fallback-to-include-entries-by-title-not-just-.patch b/0011-Allow-fallback-to-include-entries-by-title-not-just-.patch similarity index 98% rename from 0015-Allow-fallback-to-include-entries-by-title-not-just-.patch rename to 0011-Allow-fallback-to-include-entries-by-title-not-just-.patch index 6450a54..b85e5e6 100644 --- a/0015-Allow-fallback-to-include-entries-by-title-not-just-.patch +++ b/0011-Allow-fallback-to-include-entries-by-title-not-just-.patch @@ -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 8397886fa0..d7a222e681 100644 +index 6a90e091f22..6444ee6f969 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -163,15 +163,40 @@ grub_menu_set_timeout (int timeout) diff --git a/0016-Make-exit-take-a-return-code.patch b/0012-Make-exit-take-a-return-code.patch similarity index 82% rename from 0016-Make-exit-take-a-return-code.patch rename to 0012-Make-exit-take-a-return-code.patch index 654ef73..87e03ad 100644 --- a/0016-Make-exit-take-a-return-code.patch +++ b/0012-Make-exit-take-a-return-code.patch @@ -13,7 +13,7 @@ Signed-off-by: Peter Jones grub-core/commands/minicmd.c | 20 ++++++++++++++++---- grub-core/kern/efi/efi.c | 9 +++++++-- grub-core/kern/emu/main.c | 2 +- - grub-core/kern/emu/misc.c | 5 +++-- + grub-core/kern/emu/misc.c | 9 +++++---- grub-core/kern/i386/coreboot/init.c | 2 +- grub-core/kern/i386/qemu/init.c | 2 +- grub-core/kern/ieee1275/init.c | 2 +- @@ -24,10 +24,10 @@ Signed-off-by: Peter Jones grub-core/kern/uboot/init.c | 6 +++--- grub-core/kern/xen/init.c | 2 +- include/grub/misc.h | 2 +- - 14 files changed, 48 insertions(+), 21 deletions(-) + 14 files changed, 50 insertions(+), 23 deletions(-) diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c -index fa498931ed..2bd3ac76f2 100644 +index fa498931ed2..2bd3ac76f2d 100644 --- a/grub-core/commands/minicmd.c +++ b/grub-core/commands/minicmd.c @@ -182,12 +182,24 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)), @@ -60,10 +60,10 @@ index fa498931ed..2bd3ac76f2 100644 } diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 8cff7be028..05d8237a9b 100644 +index b93ae3aba12..885d7c6420e 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -165,11 +165,16 @@ grub_reboot (void) +@@ -175,11 +175,16 @@ grub_reboot (void) } void @@ -76,14 +76,14 @@ index 8cff7be028..05d8237a9b 100644 + rc = GRUB_EFI_SUCCESS; + grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); - efi_call_4 (grub_efi_system_table->boot_services->exit, -- grub_efi_image_handle, GRUB_EFI_SUCCESS, 0, 0); -+ grub_efi_image_handle, rc, 0, 0); + grub_efi_system_table->boot_services->exit (grub_efi_image_handle, +- GRUB_EFI_SUCCESS, 0, 0); ++ rc, 0, 0); for (;;) ; } diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c -index 425bb96034..55ea5a11cc 100644 +index 855b11c3dec..38c1576a2ef 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,19 @@ index 425bb96034..55ea5a11cc 100644 grub_reboot (); } diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c -index dfd8a8ec48..0ff13bcaf8 100644 +index 521220b49d2..16c79bc9488 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c -@@ -151,9 +151,10 @@ xasprintf (const char *fmt, ...) +@@ -83,7 +83,7 @@ grub_util_error (const char *fmt, ...) + vfprintf (stderr, fmt, ap); + va_end (ap); + fprintf (stderr, ".\n"); +- grub_exit (); ++ grub_exit (1); + } + + void * +@@ -152,12 +152,13 @@ xasprintf (const char *fmt, ...) #if !defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL) void @@ -107,13 +116,17 @@ index dfd8a8ec48..0ff13bcaf8 100644 +__attribute__ ((noreturn)) +grub_exit (int rc) { +-#if defined (GRUB_KERNEL) ++#if defined (GRUB_KERNEL) && !defined (GRUB_MACHINE_EFI) + grub_reboot (); + #endif - exit (1); + exit (rc < 0 ? 1 : rc); } #endif diff --git a/grub-core/kern/i386/coreboot/init.c b/grub-core/kern/i386/coreboot/init.c -index 3314f027fe..36f9134b7b 100644 +index 4fae8b571f1..feaf9295e30 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 +139,7 @@ index 3314f027fe..36f9134b7b 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 271b6fbfab..9fafe98f01 100644 +index 08f81d25e68..604fc94b5a0 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,11 +152,11 @@ index 271b6fbfab..9fafe98f01 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 d483e35eed..e71d158416 100644 +index fb7d1a3bacf..50c65b2f6e5 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c -@@ -71,7 +71,7 @@ grub_addr_t grub_ieee1275_original_stack; - #endif +@@ -114,7 +114,7 @@ grub_addr_t grub_ieee1275_original_stack; + #define BYTE22 (DY_MEM_V2 | DRC_INFO) void -grub_exit (void) @@ -152,7 +165,7 @@ index d483e35eed..e71d158416 100644 grub_ieee1275_exit (); } diff --git a/grub-core/kern/mips/arc/init.c b/grub-core/kern/mips/arc/init.c -index 2ed3ff3191..5c40c34078 100644 +index 2ed3ff3191e..5c40c34078d 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 +178,7 @@ index 2ed3ff3191..5c40c34078 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 7b96531b98..dff598ca7b 100644 +index 5bd721260f6..97b09b0eeea 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 +191,7 @@ index 7b96531b98..dff598ca7b 100644 grub_halt (); } diff --git a/grub-core/kern/mips/qemu_mips/init.c b/grub-core/kern/mips/qemu_mips/init.c -index be88b77d22..8b6c55ffc0 100644 +index b5477b87ffa..69488a34e7c 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 +204,10 @@ index be88b77d22..8b6c55ffc0 100644 grub_halt (); } diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 3af336ee22..63b586d09c 100644 +index 7cee5d75c3c..11037dc0227 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -1209,9 +1209,18 @@ grub_abort (void) +@@ -1311,9 +1311,18 @@ grub_abort (void) grub_getkey (); } @@ -215,7 +228,7 @@ index 3af336ee22..63b586d09c 100644 grub_fatal (const char *fmt, ...) { diff --git a/grub-core/kern/uboot/init.c b/grub-core/kern/uboot/init.c -index 3e338645c5..be2a5be1d0 100644 +index 3e338645c57..be2a5be1d07 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; @@ -240,7 +253,7 @@ index 3e338645c5..be2a5be1d0 100644 else if (ver > API_SIG_VERSION) { diff --git a/grub-core/kern/xen/init.c b/grub-core/kern/xen/init.c -index 782ca72952..708b060f32 100644 +index 782ca72952a..708b060f324 100644 --- a/grub-core/kern/xen/init.c +++ b/grub-core/kern/xen/init.c @@ -584,7 +584,7 @@ grub_machine_init (void) @@ -253,15 +266,15 @@ index 782ca72952..708b060f32 100644 struct sched_shutdown arg; diff --git a/include/grub/misc.h b/include/grub/misc.h -index 7d2b551969..fd18e6320b 100644 +index 1b35a167fde..72aff15750d 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h -@@ -353,7 +353,7 @@ int EXPORT_FUNC(grub_vsnprintf) (char *str, grub_size_t n, const char *fmt, - char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...) +@@ -385,7 +385,7 @@ char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))) WARN_UNUSED_RESULT; char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args) WARN_UNUSED_RESULT; + -void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn)); +void EXPORT_FUNC(grub_exit) (int rc) __attribute__ ((noreturn)); + void EXPORT_FUNC(grub_abort) (void) __attribute__ ((noreturn)); grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, grub_uint64_t d, - grub_uint64_t *r); diff --git a/0017-Make-efi-machines-load-an-env-block-from-a-variable.patch b/0013-Make-efi-machines-load-an-env-block-from-a-variable.patch similarity index 71% rename from 0017-Make-efi-machines-load-an-env-block-from-a-variable.patch rename to 0013-Make-efi-machines-load-an-env-block-from-a-variable.patch index ecfab5a..9355298 100644 --- a/0017-Make-efi-machines-load-an-env-block-from-a-variable.patch +++ b/0013-Make-efi-machines-load-an-env-block-from-a-variable.patch @@ -6,14 +6,14 @@ Subject: [PATCH] Make efi machines load an env block from a variable Signed-off-by: Peter Jones --- grub-core/Makefile.core.def | 1 + - grub-core/kern/efi/init.c | 36 +++++++++++++++++++++++++++++++++++- - 2 files changed, 36 insertions(+), 1 deletion(-) + grub-core/kern/efi/init.c | 34 ++++++++++++++++++++++++++++++++++ + 2 files changed, 35 insertions(+) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 45d3edaa4d..c865a08b02 100644 +index 1571421d7e8..0bffbfea917 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -207,6 +207,7 @@ kernel = { +@@ -219,6 +219,7 @@ kernel = { efi = kern/efi/acpi.c; efi = kern/efi/sb.c; efi = kern/lockdown.c; @@ -22,10 +22,10 @@ index 45d3edaa4d..c865a08b02 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 7facacf09c..6d39bd3ad2 100644 +index 6c54af6e79e..b5201974a76 100644 --- a/grub-core/kern/efi/init.c +++ b/grub-core/kern/efi/init.c -@@ -27,8 +27,11 @@ +@@ -28,8 +28,11 @@ #include #include #include @@ -36,8 +36,8 @@ index 7facacf09c..6d39bd3ad2 100644 + #ifdef GRUB_STACK_PROTECTOR - static grub_efi_guid_t rng_protocol_guid = GRUB_EFI_RNG_PROTOCOL_GUID; -@@ -82,6 +85,36 @@ stack_protector_init (void) + static grub_efi_char16_t stack_chk_fail_msg[] = +@@ -103,6 +106,36 @@ stack_protector_init (void) grub_addr_t grub_modbase; @@ -58,7 +58,7 @@ index 7facacf09c..6d39bd3ad2 100644 +static void +grub_efi_env_init (void) +{ -+ grub_efi_guid_t efi_grub_guid = GRUB_EFI_GRUB_VARIABLE_GUID; ++ grub_guid_t efi_grub_guid = GRUB_EFI_GRUB_VARIABLE_GUID; + struct grub_envblk envblk_s = { NULL, 0 }; + grub_envblk_t envblk = &envblk_s; + @@ -71,19 +71,14 @@ index 7facacf09c..6d39bd3ad2 100644 + grub_free (envblk_s.buf); +} + - void + __attribute__ ((__optimize__ ("-fno-stack-protector"))) void grub_efi_init (void) { -@@ -108,10 +141,11 @@ grub_efi_init (void) - efi_call_4 (grub_efi_system_table->boot_services->set_watchdog_timer, - 0, 0, 0, NULL); +@@ -128,6 +161,7 @@ grub_efi_init (void) + + grub_efi_system_table->boot_services->set_watchdog_timer (0, 0, 0, NULL); + grub_efi_env_init (); grub_efidisk_init (); - } - --void (*grub_efi_net_config) (grub_efi_handle_t hnd, -+void (*grub_efi_net_config) (grub_efi_handle_t hnd, - char **device, - char **path); + grub_efi_register_debug_commands (); diff --git a/0018-Migrate-PPC-from-Yaboot-to-Grub2.patch b/0014-Migrate-PPC-from-Yaboot-to-Grub2.patch similarity index 96% rename from 0018-Migrate-PPC-from-Yaboot-to-Grub2.patch rename to 0014-Migrate-PPC-from-Yaboot-to-Grub2.patch index 1e310e9..1ff254c 100644 --- a/0018-Migrate-PPC-from-Yaboot-to-Grub2.patch +++ b/0014-Migrate-PPC-from-Yaboot-to-Grub2.patch @@ -15,11 +15,11 @@ Signed-off-by: Robbie Harwood create mode 100644 util/grub.d/20_ppc_terminfo.in diff --git a/Makefile.util.def b/Makefile.util.def -index f8b356cc1f..2c9b283a23 100644 +index 9432365a9df..09bfcadd976 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -508,6 +508,13 @@ script = { - condition = COND_HOST_LINUX; +@@ -517,6 +517,13 @@ script = { + installdir = grubconf; }; +script = { @@ -34,7 +34,7 @@ index f8b356cc1f..2c9b283a23 100644 common = util/grub.d/30_os-prober.in; diff --git a/util/grub.d/20_ppc_terminfo.in b/util/grub.d/20_ppc_terminfo.in new file mode 100644 -index 0000000000..10d6658682 +index 00000000000..10d66586820 --- /dev/null +++ b/util/grub.d/20_ppc_terminfo.in @@ -0,0 +1,114 @@ diff --git a/0019-Add-fw_path-variable-revised.patch b/0015-Add-fw_path-variable-revised.patch similarity index 96% rename from 0019-Add-fw_path-variable-revised.patch rename to 0015-Add-fw_path-variable-revised.patch index 804938b..4012f3f 100644 --- a/0019-Add-fw_path-variable-revised.patch +++ b/0015-Add-fw_path-variable-revised.patch @@ -17,7 +17,7 @@ Signed-off-by: Robbie Harwood 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index 73967e2f5b..d1de9fa687 100644 +index 731c07c2901..463dafdba02 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c @@ -128,16 +128,15 @@ grub_set_prefix_and_root (void) @@ -44,7 +44,7 @@ index 73967e2f5b..d1de9fa687 100644 } diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 70614de156..62571e6dfc 100644 +index d3f53d93d87..08f48c71df1 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -339,7 +339,30 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), diff --git a/0020-Pass-x-hex-hex-straight-through-unmolested.patch b/0016-Pass-x-hex-hex-straight-through-unmolested.patch similarity index 97% rename from 0020-Pass-x-hex-hex-straight-through-unmolested.patch rename to 0016-Pass-x-hex-hex-straight-through-unmolested.patch index c2623ac..e1aa1af 100644 --- a/0020-Pass-x-hex-hex-straight-through-unmolested.patch +++ b/0016-Pass-x-hex-hex-straight-through-unmolested.patch @@ -13,7 +13,7 @@ Signed-off-by: Peter Jones 3 files changed, 75 insertions(+), 9 deletions(-) diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c -index cc3290311f..8f67a4be7f 100644 +index ed65865050a..5455242c352 100644 --- a/grub-core/commands/wildcard.c +++ b/grub-core/commands/wildcard.c @@ -488,6 +488,12 @@ check_file (const char *dir, const char *basename) @@ -47,7 +47,7 @@ index cc3290311f..8f67a4be7f 100644 *optr++ = iptr[1]; iptr += 2; diff --git a/grub-core/lib/cmdline.c b/grub-core/lib/cmdline.c -index ed0b149dca..8e2294d8ff 100644 +index ed0b149dca5..8e2294d8ff6 100644 --- a/grub-core/lib/cmdline.c +++ b/grub-core/lib/cmdline.c @@ -20,6 +20,12 @@ @@ -97,7 +97,7 @@ index ed0b149dca..8e2294d8ff 100644 *buf++ = *c; diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c -index ad80399246..0c6dd9c520 100644 +index dab8fd2aeb0..c19b4bf700e 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c @@ -56,6 +56,12 @@ static struct grub_script_scope *scope = 0; diff --git a/0021-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch b/0017-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch similarity index 98% rename from 0021-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch rename to 0017-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch index c452b5f..56582e5 100644 --- a/0021-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch +++ b/0017-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch @@ -28,10 +28,10 @@ Signed-off-by: Will Thompson create mode 100644 grub-core/commands/loadenv.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index c865a08b02..c15e91943b 100644 +index 0bffbfea917..47c0fc755a2 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -814,6 +814,16 @@ module = { +@@ -842,6 +842,16 @@ module = { common = commands/blocklist.c; }; @@ -48,7 +48,7 @@ index c865a08b02..c15e91943b 100644 module = { name = boot; common = commands/boot.c; -@@ -980,6 +990,7 @@ module = { +@@ -1009,6 +1019,7 @@ module = { module = { name = loadenv; common = commands/loadenv.c; @@ -58,7 +58,7 @@ index c865a08b02..c15e91943b 100644 diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c new file mode 100644 -index 0000000000..e907a6a5d2 +index 00000000000..e907a6a5d28 --- /dev/null +++ b/grub-core/commands/blscfg.c @@ -0,0 +1,1177 @@ @@ -1240,7 +1240,7 @@ index 0000000000..e907a6a5d2 + grub_unregister_extcmd (oldcmd); +} diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c -index cc5971f4db..782761c31a 100644 +index e9e9d94eff5..2c5d1a0ef9a 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -143,7 +143,7 @@ legacy_file (const char *filename) @@ -1263,7 +1263,7 @@ index cc5971f4db..782761c31a 100644 } diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c -index 3fd664aac3..163b9a0904 100644 +index 16644584978..dfcb19e0ff8 100644 --- a/grub-core/commands/loadenv.c +++ b/grub-core/commands/loadenv.c @@ -28,6 +28,8 @@ @@ -1358,7 +1358,7 @@ index 3fd664aac3..163b9a0904 100644 grub_cmd_load_env (grub_extcmd_context_t ctxt, int argc, char **args) { diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c -index 720e6d8ea3..b194123eb6 100644 +index 720e6d8ea3b..b194123eb67 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, @@ -1430,7 +1430,7 @@ index 720e6d8ea3..b194123eb6 100644 src[len - 1] = ch; args[argc - 1] = src; diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 62571e6dfc..7ca2e5400b 100644 +index 08f48c71df1..1317279c081 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -21,6 +21,7 @@ @@ -1455,7 +1455,7 @@ index 62571e6dfc..7ca2e5400b 100644 grub_free ((void *) entry->title); diff --git a/grub-core/commands/loadenv.h b/grub-core/commands/loadenv.h new file mode 100644 -index 0000000000..952f46121b +index 00000000000..952f46121bd --- /dev/null +++ b/grub-core/commands/loadenv.h @@ -0,0 +1,93 @@ @@ -1553,7 +1553,7 @@ index 0000000000..952f46121b + return 0; +} diff --git a/include/grub/compiler.h b/include/grub/compiler.h -index 8f3be3ae70..ebafec6895 100644 +index 0c5519387b2..441a9eca07c 100644 --- a/include/grub/compiler.h +++ b/include/grub/compiler.h @@ -56,4 +56,6 @@ @@ -1564,7 +1564,7 @@ index 8f3be3ae70..ebafec6895 100644 + #endif /* ! GRUB_COMPILER_HEADER */ diff --git a/include/grub/menu.h b/include/grub/menu.h -index ee2b5e9104..0acdc2aa6b 100644 +index ee2b5e91045..0acdc2aa6bf 100644 --- a/include/grub/menu.h +++ b/include/grub/menu.h @@ -20,6 +20,16 @@ @@ -1595,7 +1595,7 @@ index ee2b5e9104..0acdc2aa6b 100644 typedef struct grub_menu_entry *grub_menu_entry_t; diff --git a/include/grub/normal.h b/include/grub/normal.h -index 218cbabcca..8839ad85a1 100644 +index 218cbabccaf..8839ad85a19 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, diff --git a/0022-Add-devicetree-loading.patch b/0018-Add-devicetree-loading.patch similarity index 90% rename from 0022-Add-devicetree-loading.patch rename to 0018-Add-devicetree-loading.patch index 466ddba..3897a2a 100644 --- a/0022-Add-devicetree-loading.patch +++ b/0018-Add-devicetree-loading.patch @@ -20,10 +20,10 @@ 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 d3e879b8e5..8ea2315ebc 100644 +index 7516a015be0..7b355115dd4 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in -@@ -248,7 +248,8 @@ export GRUB_DEFAULT \ +@@ -252,7 +252,8 @@ export GRUB_DEFAULT \ GRUB_ENABLE_CRYPTODISK \ GRUB_BADRAM \ GRUB_OS_PROBER_SKIP_LIST \ @@ -34,10 +34,10 @@ index d3e879b8e5..8ea2315ebc 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 e8b01c0d0c..dc75a1c30b 100644 +index cc393be7eda..00d4b220ccb 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in -@@ -153,6 +153,13 @@ EOF +@@ -155,6 +155,13 @@ EOF sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' initrd $(echo $initrd_path) @@ -51,7 +51,7 @@ index e8b01c0d0c..dc75a1c30b 100644 EOF fi sed "s/^/$submenu_indentation/" << EOF -@@ -236,6 +243,14 @@ while [ "x$list" != "x" ] ; do +@@ -250,6 +257,14 @@ for linux in ${reverse_sorted_list}; do gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2 fi diff --git a/0023-Enable-pager-by-default.-985860.patch b/0019-Enable-pager-by-default.-985860.patch similarity index 94% rename from 0023-Enable-pager-by-default.-985860.patch rename to 0019-Enable-pager-by-default.-985860.patch index 63cf787..8f38cc2 100644 --- a/0023-Enable-pager-by-default.-985860.patch +++ b/0019-Enable-pager-by-default.-985860.patch @@ -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 93a90233ea..858b526c92 100644 +index 6a316a5ba77..c2d8b093762 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_ diff --git a/0024-Don-t-say-GNU-Linux-in-generated-menus.patch b/0020-Don-t-say-GNU-Linux-in-generated-menus.patch similarity index 91% rename from 0024-Don-t-say-GNU-Linux-in-generated-menus.patch rename to 0020-Don-t-say-GNU-Linux-in-generated-menus.patch index 5b96784..a299f05 100644 --- a/0024-Don-t-say-GNU-Linux-in-generated-menus.patch +++ b/0020-Don-t-say-GNU-Linux-in-generated-menus.patch @@ -13,20 +13,20 @@ Subject: [PATCH] Don't say "GNU/Linux" in generated menus. 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 7ca2e5400b..98372217ad 100644 +index 1317279c081..568c2adfa16 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -218,7 +218,7 @@ grub_normal_init_page (struct grub_term_output *term, - + grub_term_cls (term); - msg_formatted = grub_xasprintf (_("GNU GRUB version %s"), PACKAGE_VERSION); + msg_formatted = grub_xasprintf (_("GRUB version %s"), PACKAGE_VERSION); if (!msg_formatted) return; - + diff --git a/tests/util/grub-shell-tester.in b/tests/util/grub-shell-tester.in -index 8a87109b15..9a4319d4f4 100644 +index 8a87109b152..9a4319d4f4f 100644 --- a/tests/util/grub-shell-tester.in +++ b/tests/util/grub-shell-tester.in @@ -56,7 +56,7 @@ for option in "$@"; do @@ -39,10 +39,10 @@ index 8a87109b15..9a4319d4f4 100644 --modules=*) ms=`echo "$option" | sed -e 's/--modules=//'` diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in -index 93e9f51484..ec1182bf93 100644 +index 496e1bab33c..e0570c88e15 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in -@@ -209,7 +209,7 @@ for option in "$@"; do +@@ -243,7 +243,7 @@ for option in "$@"; do usage exit 0 ;; -v | --version) @@ -50,9 +50,9 @@ index 93e9f51484..ec1182bf93 100644 + echo "$0 (GRUB ${PACKAGE_VERSION})" exit 0 ;; --trim) - trim=1 + trim=1 ;; diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index dc75a1c30b..4a499c53a6 100644 +index 00d4b220ccb..901745707f1 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -29,9 +29,9 @@ export TEXTDOMAINDIR="@localedir@" @@ -68,7 +68,7 @@ index dc75a1c30b..4a499c53a6 100644 fi diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in -index 3b1f470492..ada20775a1 100644 +index 94dd8be1342..98ee5bc58dc 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -29,9 +29,9 @@ export TEXTDOMAINDIR="@localedir@" diff --git a/0025-Add-.eh_frame-to-list-of-relocations-stripped.patch b/0021-Add-.eh_frame-to-list-of-relocations-stripped.patch similarity index 76% rename from 0025-Add-.eh_frame-to-list-of-relocations-stripped.patch rename to 0021-Add-.eh_frame-to-list-of-relocations-stripped.patch index 0532a04..9344171 100644 --- a/0025-Add-.eh_frame-to-list-of-relocations-stripped.patch +++ b/0021-Add-.eh_frame-to-list-of-relocations-stripped.patch @@ -3,20 +3,21 @@ From: Fedora Ninjas Date: Mon, 13 Jan 2014 21:50:59 -0500 Subject: [PATCH] Add .eh_frame to list of relocations stripped +Signed-off-by: Peter Jones --- conf/Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/Makefile.common b/conf/Makefile.common -index 2a1a886f6d..191b1a70c6 100644 +index b8f216f6cd3..ece9ed8a1bf 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common -@@ -38,7 +38,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding +@@ -41,7 +41,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) -STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx +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 - - CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding - LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d + if !COND_emu + if COND_HAVE_ASM_USCORE + LDFLAGS_KERNEL += -Wl,--defsym=_malloc=_grub_malloc -Wl,--defsym=_free=_grub_free diff --git a/0026-Don-t-require-a-password-to-boot-entries-generated-b.patch b/0022-Don-t-require-a-password-to-boot-entries-generated-b.patch similarity index 96% rename from 0026-Don-t-require-a-password-to-boot-entries-generated-b.patch rename to 0022-Don-t-require-a-password-to-boot-entries-generated-b.patch index 89887c1..b280686 100644 --- a/0026-Don-t-require-a-password-to-boot-entries-generated-b.patch +++ b/0022-Don-t-require-a-password-to-boot-entries-generated-b.patch @@ -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 4a499c53a6..cf8d118698 100644 +index 901745707f1..9c31a94decb 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -26,7 +26,7 @@ datarootdir="@datarootdir@" diff --git a/0027-use-fw_path-prefix-when-fallback-searching-for-grub-.patch b/0023-use-fw_path-prefix-when-fallback-searching-for-grub-.patch similarity index 97% rename from 0027-use-fw_path-prefix-when-fallback-searching-for-grub-.patch rename to 0023-use-fw_path-prefix-when-fallback-searching-for-grub-.patch index 1da91e1..40f598d 100644 --- a/0027-use-fw_path-prefix-when-fallback-searching-for-grub-.patch +++ b/0023-use-fw_path-prefix-when-fallback-searching-for-grub-.patch @@ -17,7 +17,7 @@ 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 98372217ad..bf24e65713 100644 +index 568c2adfa16..0b2bbee19c3 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -347,7 +347,7 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), diff --git a/0028-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch b/0024-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch similarity index 99% rename from 0028-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch rename to 0024-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch index 0d77281..be44d1a 100644 --- a/0028-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch +++ b/0024-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch @@ -9,7 +9,7 @@ Signed-off-by: Peter Jones 1 file changed, 51 insertions(+), 46 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index bf24e65713..0a99768f75 100644 +index 0b2bbee19c3..4c89892fa70 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -345,61 +345,66 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)), diff --git a/0029-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch b/0025-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch similarity index 96% rename from 0029-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch rename to 0025-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch index f22e6f9..d29c0af 100644 --- a/0029-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch +++ b/0025-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch @@ -14,7 +14,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 cf8d118698..5f6d3c8d52 100644 +index 9c31a94decb..b7809091b36 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -29,7 +29,8 @@ export TEXTDOMAINDIR="@localedir@" diff --git a/0031-Try-prefix-if-fw_path-doesn-t-work.patch b/0026-Try-prefix-if-fw_path-doesn-t-work.patch similarity index 93% rename from 0031-Try-prefix-if-fw_path-doesn-t-work.patch rename to 0026-Try-prefix-if-fw_path-doesn-t-work.patch index a1c0d9e..effa351 100644 --- a/0031-Try-prefix-if-fw_path-doesn-t-work.patch +++ b/0026-Try-prefix-if-fw_path-doesn-t-work.patch @@ -7,38 +7,26 @@ Related: rhbz#1148652 Signed-off-by: Peter Jones --- - grub-core/kern/ieee1275/init.c | 28 +++++---- + grub-core/kern/ieee1275/init.c | 34 ++++++----- grub-core/net/net.c | 2 +- grub-core/normal/main.c | 134 ++++++++++++++++++++--------------------- - 3 files changed, 82 insertions(+), 82 deletions(-) + 3 files changed, 85 insertions(+), 85 deletions(-) diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index e71d158416..0cd2a62723 100644 +index 50c65b2f6e5..51c1e1c9d9f 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c -@@ -127,23 +127,25 @@ grub_machine_get_bootlocation (char **device, char **path) +@@ -170,23 +170,25 @@ grub_machine_get_bootlocation (char **device, char **path) grub_free (canon); } else - *device = grub_ieee1275_encode_devname (bootpath); -- grub_free (type); -- -- filename = grub_ieee1275_get_filename (bootpath); -- if (filename) - { -- char *lastslash = grub_strrchr (filename, '\\'); -- -- /* Truncate at last directory. */ -- if (lastslash) ++ { + filename = grub_ieee1275_get_filename (bootpath); + if (filename) - { -- *lastslash = '\0'; -- grub_translate_ieee1275_path (filename); ++ { + char *lastslash = grub_strrchr (filename, '\\'); - -- *path = filename; -- } ++ + /* Truncate at last directory. */ + if (lastslash) + { @@ -49,17 +37,32 @@ index e71d158416..0cd2a62723 100644 + } + } + *device = grub_ieee1275_encode_devname (bootpath); - } ++ } + -+ grub_free (type); + grub_free (type); +- +- filename = grub_ieee1275_get_filename (bootpath); +- if (filename) +- { +- char *lastslash = grub_strrchr (filename, '\\'); +- +- /* Truncate at last directory. */ +- if (lastslash) +- { +- *lastslash = '\0'; +- grub_translate_ieee1275_path (filename); +- +- *path = filename; +- } +- } grub_free (bootpath); } diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 4d3eb5c1a5..0ef148f4ad 100644 +index 8cad4fb6d4d..54451cea2a7 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c -@@ -1869,7 +1869,7 @@ grub_net_search_config_file (char *config) +@@ -2005,7 +2005,7 @@ grub_net_search_config_file (char *config) /* Remove the remaining minus sign at the end. */ config[config_len] = '\0'; @@ -69,7 +72,7 @@ index 4d3eb5c1a5..0ef148f4ad 100644 static struct grub_preboot *fini_hnd; diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 0a99768f75..55558cc0b9 100644 +index 4c89892fa70..3463f444f74 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -335,81 +335,79 @@ grub_enter_normal_mode (const char *config) diff --git a/0032-Make-grub2-mkconfig-construct-titles-that-look-like-.patch b/0027-Make-grub2-mkconfig-construct-titles-that-look-like-.patch similarity index 95% rename from 0032-Make-grub2-mkconfig-construct-titles-that-look-like-.patch rename to 0027-Make-grub2-mkconfig-construct-titles-that-look-like-.patch index db101c0..1fb624e 100644 --- a/0032-Make-grub2-mkconfig-construct-titles-that-look-like-.patch +++ b/0027-Make-grub2-mkconfig-construct-titles-that-look-like-.patch @@ -12,10 +12,10 @@ 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 5f6d3c8d52..786dbabb4a 100644 +index b7809091b36..993c53ad92e 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in -@@ -78,6 +78,32 @@ case x"$GRUB_FS" in +@@ -80,6 +80,32 @@ case x"$GRUB_FS" in ;; esac @@ -48,7 +48,7 @@ index 5f6d3c8d52..786dbabb4a 100644 title_correction_code= linux_entry () -@@ -91,17 +117,11 @@ linux_entry () +@@ -93,17 +119,11 @@ linux_entry () boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" fi if [ x$type != xsimple ] ; then diff --git a/0033-Add-friendly-grub2-password-config-tool-985962.patch b/0028-Add-friendly-grub2-password-config-tool-985962.patch similarity index 94% rename from 0033-Add-friendly-grub2-password-config-tool-985962.patch rename to 0028-Add-friendly-grub2-password-config-tool-985962.patch index f430e96..2e1ba2c 100644 --- a/0033-Add-friendly-grub2-password-config-tool-985962.patch +++ b/0028-Add-friendly-grub2-password-config-tool-985962.patch @@ -29,10 +29,10 @@ Signed-off-by: Robbie Harwood create mode 100644 util/grub.d/01_users.in diff --git a/configure.ac b/configure.ac -index 8331f95b64..7f59ad788f 100644 +index ae3a49321ad..493e336ec6c 100644 --- a/configure.ac +++ b/configure.ac -@@ -72,6 +72,7 @@ grub_TRANSFORM([grub-mkrelpath]) +@@ -77,6 +77,7 @@ grub_TRANSFORM([grub-mkrelpath]) grub_TRANSFORM([grub-mkrescue]) grub_TRANSFORM([grub-probe]) grub_TRANSFORM([grub-reboot]) @@ -41,10 +41,10 @@ index 8331f95b64..7f59ad788f 100644 grub_TRANSFORM([grub-set-default]) grub_TRANSFORM([grub-sparc64-setup]) diff --git a/Makefile.util.def b/Makefile.util.def -index 2c9b283a23..4ee22c5daa 100644 +index 09bfcadd976..95884956a68 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -452,6 +452,12 @@ script = { +@@ -455,6 +455,12 @@ script = { installdir = grubconf; }; @@ -57,7 +57,7 @@ index 2c9b283a23..4ee22c5daa 100644 script = { name = '10_windows'; common = util/grub.d/10_windows.in; -@@ -724,6 +730,13 @@ script = { +@@ -733,6 +739,13 @@ script = { installdir = sbin; }; @@ -73,17 +73,17 @@ index 2c9b283a23..4ee22c5daa 100644 common = util/grub-mkconfig_lib.in; diff --git a/docs/man/grub-set-password.h2m b/docs/man/grub-set-password.h2m new file mode 100644 -index 0000000000..10ee82f4d5 +index 00000000000..10ee82f4d52 --- /dev/null +++ b/docs/man/grub-set-password.h2m @@ -0,0 +1,2 @@ +[NAME] +grub-set-password \- generate the user.cfg file containing the hashed grub bootloader password diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 8ea2315ebc..ba14cf6261 100644 +index 7b355115dd4..5f2824d4f58 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in -@@ -276,6 +276,8 @@ for i in "${grub_mkconfig_dir}"/* ; do +@@ -280,6 +280,8 @@ for i in "${grub_mkconfig_dir}"/* ; do *~) ;; # emacsen autosave files. FIXME: support other editors */\#*\#) ;; @@ -94,7 +94,7 @@ index 8ea2315ebc..ba14cf6261 100644 echo diff --git a/util/grub-set-password.in b/util/grub-set-password.in new file mode 100644 -index 0000000000..5ebf50576d +index 00000000000..5ebf50576d6 --- /dev/null +++ b/util/grub-set-password.in @@ -0,0 +1,128 @@ @@ -228,7 +228,7 @@ index 0000000000..5ebf50576d +fi diff --git a/util/grub.d/01_users.in b/util/grub.d/01_users.in new file mode 100644 -index 0000000000..db2f44bfb7 +index 00000000000..db2f44bfb78 --- /dev/null +++ b/util/grub.d/01_users.in @@ -0,0 +1,11 @@ diff --git a/0034-tcp-add-window-scaling-support.patch b/0029-tcp-add-window-scaling-support.patch similarity index 95% rename from 0034-tcp-add-window-scaling-support.patch rename to 0029-tcp-add-window-scaling-support.patch index 61b5a67..ef3a81e 100644 --- a/0034-tcp-add-window-scaling-support.patch +++ b/0029-tcp-add-window-scaling-support.patch @@ -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 e8ad34b84d..7d4b822626 100644 +index 93dee0caa1b..902ab7e8ae6 100644 --- a/grub-core/net/tcp.c +++ b/grub-core/net/tcp.c @@ -106,6 +106,18 @@ struct tcphdr @@ -39,7 +39,7 @@ index e8ad34b84d..7d4b822626 100644 struct tcp_pseudohdr { grub_uint32_t src; -@@ -566,7 +578,7 @@ grub_net_tcp_open (char *server, +@@ -571,7 +583,7 @@ grub_net_tcp_open (char *server, grub_net_tcp_socket_t socket; static grub_uint16_t in_port = 21550; struct grub_net_buff *nb; @@ -48,7 +48,7 @@ index e8ad34b84d..7d4b822626 100644 int i; grub_uint8_t *nbd; grub_net_link_level_address_t ll_target_addr; -@@ -635,20 +647,24 @@ grub_net_tcp_open (char *server, +@@ -640,20 +652,24 @@ grub_net_tcp_open (char *server, } tcph = (void *) nb->data; diff --git a/0035-efinet-and-bootp-add-support-for-dhcpv6.patch b/0030-efinet-and-bootp-add-support-for-dhcpv6.patch similarity index 84% rename from 0035-efinet-and-bootp-add-support-for-dhcpv6.patch rename to 0030-efinet-and-bootp-add-support-for-dhcpv6.patch index efeeee0..19a63c5 100644 --- a/0035-efinet-and-bootp-add-support-for-dhcpv6.patch +++ b/0030-efinet-and-bootp-add-support-for-dhcpv6.patch @@ -6,18 +6,18 @@ Subject: [PATCH] efinet and bootp: add support for dhcpv6 Signed-off-by: Peter Jones --- grub-core/net/bootp.c | 173 +++++++++++++++++++++++++++++++++++++ - grub-core/net/drivers/efi/efinet.c | 53 ++++++++++-- + grub-core/net/drivers/efi/efinet.c | 84 +++++++++++++----- grub-core/net/net.c | 72 +++++++++++++++ - grub-core/net/tftp.c | 4 + + grub-core/net/tftp.c | 3 + include/grub/efi/api.h | 129 +++++++++++++++++++++++++-- include/grub/net.h | 60 +++++++++++++ - 6 files changed, 477 insertions(+), 14 deletions(-) + 6 files changed, 491 insertions(+), 30 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 6fb5627025..e28fb6a09f 100644 +index abe45ef7bf6..02d2c2614cb 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c -@@ -902,6 +902,179 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), +@@ -905,6 +905,179 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), static grub_command_t cmd_getdhcp, cmd_bootp, cmd_dhcp; @@ -198,7 +198,7 @@ index 6fb5627025..e28fb6a09f 100644 grub_bootp_init (void) { diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 5388f952ba..173fb63153 100644 +index 3ea25cf9894..2af8742f904 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -18,11 +18,14 @@ @@ -216,16 +216,16 @@ index 5388f952ba..173fb63153 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -329,7 +332,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -346,7 +349,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, char **path) { struct grub_net_card *card; - grub_efi_device_path_t *dp; + grub_efi_device_path_t *dp, *ldp = NULL; - - dp = grub_efi_get_device_path (hnd); - if (! dp) -@@ -340,14 +343,19 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, + struct grub_net_network_level_interface *inter; + grub_efi_device_path_t *vlan_dp; + grub_efi_uint16_t vlan_dp_len; +@@ -361,14 +364,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; @@ -246,7 +246,7 @@ index 5388f952ba..173fb63153 100644 int match; /* EDK2 UEFI PXE driver creates pseudo devices with type IPv4/IPv6 -@@ -356,7 +364,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -377,7 +385,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. */ @@ -254,7 +254,7 @@ index 5388f952ba..173fb63153 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)) -@@ -373,16 +380,46 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -394,41 +401,70 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, if (!match) continue; } @@ -265,11 +265,6 @@ index 5388f952ba..173fb63153 100644 continue; + pxe_mode = pxe->mode; -- grub_net_configure_by_dhcp_ack (card->name, card, 0, -- (struct grub_net_bootp_packet *) -- &pxe_mode->dhcp_ack, -- sizeof (pxe_mode->dhcp_ack), -- 1, device, path); + if (pxe_mode->using_ipv6) + { + grub_net_link_level_address_t hwaddr; @@ -281,41 +276,86 @@ index 5388f952ba..173fb63153 100644 + pxe_mode->dhcp_ack_received ? "" : " cannot continue"); + if (!pxe_mode->dhcp_ack_received) + continue; -+ + +- inter = grub_net_configure_by_dhcp_ack (card->name, card, 0, +- (struct grub_net_bootp_packet *) +- &pxe_mode->dhcp_ack, +- sizeof (pxe_mode->dhcp_ack), +- 1, device, path); + hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; + grub_memcpy (hwaddr.mac, + card->efi_net->mode->current_address, + sizeof (hwaddr.mac)); -+ -+ intf = grub_net_configure_by_dhcpv6_ack (card->name, card, 0, &hwaddr, + +- if (inter != NULL) ++ inter = grub_net_configure_by_dhcpv6_ack (card->name, card, 0, &hwaddr, + (const struct grub_net_dhcpv6_packet *)&pxe_mode->dhcp_ack.dhcpv6, + 1, device, path); -+ if (intf && device && path) ++ if (inter && device && path) + grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path); + } + else -+ { + { +- /* +- * Search the device path for any VLAN subtype and use it +- * to configure the interface. +- */ +- vlan_dp = dp; + grub_dprintf ("efinet", "using ipv4 and dhcp\n"); -+ grub_net_configure_by_dhcp_ack (card->name, card, 0, -+ (struct grub_net_bootp_packet *) -+ &pxe_mode->dhcp_ack, -+ sizeof (pxe_mode->dhcp_ack), -+ 1, device, path); ++ inter = grub_net_configure_by_dhcp_ack (card->name, card, 0, ++ (struct grub_net_bootp_packet *) ++ &pxe_mode->dhcp_ack, ++ sizeof (pxe_mode->dhcp_ack), ++ 1, device, path); + +- while (!GRUB_EFI_END_ENTIRE_DEVICE_PATH (vlan_dp)) + grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path); -+ } - return; ++ if (inter != NULL) + { +- if (GRUB_EFI_DEVICE_PATH_TYPE (vlan_dp) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE && +- GRUB_EFI_DEVICE_PATH_SUBTYPE (vlan_dp) == GRUB_EFI_VLAN_DEVICE_PATH_SUBTYPE) ++ /* ++ * Search the device path for any VLAN subtype and use it ++ * to configure the interface. ++ */ ++ vlan_dp = dp; ++ ++ while (!GRUB_EFI_END_ENTIRE_DEVICE_PATH (vlan_dp)) + { +- vlan = (grub_efi_vlan_device_path_t *) vlan_dp; +- inter->vlantag = vlan->vlan_id; +- break; ++ if (GRUB_EFI_DEVICE_PATH_TYPE (vlan_dp) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE && ++ GRUB_EFI_DEVICE_PATH_SUBTYPE (vlan_dp) == GRUB_EFI_VLAN_DEVICE_PATH_SUBTYPE) ++ { ++ vlan = (grub_efi_vlan_device_path_t *) vlan_dp; ++ inter->vlantag = vlan->vlan_id; ++ break; ++ } ++ ++ vlan_dp_len = GRUB_EFI_DEVICE_PATH_LENGTH (vlan_dp); ++ vlan_dp = (grub_efi_device_path_t *) ((grub_efi_uint8_t *) vlan_dp + vlan_dp_len); + } +- +- vlan_dp_len = GRUB_EFI_DEVICE_PATH_LENGTH (vlan_dp); +- vlan_dp = (grub_efi_device_path_t *) ((grub_efi_uint8_t *) vlan_dp + vlan_dp_len); + } ++ return; + } +- return; } } + diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 0ef148f4ad..22f2689aae 100644 +index 54451cea2a7..20c55257647 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c -@@ -960,6 +960,78 @@ grub_net_network_level_interface_register (struct grub_net_network_level_interfa +@@ -984,6 +984,78 @@ grub_net_network_level_interface_register (struct grub_net_network_level_interfa grub_net_network_level_interfaces = inter; } +int -+grub_ipv6_get_masksize (grub_uint16_t be_mask[8]) ++grub_ipv6_get_masksize (grub_uint16_t *be_mask) +{ + grub_uint8_t *mask; + grub_uint16_t mask16[8]; @@ -390,10 +430,10 @@ index 0ef148f4ad..22f2689aae 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 7f44b30f52..4ab2f5c735 100644 +index 409b1d09bcd..f300a9d4007 100644 --- a/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c -@@ -358,18 +358,22 @@ tftp_open (struct grub_file *file, const char *filename) +@@ -359,6 +359,7 @@ tftp_open (struct grub_file *file, const char *filename) file->not_easily_seekable = 1; file->data = data; @@ -401,14 +441,13 @@ index 7f44b30f52..4ab2f5c735 100644 err = grub_net_resolve_address (file->device->net->server, &addr); if (err) { -+ grub_dprintf("tftp", "Address resolution failed: %d\n", err); - grub_free (data); +@@ -369,11 +370,13 @@ tftp_open (struct grub_file *file, const char *filename) return err; } + grub_dprintf("tftp", "opening connection\n"); data->sock = grub_net_udp_open (addr, - TFTP_SERVER_PORT, tftp_receive, + port ? port : TFTP_SERVER_PORT, tftp_receive, file); if (!data->sock) { @@ -417,10 +456,10 @@ index 7f44b30f52..4ab2f5c735 100644 return grub_errno; } diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index f1a52210c0..117469450d 100644 +index d44d00ad7d5..c6d702831f7 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -592,10 +592,16 @@ typedef void *grub_efi_handle_t; +@@ -637,10 +637,16 @@ typedef void *grub_efi_handle_t; typedef void *grub_efi_event_t; typedef grub_efi_uint64_t grub_efi_lba_t; typedef grub_efi_uintn_t grub_efi_tpl_t; @@ -441,7 +480,7 @@ index f1a52210c0..117469450d 100644 typedef grub_efi_uint64_t grub_efi_physical_address_t; typedef grub_efi_uint64_t grub_efi_virtual_address_t; -@@ -1474,16 +1480,127 @@ struct grub_efi_simple_text_output_interface +@@ -1521,16 +1527,127 @@ struct grub_efi_simple_text_output_interface }; typedef struct grub_efi_simple_text_output_interface grub_efi_simple_text_output_interface_t; @@ -572,10 +611,10 @@ index f1a52210c0..117469450d 100644 typedef struct grub_efi_pxe diff --git a/include/grub/net.h b/include/grub/net.h -index 7ae4b6bd80..8a05ec4fe7 100644 +index 844e501c128..bf8430a6364 100644 --- a/include/grub/net.h +++ b/include/grub/net.h -@@ -447,6 +447,51 @@ struct grub_net_bootp_packet +@@ -450,6 +450,51 @@ struct grub_net_bootp_packet grub_uint8_t vendor[0]; } GRUB_PACKED; @@ -627,7 +666,7 @@ index 7ae4b6bd80..8a05ec4fe7 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 -@@ -482,6 +527,21 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -485,6 +530,21 @@ grub_net_configure_by_dhcp_ack (const char *name, grub_size_t size, int is_def, char **device, char **path); diff --git a/0072-bootp-New-net_bootp6-command.patch b/0031-bootp-New-net_bootp6-command.patch similarity index 96% rename from 0072-bootp-New-net_bootp6-command.patch rename to 0031-bootp-New-net_bootp6-command.patch index bef3acd..91e58f2 100644 --- a/0072-bootp-New-net_bootp6-command.patch +++ b/0031-bootp-New-net_bootp6-command.patch @@ -12,14 +12,14 @@ Signed-off-by: Ken Lin Signed-off-by: Peter Jones --- grub-core/net/bootp.c | 1059 ++++++++++++++++++++++++++++++------ - grub-core/net/drivers/efi/efinet.c | 20 +- + grub-core/net/drivers/efi/efinet.c | 18 +- grub-core/net/ip.c | 39 ++ include/grub/efi/api.h | 2 +- include/grub/net.h | 91 ++-- - 5 files changed, 1002 insertions(+), 209 deletions(-) + 5 files changed, 1001 insertions(+), 208 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 08b6b2b5d6..fe93b80f1c 100644 +index 02d2c2614cb..e0aec25233d 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -24,6 +24,98 @@ @@ -121,7 +121,7 @@ index 08b6b2b5d6..fe93b80f1c 100644 struct grub_dhcp_discover_options { -@@ -604,6 +696,584 @@ out: +@@ -610,6 +702,584 @@ out: return err; } @@ -427,7 +427,7 @@ index 08b6b2b5d6..fe93b80f1c 100644 + grub_dhcp6_session_t se; + struct grub_datetime date; + grub_err_t err; -+ grub_int32_t t = 0; ++ grub_int64_t t = 0; + + se = grub_malloc (sizeof (*se)); + @@ -706,7 +706,7 @@ index 08b6b2b5d6..fe93b80f1c 100644 /* * This is called directly from net/ip.c:handle_dgram(), because those * BOOTP/DHCP packets are a bit special due to their improper -@@ -672,6 +1342,77 @@ grub_net_process_dhcp (struct grub_net_buff *nb, +@@ -678,6 +1348,77 @@ grub_net_process_dhcp (struct grub_net_buff *nb, } } @@ -784,7 +784,7 @@ index 08b6b2b5d6..fe93b80f1c 100644 static grub_err_t grub_cmd_dhcpopt (struct grub_command *cmd __attribute__ ((unused)), int argc, char **args) -@@ -897,180 +1638,174 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), +@@ -903,180 +1644,174 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), return err; } @@ -1119,7 +1119,7 @@ index 08b6b2b5d6..fe93b80f1c 100644 void grub_bootp_init (void) -@@ -1084,11 +1819,15 @@ grub_bootp_init (void) +@@ -1090,11 +1825,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.")); @@ -1136,10 +1136,10 @@ index 08b6b2b5d6..fe93b80f1c 100644 grub_unregister_command (cmd_bootp); grub_unregister_command (cmd_dhcp); diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index a673bea807..8e25680db0 100644 +index 2af8742f904..3e2432fb61c 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c -@@ -393,9 +393,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -410,9 +410,6 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, pxe_mode = pxe->mode; if (pxe_mode->using_ipv6) { @@ -1149,7 +1149,7 @@ index a673bea807..8e25680db0 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", -@@ -403,15 +400,14 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -420,14 +417,13 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, if (!pxe_mode->dhcp_ack_received) continue; @@ -1158,26 +1158,24 @@ index a673bea807..8e25680db0 100644 - card->efi_net->mode->current_address, - sizeof (hwaddr.mac)); - -- intf = grub_net_configure_by_dhcpv6_ack (card->name, card, 0, &hwaddr, +- inter = grub_net_configure_by_dhcpv6_ack (card->name, card, 0, &hwaddr, - (const struct grub_net_dhcpv6_packet *)&pxe_mode->dhcp_ack.dhcpv6, - 1, device, path); -- if (intf && device && path) -+ grub_net_configure_by_dhcpv6_reply (card->name, card, 0, -+ (struct grub_net_dhcp6_packet *) -+ &pxe_mode->dhcp_ack, -+ sizeof (pxe_mode->dhcp_ack), -+ 1, device, path); ++ inter = grub_net_configure_by_dhcpv6_reply (card->name, card, 0, ++ (struct grub_net_dhcp6_packet *) ++ &pxe_mode->dhcp_ack, ++ sizeof (pxe_mode->dhcp_ack), ++ 1, device, path); + if (grub_errno) + grub_print_error (); -+ if (device && path) + if (inter && device && path) grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path); } - else diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c -index a5896f6dc2..ce6bdc75c6 100644 +index 3c3d0be0e57..f967618e53f 100644 --- a/grub-core/net/ip.c +++ b/grub-core/net/ip.c -@@ -239,6 +239,45 @@ handle_dgram (struct grub_net_buff *nb, +@@ -240,6 +240,45 @@ handle_dgram (struct grub_net_buff *nb, { struct udphdr *udph; udph = (struct udphdr *) nb->data; @@ -1224,10 +1222,10 @@ index a5896f6dc2..ce6bdc75c6 100644 { const struct grub_net_bootp_packet *bootp; diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 9962880147..7614b58dca 100644 +index c6d702831f7..c1b869db520 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -1532,7 +1532,7 @@ typedef struct grub_efi_pxe_ip_filter +@@ -1570,7 +1570,7 @@ typedef struct grub_efi_pxe_ip_filter { grub_efi_uint8_t filters; grub_efi_uint8_t ip_count; @@ -1237,10 +1235,10 @@ index 9962880147..7614b58dca 100644 } grub_efi_pxe_ip_filter_t; diff --git a/include/grub/net.h b/include/grub/net.h -index d55d505a03..543251f727 100644 +index bf8430a6364..ff901b96e22 100644 --- a/include/grub/net.h +++ b/include/grub/net.h -@@ -451,50 +451,65 @@ struct grub_net_bootp_packet +@@ -450,50 +450,65 @@ struct grub_net_bootp_packet grub_uint8_t vendor[0]; } GRUB_PACKED; @@ -1336,7 +1334,7 @@ index d55d505a03..543251f727 100644 #define GRUB_NET_BOOTP_RFC1048_MAGIC_0 0x63 #define GRUB_NET_BOOTP_RFC1048_MAGIC_1 0x82 -@@ -532,12 +547,12 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -531,12 +546,12 @@ grub_net_configure_by_dhcp_ack (const char *name, int is_def, char **device, char **path); struct grub_net_network_level_interface * @@ -1355,7 +1353,7 @@ index d55d505a03..543251f727 100644 int grub_ipv6_get_masksize(grub_uint16_t *mask); -@@ -554,6 +569,10 @@ void +@@ -553,6 +568,10 @@ void grub_net_process_dhcp (struct grub_net_buff *nb, struct grub_net_network_level_interface *iface); diff --git a/0036-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch b/0032-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch similarity index 92% rename from 0036-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch rename to 0032-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch index 95490cd..8890e10 100644 --- a/0036-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch +++ b/0032-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch @@ -24,10 +24,10 @@ Resolves: rhbz#1226325 create mode 100644 util/grub-get-kernel-settings.in diff --git a/configure.ac b/configure.ac -index 7f59ad788f..0d0e6782a1 100644 +index 493e336ec6c..3602b4ab62b 100644 --- a/configure.ac +++ b/configure.ac -@@ -65,6 +65,7 @@ grub_TRANSFORM([grub-install]) +@@ -70,6 +70,7 @@ grub_TRANSFORM([grub-install]) grub_TRANSFORM([grub-mkconfig]) grub_TRANSFORM([grub-mkfont]) grub_TRANSFORM([grub-mkimage]) @@ -36,10 +36,10 @@ index 7f59ad788f..0d0e6782a1 100644 grub_TRANSFORM([grub-mklayout]) grub_TRANSFORM([grub-mkpasswd-pbkdf2]) diff --git a/Makefile.util.def b/Makefile.util.def -index 4ee22c5daa..18a9242776 100644 +index 95884956a68..84a17ef5cfa 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -716,6 +716,13 @@ script = { +@@ -725,6 +725,13 @@ script = { installdir = sbin; }; @@ -55,17 +55,17 @@ index 4ee22c5daa..18a9242776 100644 common = util/grub-set-default.in; diff --git a/docs/man/grub-get-kernel-settings.h2m b/docs/man/grub-get-kernel-settings.h2m new file mode 100644 -index 0000000000..b8051f01f3 +index 00000000000..b8051f01f3a --- /dev/null +++ b/docs/man/grub-get-kernel-settings.h2m @@ -0,0 +1,2 @@ +[NAME] +grub-get-kernel-settings \- Evaluate the system's kernel installation settings for use while making a grub configuration file diff --git a/util/bash-completion.d/grub-completion.bash.in b/util/bash-completion.d/grub-completion.bash.in -index 44bf135b9f..5c4acd496d 100644 +index 213ce1e57cf..da7fca5efac 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} && \ +@@ -275,6 +275,28 @@ have ${__grub_sparc64_setup_program} && \ unset __grub_sparc64_setup_program @@ -96,7 +96,7 @@ index 44bf135b9f..5c4acd496d 100644 # diff --git a/util/grub-get-kernel-settings.in b/util/grub-get-kernel-settings.in new file mode 100644 -index 0000000000..7e87dfccc0 +index 00000000000..7e87dfccc0e --- /dev/null +++ b/util/grub-get-kernel-settings.in @@ -0,0 +1,88 @@ @@ -189,7 +189,7 @@ index 0000000000..7e87dfccc0 + echo export GRUB_UPDATE_DEFAULT_KERNEL +fi diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index ba14cf6261..005f093809 100644 +index 5f2824d4f58..28e92515795 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -45,6 +45,7 @@ grub_probe="${sbindir}/@grub_probe@" @@ -210,10 +210,10 @@ index ba14cf6261..005f093809 100644 if [ -z "${GRUB_DISABLE_LINUX_UUID}" ]; then GRUB_DISABLE_LINUX_UUID="true" diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 786dbabb4a..292e333324 100644 +index 993c53ad92e..e8ab4082f87 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in -@@ -111,7 +111,8 @@ linux_entry () +@@ -113,7 +113,8 @@ linux_entry () os="$1" version="$2" type="$3" @@ -223,7 +223,7 @@ index 786dbabb4a..292e333324 100644 if [ -z "$boot_device_id" ]; then boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" -@@ -123,6 +124,9 @@ linux_entry () +@@ -125,6 +126,9 @@ linux_entry () 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 @@ -233,7 +233,7 @@ index 786dbabb4a..292e333324 100644 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/" -@@ -306,11 +310,15 @@ while [ "x$list" != "x" ] ; do +@@ -320,11 +324,15 @@ for linux in ${reverse_sorted_list}; do fi if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xtrue ]; then @@ -251,7 +251,7 @@ index 786dbabb4a..292e333324 100644 if [ -z "$boot_device_id" ]; then boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" fi -@@ -319,10 +327,15 @@ while [ "x$list" != "x" ] ; do +@@ -333,10 +341,15 @@ for linux in ${reverse_sorted_list}; do is_top_level=false fi @@ -266,6 +266,6 @@ index 786dbabb4a..292e333324 100644 if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then - linux_entry "${OS}" "${version}" recovery \ + linux_entry "${OS}" "${version}" recovery standard \ - "single ${GRUB_CMDLINE_LINUX}" + "${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}" fi - + done diff --git a/0038-Make-grub_fatal-also-backtrace.patch b/0033-Make-grub_fatal-also-backtrace.patch similarity index 89% rename from 0038-Make-grub_fatal-also-backtrace.patch rename to 0033-Make-grub_fatal-also-backtrace.patch index f876575..1cfe763 100644 --- a/0038-Make-grub_fatal-also-backtrace.patch +++ b/0033-Make-grub_fatal-also-backtrace.patch @@ -5,18 +5,18 @@ Subject: [PATCH] Make grub_fatal() also backtrace. --- grub-core/Makefile.core.def | 3 ++ - grub-core/kern/misc.c | 8 +++++- + grub-core/kern/misc.c | 6 ++++ grub-core/lib/arm64/backtrace.c | 62 +++++++++++++++++++++++++++++++++++++++++ grub-core/lib/backtrace.c | 2 ++ grub-core/lib/i386/backtrace.c | 14 +++++++++- - 5 files changed, 87 insertions(+), 2 deletions(-) + 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 grub-core/lib/arm64/backtrace.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index c15e91943b..058c88ac3a 100644 +index 47c0fc755a2..63f053b3add 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -188,6 +188,9 @@ kernel = { +@@ -199,6 +199,9 @@ kernel = { softdiv = lib/division.c; @@ -27,19 +27,19 @@ index c15e91943b..058c88ac3a 100644 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 63b586d09c..a3e215155b 100644 +index 11037dc0227..465a8e74ea7 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -24,6 +24,7 @@ - #include - #include +@@ -26,6 +26,7 @@ #include + #include + #include +#include union printf_arg { -@@ -1199,8 +1200,13 @@ grub_printf_fmt_check (const char *fmt, const char *fmt_expected) - static void __attribute__ ((noreturn)) +@@ -1301,6 +1302,11 @@ grub_printf_fmt_check (const char *fmt, const char *fmt_expected) + void __attribute__ ((noreturn)) grub_abort (void) { +#ifndef GRUB_UTIL @@ -48,14 +48,11 @@ index 63b586d09c..a3e215155b 100644 +#endif +#endif grub_printf ("\nAborted."); -- -+ + #ifndef GRUB_UTIL - if (grub_term_inputs) - #endif diff --git a/grub-core/lib/arm64/backtrace.c b/grub-core/lib/arm64/backtrace.c new file mode 100644 -index 0000000000..1079b5380e +index 00000000000..1079b5380e1 --- /dev/null +++ b/grub-core/lib/arm64/backtrace.c @@ -0,0 +1,62 @@ @@ -122,7 +119,7 @@ index 0000000000..1079b5380e +} + diff --git a/grub-core/lib/backtrace.c b/grub-core/lib/backtrace.c -index 825a8800e2..c0ad6ab8be 100644 +index 825a8800e25..c0ad6ab8be1 100644 --- a/grub-core/lib/backtrace.c +++ b/grub-core/lib/backtrace.c @@ -29,6 +29,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); @@ -142,7 +139,7 @@ index 825a8800e2..c0ad6ab8be 100644 } diff --git a/grub-core/lib/i386/backtrace.c b/grub-core/lib/i386/backtrace.c -index c3e03c7275..c67273db3a 100644 +index c3e03c7275c..c67273db3ae 100644 --- a/grub-core/lib/i386/backtrace.c +++ b/grub-core/lib/i386/backtrace.c @@ -15,11 +15,23 @@ diff --git a/0039-Make-our-info-pages-say-grub2-where-appropriate.patch b/0034-Make-our-info-pages-say-grub2-where-appropriate.patch similarity index 80% rename from 0039-Make-our-info-pages-say-grub2-where-appropriate.patch rename to 0034-Make-our-info-pages-say-grub2-where-appropriate.patch index afba285..992bb43 100644 --- a/0039-Make-our-info-pages-say-grub2-where-appropriate.patch +++ b/0034-Make-our-info-pages-say-grub2-where-appropriate.patch @@ -9,11 +9,11 @@ time. Signed-off-by: Peter Jones --- docs/grub-dev.texi | 4 +- - docs/grub.texi | 321 ++++++++++++++++++++++++++++------------------------- - 2 files changed, 171 insertions(+), 154 deletions(-) + docs/grub.texi | 357 ++++++++++++++++++++++++++++------------------------- + 2 files changed, 189 insertions(+), 172 deletions(-) diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi -index 6c629a23e2..19f708ee66 100644 +index 1276c59302a..04c6678cb6b 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -1,7 +1,7 @@ @@ -35,7 +35,7 @@ index 6c629a23e2..19f708ee66 100644 @setchapternewpage odd diff --git a/docs/grub.texi b/docs/grub.texi -index 69f08d289f..0615d0ed97 100644 +index 974bc0ddb07..c30701b4e1f 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1,7 +1,7 @@ @@ -72,31 +72,7 @@ index 69f08d289f..0615d0ed97 100644 @end direntry @setchapternewpage odd -@@ -103,15 +103,15 @@ This edition documents version @value{VERSION}. - * Platform-specific operations:: Platform-specific operations - * Supported kernels:: The list of supported kernels - * Troubleshooting:: Error messages produced by GRUB --* Invoking grub-install:: How to use the GRUB installer --* Invoking grub-mkconfig:: Generate a GRUB configuration file --* Invoking grub-mkpasswd-pbkdf2:: -+* Invoking grub2-install:: How to use the GRUB installer -+* Invoking grub2-mkconfig:: Generate a GRUB configuration file -+* Invoking grub2-mkpasswd-pbkdf2:: - Generate GRUB password hashes --* Invoking grub-mkrelpath:: Make system path relative to its root --* Invoking grub-mkrescue:: Make a GRUB rescue image --* Invoking grub-mount:: Mount a file system using GRUB --* Invoking grub-probe:: Probe device information for GRUB --* Invoking grub-script-check:: Check GRUB script file for syntax errors -+* Invoking grub2-mkrelpath:: Make system path relative to its root -+* Invoking grub2-mkrescue:: Make a GRUB rescue image -+* Invoking grub2-mount:: Mount a file system using GRUB -+* Invoking grub2-probe:: Probe device information for GRUB -+* Invoking grub2-script-check:: Check GRUB script file for syntax errors - * Obtaining and Building GRUB:: How to obtain and build GRUB - * Reporting bugs:: Where you should send a bug report - * Future:: Some future plans on GRUB -@@ -230,7 +230,7 @@ surprising. +@@ -223,7 +223,7 @@ surprising. @item @file{grub.cfg} is typically automatically generated by @@ -105,7 +81,7 @@ index 69f08d289f..0615d0ed97 100644 easier to handle versioned kernel upgrades. @item -@@ -244,7 +244,7 @@ scripting language: variables, conditionals, and loops are available. +@@ -237,7 +237,7 @@ scripting language: variables, conditionals, and loops are available. @item A small amount of persistent storage is available across reboots, using the @command{save_env} and @command{load_env} commands in GRUB and the @@ -114,7 +90,7 @@ index 69f08d289f..0615d0ed97 100644 (@pxref{Environment block}). @item -@@ -549,7 +549,7 @@ On OS which have device nodes similar to Unix-like OS GRUB tools use the +@@ -542,7 +542,7 @@ On OS which have device nodes similar to Unix-like OS GRUB tools use the OS name. E.g. for GNU/Linux: @example @@ -123,7 +99,7 @@ index 69f08d289f..0615d0ed97 100644 @end example On AROS we use another syntax. For volumes: -@@ -572,7 +572,7 @@ For disks we use syntax: +@@ -565,7 +565,7 @@ For disks we use syntax: E.g. @example @@ -132,7 +108,7 @@ index 69f08d289f..0615d0ed97 100644 @end example On Windows we use UNC path. For volumes it's typically -@@ -599,7 +599,7 @@ For disks it's +@@ -592,7 +592,7 @@ For disks it's E.g. @example @@ -141,7 +117,7 @@ index 69f08d289f..0615d0ed97 100644 @end example Beware that you may need to further escape the backslashes depending on your -@@ -609,7 +609,7 @@ When compiled with cygwin support then cygwin drive names are automatically +@@ -602,7 +602,7 @@ When compiled with cygwin support then cygwin drive names are automatically when needed. E.g. @example @@ -150,7 +126,7 @@ index 69f08d289f..0615d0ed97 100644 @end example @node Installation -@@ -622,7 +622,7 @@ from the source tarball, or as a package for your OS. +@@ -615,7 +615,7 @@ from the source tarball, or as a package for your OS. After you have done that, you need to install the boot loader on a drive (floppy or hard disk) by using the utility @@ -159,7 +135,7 @@ index 69f08d289f..0615d0ed97 100644 GRUB comes with boot images, which are normally put in the directory @file{/usr/lib/grub/-} (for BIOS-based machines -@@ -633,22 +633,22 @@ loader needs to find them (usually @file{/boot}) will be called +@@ -626,22 +626,22 @@ loader needs to find them (usually @file{/boot}) will be called the @dfn{boot directory}. @menu @@ -187,7 +163,7 @@ index 69f08d289f..0615d0ed97 100644 The usage is basically very simple. You only need to specify one argument to the program, namely, where to install the boot loader. The -@@ -657,13 +657,13 @@ For example, under Linux the following will install GRUB into the MBR +@@ -650,13 +650,13 @@ For example, under Linux the following will install GRUB into the MBR of the first IDE disk: @example @@ -203,7 +179,7 @@ index 69f08d289f..0615d0ed97 100644 @end example But all the above examples assume that GRUB should put images under -@@ -677,7 +677,7 @@ boot floppy with a filesystem. Here is an example: +@@ -670,7 +670,7 @@ boot floppy with a filesystem. Here is an example: # @kbd{mke2fs /dev/fd0} # @kbd{mount -t ext2 /dev/fd0 /mnt} # @kbd{mkdir /mnt/boot} @@ -212,7 +188,7 @@ index 69f08d289f..0615d0ed97 100644 # @kbd{umount /mnt} @end group @end example -@@ -689,30 +689,37 @@ floppy instead of exposing the USB drive as a hard disk (they call it +@@ -682,30 +682,37 @@ floppy instead of exposing the USB drive as a hard disk (they call it @example # @kbd{losetup /dev/loop0 /dev/sdb1} # @kbd{mount /dev/loop0 /mnt/usb} @@ -254,7 +230,7 @@ index 69f08d289f..0615d0ed97 100644 @end example @node Making a GRUB bootable CD-ROM -@@ -732,10 +739,10 @@ usually also need to include a configuration file @file{grub.cfg} and some +@@ -725,10 +732,10 @@ usually also need to include a configuration file @file{grub.cfg} and some other GRUB modules. To make a simple generic GRUB rescue CD, you can use the @@ -267,7 +243,7 @@ index 69f08d289f..0615d0ed97 100644 @end example You will often need to include other files in your image. To do this, first -@@ -758,7 +765,7 @@ directory @file{iso/}. +@@ -751,7 +758,7 @@ directory @file{iso/}. Finally, make the image: @example @@ -276,7 +252,7 @@ index 69f08d289f..0615d0ed97 100644 @end example This produces a file named @file{grub.iso}, which then can be burned -@@ -774,7 +781,7 @@ storage devices. +@@ -767,7 +774,7 @@ storage devices. @node Device map @section The map between BIOS drives and OS devices @@ -285,7 +261,7 @@ index 69f08d289f..0615d0ed97 100644 etc.) read it to map BIOS drives to OS devices. This file consists of lines like this: -@@ -1254,23 +1261,23 @@ need to write the whole thing by hand. +@@ -1269,23 +1276,23 @@ need to write the whole thing by hand. @node Simple configuration @section Simple configuration handling @@ -314,7 +290,7 @@ index 69f08d289f..0615d0ed97 100644 valid POSIX shell input; normally, it will just be a sequence of @samp{KEY=value} lines, but if the value contains spaces or other special characters then it must be quoted. For example: -@@ -1308,7 +1315,7 @@ works it's not recommended since titles often contain unstable device names +@@ -1323,7 +1330,7 @@ works it's not recommended since titles often contain unstable device names and may be translated If you set this to @samp{saved}, then the default menu entry will be that @@ -323,7 +299,7 @@ index 69f08d289f..0615d0ed97 100644 the environment block, which may not be available in all situations (@pxref{Environment block}). -@@ -1319,7 +1326,7 @@ If this option is set to @samp{true}, then, when an entry is selected, save +@@ -1334,7 +1341,7 @@ If this option is set to @samp{true}, then, when an entry is selected, save it as a new default entry for use by future runs of GRUB. This is only useful if @samp{GRUB_DEFAULT=saved}; it is a separate option because @samp{GRUB_DEFAULT=saved} is useful without this option, in conjunction with @@ -332,7 +308,7 @@ index 69f08d289f..0615d0ed97 100644 This option relies on the environment block, which may not be available in all situations (@pxref{Environment block}). -@@ -1449,7 +1456,7 @@ intel-uc.img intel-ucode.img amd-uc.img amd-ucode.img early_ucode.cpio microcode +@@ -1481,15 +1488,15 @@ intel-uc.img intel-ucode.img amd-uc.img amd-ucode.img early_ucode.cpio microcode @end example @item GRUB_DISABLE_LINUX_UUID @@ -341,7 +317,17 @@ index 69f08d289f..0615d0ed97 100644 universally-unique identifiers (UUIDs) to identify the root filesystem to 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 -@@ -1471,7 +1478,7 @@ If this option is set to @samp{true}, disable the generation of recovery + 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 ++If @command{grub2-mkconfig} cannot identify the root filesystem via its ++universally-unique indentifier (UUID), @command{grub2-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 +@@ -1503,7 +1510,7 @@ If this option is set to @samp{true}, disable the generation of recovery mode menu entries. @item GRUB_DISABLE_UUID @@ -350,7 +336,7 @@ index 69f08d289f..0615d0ed97 100644 universally-unique identifiers (UUIDs) to identify various filesystems to search for files. This is usually more reliable, but in some cases it may not be appropriate. To disable this use of UUIDs, set this option to -@@ -1482,12 +1489,12 @@ not be appropriate. To disable this use of UUIDs, set this option to +@@ -1514,12 +1521,12 @@ not be appropriate. To disable this use of UUIDs, set this option to @item GRUB_VIDEO_BACKEND If graphical video support is required, either because the @samp{gfxterm} graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is set, @@ -366,7 +352,7 @@ index 69f08d289f..0615d0ed97 100644 @item GRUB_GFXMODE Set the resolution used on the @samp{gfxterm} graphical terminal. Note that -@@ -1519,7 +1526,7 @@ boot sequence. If you have problems, set this option to @samp{text} and +@@ -1552,7 +1559,7 @@ boot sequence. If you have problems, set this option to @samp{text} and GRUB will tell Linux to boot in normal text mode. @item GRUB_DISABLE_OS_PROBER @@ -375,7 +361,7 @@ index 69f08d289f..0615d0ed97 100644 @command{os-prober} program, if installed, to discover other operating systems installed on the same system and generate appropriate menu entries for them. Set this option to @samp{true} to disable this. -@@ -1529,7 +1536,7 @@ List of space-separated FS UUIDs of filesystems to be ignored from os-prober +@@ -1562,7 +1569,7 @@ List of space-separated FS UUIDs of filesystems to be ignored from os-prober output. For efi chainloaders it's @@ @item GRUB_DISABLE_SUBMENU @@ -384,7 +370,7 @@ index 69f08d289f..0615d0ed97 100644 the kernel with highest version number and put all other found kernels or alternative menu entries for recovery mode in submenu. For entries returned by @command{os-prober} first entry will be put on top level and all others -@@ -1537,11 +1544,11 @@ in submenu. If this option is set to @samp{true}, flat menu with all entries +@@ -1570,11 +1577,11 @@ in submenu. If this option is set to @samp{true}, flat menu with all entries on top level will be generated instead. Changing this option will require changing existing values of @samp{GRUB_DEFAULT}, @samp{fallback} (@pxref{fallback}) and @samp{default} (@pxref{default}) environment variables as well as saved @@ -399,7 +385,7 @@ index 69f08d289f..0615d0ed97 100644 check for encrypted disks and generate additional commands needed to access them during boot. Note that in this case unattended boot is not possible because GRUB will wait for passphrase to unlock encrypted container. -@@ -1600,7 +1607,7 @@ confusing @samp{GRUB_TIMEOUT_STYLE=countdown} or +@@ -1633,7 +1640,7 @@ confusing @samp{GRUB_TIMEOUT_STYLE=countdown} or @end table @@ -408,7 +394,48 @@ index 69f08d289f..0615d0ed97 100644 edit the scripts in @file{/etc/grub.d} directly. @file{/etc/grub.d/40_custom} is particularly useful for adding entire custom menu entries; simply type the menu entries you want to add at the end of -@@ -1862,7 +1869,7 @@ images as well. +@@ -1641,14 +1648,14 @@ 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} ++If the target operating system uses the Linux kernel, @command{grub2-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 ++to @samp{true}, prevents @command{grub2-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 ++to @samp{true}, prevents @command{grub2-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. +@@ -1658,18 +1665,18 @@ 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} ++identified by its UUID. Because of this behavior, the @command{grub2-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 ++then @command{grub2-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. ++@command{grub2-command} will identify by its Linux device name. + +-The following table summarizes the behavior of the @command{grub-mkconfig} ++The following table summarizes the behavior of the @command{grub2-mkconfig} + command. + + @multitable {detected} {GRUB_DISABLE_LINUX_PARTUUID} {GRUB_DISABLE_LINUX_UUID} {Linux Root} +@@ -1898,7 +1905,7 @@ images as well. Mount this partition on/mnt/boot and disable GRUB in all OSes and manually install self-compiled latest GRUB with: @@ -417,7 +444,7 @@ index 69f08d289f..0615d0ed97 100644 In all the OSes install GRUB tools but disable installing GRUB in bootsector, so you'll have menu.lst and grub.cfg available for use. Also disable os-prober -@@ -1872,20 +1879,20 @@ use by setting: +@@ -1908,20 +1915,20 @@ use by setting: in /etc/default/grub @@ -441,7 +468,7 @@ index 69f08d289f..0615d0ed97 100644 @} menuentry "Windows XP" @{ -@@ -1948,15 +1955,15 @@ GRUB supports embedding a configuration file directly into the core image, +@@ -1984,15 +1991,15 @@ GRUB supports embedding a configuration file directly into the core image, so that it is loaded before entering normal mode. This is useful, for example, when it is not straightforward to find the real configuration file, or when you need to debug problems with loading that file. @@ -460,7 +487,7 @@ index 69f08d289f..0615d0ed97 100644 After the embedded configuration file (if any) is executed, GRUB will load the @samp{normal} module (@pxref{normal}), which will then read the real -@@ -1991,13 +1998,13 @@ included in the core image: +@@ -2027,13 +2034,13 @@ included in the core image: @example @group search.fs_label grub root @@ -478,7 +505,7 @@ index 69f08d289f..0615d0ed97 100644 else echo "Could not find an example configuration file!" fi -@@ -2521,7 +2528,7 @@ grub-mknetdir --net-directory=/srv/tftp --subdir=/boot/grub -d /usr/lib/grub/i38 +@@ -2557,7 +2564,7 @@ grub-mknetdir --net-directory=/srv/tftp --subdir=/boot/grub -d /usr/lib/grub/i38 @end group @end example @@ -487,7 +514,7 @@ index 69f08d289f..0615d0ed97 100644 server. The grub.cfg file is placed in the same directory as the path output by -@@ -2715,7 +2722,7 @@ team are: +@@ -2760,7 +2767,7 @@ team are: @end table To take full advantage of this function, install GRUB into the MBR @@ -496,7 +523,7 @@ index 69f08d289f..0615d0ed97 100644 If you have a laptop which has a similar feature and not in the above list could you figure your address and contribute? -@@ -2776,7 +2783,7 @@ bytes. +@@ -2821,7 +2828,7 @@ bytes. The sole function of @file{boot.img} is to read the first sector of the core image from a local disk and jump to it. Because of the size restriction, @file{boot.img} cannot understand any file system structure, so @@ -505,7 +532,7 @@ index 69f08d289f..0615d0ed97 100644 core image into @file{boot.img} when installing GRUB. @item diskboot.img -@@ -2806,7 +2813,7 @@ images. +@@ -2851,7 +2858,7 @@ images. @item core.img This is the core image of GRUB. It is built dynamically from the kernel @@ -514,7 +541,7 @@ index 69f08d289f..0615d0ed97 100644 program. Usually, it contains enough modules to access @file{/boot/grub}, and loads everything else (including menu handling, the ability to load target operating systems, and so on) from the file system at run-time. The -@@ -2858,7 +2865,7 @@ GRUB 2 has no single Stage 2 image. Instead, it loads modules from +@@ -2903,7 +2910,7 @@ GRUB 2 has no single Stage 2 image. Instead, it loads modules from In GRUB 2, images for booting from CD-ROM drives are now constructed using @file{cdboot.img} and @file{core.img}, making sure that the core image contains the @samp{iso9660} module. It is usually best to use the @@ -523,7 +550,7 @@ index 69f08d289f..0615d0ed97 100644 @item nbgrub There is as yet no equivalent for @file{nbgrub} in GRUB 2; it was used by -@@ -3014,8 +3021,8 @@ There are two ways to specify files, by @dfn{absolute file name} and by +@@ -3071,8 +3078,8 @@ There are two ways to specify files, by @dfn{absolute file name} and by An absolute file name resembles a Unix absolute file name, using @samp{/} for the directory separator (not @samp{\} as in DOS). One @@ -534,7 +561,7 @@ index 69f08d289f..0615d0ed97 100644 disk. If you omit the device name in an absolute file name, GRUB uses GRUB's @dfn{root device} implicitly. So if you set the root device to, say, @samp{(hd1,1)} by the command @samp{set root=(hd1,1)} (@pxref{set}), -@@ -3023,8 +3030,8 @@ then @code{/boot/kernel} is the same as @code{(hd1,1)/boot/kernel}. +@@ -3080,8 +3087,8 @@ then @code{/boot/kernel} is the same as @code{(hd1,1)/boot/kernel}. On ZFS filesystem the first path component must be @var{volume}@samp{@@}[@var{snapshot}]. @@ -545,7 +572,7 @@ index 69f08d289f..0615d0ed97 100644 @samp{snap-129}. Trailing @samp{@@} after volume name is mandatory even if snapshot name is omitted. -@@ -3427,7 +3434,7 @@ The more recent release of Minix would then be identified as +@@ -3500,7 +3507,7 @@ The more recent release of Minix would then be identified as @samp{other>minix>minix-3.4.0}. This variable is often set by @samp{GRUB_DEFAULT} (@pxref{Simple @@ -554,7 +581,7 @@ index 69f08d289f..0615d0ed97 100644 @node fallback -@@ -3517,7 +3524,7 @@ If this variable is set, it names the language code that the +@@ -3590,7 +3597,7 @@ If this variable is set, it names the language code that the example, French would be named as @samp{fr}, and Simplified Chinese as @samp{zh_CN}. @@ -563,7 +590,7 @@ index 69f08d289f..0615d0ed97 100644 reasonable default for this variable based on the system locale. -@@ -3525,10 +3532,10 @@ reasonable default for this variable based on the system locale. +@@ -3598,10 +3605,10 @@ reasonable default for this variable based on the system locale. @subsection locale_dir If this variable is set, it names the directory where translation files may @@ -576,7 +603,7 @@ index 69f08d289f..0615d0ed97 100644 default for this variable if internationalization is needed and any translation files are available. -@@ -3646,7 +3653,7 @@ input. The default is not to pause output. +@@ -3738,7 +3745,7 @@ input. The default is not to pause output. The location of the @samp{/boot/grub} directory as an absolute file name (@pxref{File name syntax}). This is normally set by GRUB at startup based @@ -585,7 +612,7 @@ index 69f08d289f..0615d0ed97 100644 dynamically loaded from this directory, so it must be set correctly in order for many parts of GRUB to work. -@@ -3737,17 +3744,17 @@ GRUB provides an ``environment block'' which can be used to save a small +@@ -3850,17 +3857,17 @@ GRUB provides an ``environment block'' which can be used to save a small amount of state. The environment block is a preallocated 1024-byte file, which normally lives @@ -605,8 +632,8 @@ index 69f08d289f..0615d0ed97 100644 +@command{grub2-mkconfig} uses this facility to implement @samp{GRUB_SAVEDEFAULT} (@pxref{Simple configuration}). - -@@ -4476,7 +4483,7 @@ Translate @var{string} into the current language. + @node Modules +@@ -4922,7 +4929,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 @@ -615,7 +642,7 @@ index 69f08d289f..0615d0ed97 100644 @end deffn -@@ -4871,7 +4878,7 @@ Define a user named @var{user} with password @var{clear-password}. +@@ -5274,7 +5281,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}. @@ -624,7 +651,7 @@ index 69f08d289f..0615d0ed97 100644 to generate password hashes. @xref{Security}. @end deffn -@@ -5814,8 +5821,8 @@ The @samp{password} (@pxref{password}) and @samp{password_pbkdf2} +@@ -6400,8 +6407,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 @@ -635,7 +662,7 @@ index 69f08d289f..0615d0ed97 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, -@@ -5860,7 +5867,7 @@ menuentry "May be run by user1 or a superuser" --users user1 @{ +@@ -6446,7 +6453,7 @@ menuentry "May be run by user1 or a superuser" --users user1 @{ @end group @end example @@ -644,11 +671,13 @@ index 69f08d289f..0615d0ed97 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} -@@ -5887,7 +5894,17 @@ may halt or otherwise impact the boot process. +@@ -6472,8 +6479,18 @@ validation fails, then file @file{foo} cannot be opened. This failure + may halt or otherwise impact the boot process. An initial trusted public key can be embedded within the GRUB @file{core.img} - using the @code{--pubkey} option to @command{grub-install} +-using the @code{--pubkey} option to @command{grub-install} -(@pxref{Invoking grub-install}). ++using the @code{--pubkey} option to @command{grub2-install} +(@pxref{Invoking grub2-install}). + +@comment Unfortunately --pubkey is not yet supported by grub2-install, @@ -663,7 +692,7 @@ index 69f08d289f..0615d0ed97 100644 GRUB uses GPG-style detached signatures (meaning that a file @file{foo.sig} will be produced when file @file{foo} is signed), and -@@ -5907,8 +5924,8 @@ gpg --detach-sign /path/to/file +@@ -6493,8 +6510,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 @@ -674,7 +703,7 @@ index 69f08d289f..0615d0ed97 100644 @example @group -@@ -5930,7 +5947,7 @@ See also: @ref{check_signatures}, @ref{verify_detached}, @ref{trust}, +@@ -6516,7 +6533,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 @@ -683,7 +712,16 @@ index 69f08d289f..0615d0ed97 100644 equal to @code{enforce} in @file{core.img} prior to processing any configuration files. -@@ -6388,10 +6405,10 @@ Required files are: +@@ -6564,7 +6581,7 @@ UTF-8 strings as comma-separated values (CSV). See + @uref{https://github.com/rhboot/shim/blob/main/SBAT.md} for more details. + + To add a data section containing the SBAT information into the binary, the +-@option{--sbat} option of @command{grub-mkimage} command should be used. The content ++@option{--sbat} option of @command{grub2-mkimage} command should be used. The content + of a CSV file, encoded with UTF-8, is copied as is to the .sbat data section into + the generated EFI binary. The CSV file can be stored anywhere on the file system. + +@@ -6975,10 +6992,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 @@ -696,7 +734,7 @@ index 69f08d289f..0615d0ed97 100644 things GRUB is supposed to do. If, instead, you only get a rescue shell, this usually means that GRUB -@@ -6417,8 +6434,8 @@ normal +@@ -7004,8 +7021,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 @@ -707,7 +745,7 @@ index 69f08d289f..0615d0ed97 100644 @itemize @bullet{} @item -@@ -6430,7 +6447,7 @@ is usually better to use UUIDs or file system labels and avoid depending on +@@ -7017,7 +7034,7 @@ is usually better to use UUIDs or file system labels and avoid depending on drive ordering entirely. @item @@ -716,14 +754,34 @@ index 69f08d289f..0615d0ed97 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. -@@ -6461,21 +6478,21 @@ entry which claims partition start at block 0. This change will not hamper - bootability on other machines. +@@ -7052,33 +7069,33 @@ bootability on other machines. + @chapter User-space utilities + + @menu +-* Invoking grub-install:: How to use the GRUB installer +-* Invoking grub-mkconfig:: Generate a GRUB configuration file +-* Invoking grub-mkpasswd-pbkdf2:: ++* Invoking grub2-install:: How to use the GRUB installer ++* Invoking grub2-mkconfig:: Generate a GRUB configuration file ++* Invoking grub2-mkpasswd-pbkdf2:: + Generate GRUB password hashes +-* Invoking grub-mkrelpath:: Make system path relative to its root +-* Invoking grub-mkrescue:: Make a GRUB rescue image +-* Invoking grub-mount:: Mount a file system using GRUB +-* Invoking grub-probe:: Probe device information for GRUB +-* Invoking grub-script-check:: Check GRUB script file for syntax errors ++* Invoking grub2-mkrelpath:: Make system path relative to its root ++* Invoking grub2-mkrescue:: Make a GRUB rescue image ++* Invoking grub2-mount:: Mount a file system using GRUB ++* Invoking grub2-probe:: Probe device information for GRUB ++* Invoking grub2-script-check:: Check GRUB script file for syntax errors + @end menu -@node Invoking grub-install --@chapter Invoking grub-install +-@section Invoking grub-install +@node Invoking grub2-install -+@chapter Invoking grub2-install ++@section Invoking grub2-install -The program @command{grub-install} generates a GRUB core image using -@command{grub-mkimage} and installs it on your system. You must specify the @@ -744,7 +802,7 @@ index 69f08d289f..0615d0ed97 100644 @table @option @item --help -@@ -6491,13 +6508,13 @@ separate partition or a removable disk. +@@ -7094,13 +7111,13 @@ separate partition or a removable disk. If this option is not specified then it defaults to @file{/boot}, so @example @@ -760,7 +818,7 @@ index 69f08d289f..0615d0ed97 100644 @end example Here is an example in which you have a separate @dfn{boot} partition which is -@@ -6505,16 +6522,16 @@ mounted on +@@ -7108,16 +7125,16 @@ mounted on @file{/mnt/boot}: @example @@ -780,14 +838,14 @@ index 69f08d289f..0615d0ed97 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 -@@ -6527,17 +6544,17 @@ installation}) where GRUB does not reside in any unpartitioned space +@@ -7130,17 +7147,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 -@node Invoking grub-mkconfig --@chapter Invoking grub-mkconfig +-@section Invoking grub-mkconfig +@node Invoking grub2-mkconfig -+@chapter Invoking grub2-mkconfig ++@section Invoking grub2-mkconfig -The program @command{grub-mkconfig} generates a configuration file for GRUB +The program @command{grub2-mkconfig} generates a configuration file for GRUB @@ -795,7 +853,7 @@ index 69f08d289f..0615d0ed97 100644 @example -grub-mkconfig -o /boot/grub/grub.cfg -+grub-mkconfig -o /boot/grub2/grub.cfg ++grub2-mkconfig -o /boot/grub2/grub.cfg @end example -@command{grub-mkconfig} accepts the following options: @@ -803,21 +861,22 @@ index 69f08d289f..0615d0ed97 100644 @table @option @item --help -@@ -6553,17 +6570,17 @@ it to standard output. +@@ -7156,17 +7173,17 @@ it to standard output. @end table -@node Invoking grub-mkpasswd-pbkdf2 --@chapter Invoking grub-mkpasswd-pbkdf2 +-@section Invoking grub-mkpasswd-pbkdf2 +@node Invoking grub2-mkpasswd-pbkdf2 -+@chapter Invoking grub2-mkpasswd-pbkdf2 ++@section Invoking grub2-mkpasswd-pbkdf2 -The program @command{grub-mkpasswd-pbkdf2} generates password hashes for +The program @command{grub2-mkpasswd-pbkdf2} generates password hashes for GRUB (@pxref{Security}). @example - grub-mkpasswd-pbkdf2 +-grub-mkpasswd-pbkdf2 ++grub2-mkpasswd-pbkdf2 @end example -@command{grub-mkpasswd-pbkdf2} accepts the following options: @@ -825,14 +884,14 @@ index 69f08d289f..0615d0ed97 100644 @table @option @item -c @var{number} -@@ -6581,23 +6598,23 @@ Length of the salt. Defaults to 64. +@@ -7184,23 +7201,23 @@ Length of the salt. Defaults to 64. @end table -@node Invoking grub-mkrelpath --@chapter Invoking grub-mkrelpath +-@section Invoking grub-mkrelpath +@node Invoking grub2-mkrelpath -+@chapter Invoking grub2-mkrelpath ++@section Invoking grub2-mkrelpath -The program @command{grub-mkrelpath} makes a file system path relative to +The program @command{grub2-mkrelpath} makes a file system path relative to @@ -855,21 +914,22 @@ index 69f08d289f..0615d0ed97 100644 @table @option @item --help -@@ -6608,17 +6625,17 @@ Print the version number of GRUB and exit. +@@ -7211,17 +7228,17 @@ Print the version number of GRUB and exit. @end table -@node Invoking grub-mkrescue --@chapter Invoking grub-mkrescue +-@section Invoking grub-mkrescue +@node Invoking grub2-mkrescue -+@chapter Invoking grub2-mkrescue ++@section Invoking grub2-mkrescue -The program @command{grub-mkrescue} generates a bootable GRUB rescue image +The program @command{grub2-mkrescue} generates a bootable GRUB rescue image (@pxref{Making a GRUB bootable CD-ROM}). @example - grub-mkrescue -o grub.iso +-grub-mkrescue -o grub.iso ++grub2-mkrescue -o grub.iso @end example -All arguments not explicitly listed as @command{grub-mkrescue} options are @@ -877,8 +937,12 @@ index 69f08d289f..0615d0ed97 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 -@@ -6633,7 +6650,7 @@ mkdir -p disk/boot/grub - grub-mkrescue -o grub.iso disk +@@ -7233,10 +7250,10 @@ commonly used to add extra files to the image: + @example + mkdir -p disk/boot/grub + @r{(add extra files to @file{disk/boot/grub})} +-grub-mkrescue -o grub.iso disk ++grub2-mkrescue -o grub.iso disk @end example -@command{grub-mkrescue} accepts the following options: @@ -886,7 +950,7 @@ index 69f08d289f..0615d0ed97 100644 @table @option @item --help -@@ -6661,15 +6678,15 @@ Use @var{file} as the @command{xorriso} program, rather than the built-in +@@ -7264,15 +7281,15 @@ Use @var{file} as the @command{xorriso} program, rather than the built-in default. @item --grub-mkimage=@var{file} @@ -897,16 +961,16 @@ index 69f08d289f..0615d0ed97 100644 -@node Invoking grub-mount --@chapter Invoking grub-mount +-@section Invoking grub-mount +@node Invoking grub2-mount -+@chapter Invoking grub2-mount ++@section Invoking grub2-mount -The program @command{grub-mount} performs a read-only mount of any file +The program @command{grub2-mount} performs a read-only mount of any file 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: -@@ -6701,13 +6718,13 @@ even if nobody has yet written a FUSE module specifically for that file +@@ -7304,13 +7321,13 @@ even if nobody has yet written a FUSE module specifically for that file system type. @end itemize @@ -914,7 +978,8 @@ index 69f08d289f..0615d0ed97 100644 +Using @command{grub2-mount} is normally as simple as: @example - grub-mount /dev/sda1 /mnt +-grub-mount /dev/sda1 /mnt ++grub2-mount /dev/sda1 /mnt @end example -@command{grub-mount} must be given one or more images and a mount point as @@ -922,7 +987,7 @@ index 69f08d289f..0615d0ed97 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: -@@ -6729,13 +6746,13 @@ Show debugging output for conditions matching @var{string}. +@@ -7332,13 +7349,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, @@ -938,22 +1003,33 @@ index 69f08d289f..0615d0ed97 100644 root of the supplied file system. If @var{device} is just a number, then it will be treated as a partition -@@ -6753,10 +6770,10 @@ Print verbose messages. +@@ -7347,7 +7364,7 @@ an entire disk in @file{disk.img}, then you can use this command to mount + its second partition: + + @example +-grub-mount -r 2 disk.img mount-point ++grub2-mount -r 2 disk.img mount-point + @end example + + @item -v +@@ -7356,18 +7373,18 @@ Print verbose messages. @end table -@node Invoking grub-probe --@chapter Invoking grub-probe +-@section Invoking grub-probe +@node Invoking grub2-probe -+@chapter Invoking grub2-probe ++@section Invoking grub2-probe -The program @command{grub-probe} probes device information for a given path +The program @command{grub2-probe} probes device information for a given path or device. @example -@@ -6764,7 +6781,7 @@ grub-probe --target=fs /boot/grub - grub-probe --target=drive --device /dev/sda1 +-grub-probe --target=fs /boot/grub +-grub-probe --target=drive --device /dev/sda1 ++grub2-probe --target=fs /boot/grub ++grub2-probe --target=drive --device /dev/sda1 @end example -@command{grub-probe} must be given a path or device as a non-option @@ -961,7 +1037,7 @@ index 69f08d289f..0615d0ed97 100644 argument, and also accepts the following options: @table @option -@@ -6777,16 +6794,16 @@ Print the version number of GRUB and exit. +@@ -7380,16 +7397,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 @@ -981,14 +1057,14 @@ index 69f08d289f..0615d0ed97 100644 @item -t @var{target} @itemx --target=@var{target} -@@ -6839,19 +6856,19 @@ Print verbose messages. +@@ -7442,19 +7459,19 @@ Print verbose messages. @end table -@node Invoking grub-script-check --@chapter Invoking grub-script-check +-@section Invoking grub-script-check +@node Invoking grub2-script-check -+@chapter Invoking grub2-script-check ++@section Invoking grub2-script-check -The program @command{grub-script-check} takes a GRUB script file +The program @command{grub2-script-check} takes a GRUB script file @@ -998,7 +1074,7 @@ index 69f08d289f..0615d0ed97 100644 @example -grub-script-check /boot/grub/grub.cfg -+grub-script-check /boot/grub2/grub.cfg ++grub2-script-check /boot/grub2/grub.cfg @end example -@command{grub-script-check} accepts the following options: diff --git a/0040-macos-just-build-chainloader-entries-don-t-try-any-x.patch b/0035-macos-just-build-chainloader-entries-don-t-try-any-x.patch similarity index 98% rename from 0040-macos-just-build-chainloader-entries-don-t-try-any-x.patch rename to 0035-macos-just-build-chainloader-entries-don-t-try-any-x.patch index 8d3139d..3246b11 100644 --- a/0040-macos-just-build-chainloader-entries-don-t-try-any-x.patch +++ b/0035-macos-just-build-chainloader-entries-don-t-try-any-x.patch @@ -20,7 +20,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 1b91c102f3..4b27bd2015 100644 +index f300e46fc6a..d7d423b2eaf 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 @@ -104,7 +104,7 @@ index 1b91c102f3..4b27bd2015 100644 } EOF } -@@ -292,11 +249,12 @@ EOF +@@ -296,11 +253,12 @@ EOF echo "$title_correction_code" ;; macosx) diff --git a/0041-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch b/0036-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch similarity index 94% rename from 0041-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch rename to 0036-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch index 57d2391..ad00442 100644 --- a/0041-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch +++ b/0036-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch @@ -19,12 +19,12 @@ 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 | 558 ++++++++++++++++++++++++++++++++++++++++++++++++--- include/grub/btrfs.h | 1 + - 2 files changed, 533 insertions(+), 20 deletions(-) + 2 files changed, 536 insertions(+), 23 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 63203034df..f1fff7385b 100644 +index ba0c583526d..f14fe9c1bda 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -38,6 +38,9 @@ @@ -89,7 +89,7 @@ index 63203034df..f1fff7385b 100644 static grub_disk_addr_t superblock_sectors[] = { 64 * 2, 64 * 1024 * 2, 256 * 1048576 * 2, 1048576ULL * 1048576ULL * 2 }; -@@ -1173,6 +1195,62 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, +@@ -1252,6 +1274,62 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, return GRUB_ERR_NONE; } @@ -152,7 +152,7 @@ index 63203034df..f1fff7385b 100644 static struct grub_btrfs_data * grub_btrfs_mount (grub_device_t dev) { -@@ -1208,6 +1286,13 @@ grub_btrfs_mount (grub_device_t dev) +@@ -1287,6 +1365,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,7 +166,7 @@ index 63203034df..f1fff7385b 100644 return data; } -@@ -1673,6 +1758,91 @@ get_root (struct grub_btrfs_data *data, struct grub_btrfs_key *key, +@@ -1784,6 +1869,91 @@ get_root (struct grub_btrfs_data *data, struct grub_btrfs_key *key, return GRUB_ERR_NONE; } @@ -258,7 +258,7 @@ index 63203034df..f1fff7385b 100644 static grub_err_t find_path (struct grub_btrfs_data *data, const char *path, struct grub_btrfs_key *key, -@@ -1691,14 +1861,26 @@ find_path (struct grub_btrfs_data *data, +@@ -1802,14 +1972,26 @@ find_path (struct grub_btrfs_data *data, char *origpath = NULL; unsigned symlinks_max = 32; @@ -289,15 +289,18 @@ index 63203034df..f1fff7385b 100644 while (1) { while (path[0] == '/') -@@ -1871,9 +2053,21 @@ find_path (struct grub_btrfs_data *data, +@@ -1982,13 +2164,25 @@ find_path (struct grub_btrfs_data *data, path = path_alloc = tmp; if (path[0] == '/') { - err = get_root (data, key, tree, type); - if (err) -- return err; + if (data->fs_tree) -+ { + { +- grub_free (direl); +- grub_free (path_alloc); +- grub_free (origpath); +- return err; + *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY; + *tree = data->fs_tree; + /* This is a tree root, so everything starts at objectid 256 */ @@ -309,12 +312,16 @@ index 63203034df..f1fff7385b 100644 + { + err = get_root (data, key, tree, type); + if (err) -+ return err; -+ } ++ { ++ grub_free (direl); ++ grub_free (path_alloc); ++ grub_free (origpath); ++ return err; ++ } + } } continue; - } -@@ -2114,18 +2308,10 @@ grub_btrfs_read (grub_file_t file, char *buf, grub_size_t len) +@@ -2256,18 +2450,10 @@ grub_btrfs_read (grub_file_t file, char *buf, grub_size_t len) data->tree, file->offset, buf, len); } @@ -336,7 +343,7 @@ index 63203034df..f1fff7385b 100644 grub_be_to_cpu16 (data->sblock.uuid[0]), grub_be_to_cpu16 (data->sblock.uuid[1]), grub_be_to_cpu16 (data->sblock.uuid[2]), -@@ -2134,6 +2320,20 @@ grub_btrfs_uuid (grub_device_t device, char **uuid) +@@ -2276,6 +2462,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])); @@ -357,7 +364,7 @@ index 63203034df..f1fff7385b 100644 grub_btrfs_unmount (data); -@@ -2190,6 +2390,242 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)), +@@ -2396,6 +2596,242 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)), } #endif @@ -600,7 +607,7 @@ index 63203034df..f1fff7385b 100644 static struct grub_fs grub_btrfs_fs = { .name = "btrfs", .fs_dir = grub_btrfs_dir, -@@ -2205,12 +2641,88 @@ static struct grub_fs grub_btrfs_fs = { +@@ -2411,12 +2847,88 @@ static struct grub_fs grub_btrfs_fs = { #endif }; @@ -690,7 +697,7 @@ index 63203034df..f1fff7385b 100644 + +// vim: si et sw=2: diff --git a/include/grub/btrfs.h b/include/grub/btrfs.h -index 9d93fb6c18..234ad97677 100644 +index 9d93fb6c182..234ad976771 100644 --- a/include/grub/btrfs.h +++ b/include/grub/btrfs.h @@ -29,6 +29,7 @@ enum diff --git a/0037-btrfs-fix-a-bad-null-check.patch b/0037-btrfs-fix-a-bad-null-check.patch new file mode 100644 index 0000000..093ca65 --- /dev/null +++ b/0037-btrfs-fix-a-bad-null-check.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 8 Jan 2024 15:41:52 -0500 +Subject: [PATCH] btrfs: fix a bad null check +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +current gcc complains: + + grub-core/fs/btrfs.c: In function ‘grub_cmd_btrfs_info’: + grub-core/fs/btrfs.c:2745:7: error: the comparison will always evaluate as ‘true’ for the address of ‘label’ will never be NULL [-Werror=address] + 2745 | if (data->sblock.label) + | ^~~~ + grub-core/fs/btrfs.c:92:8: note: ‘label’ declared here + 92 | char label[0x100]; + | ^~~~~ + cc1: all warnings being treated as errors + +Obviously this check should be on the first data byte instead of the +symbol itself. + +Signed-off-by: Peter Jones +--- + grub-core/fs/btrfs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c +index f14fe9c1bda..8e2b1e9f7bc 100644 +--- a/grub-core/fs/btrfs.c ++++ b/grub-core/fs/btrfs.c +@@ -2625,7 +2625,7 @@ grub_cmd_btrfs_info (grub_command_t cmd __attribute__ ((unused)), int argc, + return grub_error (GRUB_ERR_BAD_ARGUMENT, "failed to open fs"); + } + +- if (data->sblock.label) ++ if (data->sblock.label[0]) + grub_printf("Label: '%s' ", data->sblock.label); + else + grub_printf("Label: none "); diff --git a/0037-bz1374141-fix-incorrect-mask-for-ppc64.patch b/0037-bz1374141-fix-incorrect-mask-for-ppc64.patch deleted file mode 100644 index 15b2111..0000000 --- a/0037-bz1374141-fix-incorrect-mask-for-ppc64.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 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 - -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(). - - /vdevice/l-lan@30000002:speed=auto,duplex=auto,192.168.88.10,,192.168.89.113,192.168.88.1,5,5,255.255.252.0,512 - -The netmask in this bootpath is no problem, since it's a value specified in firmware. But, -The value of 'subnet_mask.ipv4' was set with 0xfffffc00, and __builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4)) returned 16 (not 22). -As a result, 16 was used for netmask wrongly. - -1111 1111 1111 1111 1111 1100 0000 0000 # subnet_mask.ipv4 (=0xfffffc00) -0000 0000 1111 1100 1111 1111 1111 1111 # grub_le_to_cpu32 (subnet_mask.ipv4) -1111 1111 0000 0011 0000 0000 0000 0000 # ~grub_le_to_cpu32 (subnet_mask.ipv4) - -And, the count of zero with __builtin_ctz can be 16. -This patch changes it as below. - -1111 1111 1111 1111 1111 1100 0000 0000 # subnet_mask.ipv4 (=0xfffffc00) -0000 0000 1111 1100 1111 1111 1111 1111 # grub_le_to_cpu32 (subnet_mask.ipv4) -1111 1111 1111 1111 1111 1100 0000 0000 # grub_swap_bytes32(grub_le_to_cpu32 (subnet_mask.ipv4)) -0000 0000 0000 0000 0000 0011 1111 1111 # ~grub_swap_bytes32(grub_le_to_cpu32 (subnet_mask.ipv4)) - -The count of zero with __builtin_clz can be 22. (clz counts the number of one bits preceding the most significant zero bit) - -Signed-off-by: Masahiro Matsuya -Signed-off-by: Robbie Harwood ---- - grub-core/net/drivers/ieee1275/ofnet.c | 3 +-- - 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 ac4e62a95c..3860b6f78d 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, - flags); - inter->vlantag = vlantag; - grub_net_add_ipv4_local (inter, -- __builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4))); -- -+ __builtin_clz (~grub_swap_bytes32(grub_le_to_cpu32 (subnet_mask.ipv4)))); - } - - if (gateway_addr.ipv4 != 0) diff --git a/0042-export-btrfs_subvol-and-btrfs_subvolid.patch b/0038-export-btrfs_subvol-and-btrfs_subvolid.patch similarity index 91% rename from 0042-export-btrfs_subvol-and-btrfs_subvolid.patch rename to 0038-export-btrfs_subvol-and-btrfs_subvolid.patch index 719866e..d35f598 100644 --- a/0042-export-btrfs_subvol-and-btrfs_subvolid.patch +++ b/0038-export-btrfs_subvol-and-btrfs_subvolid.patch @@ -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 f1fff7385b..ad1b56b716 100644 +index 8e2b1e9f7bc..14e38a4df02 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -2714,6 +2714,8 @@ GRUB_MOD_INIT (btrfs) +@@ -2920,6 +2920,8 @@ GRUB_MOD_INIT (btrfs) subvol_set_env); grub_register_variable_hook ("btrfs_subvolid", subvolid_get_env, subvolid_set_env); diff --git a/0043-grub2-btrfs-03-follow_default.patch b/0039-grub2-btrfs-03-follow_default.patch similarity index 90% rename from 0043-grub2-btrfs-03-follow_default.patch rename to 0039-grub2-btrfs-03-follow_default.patch index 621f029..bbe2fbc 100644 --- a/0043-grub2-btrfs-03-follow_default.patch +++ b/0039-grub2-btrfs-03-follow_default.patch @@ -10,10 +10,10 @@ Signed-off-by: Robbie Harwood 1 file changed, 76 insertions(+), 31 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index ad1b56b716..113c1f746c 100644 +index 14e38a4df02..d47f9ab0352 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -1256,6 +1256,7 @@ grub_btrfs_mount (grub_device_t dev) +@@ -1335,6 +1335,7 @@ grub_btrfs_mount (grub_device_t dev) { struct grub_btrfs_data *data; grub_err_t err; @@ -21,7 +21,7 @@ index ad1b56b716..113c1f746c 100644 if (!dev->disk) { -@@ -1286,11 +1287,14 @@ grub_btrfs_mount (grub_device_t dev) +@@ -1365,11 +1366,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; @@ -40,7 +40,7 @@ index ad1b56b716..113c1f746c 100644 } return data; -@@ -1855,24 +1859,39 @@ find_path (struct grub_btrfs_data *data, +@@ -1966,24 +1970,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; @@ -87,7 +87,7 @@ index ad1b56b716..113c1f746c 100644 } else { -@@ -1883,15 +1902,23 @@ find_path (struct grub_btrfs_data *data, +@@ -1994,15 +2013,23 @@ find_path (struct grub_btrfs_data *data, while (1) { @@ -120,7 +120,7 @@ index ad1b56b716..113c1f746c 100644 if (*type != GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY) { -@@ -1902,7 +1929,9 @@ find_path (struct grub_btrfs_data *data, +@@ -2013,7 +2040,9 @@ find_path (struct grub_btrfs_data *data, if (ctokenlen == 1 && ctoken[0] == '.') { @@ -131,7 +131,7 @@ index ad1b56b716..113c1f746c 100644 continue; } if (ctokenlen == 2 && ctoken[0] == '.' && ctoken[1] == '.') -@@ -1933,8 +1962,9 @@ find_path (struct grub_btrfs_data *data, +@@ -2044,8 +2073,9 @@ find_path (struct grub_btrfs_data *data, *type = GRUB_BTRFS_DIR_ITEM_TYPE_DIRECTORY; key->object_id = key_out.offset; @@ -143,7 +143,7 @@ index ad1b56b716..113c1f746c 100644 continue; } -@@ -2003,7 +2033,9 @@ find_path (struct grub_btrfs_data *data, +@@ -2114,7 +2144,9 @@ find_path (struct grub_btrfs_data *data, return err; } @@ -154,7 +154,7 @@ index ad1b56b716..113c1f746c 100644 if (cdirel->type == GRUB_BTRFS_DIR_ITEM_TYPE_SYMLINK) { struct grub_btrfs_inode inode; -@@ -2053,14 +2085,26 @@ find_path (struct grub_btrfs_data *data, +@@ -2164,14 +2196,26 @@ find_path (struct grub_btrfs_data *data, path = path_alloc = tmp; if (path[0] == '/') { @@ -188,7 +188,7 @@ index ad1b56b716..113c1f746c 100644 } else { -@@ -2716,6 +2760,7 @@ GRUB_MOD_INIT (btrfs) +@@ -2922,6 +2966,7 @@ GRUB_MOD_INIT (btrfs) subvolid_set_env); grub_env_export ("btrfs_subvol"); grub_env_export ("btrfs_subvolid"); diff --git a/0044-grub2-btrfs-04-grub2-install.patch b/0040-grub2-btrfs-04-grub2-install.patch similarity index 87% rename from 0044-grub2-btrfs-04-grub2-install.patch rename to 0040-grub2-btrfs-04-grub2-install.patch index 6b2bc78..c7b5656 100644 --- a/0044-grub2-btrfs-04-grub2-install.patch +++ b/0040-grub2-btrfs-04-grub2-install.patch @@ -9,16 +9,16 @@ Signed-off-by: Robbie Harwood grub-core/osdep/linux/getroot.c | 7 +++++++ grub-core/osdep/unix/config.c | 17 +++++++++++++++-- util/config.c | 10 ++++++++++ - util/grub-install.c | 15 +++++++++++++++ + util/grub-install.c | 14 ++++++++++++++ util/grub-mkrelpath.c | 6 ++++++ include/grub/emu/config.h | 1 + - 6 files changed, 54 insertions(+), 2 deletions(-) + 6 files changed, 53 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c -index 001b818fe5..caf9b1ccd3 100644 +index 7dd775d2ad9..7c29b3523b4 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) +@@ -373,6 +373,7 @@ get_btrfs_fs_prefix (const char *mount_path) return NULL; } @@ -26,7 +26,7 @@ index 001b818fe5..caf9b1ccd3 100644 char ** grub_find_root_devices_from_mountinfo (const char *dir, char **relroot) -@@ -519,6 +520,12 @@ again: +@@ -516,6 +517,12 @@ again: { ret = grub_find_root_devices_from_btrfs (dir); fs_prefix = get_btrfs_fs_prefix (entries[i].enc_path); @@ -40,7 +40,7 @@ index 001b818fe5..caf9b1ccd3 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 7d6325138c..46a881530c 100644 +index 0b1f7618d21..0ce0e309ac0 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) @@ -75,7 +75,7 @@ index 7d6325138c..46a881530c 100644 argv[2] = script; argv[3] = '\0'; diff --git a/util/config.c b/util/config.c -index ebcdd8f5e2..f044a880a7 100644 +index ebcdd8f5e22..f044a880a76 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) @@ -96,19 +96,19 @@ index ebcdd8f5e2..f044a880a7 100644 sizeof ("GRUB_DISTRIBUTOR=") - 1) == 0) { diff --git a/util/grub-install.c b/util/grub-install.c -index 0fbe7f78c6..0f66f36d23 100644 +index 7dc5657bb67..ec3ed49674b 100644 --- a/util/grub-install.c +++ b/util/grub-install.c -@@ -827,6 +827,8 @@ fill_core_services (const char *core_services) - free (sysv_plist); +@@ -843,6 +843,8 @@ try_open (const char *path) } + #endif +extern int use_relative_path_on_btrfs; + int main (int argc, char *argv[]) { -@@ -860,6 +862,9 @@ main (int argc, char *argv[]) +@@ -876,6 +878,9 @@ main (int argc, char *argv[]) grub_util_load_config (&config); @@ -118,11 +118,10 @@ index 0fbe7f78c6..0f66f36d23 100644 if (!bootloader_id && config.grub_distributor) { char *ptr; -@@ -1352,6 +1357,16 @@ main (int argc, char *argv[]) - fprintf (load_cfg_f, "set debug='%s'\n", - debug_image); +@@ -1366,6 +1371,15 @@ main (int argc, char *argv[]) + relative_grubdir = xstrdup ("/"); } -+ + + if (config.is_suse_btrfs_snapshot_enabled + && grub_strncmp(grub_fs->name, "btrfs", sizeof ("btrfs") - 1) == 0) + { @@ -136,7 +135,7 @@ index 0fbe7f78c6..0f66f36d23 100644 char *install_drive = NULL; diff --git a/util/grub-mkrelpath.c b/util/grub-mkrelpath.c -index 47a241a391..5db7a9a7d9 100644 +index 47a241a391b..5db7a9a7d97 100644 --- a/util/grub-mkrelpath.c +++ b/util/grub-mkrelpath.c @@ -40,9 +40,12 @@ struct arguments @@ -163,7 +162,7 @@ index 47a241a391..5db7a9a7d9 100644 if (state->arg_num == 0) arguments->pathname = xstrdup (arg); diff --git a/include/grub/emu/config.h b/include/grub/emu/config.h -index 875d5896ce..c9a7e5f4ad 100644 +index 875d5896ce1..c9a7e5f4ade 100644 --- a/include/grub/emu/config.h +++ b/include/grub/emu/config.h @@ -37,6 +37,7 @@ struct grub_util_config diff --git a/0045-grub2-btrfs-05-grub2-mkconfig.patch b/0041-grub2-btrfs-05-grub2-mkconfig.patch similarity index 93% rename from 0045-grub2-btrfs-05-grub2-mkconfig.patch rename to 0041-grub2-btrfs-05-grub2-mkconfig.patch index ca3f86b..f1187fd 100644 --- a/0045-grub2-btrfs-05-grub2-mkconfig.patch +++ b/0041-grub2-btrfs-05-grub2-mkconfig.patch @@ -13,10 +13,10 @@ Signed-off-by: Michael Chang 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 005f093809..535c0f0249 100644 +index 28e92515795..884e4d363ca 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in -@@ -252,7 +252,8 @@ export GRUB_DEFAULT \ +@@ -256,7 +256,8 @@ export GRUB_DEFAULT \ GRUB_BADRAM \ GRUB_OS_PROBER_SKIP_LIST \ GRUB_DISABLE_SUBMENU \ @@ -27,7 +27,7 @@ index 005f093809..535c0f0249 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 0f6505bf3b..5e96f6cc5d 100644 +index 33e1750aebb..0ba0e0e1c65 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -49,7 +49,11 @@ grub_warn () @@ -43,7 +43,7 @@ index 0f6505bf3b..5e96f6cc5d 100644 is_path_readable_by_grub () diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in -index 858b526c92..de727e6ee6 100644 +index c2d8b093762..3e1b77265db 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -27,6 +27,14 @@ export TEXTDOMAINDIR="@localedir@" @@ -90,10 +90,10 @@ index 858b526c92..de727e6ee6 100644 +EOF +fi diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 292e333324..7bb3a211a7 100644 +index e8ab4082f87..48ff32c1da4 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in -@@ -66,10 +66,14 @@ fi +@@ -68,10 +68,14 @@ fi case x"$GRUB_FS" in xbtrfs) @@ -109,10 +109,10 @@ index 292e333324..7bb3a211a7 100644 xzfs) rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in -index ada20775a1..e9e73b815f 100644 +index 98ee5bc58dc..efcded0fbb4 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in -@@ -73,10 +73,14 @@ fi +@@ -75,10 +75,14 @@ fi case x"$GRUB_FS" in xbtrfs) diff --git a/0046-grub2-btrfs-06-subvol-mount.patch b/0042-grub2-btrfs-06-subvol-mount.patch similarity index 94% rename from 0046-grub2-btrfs-06-subvol-mount.patch rename to 0042-grub2-btrfs-06-subvol-mount.patch index 8cdf247..7ddae56 100644 --- a/0046-grub2-btrfs-06-subvol-mount.patch +++ b/0042-grub2-btrfs-06-subvol-mount.patch @@ -13,7 +13,7 @@ Signed-off-by: Robbie Harwood 4 files changed, 392 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 113c1f746c..d323746ecf 100644 +index d47f9ab0352..d44a1c73b8a 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -41,6 +41,7 @@ @@ -37,7 +37,7 @@ index 113c1f746c..d323746ecf 100644 static grub_err_t read_sblock (grub_disk_t disk, struct grub_btrfs_superblock *sb) -@@ -1223,9 +1230,26 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path) +@@ -1302,9 +1309,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; @@ -64,10 +64,10 @@ index 113c1f746c..d323746ecf 100644 if (err) return grub_error(GRUB_ERR_FILE_NOT_FOUND, "couldn't locate %s\n", path); -@@ -2199,11 +2223,20 @@ grub_btrfs_dir (grub_device_t device, const char *path, - int r = 0; +@@ -2316,11 +2340,20 @@ grub_btrfs_dir (grub_device_t device, const char *path, grub_uint64_t tree; grub_uint8_t type; + grub_size_t est_size = 0; + char *new_path = NULL; if (!data) @@ -86,7 +86,7 @@ index 113c1f746c..d323746ecf 100644 if (err) { grub_btrfs_unmount (data); -@@ -2305,11 +2338,21 @@ grub_btrfs_open (struct grub_file *file, const char *name) +@@ -2447,11 +2480,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; @@ -109,7 +109,7 @@ index 113c1f746c..d323746ecf 100644 if (err) { grub_btrfs_unmount (data); -@@ -2480,6 +2523,150 @@ grub_cmd_btrfs_info (grub_command_t cmd __attribute__ ((unused)), int argc, +@@ -2686,6 +2729,150 @@ grub_cmd_btrfs_info (grub_command_t cmd __attribute__ ((unused)), int argc, return 0; } @@ -260,7 +260,7 @@ index 113c1f746c..d323746ecf 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, -@@ -2686,6 +2873,7 @@ static struct grub_fs grub_btrfs_fs = { +@@ -2892,6 +3079,7 @@ static struct grub_fs grub_btrfs_fs = { }; static grub_command_t cmd_info; @@ -268,7 +268,7 @@ index 113c1f746c..d323746ecf 100644 static grub_extcmd_t cmd_list_subvols; static char * -@@ -2749,6 +2937,9 @@ GRUB_MOD_INIT (btrfs) +@@ -2955,6 +3143,9 @@ GRUB_MOD_INIT (btrfs) cmd_info = grub_register_command("btrfs-info", grub_cmd_btrfs_info, "DEVICE", "Print BtrFS info about DEVICE."); @@ -279,10 +279,10 @@ index 113c1f746c..d323746ecf 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 caf9b1ccd3..28790307e0 100644 +index 7c29b3523b4..74a48c03026 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c -@@ -107,6 +107,14 @@ struct btrfs_ioctl_search_key +@@ -103,6 +103,14 @@ struct btrfs_ioctl_search_key grub_uint32_t unused[9]; }; @@ -297,7 +297,7 @@ index caf9b1ccd3..28790307e0 100644 struct btrfs_ioctl_search_args { struct btrfs_ioctl_search_key key; grub_uint64_t buf[(4096 - sizeof(struct btrfs_ioctl_search_key)) -@@ -378,6 +386,109 @@ get_btrfs_fs_prefix (const char *mount_path) +@@ -375,6 +383,109 @@ get_btrfs_fs_prefix (const char *mount_path) int use_relative_path_on_btrfs = 0; @@ -407,7 +407,7 @@ index caf9b1ccd3..28790307e0 100644 char ** grub_find_root_devices_from_mountinfo (const char *dir, char **relroot) { -@@ -519,12 +630,15 @@ again: +@@ -516,12 +627,15 @@ again: else if (grub_strcmp (entries[i].fstype, "btrfs") == 0) { ret = grub_find_root_devices_from_btrfs (dir); @@ -426,7 +426,7 @@ index caf9b1ccd3..28790307e0 100644 } } else if (!retry && grub_strcmp (entries[i].fstype, "autofs") == 0) -@@ -1150,6 +1264,34 @@ grub_util_get_grub_dev_os (const char *os_dev) +@@ -1147,6 +1261,34 @@ grub_util_get_grub_dev_os (const char *os_dev) return grub_dev; } @@ -462,10 +462,10 @@ index caf9b1ccd3..28790307e0 100644 grub_make_system_path_relative_to_its_root_os (const char *path) { diff --git a/util/grub-install.c b/util/grub-install.c -index 0f66f36d23..84ed6e88ec 100644 +index ec3ed49674b..d3ec2570d1d 100644 --- a/util/grub-install.c +++ b/util/grub-install.c -@@ -1569,6 +1569,55 @@ main (int argc, char *argv[]) +@@ -1615,6 +1615,55 @@ main (int argc, char *argv[]) prefix_drive = xasprintf ("(%s)", grub_drives[0]); } @@ -522,7 +522,7 @@ index 0f66f36d23..84ed6e88ec 100644 const char *core_name = NULL; diff --git a/include/grub/emu/getroot.h b/include/grub/emu/getroot.h -index 73fa2d34ab..9c642ae3fe 100644 +index 73fa2d34abb..9c642ae3fe3 100644 --- a/include/grub/emu/getroot.h +++ b/include/grub/emu/getroot.h @@ -53,6 +53,11 @@ char ** diff --git a/0047-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch b/0043-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch similarity index 94% rename from 0047-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch rename to 0043-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch index a5db09a..1b3a969 100644 --- a/0047-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch +++ b/0043-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch @@ -10,10 +10,10 @@ 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 d323746ecf..673ded0352 100644 +index d44a1c73b8a..dba86d19b1a 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -1260,11 +1260,41 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path) +@@ -1339,11 +1339,41 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path) return GRUB_ERR_NONE; } diff --git a/0048-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch b/0044-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch similarity index 97% rename from 0048-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch rename to 0044-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch index 99c106d..add5764 100644 --- a/0048-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch +++ b/0044-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch @@ -10,10 +10,10 @@ Signed-off-by: Robbie Harwood 1 file changed, 238 insertions(+) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 673ded0352..2b21cbaa67 100644 +index dba86d19b1a..87e4dd1a07a 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c -@@ -2887,6 +2887,238 @@ out: +@@ -3093,6 +3093,238 @@ out: return 0; } @@ -252,7 +252,7 @@ index 673ded0352..2b21cbaa67 100644 static struct grub_fs grub_btrfs_fs = { .name = "btrfs", .fs_dir = grub_btrfs_dir, -@@ -2905,6 +3137,7 @@ static struct grub_fs grub_btrfs_fs = { +@@ -3111,6 +3343,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; @@ -260,7 +260,7 @@ index 673ded0352..2b21cbaa67 100644 static char * subvolid_set_env (struct grub_env_var *var __attribute__ ((unused)), -@@ -2975,6 +3208,11 @@ GRUB_MOD_INIT (btrfs) +@@ -3181,6 +3414,11 @@ GRUB_MOD_INIT (btrfs) "[-p|-n] [-o var] DEVICE", "Print list of BtrFS subvolumes on " "DEVICE.", options); diff --git a/0049-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch b/0045-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch similarity index 82% rename from 0049-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch rename to 0045-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch index d07dd27..b88fbab 100644 --- a/0049-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch +++ b/0045-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch @@ -10,21 +10,21 @@ 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 585fa6662b..03f9a9d011 100644 +index a5cd99e5afa..8d98203a784 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h -@@ -24,6 +24,10 @@ - #include - #include +@@ -36,6 +36,10 @@ struct linux_arch_kernel_header { + struct grub_pe_image_header pe_image_header; + }; +/* Variables. */ +extern grub_efi_system_table_t *EXPORT_VAR(grub_efi_system_table); +extern grub_efi_handle_t EXPORT_VAR(grub_efi_image_handle); + /* Functions. */ - void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_efi_guid_t *protocol, + void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_guid_t *protocol, void *registration); -@@ -60,6 +64,33 @@ EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size, +@@ -71,6 +75,33 @@ EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size, grub_efi_uintn_t *descriptor_size, grub_efi_uint32_t *descriptor_version); void grub_efi_memory_fini (void); @@ -39,7 +39,7 @@ index 585fa6662b..03f9a9d011 100644 + grub_efi_status_t status; + + b = grub_efi_system_table->boot_services; -+ status = efi_call_3 (b->allocate_pool, pool_type, buffer_size, buffer); ++ status = b->allocate_pool(pool_type, buffer_size, buffer); + return status; +} + @@ -51,14 +51,14 @@ index 585fa6662b..03f9a9d011 100644 + grub_efi_status_t status; + + b = grub_efi_system_table->boot_services; -+ status = efi_call_1 (b->free_pool, buffer); ++ status = b->free_pool(buffer); + return status; +} + 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); -@@ -115,10 +146,7 @@ void grub_efi_init (void); +@@ -140,10 +171,7 @@ void grub_efi_init (void); void grub_efi_fini (void); void grub_efi_set_prefix (void); diff --git a/0046-Use-grub_efi_.-memory-helpers-where-reasonable.patch b/0046-Use-grub_efi_.-memory-helpers-where-reasonable.patch new file mode 100644 index 0000000..0523c64 --- /dev/null +++ b/0046-Use-grub_efi_.-memory-helpers-where-reasonable.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 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. + +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 +get more reasonable type checking. + +Signed-off-by: Peter Jones +--- + grub-core/loader/efi/chainloader.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index 1de98f78313..2036924504b 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -95,7 +95,7 @@ grub_chainloader_boot (void *context) + } + + if (exit_data) +- b->free_pool (exit_data); ++ grub_efi_free_pool (exit_data); + + grub_loader_unset (); + +@@ -419,7 +419,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + grub_free (file_path); + + if (address) +- b->free_pages (address, pages); ++ grub_efi_free_pages (address, pages); + + if (image_handle != NULL) + b->unload_image (image_handle); diff --git a/0047-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch b/0047-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch new file mode 100644 index 0000000..c852ced --- /dev/null +++ b/0047-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch @@ -0,0 +1,33 @@ +From 0000000000000000000000000000000000000000 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. + +This avoids syntax checkers getting confused about if it's llx or lx. + +Signed-off-by: Peter Jones +--- + include/grub/efi/api.h | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h +index c1b869db520..daa9268fdaa 100644 +--- a/include/grub/efi/api.h ++++ b/include/grub/efi/api.h +@@ -577,7 +577,16 @@ 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_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" ++#define PRIdGRUB_EFI_STATUS "ld" ++#else ++#define PRIxGRUB_EFI_STATUS "llx" ++#define PRIdGRUB_EFI_STATUS "lld" ++#endif + + /* + * On x86, the EFI calling convention may deviate from the local one, so diff --git a/0052-don-t-use-int-for-efi-status.patch b/0048-don-t-use-int-for-efi-status.patch similarity index 88% rename from 0052-don-t-use-int-for-efi-status.patch rename to 0048-don-t-use-int-for-efi-status.patch index 4d48e37..de4367d 100644 --- a/0052-don-t-use-int-for-efi-status.patch +++ b/0048-don-t-use-int-for-efi-status.patch @@ -8,10 +8,10 @@ Subject: [PATCH] don't use int for efi status 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 05d8237a9b..ae9885edb8 100644 +index 885d7c6420e..2bb8a0e7a38 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -167,7 +167,7 @@ grub_reboot (void) +@@ -177,7 +177,7 @@ grub_reboot (void) void grub_exit (int retval) { diff --git a/0053-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch b/0049-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch similarity index 96% rename from 0053-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch rename to 0049-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch index fb71ea5..44c0819 100644 --- a/0053-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch +++ b/0049-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch @@ -8,7 +8,7 @@ Subject: [PATCH] make GRUB_MOD_INIT() declare its function prototypes. 1 file changed, 2 insertions(+) diff --git a/include/grub/dl.h b/include/grub/dl.h -index b3753c9ca2..91933b85f2 100644 +index cd1f46c8bad..f2bf50eb98d 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -54,6 +54,7 @@ grub_mod_fini (void) diff --git a/0054-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch b/0050-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch similarity index 92% rename from 0054-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch rename to 0050-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch index ae8a8c6..8dfb85f 100644 --- a/0054-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch +++ b/0050-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch @@ -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 84ed6e88ec..a2bec7446c 100644 +index d3ec2570d1d..66ef9494d9d 100644 --- a/util/grub-install.c +++ b/util/grub-install.c -@@ -1190,18 +1190,8 @@ main (int argc, char *argv[]) +@@ -1234,18 +1234,8 @@ main (int argc, char *argv[]) char *d; is_guess = 1; diff --git a/0050-Use-grub_efi_.-memory-helpers-where-reasonable.patch b/0050-Use-grub_efi_.-memory-helpers-where-reasonable.patch deleted file mode 100644 index 2a3d27b..0000000 --- a/0050-Use-grub_efi_.-memory-helpers-where-reasonable.patch +++ /dev/null @@ -1,106 +0,0 @@ -From 0000000000000000000000000000000000000000 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. - -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 -get more reasonable type checking. - -Signed-off-by: Peter Jones ---- - grub-core/loader/efi/chainloader.c | 24 +++++++++--------------- - 1 file changed, 9 insertions(+), 15 deletions(-) - -diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 07c4937898..89ac84cc66 100644 ---- a/grub-core/loader/efi/chainloader.c -+++ b/grub-core/loader/efi/chainloader.c -@@ -65,7 +65,7 @@ grub_chainloader_unload (void) - - b = grub_efi_system_table->boot_services; - efi_call_1 (b->unload_image, image_handle); -- efi_call_2 (b->free_pages, address, pages); -+ grub_efi_free_pages (address, pages); - - grub_free (file_path); - grub_free (cmdline); -@@ -108,7 +108,7 @@ grub_chainloader_boot (void) - } - - if (exit_data) -- efi_call_1 (b->free_pool, exit_data); -+ grub_efi_free_pool (exit_data); - - grub_loader_unset (); - -@@ -527,10 +527,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) - { -- grub_efi_boot_services_t *b; - grub_efi_loaded_image_t *li, li_bak; - grub_efi_status_t efi_status; -- char *buffer = NULL; -+ void *buffer = NULL; - char *buffer_aligned = NULL; - grub_efi_uint32_t i; - struct grub_pe32_section_table *section; -@@ -541,8 +540,6 @@ handle_image (void *data, grub_efi_uint32_t datasize) - int found_entry_point = 0; - int rc; - -- b = grub_efi_system_table->boot_services; -- - rc = read_header (data, datasize, &context); - if (rc < 0) - { -@@ -582,8 +579,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); - -- efi_status = efi_call_3 (b->allocate_pool, GRUB_EFI_LOADER_DATA, -- buffer_size, &buffer); -+ efi_status = grub_efi_allocate_pool (GRUB_EFI_LOADER_DATA, buffer_size, -+ &buffer); - - if (efi_status != GRUB_EFI_SUCCESS) - { -@@ -815,14 +812,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)); -- efi_status = efi_call_1 (b->free_pool, buffer); -+ efi_status = grub_efi_free_pool (buffer); - - return 1; - - error_exit: - grub_dprintf ("chain", "error_exit: grub_errno: %d\n", grub_errno); - if (buffer) -- efi_call_1 (b->free_pool, buffer); -+ grub_efi_free_pool (buffer); - - return 0; - } -@@ -830,10 +827,7 @@ error_exit: - static grub_err_t - grub_secureboot_chainloader_unload (void) - { -- grub_efi_boot_services_t *b; -- -- b = grub_efi_system_table->boot_services; -- efi_call_2 (b->free_pages, address, pages); -+ grub_efi_free_pages (address, pages); - grub_free (file_path); - grub_free (cmdline); - cmdline = 0; -@@ -1100,7 +1094,7 @@ fail: - grub_free (file_path); - - if (address) -- efi_call_2 (b->free_pages, address, pages); -+ grub_efi_free_pages (address, pages); - - if (cmdline) - grub_free (cmdline); diff --git a/0055-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch b/0051-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch similarity index 85% rename from 0055-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch rename to 0051-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch index cd58ff4..026fe5e 100644 --- a/0055-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch +++ b/0051-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch @@ -9,10 +9,10 @@ Signed-off-by: Peter Jones 1 file changed, 5 insertions(+) diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in -index e9e73b815f..c23b064be6 100644 +index efcded0fbb4..4ecf5deea17 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in -@@ -153,6 +153,7 @@ linux_entry_xsm () +@@ -156,6 +156,7 @@ linux_entry_xsm () else xen_rm_opts="no-real-mode edd=off" fi @@ -20,15 +20,15 @@ index e9e73b815f..c23b064be6 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} -@@ -166,6 +167,7 @@ EOF - done - sed "s/^/$submenu_indentation/" << EOF +@@ -168,6 +169,7 @@ EOF + initrd_path="${rel_dirname}/${i}" + sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' + insmod ${xen_module} ${module_loader} --nounzip $(echo $initrd_path) EOF - fi -@@ -253,13 +255,16 @@ while [ "x${xen_list}" != "x" ] ; do + done +@@ -269,13 +271,16 @@ for current_xen in ${reverse_sorted_xen_list}; do 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 diff --git a/0051-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch b/0051-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch deleted file mode 100644 index f649c8c..0000000 --- a/0051-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 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. - -This avoids syntax checkers getting confused about if it's llx or lx. - -Signed-off-by: Peter Jones ---- - grub-core/loader/efi/chainloader.c | 3 ++- - include/grub/efi/api.h | 9 +++++++++ - 2 files changed, 11 insertions(+), 1 deletion(-) - -diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 89ac84cc66..ac8dfd40c6 100644 ---- a/grub-core/loader/efi/chainloader.c -+++ b/grub-core/loader/efi/chainloader.c -@@ -810,7 +810,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); - -- grub_dprintf ("chain", "entry_point returned %ld\n", efi_status); -+ grub_dprintf ("chain", "entry_point returned 0x%"PRIxGRUB_EFI_STATUS"\n", -+ efi_status); - grub_memcpy (li, &li_bak, sizeof (grub_efi_loaded_image_t)); - efi_status = grub_efi_free_pool (buffer); - -diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 117469450d..9962880147 100644 ---- a/include/grub/efi/api.h -+++ b/include/grub/efi/api.h -@@ -546,7 +546,16 @@ 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_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" -+#define PRIdGRUB_EFI_STATUS "ld" -+#else -+#define PRIxGRUB_EFI_STATUS "llx" -+#define PRIdGRUB_EFI_STATUS "lld" -+#endif - - #define GRUB_EFI_ERROR_CODE(value) \ - ((((grub_efi_status_t) 1) << (sizeof (grub_efi_status_t) * 8 - 1)) | (value)) diff --git a/0057-align-struct-efi_variable-better.patch b/0052-align-struct-efi_variable-better.patch similarity index 91% rename from 0057-align-struct-efi_variable-better.patch rename to 0052-align-struct-efi_variable-better.patch index 361cb13..24c3237 100644 --- a/0057-align-struct-efi_variable-better.patch +++ b/0052-align-struct-efi_variable-better.patch @@ -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 36d2dedf47..9d93ba88ba 100644 +index 2ff42984545..6363fd522e1 100644 --- a/include/grub/efiemu/runtime.h +++ b/include/grub/efiemu/runtime.h @@ -33,5 +33,5 @@ struct efi_variable @@ -20,10 +20,10 @@ index 36d2dedf47..9d93ba88ba 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 0a3ff15913..ba446d9904 100644 +index 064066e2e18..59e030268c2 100644 --- a/include/grub/types.h +++ b/include/grub/types.h -@@ -29,6 +29,7 @@ +@@ -30,6 +30,7 @@ #else #define GRUB_PACKED __attribute__ ((packed)) #endif diff --git a/0058-Add-BLS-support-to-grub-mkconfig.patch b/0053-Add-BLS-support-to-grub-mkconfig.patch similarity index 96% rename from 0058-Add-BLS-support-to-grub-mkconfig.patch rename to 0053-Add-BLS-support-to-grub-mkconfig.patch index 3e5b230..6b60ee7 100644 --- a/0058-Add-BLS-support-to-grub-mkconfig.patch +++ b/0053-Add-BLS-support-to-grub-mkconfig.patch @@ -33,7 +33,7 @@ Signed-off-by: Robbie Harwood 3 files changed, 243 insertions(+), 6 deletions(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 535c0f0249..f55339a3f6 100644 +index 884e4d363ca..bec52e052fc 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -50,6 +50,8 @@ grub_get_kernel_settings="${sbindir}/@grub_get_kernel_settings@" @@ -63,7 +63,7 @@ index 535c0f0249..f55339a3f6 100644 -*) gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2 usage -@@ -253,7 +259,8 @@ export GRUB_DEFAULT \ +@@ -257,7 +263,8 @@ export GRUB_DEFAULT \ GRUB_OS_PROBER_SKIP_LIST \ GRUB_DISABLE_SUBMENU \ GRUB_DEFAULT_DTB \ @@ -74,7 +74,7 @@ index 535c0f0249..f55339a3f6 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 5e96f6cc5d..301d8a8a1e 100644 +index 0ba0e0e1c65..c2e107b41ab 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -30,6 +30,9 @@ fi @@ -131,10 +131,10 @@ index 5e96f6cc5d..301d8a8a1e 100644 fi IFS="$old_ifs" diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 7bb3a211a7..2851952659 100644 +index 48ff32c1da4..cd9aea0cc01 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in -@@ -82,6 +82,218 @@ case x"$GRUB_FS" in +@@ -84,6 +84,218 @@ case x"$GRUB_FS" in ;; esac @@ -353,7 +353,7 @@ index 7bb3a211a7..2851952659 100644 mktitle () { local title_type -@@ -121,6 +333,7 @@ linux_entry () +@@ -123,6 +335,7 @@ linux_entry () if [ -z "$boot_device_id" ]; then boot_device_id="$(grub_get_device_id "${GRUB_DEVICE}")" fi @@ -361,15 +361,15 @@ index 7bb3a211a7..2851952659 100644 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 -@@ -231,6 +444,7 @@ is_top_level=true - while [ "x$list" != "x" ] ; do - linux=`version_find_latest $list` +@@ -243,6 +456,7 @@ fi + is_top_level=true + for linux in ${reverse_sorted_list}; do 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` -@@ -269,7 +483,9 @@ while [ "x$list" != "x" ] ; do +@@ -283,7 +497,9 @@ for linux in ${reverse_sorted_list}; do for i in ${initrd}; do initrd_display="${initrd_display} ${dirname}/${i}" done diff --git a/0059-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch b/0054-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch similarity index 89% rename from 0059-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch rename to 0054-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch index 1ac900c..4b925a5 100644 --- a/0059-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch +++ b/0054-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch @@ -12,10 +12,10 @@ 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 a3e215155b..c60601b699 100644 +index 465a8e74ea7..b1d399d37d7 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -1201,7 +1201,7 @@ static void __attribute__ ((noreturn)) +@@ -1303,7 +1303,7 @@ void __attribute__ ((noreturn)) grub_abort (void) { #ifndef GRUB_UTIL diff --git a/0060-Add-grub2-switch-to-blscfg.patch b/0055-Add-grub2-switch-to-blscfg.patch similarity index 97% rename from 0060-Add-grub2-switch-to-blscfg.patch rename to 0055-Add-grub2-switch-to-blscfg.patch index e316116..cb97a28 100644 --- a/0060-Add-grub2-switch-to-blscfg.patch +++ b/0055-Add-grub2-switch-to-blscfg.patch @@ -20,10 +20,10 @@ Signed-off-by: Robbie Harwood create mode 100644 util/grub-switch-to-blscfg.in diff --git a/Makefile.util.def b/Makefile.util.def -index 18a9242776..88f55e35c4 100644 +index 84a17ef5cfa..acbcc8c208c 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -1348,6 +1348,13 @@ program = { +@@ -1387,6 +1387,13 @@ program = { ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -39,14 +39,14 @@ index 18a9242776..88f55e35c4 100644 mansection = 1; diff --git a/docs/man/grub-switch-to-blscfg.h2m b/docs/man/grub-switch-to-blscfg.h2m new file mode 100644 -index 0000000000..fa341426a5 +index 00000000000..fa341426a50 --- /dev/null +++ b/docs/man/grub-switch-to-blscfg.h2m @@ -0,0 +1,2 @@ +[NAME] +grub-switch-to-blscfg \- switch to using BLS config files diff --git a/util/grub-set-password.in b/util/grub-set-password.in -index 5ebf50576d..c0b5ebbfdc 100644 +index 5ebf50576d6..c0b5ebbfdc5 100644 --- a/util/grub-set-password.in +++ b/util/grub-set-password.in @@ -1,6 +1,6 @@ @@ -59,7 +59,7 @@ index 5ebf50576d..c0b5ebbfdc 100644 else diff --git a/util/grub-switch-to-blscfg.in b/util/grub-switch-to-blscfg.in new file mode 100644 -index 0000000000..a851424beb +index 00000000000..a851424beb2 --- /dev/null +++ b/util/grub-switch-to-blscfg.in @@ -0,0 +1,317 @@ @@ -381,10 +381,10 @@ index 0000000000..a851424beb +# Bye. +exit 0 diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 2851952659..e490e1a43a 100644 +index cd9aea0cc01..b8bc37e92aa 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in -@@ -138,7 +138,7 @@ blsdir="/boot/loader/entries" +@@ -140,7 +140,7 @@ blsdir="/boot/loader/entries" get_sorted_bls() { diff --git a/0056-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch b/0056-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch deleted file mode 100644 index beef0f3..0000000 --- a/0056-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch +++ /dev/null @@ -1,211 +0,0 @@ -From 0000000000000000000000000000000000000000 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. - -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 -to do so (as measured with the stopwatch on my phone), with a tsc delta -of 0x1cd1c85300, or around 125 billion cycles. - -If instead of trying to wait for 5-200ms to show up on the pmtimer, we try -to wait for 5-200us, it decides it's broken in ~0x2626aa0 TSCs, aka ~2.4 -million cycles, or more or less instantly. - -Additionally, this reading the pmtimer was returning 0xffffffff anyway, -and that's obviously an invalid return. I've added a check for that and -0 so we don't bother waiting for the test if what we're seeing is dead -pins with no response at all. - -If "debug" is includes "pmtimer", you will see one of the following -three outcomes. If pmtimer gives all 0 or all 1 bits, you will see: - -kern/i386/tsc_pmtimer.c:77: pmtimer: 0xffffff bad_reads: 1 -kern/i386/tsc_pmtimer.c:77: pmtimer: 0xffffff bad_reads: 2 -kern/i386/tsc_pmtimer.c:77: pmtimer: 0xffffff bad_reads: 3 -kern/i386/tsc_pmtimer.c:77: pmtimer: 0xffffff bad_reads: 4 -kern/i386/tsc_pmtimer.c:77: pmtimer: 0xffffff bad_reads: 5 -kern/i386/tsc_pmtimer.c:77: pmtimer: 0xffffff bad_reads: 6 -kern/i386/tsc_pmtimer.c:77: pmtimer: 0xffffff bad_reads: 7 -kern/i386/tsc_pmtimer.c:77: pmtimer: 0xffffff bad_reads: 8 -kern/i386/tsc_pmtimer.c:77: pmtimer: 0xffffff bad_reads: 9 -kern/i386/tsc_pmtimer.c:77: pmtimer: 0xffffff bad_reads: 10 -kern/i386/tsc_pmtimer.c:78: timer is broken; giving up. - -This outcome was tested using qemu+kvm with UEFI (OVMF) firmware and -these options: -machine pc-q35-2.10 -cpu Broadwell-noTSX - -If pmtimer gives any other bit patterns but is not actually marching -forward fast enough to use for clock calibration, you will see: - -kern/i386/tsc_pmtimer.c:121: pmtimer delta is 0x0 (1904 iterations) -kern/i386/tsc_pmtimer.c:124: tsc delta is implausible: 0x2626aa0 - -This outcome was tested using grub compiled with GRUB_PMTIMER_IGNORE_BAD_READS -defined (so as not to trip the bad read test) using qemu+kvm with UEFI -(OVMF) firmware, and these options: -machine pc-q35-2.10 -cpu Broadwell-noTSX - -If pmtimer actually works, you'll see something like: - -kern/i386/tsc_pmtimer.c:121: pmtimer delta is 0x0 (1904 iterations) -kern/i386/tsc_pmtimer.c:124: tsc delta is implausible: 0x2626aa0 - -This outcome was tested using qemu+kvm with UEFI (OVMF) firmware, and -these options: -machine pc-i440fx-2.4 -cpu Broadwell-noTSX - -I've also tested this outcome on a real Intel Xeon E3-1275v3 on an Intel -Server Board S1200V3RPS using the SDV.RP.B8 "Release" build here: -https://firmware.intel.com/sites/default/files/UEFIDevKit_S1200RP_vB8.zip - -Signed-off-by: Peter Jones ---- - grub-core/kern/i386/tsc_pmtimer.c | 109 +++++++++++++++++++++++++++++++------- - 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 c9c3616997..ca15c3aacd 100644 ---- a/grub-core/kern/i386/tsc_pmtimer.c -+++ b/grub-core/kern/i386/tsc_pmtimer.c -@@ -28,40 +28,101 @@ - #include - #include - -+/* -+ * Define GRUB_PMTIMER_IGNORE_BAD_READS if you're trying to test a timer that's -+ * present but doesn't keep time well. -+ */ -+// #define GRUB_PMTIMER_IGNORE_BAD_READS -+ - grub_uint64_t - grub_pmtimer_wait_count_tsc (grub_port_t pmtimer, - grub_uint16_t num_pm_ticks) - { - grub_uint32_t start; -- grub_uint32_t last; -- grub_uint32_t cur, end; -+ grub_uint64_t cur, end; - grub_uint64_t start_tsc; - grub_uint64_t end_tsc; -- int num_iter = 0; -+ unsigned int num_iter = 0; -+#ifndef GRUB_PMTIMER_IGNORE_BAD_READS -+ int bad_reads = 0; -+#endif - -- start = grub_inl (pmtimer) & 0xffffff; -- last = start; -+ /* -+ * Some timers are 24-bit and some are 32-bit, but it doesn't make much -+ * difference to us. Caring which one we have isn't really worth it since -+ * the low-order digits will give us enough data to calibrate TSC. So just -+ * mask the top-order byte off. -+ */ -+ cur = start = grub_inl (pmtimer) & 0xffffffUL; - end = start + num_pm_ticks; - start_tsc = grub_get_tsc (); - while (1) - { -- cur = grub_inl (pmtimer) & 0xffffff; -- if (cur < last) -- cur |= 0x1000000; -- num_iter++; -+ cur &= 0xffffffffff000000ULL; -+ cur |= grub_inl (pmtimer) & 0xffffffUL; -+ -+ end_tsc = grub_get_tsc(); -+ -+#ifndef GRUB_PMTIMER_IGNORE_BAD_READS -+ /* -+ * If we get 10 reads in a row that are obviously dead pins, there's no -+ * reason to do this thousands of times. -+ */ -+ if (cur == 0xffffffUL || cur == 0) -+ { -+ bad_reads++; -+ grub_dprintf ("pmtimer", -+ "pmtimer: 0x%"PRIxGRUB_UINT64_T" bad_reads: %d\n", -+ cur, bad_reads); -+ grub_dprintf ("pmtimer", "timer is broken; giving up.\n"); -+ -+ if (bad_reads == 10) -+ return 0; -+ } -+#endif -+ -+ if (cur < start) -+ cur += 0x1000000; -+ - if (cur >= end) - { -- end_tsc = grub_get_tsc (); -+ grub_dprintf ("pmtimer", "pmtimer delta is 0x%"PRIxGRUB_UINT64_T"\n", -+ cur - start); -+ grub_dprintf ("pmtimer", "tsc delta is 0x%"PRIxGRUB_UINT64_T"\n", -+ end_tsc - start_tsc); - return end_tsc - start_tsc; - } -- /* Check for broken PM timer. -- 50000000 TSCs is between 5 ms (10GHz) and 200 ms (250 MHz) -- if after this time we still don't have 1 ms on pmtimer, then -- pmtimer is broken. -+ -+ /* -+ * Check for broken PM timer. 1ms at 10GHz should be 1E+7 TSCs; at -+ * 250MHz it should be 2.5E6. So if after 4E+7 TSCs on a 10GHz machine, -+ * we should have seen pmtimer show 4ms of change (i.e. cur =~ -+ * start+14320); on a 250MHz machine that should be 16ms (start+57280). -+ * If after this a time we still don't have 1ms on pmtimer, then pmtimer -+ * is broken. -+ * -+ * Likewise, if our code is perfectly efficient and introduces no delays -+ * whatsoever, on a 10GHz system we should see a TSC delta of 3580 in -+ * ~3580 iterations. On a 250MHz machine that should be ~900 iterations. -+ * -+ * With those factors in mind, there are two limits here. There's a hard -+ * limit here at 8x our desired pm timer delta, picked as an arbitrarily -+ * large value that's still not a lot of time to humans, because if we -+ * get that far this is either an implausibly fast machine or the pmtimer -+ * is not running. And there's another limit on 4x our 10GHz tsc delta -+ * without seeing cur converge on our target value. - */ -- if ((num_iter & 0xffffff) == 0 && grub_get_tsc () - start_tsc > 5000000) { -- return 0; -- } -+ if ((++num_iter > (grub_uint32_t)num_pm_ticks << 3UL) || -+ end_tsc - start_tsc > 40000000) -+ { -+ grub_dprintf ("pmtimer", -+ "pmtimer delta is 0x%"PRIxGRUB_UINT64_T" (%u iterations)\n", -+ cur - start, num_iter); -+ grub_dprintf ("pmtimer", -+ "tsc delta is implausible: 0x%"PRIxGRUB_UINT64_T"\n", -+ end_tsc - start_tsc); -+ return 0; -+ } - } - } - -@@ -74,12 +135,20 @@ grub_tsc_calibrate_from_pmtimer (void) - - fadt = grub_acpi_find_fadt (); - if (!fadt) -- return 0; -+ { -+ grub_dprintf ("pmtimer", "No FADT found; not using pmtimer.\n"); -+ return 0; -+ } - pmtimer = fadt->pmtimer; - if (!pmtimer) -- return 0; -+ { -+ grub_dprintf ("pmtimer", "FADT does not specify pmtimer; skipping.\n"); -+ return 0; -+ } - -- /* It's 3.579545 MHz clock. Wait 1 ms. */ -+ /* -+ * It's 3.579545 MHz clock. Wait 1 ms. -+ */ - tsc_diff = grub_pmtimer_wait_count_tsc (pmtimer, 3580); - if (tsc_diff == 0) - return 0; diff --git a/0062-normal-don-t-draw-our-startup-message-if-debug-is-se.patch b/0056-normal-don-t-draw-our-startup-message-if-debug-is-se.patch similarity index 87% rename from 0062-normal-don-t-draw-our-startup-message-if-debug-is-se.patch rename to 0056-normal-don-t-draw-our-startup-message-if-debug-is-se.patch index a916299..7b26166 100644 --- a/0062-normal-don-t-draw-our-startup-message-if-debug-is-se.patch +++ b/0056-normal-don-t-draw-our-startup-message-if-debug-is-se.patch @@ -8,7 +8,7 @@ Subject: [PATCH] normal: don't draw our startup message if debug is set 1 file changed, 3 insertions(+) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 55558cc0b9..af9792c963 100644 +index 3463f444f74..b5fa6156549 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -430,6 +430,9 @@ grub_normal_reader_init (int nested) @@ -20,4 +20,4 @@ index 55558cc0b9..af9792c963 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"), + "else TAB lists possible device or file completions. To enable " diff --git a/0063-Work-around-some-minor-include-path-weirdnesses.patch b/0057-Work-around-some-minor-include-path-weirdnesses.patch similarity index 97% rename from 0063-Work-around-some-minor-include-path-weirdnesses.patch rename to 0057-Work-around-some-minor-include-path-weirdnesses.patch index c7ae8d0..460d792 100644 --- a/0063-Work-around-some-minor-include-path-weirdnesses.patch +++ b/0057-Work-around-some-minor-include-path-weirdnesses.patch @@ -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 0000000000..1592f6f76b +index 00000000000..1592f6f76b5 --- /dev/null +++ b/include/grub/arm/efi/console.h @@ -0,0 +1,24 @@ @@ -47,7 +47,7 @@ index 0000000000..1592f6f76b +#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 0000000000..9568933938 +index 00000000000..95689339384 --- /dev/null +++ b/include/grub/arm64/efi/console.h @@ -0,0 +1,24 @@ @@ -77,7 +77,7 @@ index 0000000000..9568933938 +#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 0000000000..9231375cb0 +index 00000000000..9231375cb07 --- /dev/null +++ b/include/grub/i386/efi/console.h @@ -0,0 +1,24 @@ @@ -107,7 +107,7 @@ index 0000000000..9231375cb0 +#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 0000000000..dba9d8678d +index 00000000000..dba9d8678d0 --- /dev/null +++ b/include/grub/x86_64/efi/console.h @@ -0,0 +1,24 @@ diff --git a/0064-Make-it-possible-to-enabled-build-id-sha1.patch b/0058-Make-it-possible-to-enabled-build-id-sha1.patch similarity index 93% rename from 0064-Make-it-possible-to-enabled-build-id-sha1.patch rename to 0058-Make-it-possible-to-enabled-build-id-sha1.patch index 99d8055..201081d 100644 --- a/0064-Make-it-possible-to-enabled-build-id-sha1.patch +++ b/0058-Make-it-possible-to-enabled-build-id-sha1.patch @@ -10,10 +10,10 @@ Signed-off-by: Peter Jones 2 files changed, 27 insertions(+) diff --git a/configure.ac b/configure.ac -index 0d0e6782a1..302300711f 100644 +index 3602b4ab62b..fcfbcbb664d 100644 --- a/configure.ac +++ b/configure.ac -@@ -1442,7 +1442,15 @@ grub_PROG_TARGET_CC +@@ -1540,7 +1540,15 @@ grub_PROG_TARGET_CC if test "x$TARGET_APPLE_LINKER" != x1 ; then grub_PROG_OBJCOPY_ABSOLUTE fi @@ -30,7 +30,7 @@ index 0d0e6782a1..302300711f 100644 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 6e14bb553c..21238fcfd0 100644 +index fa7840f09af..0231e64e337 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -136,6 +136,25 @@ if test "x$grub_cv_prog_ld_build_id_none" = xyes; then diff --git a/0061-make-better-backtraces.patch b/0059-make-better-backtraces.patch similarity index 93% rename from 0061-make-better-backtraces.patch rename to 0059-make-better-backtraces.patch index 7fdcaf7..d7f64a6 100644 --- a/0061-make-better-backtraces.patch +++ b/0059-make-better-backtraces.patch @@ -15,7 +15,7 @@ Signed-off-by: Peter Jones 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/misc.c | 11 +-- grub-core/kern/mm.c | 6 +- grub-core/lib/arm64/backtrace.c | 62 ---------------- grub-core/lib/i386/backtrace.c | 78 -------------------- @@ -29,7 +29,7 @@ Signed-off-by: Peter Jones 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(+), 167 deletions(-) + 24 files changed, 413 insertions(+), 166 deletions(-) rename grub-core/{lib => commands}/backtrace.c (98%) create mode 100644 grub-core/kern/arm64/backtrace.c create mode 100644 grub-core/kern/backtrace.c @@ -38,7 +38,7 @@ Signed-off-by: Peter Jones delete mode 100644 grub-core/lib/i386/backtrace.c diff --git a/Makefile.util.def b/Makefile.util.def -index 88f55e35c4..bda9fd1211 100644 +index acbcc8c208c..1079add5bbe 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -51,6 +51,12 @@ library = { @@ -55,10 +55,10 @@ index 88f55e35c4..bda9fd1211 100644 library = { diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 058c88ac3a..52ec0fafcd 100644 +index 63f053b3add..6645fbae34f 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -142,6 +142,12 @@ kernel = { +@@ -153,6 +153,12 @@ kernel = { common = kern/rescue_reader.c; common = kern/term.c; common = kern/verifiers.c; @@ -71,7 +71,7 @@ index 058c88ac3a..52ec0fafcd 100644 noemu = kern/compiler-rt.c; noemu = kern/mm.c; -@@ -188,9 +194,6 @@ kernel = { +@@ -199,9 +205,6 @@ kernel = { softdiv = lib/division.c; @@ -81,7 +81,7 @@ index 058c88ac3a..52ec0fafcd 100644 i386 = kern/i386/dl.c; i386_xen = kern/i386/dl.c; i386_xen_pvh = kern/i386/dl.c; -@@ -2399,15 +2402,12 @@ module = { +@@ -2455,15 +2458,12 @@ module = { module = { name = backtrace; @@ -103,7 +103,7 @@ 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 c0ad6ab8be..8b5ec3913b 100644 +index c0ad6ab8be1..8b5ec3913b5 100644 --- a/grub-core/lib/backtrace.c +++ b/grub-core/commands/backtrace.c @@ -54,7 +54,7 @@ grub_cmd_backtrace (grub_command_t cmd __attribute__ ((unused)), @@ -116,7 +116,7 @@ index c0ad6ab8be..8b5ec3913b 100644 } diff --git a/grub-core/gdb/cstub.c b/grub-core/gdb/cstub.c -index b64acd70fe..99281472d3 100644 +index b64acd70fee..99281472d36 100644 --- a/grub-core/gdb/cstub.c +++ b/grub-core/gdb/cstub.c @@ -215,7 +215,6 @@ grub_gdb_trap (int trap_no) @@ -129,7 +129,7 @@ index b64acd70fe..99281472d3 100644 diff --git a/grub-core/kern/arm64/backtrace.c b/grub-core/kern/arm64/backtrace.c new file mode 100644 -index 0000000000..019c6fdfef +index 00000000000..019c6fdfef2 --- /dev/null +++ b/grub-core/kern/arm64/backtrace.c @@ -0,0 +1,94 @@ @@ -229,7 +229,7 @@ index 0000000000..019c6fdfef +} diff --git a/grub-core/kern/backtrace.c b/grub-core/kern/backtrace.c new file mode 100644 -index 0000000000..4a82e865cc +index 00000000000..4a82e865cc6 --- /dev/null +++ b/grub-core/kern/backtrace.c @@ -0,0 +1,97 @@ @@ -331,10 +331,10 @@ index 0000000000..4a82e865cc + grub_backtrace (skip + 1); +} diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 7afb9e6f72..88d2077709 100644 +index 0bf40caa61a..931f6e41442 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c -@@ -124,6 +124,50 @@ grub_dl_resolve_symbol (const char *name) +@@ -115,6 +115,50 @@ grub_dl_resolve_symbol (const char *name) return 0; } @@ -385,7 +385,7 @@ index 7afb9e6f72..88d2077709 100644 /* Register a symbol with the name NAME and the address ADDR. */ grub_err_t grub_dl_register_symbol (const char *name, void *addr, int isfunc, -@@ -336,6 +380,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e) +@@ -330,6 +374,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e) const char *str; Elf_Word size, entsize; @@ -395,7 +395,7 @@ index 7afb9e6f72..88d2077709 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 0000000000..2413f9a57d +index 00000000000..2413f9a57db --- /dev/null +++ b/grub-core/kern/i386/backtrace.c @@ -0,0 +1,125 @@ @@ -525,7 +525,7 @@ index 0000000000..2413f9a57d +#endif +} diff --git a/grub-core/kern/i386/pc/init.c b/grub-core/kern/i386/pc/init.c -index 27bc68b8a5..b51d0abfa6 100644 +index 326d491c586..fe7ad14d45c 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) @@ -537,7 +537,7 @@ index 27bc68b8a5..b51d0abfa6 100644 /* Helper for grub_machine_init. */ static int -@@ -217,7 +217,7 @@ grub_machine_init (void) +@@ -226,7 +226,7 @@ grub_machine_init (void) /* This has to happen before any BIOS calls. */ grub_via_workaround_init (); @@ -547,27 +547,23 @@ index 27bc68b8a5..b51d0abfa6 100644 /* Initialize the console as early as possible. */ grub_console_init (); diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 0cd2a62723..937c1bc44c 100644 +index 51c1e1c9d9f..c4d6962197b 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c -@@ -63,7 +63,6 @@ - #define HEAP_MAX_ADDR (unsigned long) (32 * 1024 * 1024) - #endif +@@ -70,7 +70,6 @@ + */ + #define RUNTIME_MIN_SPACE (128UL * 1024 * 1024) -extern char _start[]; extern char _end[]; #ifdef __sparc__ diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index c60601b699..a432a6be54 100644 +index b1d399d37d7..779586658cb 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -1197,15 +1197,15 @@ grub_printf_fmt_check (const char *fmt, const char *fmt_expected) - - - /* Abort GRUB. This function does not return. */ --static void __attribute__ ((noreturn)) -+static inline void __attribute__ ((noreturn)) +@@ -1302,12 +1302,12 @@ grub_printf_fmt_check (const char *fmt, const char *fmt_expected) + void __attribute__ ((noreturn)) grub_abort (void) { -#ifndef GRUB_UTIL @@ -584,7 +580,7 @@ index c60601b699..a432a6be54 100644 #ifndef GRUB_UTIL if (grub_term_inputs) -@@ -1232,6 +1232,7 @@ grub_fatal (const char *fmt, ...) +@@ -1334,6 +1334,7 @@ grub_fatal (const char *fmt, ...) { va_list ap; @@ -593,10 +589,10 @@ index c60601b699..a432a6be54 100644 grub_vprintf (_(fmt), ap); va_end (ap); diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index c070afc621..d8c8377578 100644 +index 027a25cd1f0..1aeeba9e27e 100644 --- a/grub-core/kern/mm.c +++ b/grub-core/kern/mm.c -@@ -97,13 +97,13 @@ get_header_from_pointer (void *ptr, grub_mm_header_t *p, grub_mm_region_t *r) +@@ -144,13 +144,13 @@ get_header_from_pointer (void *ptr, grub_mm_header_t *p, grub_mm_region_t *r) break; if (! *r) @@ -615,7 +611,7 @@ index c070afc621..d8c8377578 100644 diff --git a/grub-core/lib/arm64/backtrace.c b/grub-core/lib/arm64/backtrace.c deleted file mode 100644 -index 1079b5380e..0000000000 +index 1079b5380e1..00000000000 --- a/grub-core/lib/arm64/backtrace.c +++ /dev/null @@ -1,62 +0,0 @@ @@ -683,7 +679,7 @@ index 1079b5380e..0000000000 - diff --git a/grub-core/lib/i386/backtrace.c b/grub-core/lib/i386/backtrace.c deleted file mode 100644 -index c67273db3a..0000000000 +index c67273db3ae..00000000000 --- a/grub-core/lib/i386/backtrace.c +++ /dev/null @@ -1,78 +0,0 @@ @@ -766,7 +762,7 @@ index c67273db3a..0000000000 -} - diff --git a/include/grub/backtrace.h b/include/grub/backtrace.h -index 395519762f..275cf85e2d 100644 +index 395519762f0..275cf85e2d3 100644 --- a/include/grub/backtrace.h +++ b/include/grub/backtrace.h @@ -19,8 +19,14 @@ @@ -787,10 +783,10 @@ index 395519762f..275cf85e2d 100644 #endif diff --git a/include/grub/dl.h b/include/grub/dl.h -index 91933b85f2..2f76e6b043 100644 +index f2bf50eb98d..8a3d188d1d1 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h -@@ -259,6 +259,8 @@ grub_dl_is_persistent (grub_dl_t mod) +@@ -258,6 +258,8 @@ grub_dl_is_persistent (grub_dl_t mod) #endif @@ -800,7 +796,7 @@ index 91933b85f2..2f76e6b043 100644 int isfunc, grub_dl_t mod); diff --git a/include/grub/kernel.h b/include/grub/kernel.h -index abbca5ea33..300a9766cd 100644 +index abbca5ea335..300a9766cda 100644 --- a/include/grub/kernel.h +++ b/include/grub/kernel.h @@ -111,6 +111,9 @@ grub_addr_t grub_modules_get_end (void); @@ -814,7 +810,7 @@ index abbca5ea33..300a9766cd 100644 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 9f8265315a..f3bc41f9d0 100644 +index 9f8265315a9..f3bc41f9d0f 100644 --- a/grub-core/kern/arm/efi/startup.S +++ b/grub-core/kern/arm/efi/startup.S @@ -23,6 +23,8 @@ @@ -827,7 +823,7 @@ index 9f8265315a..f3bc41f9d0 100644 /* * 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 3946fe8e18..5679a1d00a 100644 +index 3946fe8e183..5679a1d00ad 100644 --- a/grub-core/kern/arm/startup.S +++ b/grub-core/kern/arm/startup.S @@ -48,6 +48,8 @@ @@ -840,7 +836,7 @@ index 3946fe8e18..5679a1d00a 100644 b codestart diff --git a/grub-core/kern/arm64/efi/startup.S b/grub-core/kern/arm64/efi/startup.S -index 666a7ee3c9..41676bdb2b 100644 +index 666a7ee3c92..41676bdb2b8 100644 --- a/grub-core/kern/arm64/efi/startup.S +++ b/grub-core/kern/arm64/efi/startup.S @@ -19,7 +19,9 @@ @@ -854,7 +850,7 @@ index 666a7ee3c9..41676bdb2b 100644 /* * 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 0d89858d9b..939f182fc7 100644 +index 0d89858d9b3..939f182fc74 100644 --- a/grub-core/kern/i386/qemu/startup.S +++ b/grub-core/kern/i386/qemu/startup.S @@ -24,7 +24,8 @@ @@ -868,7 +864,7 @@ index 0d89858d9b..939f182fc7 100644 jmp codestart diff --git a/grub-core/kern/ia64/efi/startup.S b/grub-core/kern/ia64/efi/startup.S -index d75c6d7cc7..8f2a593e52 100644 +index d75c6d7cc74..8f2a593e529 100644 --- a/grub-core/kern/ia64/efi/startup.S +++ b/grub-core/kern/ia64/efi/startup.S @@ -24,8 +24,9 @@ @@ -883,7 +879,7 @@ index d75c6d7cc7..8f2a593e52 100644 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 03b916f053..701bf63abc 100644 +index 03b916f0534..701bf63abcf 100644 --- a/grub-core/kern/sparc64/ieee1275/crt0.S +++ b/grub-core/kern/sparc64/ieee1275/crt0.S @@ -22,7 +22,8 @@ @@ -897,7 +893,7 @@ index 03b916f053..701bf63abc 100644 ba codestart mov %o4, %o0 diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am -index ee88e44e97..bfd29a3bf0 100644 +index f18550c1c98..b7192a3da82 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -66,6 +66,7 @@ CLEANFILES += grub_script.yy.c grub_script.yy.h diff --git a/0060-Fixup-for-newer-compiler.patch b/0060-Fixup-for-newer-compiler.patch new file mode 100644 index 0000000..b0c1966 --- /dev/null +++ b/0060-Fixup-for-newer-compiler.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 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 + +--- + grub-core/fs/btrfs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c +index 87e4dd1a07a..ad35e75750b 100644 +--- a/grub-core/fs/btrfs.c ++++ b/grub-core/fs/btrfs.c +@@ -218,7 +218,7 @@ struct grub_btrfs_inode + grub_uint64_t size; + grub_uint8_t dummy2[0x70]; + struct grub_btrfs_time mtime; +-} GRUB_PACKED; ++} GRUB_PACKED __attribute__ ((aligned(8))); + + struct grub_btrfs_extent_data + { diff --git a/0068-Don-t-attempt-to-export-the-start-and-_start-symbols.patch b/0061-Don-t-attempt-to-export-the-start-and-_start-symbols.patch similarity index 97% rename from 0068-Don-t-attempt-to-export-the-start-and-_start-symbols.patch rename to 0061-Don-t-attempt-to-export-the-start-and-_start-symbols.patch index 9b78c00..0e925ee 100644 --- a/0068-Don-t-attempt-to-export-the-start-and-_start-symbols.patch +++ b/0061-Don-t-attempt-to-export-the-start-and-_start-symbols.patch @@ -26,7 +26,7 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 2 insertions(+) diff --git a/include/grub/kernel.h b/include/grub/kernel.h -index 300a9766cd..55849777ea 100644 +index 300a9766cda..55849777eaa 100644 --- a/include/grub/kernel.h +++ b/include/grub/kernel.h @@ -111,8 +111,10 @@ grub_addr_t grub_modules_get_end (void); diff --git a/0069-Fixup-for-newer-compiler.patch b/0062-Fixup-for-newer-compiler.patch similarity index 79% rename from 0069-Fixup-for-newer-compiler.patch rename to 0062-Fixup-for-newer-compiler.patch index 167dca1..0d495c1 100644 --- a/0069-Fixup-for-newer-compiler.patch +++ b/0062-Fixup-for-newer-compiler.patch @@ -8,15 +8,15 @@ Subject: [PATCH] Fixup for newer compiler 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/Makefile.common b/conf/Makefile.common -index 191b1a70c6..5f0ef96985 100644 +index ece9ed8a1bf..6262f21a772 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common -@@ -38,7 +38,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding +@@ -41,7 +41,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) 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 +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 + if !COND_emu + if COND_HAVE_ASM_USCORE + LDFLAGS_KERNEL += -Wl,--defsym=_malloc=_grub_malloc -Wl,--defsym=_free=_grub_free diff --git a/0070-Add-support-for-non-Ethernet-network-cards.patch b/0063-Add-support-for-non-Ethernet-network-cards.patch similarity index 90% rename from 0070-Add-support-for-non-Ethernet-network-cards.patch rename to 0063-Add-support-for-non-Ethernet-network-cards.patch index fb44628..95ea8fc 100644 --- a/0070-Add-support-for-non-Ethernet-network-cards.patch +++ b/0063-Add-support-for-non-Ethernet-network-cards.patch @@ -23,22 +23,22 @@ Signed-off-by: Andrzej Kacprowski [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/arp.c | 156 ++++++++++++++++++++++----------- 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 | 89 +++++++++---------- grub-core/net/icmp6.c | 15 ++-- grub-core/net/ip.c | 4 +- grub-core/net/net.c | 50 ++++++----- include/grub/net.h | 19 ++-- - 12 files changed, 219 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 54306e3b16..67b409a8ac 100644 +index 1d367436cfc..8bf0a06e193 100644 --- a/grub-core/net/arp.c +++ b/grub-core/net/arp.c @@ -31,22 +31,12 @@ enum @@ -137,7 +137,7 @@ index 54306e3b16..67b409a8ac 100644 nbd = nb.data; send_ethernet_packet (inf, &nb, target_mac_addr, GRUB_NET_ETHERTYPE_ARP); -@@ -114,28 +124,53 @@ grub_err_t +@@ -114,30 +124,56 @@ grub_err_t grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card, grub_uint16_t *vlantag) { @@ -177,33 +177,36 @@ index 54306e3b16..67b409a8ac 100644 + + /* The source protocol address. */ sender_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; -+ grub_memcpy(&sender_addr.ipv4, tmp_ptr, pln); -+ tmp_ptr += pln; -+ -+ 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; +- target_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; - sender_addr.ipv4 = arp_packet->sender_ip; - target_addr.ipv4 = arp_packet->recv_ip; + sender_addr.option = 0; + target_addr.option = 0; - if (arp_packet->sender_ip == pending_req) -+ grub_memcpy(&target_addr.ipv4, tmp_ptr, pln); -+ -+ if (sender_addr.ipv4 == pending_req) - have_pending = 1; +- 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); -- ++ grub_memcpy(&target_addr.ipv4, tmp_ptr, pln); ++ tmp_ptr += pln; ++ + 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; ++ grub_memcpy(&target_addr.ipv4, tmp_ptr, pln); ++ ++ if (sender_addr.ipv4 == pending_req) ++ have_pending = 1; ++ FOR_NET_NETWORK_LEVEL_INTERFACES (inf) { /* Verify vlantag id */ -@@ -148,11 +183,11 @@ grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card, +@@ -150,11 +186,11 @@ grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card, /* Am I the protocol address target? */ if (grub_net_addr_cmp (&inf->address, &target_addr) == 0 @@ -217,7 +220,7 @@ index 54306e3b16..67b409a8ac 100644 grub_uint8_t arp_data[128]; grub_err_t err; -@@ -161,25 +196,39 @@ grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card, +@@ -163,25 +199,39 @@ grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card, grub_netbuff_clear (&nb_reply); grub_netbuff_reserve (&nb_reply, 128); @@ -271,10 +274,10 @@ index 54306e3b16..67b409a8ac 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 e28fb6a09f..08b6b2b5d6 100644 +index e0aec25233d..76e4c11a46f 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c -@@ -233,7 +233,6 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -325,7 +325,6 @@ grub_net_configure_by_dhcp_ack (const char *name, int is_def, char **device, char **path) { grub_net_network_level_address_t addr; @@ -282,7 +285,7 @@ index e28fb6a09f..08b6b2b5d6 100644 struct grub_net_network_level_interface *inter; int mask = -1; char server_ip[sizeof ("xxx.xxx.xxx.xxx")]; -@@ -250,12 +249,8 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -343,12 +342,8 @@ grub_net_configure_by_dhcp_ack (const char *name, if (path) *path = 0; @@ -297,7 +300,7 @@ index e28fb6a09f..08b6b2b5d6 100644 if (!inter) return 0; -@@ -567,7 +562,9 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface) +@@ -660,7 +655,9 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface) grub_memset (pack, 0, sizeof (*pack)); pack->opcode = 1; pack->hw_type = 1; @@ -308,20 +311,20 @@ index e28fb6a09f..08b6b2b5d6 100644 err = grub_get_datetime (&date); if (err || !grub_datetime2unixtime (&date, &t)) { -@@ -580,7 +577,7 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface) +@@ -673,7 +670,7 @@ send_dhcp_packet (struct grub_net_network_level_interface *iface) else pack->ident = iface->xid; - 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)); - + err = grub_netbuff_push (nb, sizeof (*udph)); + if (err) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 173fb63153..a673bea807 100644 +index 3e2432fb61c..7deb0a32efd 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c -@@ -279,6 +279,9 @@ grub_efinet_findcards (void) +@@ -288,6 +288,9 @@ grub_efinet_findcards (void) /* This should not happen... Why? */ continue; @@ -329,12 +332,12 @@ index 173fb63153..a673bea807 100644 + continue; + if (net->mode->state == GRUB_EFI_NETWORK_STOPPED - && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) + && net->start (net) != GRUB_EFI_SUCCESS) continue; -@@ -315,10 +318,11 @@ grub_efinet_findcards (void) - card->name = grub_xasprintf ("efinet%d", i++); - card->driver = &efidriver; - card->flags = 0; +@@ -332,10 +335,11 @@ grub_efinet_findcards (void) + * such as LoadFile2 for initrd loading. + */ + card->flags = GRUB_NET_CARD_NO_CLOSE_ON_FINI_HW; - card->default_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; + card->default_address.type = net->mode->if_type; + card->default_address.len = net->mode->hwaddr_size; @@ -346,7 +349,7 @@ index 173fb63153..a673bea807 100644 card->efi_handle = *handle; diff --git a/grub-core/net/drivers/emu/emunet.c b/grub-core/net/drivers/emu/emunet.c -index b194920861..5b6c5e16a6 100644 +index 5f311d40f49..7461d13bbc2 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 +361,7 @@ index b194920861..5b6c5e16a6 100644 }, .flags = 0 diff --git a/grub-core/net/drivers/i386/pc/pxe.c b/grub-core/net/drivers/i386/pc/pxe.c -index 3f4152d036..9f8fb4b6d2 100644 +index db17186ee7d..816d1d0eeda 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 +393,7 @@ index 3f4152d036..9f8fb4b6d2 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 3860b6f78d..bcb3f9ea02 100644 +index 78f03df8e21..c56461ff1ae 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, @@ -401,7 +404,7 @@ index 3860b6f78d..bcb3f9ea02 100644 args = bootpath + grub_strlen (devpath) + 1; do -@@ -503,6 +504,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias) +@@ -491,6 +492,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias) grub_memcpy (&lla.mac, pprop, 6); lla.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; @@ -410,7 +413,7 @@ index 3860b6f78d..bcb3f9ea02 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 056052e40d..22ebcbf211 100644 +index b9d5a0cd494..9f3354a1b74 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 +425,7 @@ index 056052e40d..22ebcbf211 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 4d7ceed6f9..9aae83a5eb 100644 +index 707bbb12cb2..1441a1bacff 100644 --- a/grub-core/net/ethernet.c +++ b/grub-core/net/ethernet.c @@ -29,13 +29,6 @@ @@ -447,7 +450,7 @@ index 4d7ceed6f9..9aae83a5eb 100644 + grub_uint8_t *eth; grub_err_t err; - grub_uint8_t etherhdr_size; -- grub_uint16_t vlantag_id = VLANTAG_IDENTIFIER; +- grub_uint16_t vlantag_id = grub_cpu_to_be16_compile_time (VLANTAG_IDENTIFIER); + grub_uint32_t vlantag = 0; + grub_uint8_t hw_addr_len = inf->card->default_address.len; + grub_uint8_t etherhdr_size = 2 * hw_addr_len + 2; @@ -487,7 +490,7 @@ index 4d7ceed6f9..9aae83a5eb 100644 if (!inf->card->opened) { err = GRUB_ERR_NONE; -@@ -85,18 +91,6 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf, +@@ -85,19 +91,6 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf, inf->card->opened = 1; } @@ -499,14 +502,15 @@ index 4d7ceed6f9..9aae83a5eb 100644 - (char *) nb->data + etherhdr_size - 6, 2); - - /* Add the tag in the middle */ +- grub_uint16_t vlan = grub_cpu_to_be16 (inf->vlantag); - grub_memcpy ((char *) nb->data + etherhdr_size - 6, &vlantag_id, 2); -- grub_memcpy ((char *) nb->data + etherhdr_size - 4, (char *) &(inf->vlantag), 2); +- grub_memcpy ((char *) nb->data + etherhdr_size - 4, &vlan, 2); - } - return inf->card->driver->send (inf->card, nb); } -@@ -104,31 +98,40 @@ grub_err_t +@@ -105,31 +98,40 @@ grub_err_t grub_net_recv_ethernet_packet (struct grub_net_buff *nb, struct grub_net_card *card) { @@ -528,7 +532,7 @@ index 4d7ceed6f9..9aae83a5eb 100644 - /* 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) +- if (grub_get_unaligned16 (nb->data + etherhdr_size - 2) == grub_cpu_to_be16_compile_time (VLANTAG_IDENTIFIER)) + hwaddress.type = card->default_address.type; + hwaddress.len = hw_addr_len; + grub_memcpy (hwaddress.mac, eth, hw_addr_len); @@ -542,7 +546,7 @@ index 4d7ceed6f9..9aae83a5eb 100644 + type = grub_be_to_cpu16 (*(grub_uint16_t*)(eth)); + if (type == VLANTAG_IDENTIFIER) { -- vlantag = grub_get_unaligned16 (nb->data + etherhdr_size); +- vlantag = grub_be_to_cpu16 (grub_get_unaligned16 (nb->data + etherhdr_size)); + /* Skip vlan tag */ + eth += 2; + vlantag = grub_be_to_cpu16 (*(grub_uint16_t*)(eth)); @@ -559,7 +563,7 @@ index 4d7ceed6f9..9aae83a5eb 100644 err = grub_netbuff_pull (nb, etherhdr_size); if (err) return err; -@@ -148,11 +151,6 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb, +@@ -149,11 +151,6 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb, } } @@ -572,7 +576,7 @@ index 4d7ceed6f9..9aae83a5eb 100644 { /* ARP packet. */ diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c -index 2cbd95dce2..56a3ec5c8e 100644 +index 9a8c4511285..5924fd53aca 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,10 +616,10 @@ index 2cbd95dce2..56a3ec5c8e 100644 } if (ohdr->type == OPTION_PREFIX && ohdr->len == 4) diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c -index ea5edf8f1f..a5896f6dc2 100644 +index f967618e53f..3c475762cc0 100644 --- a/grub-core/net/ip.c +++ b/grub-core/net/ip.c -@@ -276,8 +276,8 @@ handle_dgram (struct grub_net_buff *nb, +@@ -316,8 +316,8 @@ handle_dgram (struct grub_net_buff *nb, if (inf->card == card && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV && inf->hwaddress.type == GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET @@ -627,7 +631,7 @@ index ea5edf8f1f..a5896f6dc2 100644 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 22f2689aae..a46f82362e 100644 +index 20c55257647..fa6b6537142 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -133,8 +133,9 @@ grub_net_link_layer_resolve (struct grub_net_network_level_interface *inf, @@ -650,7 +654,7 @@ index 22f2689aae..a46f82362e 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); -@@ -762,23 +764,23 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target, char *buf) +@@ -772,23 +774,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) { @@ -688,8 +692,8 @@ index 22f2689aae..a46f82362e 100644 - grub_printf (_("Unsupported hw address type %d\n"), addr->type); } - int -@@ -789,13 +791,17 @@ grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a, + void +@@ -813,13 +815,17 @@ grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a, return -1; if (a->type > b->type) return +1; @@ -713,7 +717,7 @@ index 22f2689aae..a46f82362e 100644 int diff --git a/include/grub/net.h b/include/grub/net.h -index 8a05ec4fe7..af0404db7e 100644 +index ff901b96e22..1d76fd9a1f5 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -29,7 +29,8 @@ @@ -728,7 +732,7 @@ index 8a05ec4fe7..af0404db7e 100644 GRUB_NET_OUR_IPV4_HEADER_SIZE = 20, @@ -42,15 +43,17 @@ enum - typedef enum grub_link_level_protocol_id + typedef enum grub_link_level_protocol_id { - GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET + /* IANA ARP constant to define hardware type. */ @@ -746,7 +750,7 @@ index 8a05ec4fe7..af0404db7e 100644 }; } grub_net_link_level_address_t; -@@ -566,11 +569,13 @@ grub_net_addr_cmp (const grub_net_network_level_address_t *a, +@@ -588,11 +591,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,5 +766,5 @@ index 8a05ec4fe7..af0404db7e 100644 + "XX:XX:XX:XX:XX:XX:XX:XX:"\ + "XX:XX:XX:XX:XX:XX:XX:XX")) - void - grub_net_addr_to_str (const grub_net_network_level_address_t *target, + /* Max VLAN id = 4094 */ + #define GRUB_NET_MAX_STR_VLAN_LEN (sizeof ("vlanXXXX")) diff --git a/0073-efinet-UEFI-IPv6-PXE-support.patch b/0064-efinet-UEFI-IPv6-PXE-support.patch similarity index 92% rename from 0073-efinet-UEFI-IPv6-PXE-support.patch rename to 0064-efinet-UEFI-IPv6-PXE-support.patch index 988c178..2d8a3ae 100644 --- a/0073-efinet-UEFI-IPv6-PXE-support.patch +++ b/0064-efinet-UEFI-IPv6-PXE-support.patch @@ -15,12 +15,12 @@ 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 8e25680db0..014e5bf980 100644 +index 7deb0a32efd..92bb7444782 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c -@@ -409,6 +409,8 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -430,6 +430,8 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, grub_print_error (); - if (device && path) + if (inter && device && path) grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path); + if (grub_errno) + grub_print_error (); @@ -28,10 +28,10 @@ index 8e25680db0..014e5bf980 100644 else { diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 7614b58dca..91ab528e4d 100644 +index daa9268fdaa..53f5c781ac3 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -1524,31 +1524,6 @@ typedef union +@@ -1571,31 +1571,6 @@ typedef union grub_efi_pxe_dhcpv6_packet_t dhcpv6; } grub_efi_pxe_packet_t; @@ -63,7 +63,7 @@ index 7614b58dca..91ab528e4d 100644 typedef struct grub_efi_pxe_icmp_error { grub_efi_uint8_t type; -@@ -1574,6 +1549,48 @@ typedef struct grub_efi_pxe_tftp_error +@@ -1621,6 +1596,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 7614b58dca..91ab528e4d 100644 typedef struct grub_efi_pxe_mode { grub_efi_boolean_t started; -@@ -1605,9 +1622,9 @@ typedef struct grub_efi_pxe_mode +@@ -1652,9 +1669,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; diff --git a/0074-grub.texi-Add-net_bootp6-doument.patch b/0065-grub.texi-Add-net_bootp6-doument.patch similarity index 88% rename from 0074-grub.texi-Add-net_bootp6-doument.patch rename to 0065-grub.texi-Add-net_bootp6-doument.patch index b42e09b..7286318 100644 --- a/0074-grub.texi-Add-net_bootp6-doument.patch +++ b/0065-grub.texi-Add-net_bootp6-doument.patch @@ -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 0615d0ed97..04ed6ac1f0 100644 +index c30701b4e1f..44c4e665a0d 100644 --- a/docs/grub.texi +++ b/docs/grub.texi -@@ -5487,6 +5487,7 @@ This command is only available on AArch64 systems. +@@ -5955,6 +5955,7 @@ Note: The command is not allowed when lockdown is enforced (@pxref{Lockdown}). * net_add_dns:: Add a DNS server * net_add_route:: Add routing entry * net_bootp:: Perform a bootp/DHCP autoconfiguration @@ -23,7 +23,7 @@ index 0615d0ed97..04ed6ac1f0 100644 * net_del_addr:: Remove IP address from interface * net_del_dns:: Remove a DNS server * net_del_route:: Remove a route entry -@@ -5611,6 +5612,22 @@ Sets environment variable @samp{net_}@var{}@samp{_boot_file} +@@ -6080,6 +6081,22 @@ Sets environment variable @samp{net_}@var{}@samp{_boot_file} @end deffn diff --git a/0066-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch b/0066-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch deleted file mode 100644 index ccf34a5..0000000 --- a/0066-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch +++ /dev/null @@ -1,178 +0,0 @@ -From 0000000000000000000000000000000000000000 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. - -This makes a grub_dprintf() call during platform init and during module -loading that tells us the virtual addresses of the .text and .data -sections of grub-core/kernel.exec and any modules it loads. - -Specifically, it displays them in the gdb "add-symbol-file" syntax, with -the presumption that there's a variable $grubdir that reflects the path -to any such binaries. - -Signed-off-by: Peter Jones ---- - grub-core/kern/dl.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ - grub-core/kern/efi/efi.c | 4 ++-- - grub-core/kern/efi/init.c | 26 +++++++++++++++++++++++- - include/grub/efi/efi.h | 2 +- - 4 files changed, 78 insertions(+), 4 deletions(-) - -diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 88d2077709..9557254035 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) - return s; - return NULL; - } -+static long -+grub_dl_find_section_index (Elf_Ehdr *e, const char *name) -+{ -+ Elf_Shdr *s; -+ const char *str; -+ unsigned i; -+ -+ s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shstrndx * e->e_shentsize); -+ str = (char *) e + s->sh_offset; -+ -+ for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); -+ i < e->e_shnum; -+ i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) -+ if (grub_strcmp (str + s->sh_name, name) == 0) -+ return (long)i; -+ return -1; -+} - - /* Me, Vladimir Serbinenko, hereby I add this module check as per new - GNU module policy. Note that this license check is informative only. -@@ -653,6 +670,37 @@ grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr) - - return GRUB_ERR_NONE; - } -+static void -+grub_dl_print_gdb_info (grub_dl_t mod, Elf_Ehdr *e) -+{ -+ void *text, *data = NULL; -+ long idx; -+ -+ idx = grub_dl_find_section_index (e, ".text"); -+ if (idx < 0) -+ return; -+ -+ text = grub_dl_get_section_addr (mod, idx); -+ if (!text) -+ return; -+ -+ idx = grub_dl_find_section_index (e, ".data"); -+ if (idx >= 0) -+ data = grub_dl_get_section_addr (mod, idx); -+ -+ if (data) -+ grub_qdprintf ("gdb", "add-symbol-file \\\n" -+ "/usr/lib/debug/usr/lib/grub/%s-%s/%s.debug " -+ "\\\n %p -s .data %p\n", -+ GRUB_TARGET_CPU, GRUB_PLATFORM, -+ mod->name, text, data); -+ else -+ grub_qdprintf ("gdb", "add-symbol-file \\\n" -+ "/usr/lib/debug/usr/lib/grub/%s-%s/%s.debug " -+ "\\\n%p\n", -+ GRUB_TARGET_CPU, GRUB_PLATFORM, -+ mod->name, text); -+} - - /* Load a module from core memory. */ - grub_dl_t -@@ -712,6 +760,8 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size) - grub_dprintf ("modules", "module name: %s\n", mod->name); - grub_dprintf ("modules", "init function: %p\n", mod->init); - -+ grub_dl_print_gdb_info (mod, e); -+ - if (grub_dl_add (mod)) - { - grub_dl_unload (mod); -diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index ae9885edb8..d6a2fb5778 100644 ---- a/grub-core/kern/efi/efi.c -+++ b/grub-core/kern/efi/efi.c -@@ -296,7 +296,7 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, - /* Search the mods section from the PE32/PE32+ image. This code uses - a PE32 header, but should work with PE32+ as well. */ - grub_addr_t --grub_efi_modules_addr (void) -+grub_efi_section_addr (const char *section_name) - { - grub_efi_loaded_image_t *image; - struct grub_pe32_header *header; -@@ -321,7 +321,7 @@ grub_efi_modules_addr (void) - i < coff_header->num_sections; - i++, section++) - { -- if (grub_strcmp (section->name, "mods") == 0) -+ if (grub_strcmp (section->name, section_name) == 0) - break; - } - -diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c -index 6d39bd3ad2..2d12e6188f 100644 ---- a/grub-core/kern/efi/init.c -+++ b/grub-core/kern/efi/init.c -@@ -115,10 +115,33 @@ grub_efi_env_init (void) - grub_free (envblk_s.buf); - } - -+static void -+grub_efi_print_gdb_info (void) -+{ -+ grub_addr_t text; -+ grub_addr_t data; -+ -+ text = grub_efi_section_addr (".text"); -+ if (!text) -+ return; -+ -+ data = grub_efi_section_addr (".data"); -+ if (data) -+ grub_qdprintf ("gdb", -+ "add-symbol-file /usr/lib/debug/usr/lib/grub/%s-%s/" -+ "kernel.exec %p -s .data %p\n", -+ GRUB_TARGET_CPU, GRUB_PLATFORM, (void *)text, (void *)data); -+ else -+ grub_qdprintf ("gdb", -+ "add-symbol-file /usr/lib/debug/usr/lib/grub/%s-%s/" -+ "kernel.exec %p\n", -+ GRUB_TARGET_CPU, GRUB_PLATFORM, (void *)text); -+} -+ - void - grub_efi_init (void) - { -- grub_modbase = grub_efi_modules_addr (); -+ grub_modbase = grub_efi_section_addr ("mods"); - /* First of all, initialize the console so that GRUB can display - messages. */ - grub_console_init (); -@@ -142,6 +165,7 @@ grub_efi_init (void) - 0, 0, 0, NULL); - - grub_efi_env_init (); -+ grub_efi_print_gdb_info (); - grub_efidisk_init (); - } - -diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 03f9a9d011..2e0691454b 100644 ---- a/include/grub/efi/efi.h -+++ b/include/grub/efi/efi.h -@@ -138,7 +138,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); -+grub_addr_t grub_efi_section_addr (const char *section); - - void grub_efi_mm_init (void); - void grub_efi_mm_fini (void); diff --git a/0075-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch b/0066-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch similarity index 95% rename from 0075-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch rename to 0066-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch index abff9eb..7109c4e 100644 --- a/0075-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch +++ b/0066-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch @@ -22,7 +22,7 @@ Signed-off-by: Ken Lin 2 files changed, 56 insertions(+) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index fe93b80f1c..8fb8918ae7 100644 +index 76e4c11a46f..f56b293ac72 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -20,6 +20,7 @@ @@ -33,7 +33,7 @@ index fe93b80f1c..8fb8918ae7 100644 #include #include #include -@@ -500,6 +501,60 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -501,6 +502,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); @@ -95,10 +95,10 @@ index fe93b80f1c..8fb8918ae7 100644 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 543251f727..42af7de250 100644 +index 1d76fd9a1f5..868c9a2ef29 100644 --- a/include/grub/net.h +++ b/include/grub/net.h -@@ -531,6 +531,7 @@ enum +@@ -533,6 +533,7 @@ enum GRUB_NET_DHCP_MESSAGE_TYPE = 53, GRUB_NET_DHCP_SERVER_IDENTIFIER = 54, GRUB_NET_DHCP_PARAMETER_REQUEST_LIST = 55, diff --git a/0136-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch b/0067-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch similarity index 93% rename from 0136-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch rename to 0067-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch index f20f5c7..4d84371 100644 --- a/0136-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch +++ b/0067-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch @@ -14,7 +14,7 @@ Signed-off-by: Peter Jones 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c -index 8fb8918ae7..7baf3540c8 100644 +index f56b293ac72..9cbdc2264c9 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -329,7 +329,7 @@ grub_net_configure_by_dhcp_ack (const char *name, @@ -26,7 +26,7 @@ index 8fb8918ae7..7baf3540c8 100644 grub_uint8_t opt_len, overload = 0; const char *boot_file = 0, *server_name = 0; grub_size_t boot_file_len, server_name_len; -@@ -505,7 +505,7 @@ grub_net_configure_by_dhcp_ack (const char *name, +@@ -506,7 +506,7 @@ grub_net_configure_by_dhcp_ack (const char *name, if (opt && opt_len) { grub_env_set_net_property (name, "vendor_class_identifier", (const char *) opt, opt_len); diff --git a/0067-Fixup-for-newer-compiler.patch b/0067-Fixup-for-newer-compiler.patch deleted file mode 100644 index ed23271..0000000 --- a/0067-Fixup-for-newer-compiler.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 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 - ---- - grub-core/fs/btrfs.c | 2 +- - include/grub/gpt_partition.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 2b21cbaa67..4cc86e9b79 100644 ---- a/grub-core/fs/btrfs.c -+++ b/grub-core/fs/btrfs.c -@@ -218,7 +218,7 @@ struct grub_btrfs_inode - grub_uint64_t size; - grub_uint8_t dummy2[0x70]; - struct grub_btrfs_time mtime; --} GRUB_PACKED; -+} GRUB_PACKED __attribute__ ((aligned(8))); - - struct grub_btrfs_extent_data - { -diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h -index 7a93f43291..8212697bf6 100644 ---- a/include/grub/gpt_partition.h -+++ b/include/grub/gpt_partition.h -@@ -76,7 +76,7 @@ struct grub_gpt_partentry - grub_uint64_t end; - grub_uint64_t attrib; - char name[72]; --} GRUB_PACKED; -+} GRUB_PACKED __attribute__ ((aligned(8))); - - grub_err_t - grub_gpt_partition_map_iterate (grub_disk_t disk, diff --git a/0076-efinet-Setting-network-from-UEFI-device-path.patch b/0068-efinet-Setting-network-from-UEFI-device-path.patch similarity index 89% rename from 0076-efinet-Setting-network-from-UEFI-device-path.patch rename to 0068-efinet-Setting-network-from-UEFI-device-path.patch index f4faf27..7153630 100644 --- a/0076-efinet-Setting-network-from-UEFI-device-path.patch +++ b/0068-efinet-Setting-network-from-UEFI-device-path.patch @@ -27,12 +27,12 @@ the same way it used to be. Signed-off-by: Michael Chang Signed-off-by: Ken Lin --- - grub-core/net/drivers/efi/efinet.c | 284 +++++++++++++++++++++++++++++++++++-- + grub-core/net/drivers/efi/efinet.c | 286 ++++++++++++++++++++++++++++++++++--- include/grub/efi/api.h | 11 ++ - 2 files changed, 280 insertions(+), 15 deletions(-) + 2 files changed, 281 insertions(+), 16 deletions(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 014e5bf980..8171ecaa5e 100644 +index 92bb7444782..eb68de22023 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -26,6 +26,7 @@ @@ -43,7 +43,7 @@ index 014e5bf980..8171ecaa5e 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -331,6 +332,227 @@ grub_efinet_findcards (void) +@@ -348,6 +349,227 @@ grub_efinet_findcards (void) grub_free (handles); } @@ -271,7 +271,7 @@ index 014e5bf980..8171ecaa5e 100644 static void grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, char **path) -@@ -346,7 +568,11 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -367,7 +589,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 014e5bf980..8171ecaa5e 100644 if (card->driver != &efidriver) continue; -@@ -370,11 +596,21 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -391,11 +617,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 014e5bf980..8171ecaa5e 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; -@@ -387,23 +623,37 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -408,23 +644,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); @@ -347,38 +347,45 @@ index 014e5bf980..8171ecaa5e 100644 + pxe_mode->dhcp_ack_received ? "yes" : "no", + pxe_mode->dhcp_ack_received ? "" : " cannot continue"); - grub_net_configure_by_dhcpv6_reply (card->name, card, 0, - (struct grub_net_dhcp6_packet *) -- &pxe_mode->dhcp_ack, -- sizeof (pxe_mode->dhcp_ack), -+ packet_buf, -+ packet_bufsz, - 1, device, path); + inter = grub_net_configure_by_dhcpv6_reply (card->name, card, 0, + (struct grub_net_dhcp6_packet *) +- &pxe_mode->dhcp_ack, +- sizeof (pxe_mode->dhcp_ack), ++ packet_buf, ++ packet_bufsz, + 1, device, path); if (grub_errno) grub_print_error (); -@@ -417,11 +667,15 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -438,8 +688,8 @@ 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 *) -- &pxe_mode->dhcp_ack, -- sizeof (pxe_mode->dhcp_ack), -+ packet_buf, -+ packet_bufsz, - 1, device, path); + inter = grub_net_configure_by_dhcp_ack (card->name, card, 0, + (struct grub_net_bootp_packet *) +- &pxe_mode->dhcp_ack, +- sizeof (pxe_mode->dhcp_ack), ++ packet_buf, ++ packet_bufsz, + 1, device, path); + grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path); +@@ -465,8 +715,12 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, + vlan_dp = (grub_efi_device_path_t *) ((grub_efi_uint8_t *) vlan_dp + vlan_dp_len); + } + } +- return; } + + if (nb) + grub_netbuff_free (nb); + - return; ++ return; } } + diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 91ab528e4d..4a51667adb 100644 +index 53f5c781ac3..fa528e73a27 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -864,6 +864,8 @@ struct grub_efi_ipv4_device_path +@@ -891,6 +891,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,9 +394,9 @@ index 91ab528e4d..4a51667adb 100644 } GRUB_PACKED; typedef struct grub_efi_ipv4_device_path grub_efi_ipv4_device_path_t; -@@ -918,6 +920,15 @@ struct grub_efi_sata_device_path +@@ -954,6 +956,15 @@ struct grub_efi_vlan_device_path } GRUB_PACKED; - typedef struct grub_efi_sata_device_path grub_efi_sata_device_path_t; + typedef struct grub_efi_vlan_device_path grub_efi_vlan_device_path_t; +#define GRUB_EFI_URI_DEVICE_PATH_SUBTYPE 24 + diff --git a/0077-efinet-Setting-DNS-server-from-UEFI-protocol.patch b/0069-efinet-Setting-DNS-server-from-UEFI-protocol.patch similarity index 84% rename from 0077-efinet-Setting-DNS-server-from-UEFI-protocol.patch rename to 0069-efinet-Setting-DNS-server-from-UEFI-protocol.patch index 2d92ff0..43d2df0 100644 --- a/0077-efinet-Setting-DNS-server-from-UEFI-protocol.patch +++ b/0069-efinet-Setting-DNS-server-from-UEFI-protocol.patch @@ -29,34 +29,34 @@ Signed-off-by: Michael Chang Signed-off-by: Ken Lin --- grub-core/net/drivers/efi/efinet.c | 163 +++++++++++++++++++++++++++++++++++++ - include/grub/efi/api.h | 75 +++++++++++++++++ - 2 files changed, 238 insertions(+) + include/grub/efi/api.h | 76 +++++++++++++++++ + 2 files changed, 239 insertions(+) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index 8171ecaa5e..715a6168d7 100644 +index eb68de22023..a91df09ee6d 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -33,6 +33,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); /* GUID. */ - static grub_efi_guid_t net_io_guid = GRUB_EFI_SIMPLE_NETWORK_GUID; - static grub_efi_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID; -+static grub_efi_guid_t ip4_config_guid = GRUB_EFI_IP4_CONFIG2_PROTOCOL_GUID; -+static grub_efi_guid_t ip6_config_guid = GRUB_EFI_IP6_CONFIG_PROTOCOL_GUID; + static grub_guid_t net_io_guid = GRUB_EFI_SIMPLE_NETWORK_GUID; + static grub_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID; ++static grub_guid_t ip4_config_guid = GRUB_EFI_IP4_CONFIG2_PROTOCOL_GUID; ++static grub_guid_t ip6_config_guid = GRUB_EFI_IP6_CONFIG_PROTOCOL_GUID; static grub_err_t send_card_buffer (struct grub_net_card *dev, -@@ -332,6 +334,125 @@ grub_efinet_findcards (void) +@@ -349,6 +351,125 @@ grub_efinet_findcards (void) grub_free (handles); } +static grub_efi_handle_t -+grub_efi_locate_device_path (grub_efi_guid_t *protocol, grub_efi_device_path_t *device_path, ++grub_efi_locate_device_path (grub_guid_t *protocol, grub_efi_device_path_t *device_path, + grub_efi_device_path_t **r_device_path) +{ + grub_efi_handle_t handle; + grub_efi_status_t status; + -+ status = efi_call_3 (grub_efi_system_table->boot_services->locate_device_path, ++ status = grub_efi_system_table->boot_services->locate_device_path( + protocol, &device_path, &handle); + + if (status != GRUB_EFI_SUCCESS) @@ -92,9 +92,9 @@ index 8171ecaa5e..715a6168d7 100644 + if (!addrs) + return 0; + -+ status = efi_call_4 (conf->get_data, conf, -+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER, -+ &data_size, addrs); ++ status = conf->get_data(conf, ++ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER, ++ &data_size, addrs); + + if (status == GRUB_EFI_BUFFER_TOO_SMALL) + { @@ -103,9 +103,9 @@ index 8171ecaa5e..715a6168d7 100644 + if (!addrs) + return 0; + -+ status = efi_call_4 (conf->get_data, conf, -+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER, -+ &data_size, addrs); ++ status = conf->get_data(conf, ++ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER, ++ &data_size, addrs); + } + + if (status != GRUB_EFI_SUCCESS) @@ -142,9 +142,9 @@ index 8171ecaa5e..715a6168d7 100644 + if (!addrs) + return 0; + -+ status = efi_call_4 (conf->get_data, conf, -+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_DNSSERVER, -+ &data_size, addrs); ++ status = conf->get_data(conf, ++ GRUB_EFI_IP6_CONFIG_DATA_TYPE_DNSSERVER, ++ &data_size, addrs); + + if (status == GRUB_EFI_BUFFER_TOO_SMALL) + { @@ -153,9 +153,9 @@ index 8171ecaa5e..715a6168d7 100644 + if (!addrs) + return 0; + -+ status = efi_call_4 (conf->get_data, conf, -+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_DNSSERVER, -+ &data_size, addrs); ++ status = conf->get_data(conf, ++ GRUB_EFI_IP6_CONFIG_DATA_TYPE_DNSSERVER, ++ &data_size, addrs); + } + + if (status != GRUB_EFI_SUCCESS) @@ -171,7 +171,7 @@ index 8171ecaa5e..715a6168d7 100644 static struct grub_net_buff * grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *use_ipv6) { -@@ -390,6 +511,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -407,6 +528,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 8171ecaa5e..715a6168d7 100644 bp = (struct grub_net_bootp_packet *) nb->tail; err = grub_netbuff_put (nb, sizeof (*bp) + 4); -@@ -451,6 +574,25 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -468,6 +591,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 8171ecaa5e..715a6168d7 100644 ptr = nb->tail; err = grub_netbuff_put (nb, 1); if (err) -@@ -483,6 +625,8 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -500,6 +642,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 8171ecaa5e..715a6168d7 100644 d6p = (struct grub_net_dhcp6_packet *)nb->tail; err = grub_netbuff_put (nb, sizeof(*d6p)); -@@ -546,6 +690,25 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -563,6 +707,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,14 +242,13 @@ index 8171ecaa5e..715a6168d7 100644 } diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 4a51667adb..0b490195ad 100644 +index fa528e73a27..248d6a28ff9 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -352,6 +352,15 @@ - #define GRUB_EFI_RNG_PROTOCOL_GUID \ - { 0x3152bca5, 0xeade, 0x433d, \ +@@ -369,6 +369,16 @@ { 0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 } \ -+ + } + +#define GRUB_EFI_IP4_CONFIG2_PROTOCOL_GUID \ + { 0x5b446ed1, 0xe30b, 0x4faa, \ + { 0x87, 0x1a, 0x36, 0x54, 0xec, 0xa3, 0x60, 0x80 } \ @@ -258,12 +257,14 @@ index 4a51667adb..0b490195ad 100644 +#define GRUB_EFI_IP6_CONFIG_PROTOCOL_GUID \ + { 0x937fe521, 0x95ae, 0x4d1a, \ + { 0x89, 0x29, 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a } \ - } - - struct grub_efi_sal_system_table -@@ -1883,6 +1892,72 @@ struct grub_efi_rng_protocol ++ } ++ + #define LINUX_EFI_INITRD_MEDIA_GUID \ + { 0x5568e427, 0x68fc, 0x4f3d, \ + { 0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68 } \ +@@ -1963,6 +1973,72 @@ struct grub_efi_load_file2 }; - typedef struct grub_efi_rng_protocol grub_efi_rng_protocol_t; + typedef struct grub_efi_load_file2 grub_efi_load_file2_t; +enum grub_efi_ip4_config2_data_type { + GRUB_EFI_IP4_CONFIG2_DATA_TYPE_INTERFACEINFO, @@ -331,6 +332,6 @@ index 4a51667adb..0b490195ad 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(__riscv) + struct initrd_media_device_path { + grub_efi_vendor_media_device_path_t vendor; + grub_efi_device_path_t end; diff --git a/0078-Support-UEFI-networking-protocols.patch b/0070-Support-UEFI-networking-protocols.patch similarity index 94% rename from 0078-Support-UEFI-networking-protocols.patch rename to 0070-Support-UEFI-networking-protocols.patch index 145becf..efa3659 100644 --- a/0078-Support-UEFI-networking-protocols.patch +++ b/0070-Support-UEFI-networking-protocols.patch @@ -33,18 +33,18 @@ Signed-off-by: Peter Jones grub-core/net/drivers/efi/efinet.c | 27 + grub-core/net/efi/dhcp.c | 397 ++++++++++ grub-core/net/efi/efi_netfs.c | 57 ++ - grub-core/net/efi/http.c | 419 +++++++++++ + grub-core/net/efi/http.c | 410 +++++++++++ grub-core/net/efi/ip4_config.c | 398 ++++++++++ grub-core/net/efi/ip6_config.c | 422 +++++++++++ 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/api.h | 195 ++++- include/grub/efi/dhcp.h | 343 +++++++++ include/grub/efi/http.h | 215 ++++++ include/grub/net/efi.h | 144 ++++ - 17 files changed, 4620 insertions(+), 41 deletions(-) + 17 files changed, 4618 insertions(+), 49 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 @@ -57,10 +57,10 @@ Signed-off-by: Peter Jones create mode 100644 include/grub/net/efi.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 52ec0fafcd..12797336c9 100644 +index 6645fbae34f..56eb6a828e8 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -2300,6 +2300,12 @@ module = { +@@ -2356,6 +2356,12 @@ module = { common = hook/datehook.c; }; @@ -73,7 +73,7 @@ index 52ec0fafcd..12797336c9 100644 module = { name = net; common = net/net.c; -@@ -2313,6 +2319,12 @@ module = { +@@ -2369,6 +2375,12 @@ module = { common = net/ethernet.c; common = net/arp.c; common = net/netbuff.c; @@ -87,7 +87,7 @@ index 52ec0fafcd..12797336c9 100644 module = { diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c -index a458c3aca7..1637731535 100644 +index a458c3aca78..1637731535e 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) @@ -100,10 +100,10 @@ index a458c3aca7..1637731535 100644 if (file->offset + res < next_buf) { diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index d6a2fb5778..2a446f5031 100644 +index 2bb8a0e7a38..bf16c4307bc 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -755,7 +755,7 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) +@@ -775,7 +775,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; @@ -112,7 +112,7 @@ index d6a2fb5778..2a446f5031 100644 (unsigned) ipv4->local_ip_address[0], (unsigned) ipv4->local_ip_address[1], (unsigned) ipv4->local_ip_address[2], -@@ -768,33 +768,60 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) +@@ -788,33 +788,60 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) (unsigned) ipv4->remote_port, (unsigned) ipv4->protocol, (unsigned) ipv4->static_ip_address); @@ -190,7 +190,7 @@ index d6a2fb5778..2a446f5031 100644 } break; case GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE: -@@ -834,6 +861,39 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) +@@ -861,6 +888,39 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) dump_vendor_path ("Messaging", (grub_efi_vendor_device_path_t *) dp); break; @@ -231,7 +231,7 @@ index d6a2fb5778..2a446f5031 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 715a6168d7..e11d759f19 100644 +index a91df09ee6d..225dc896da0 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -27,6 +27,7 @@ @@ -242,7 +242,7 @@ index 715a6168d7..e11d759f19 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -491,6 +492,17 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u +@@ -508,6 +509,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); @@ -260,7 +260,7 @@ index 715a6168d7..e11d759f19 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)) -@@ -760,6 +772,7 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -781,6 +793,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 @@ -268,7 +268,7 @@ index 715a6168d7..e11d759f19 100644 && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_URI_DEVICE_PATH_SUBTYPE)) continue; dup_dp = grub_efi_duplicate_device_path (dp); -@@ -774,6 +787,15 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -795,6 +808,15 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, dup_ldp->length = sizeof (*dup_ldp); } @@ -284,7 +284,7 @@ index 715a6168d7..e11d759f19 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; -@@ -845,6 +867,9 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -889,6 +911,9 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, GRUB_MOD_INIT(efinet) { @@ -294,8 +294,8 @@ index 715a6168d7..e11d759f19 100644 grub_efinet_findcards (); grub_efi_net_config = grub_efi_net_config_real; } -@@ -856,5 +881,7 @@ GRUB_MOD_FINI(efinet) - FOR_NET_CARDS_SAFE (card, next) +@@ -900,5 +925,7 @@ GRUB_MOD_FINI(efinet) + FOR_NET_CARDS_SAFE (card, next) if (card->driver == &efidriver) grub_net_card_unregister (card); + @@ -304,7 +304,7 @@ index 715a6168d7..e11d759f19 100644 diff --git a/grub-core/net/efi/dhcp.c b/grub-core/net/efi/dhcp.c new file mode 100644 -index 0000000000..dbef63d8c0 +index 00000000000..ca19902441b --- /dev/null +++ b/grub-core/net/efi/dhcp.c @@ -0,0 +1,397 @@ @@ -385,7 +385,7 @@ index 0000000000..dbef63d8c0 + grub_efi_uint32_t option_count = 0; + grub_efi_uint32_t i; + -+ status = efi_call_4 (dhcp4->parse, dhcp4, reply_packet, &option_count, NULL); ++ status = dhcp4->parse(dhcp4, reply_packet, &option_count, NULL); + + if (status != GRUB_EFI_BUFFER_TOO_SMALL) + return NULL; @@ -394,7 +394,7 @@ index 0000000000..dbef63d8c0 + if (!option_list) + return NULL; + -+ status = efi_call_4 (dhcp4->parse, dhcp4, reply_packet, &option_count, option_list); ++ status = dhcp4->parse(dhcp4, reply_packet, &option_count, option_list); + if (status != GRUB_EFI_SUCCESS) + { + grub_free (option_list); @@ -443,13 +443,13 @@ index 0000000000..dbef63d8c0 + + if (!mode->started) + { -+ status = efi_call_2 (pxe->start, pxe, 0); ++ status = pxe->start(pxe, 0); + + if (status != GRUB_EFI_SUCCESS) + grub_printf ("Couldn't start PXE\n"); + } + -+ status = efi_call_2 (pxe->dhcp, pxe, 0); ++ status = pxe->dhcp(pxe, 0); + if (status != GRUB_EFI_SUCCESS) + { + grub_printf ("dhcp4 configure failed, %d\n", (int)status); @@ -500,7 +500,7 @@ index 0000000000..dbef63d8c0 + config.option_list = &options; + + /* FIXME: What if the dhcp has bounded */ -+ status = efi_call_2 (netdev->dhcp4->configure, netdev->dhcp4, &config); ++ status = netdev->dhcp4->configure(netdev->dhcp4, &config); + grub_free (options); + if (status != GRUB_EFI_SUCCESS) + { @@ -508,14 +508,14 @@ index 0000000000..dbef63d8c0 + continue; + } + -+ status = efi_call_2 (netdev->dhcp4->start, netdev->dhcp4, NULL); ++ status = netdev->dhcp4->start(netdev->dhcp4, NULL); + if (status != GRUB_EFI_SUCCESS) + { + grub_printf ("dhcp4 start failed, %d\n", (int)status); + continue; + } + -+ status = efi_call_2 (netdev->dhcp4->get_mode_data, netdev->dhcp4, &mode); ++ status = netdev->dhcp4->get_mode_data(netdev->dhcp4, &mode); + if (status != GRUB_EFI_SUCCESS) + { + grub_printf ("dhcp4 get mode failed, %d\n", (int)status); @@ -616,21 +616,21 @@ index 0000000000..dbef63d8c0 + config.rapid_commit = 0; + config.solicit_retransmission = &retrans; + -+ status = efi_call_2 (dev->dhcp6->configure, dev->dhcp6, &config); ++ status = dev->dhcp6->configure(dev->dhcp6, &config); + grub_free (opt); + if (status != GRUB_EFI_SUCCESS) + { + grub_printf ("dhcp6 configure failed, %d\n", (int)status); + continue; + } -+ status = efi_call_1 (dev->dhcp6->start, dev->dhcp6); ++ status = dev->dhcp6->start(dev->dhcp6); + if (status != GRUB_EFI_SUCCESS) + { + grub_printf ("dhcp6 start failed, %d\n", (int)status); + continue; + } + -+ status = efi_call_3 (dev->dhcp6->get_mode_data, dev->dhcp6, &mode, NULL); ++ status = dev->dhcp6->get_mode_data(dev->dhcp6, &mode, NULL); + if (status != GRUB_EFI_SUCCESS) + { + grub_printf ("dhcp4 get mode failed, %d\n", (int)status); @@ -666,12 +666,12 @@ index 0000000000..dbef63d8c0 + grub_efi_dhcp6_packet_option_t **options = NULL; + grub_efi_uint32_t i; + -+ status = efi_call_4 (dev->dhcp6->parse, dev->dhcp6, mode.ia->reply_packet, &count, NULL); ++ status = dev->dhcp6->parse(dev->dhcp6, mode.ia->reply_packet, &count, NULL); + + if (status == GRUB_EFI_BUFFER_TOO_SMALL && count) + { + options = grub_malloc (count * sizeof(*options)); -+ status = efi_call_4 (dev->dhcp6->parse, dev->dhcp6, mode.ia->reply_packet, &count, options); ++ status = dev->dhcp6->parse(dev->dhcp6, mode.ia->reply_packet, &count, options); + } + + if (status != GRUB_EFI_SUCCESS) @@ -696,8 +696,8 @@ index 0000000000..dbef63d8c0 + grub_free (options); + } + -+ efi_call_1 (b->free_pool, mode.client_id); -+ efi_call_1 (b->free_pool, mode.ia); ++ b->free_pool(mode.client_id); ++ b->free_pool(mode.ia); + } + + return GRUB_ERR_NONE; @@ -707,7 +707,7 @@ index 0000000000..dbef63d8c0 +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 0000000000..ef371d885e +index 00000000000..ef371d885ea --- /dev/null +++ b/grub-core/net/efi/efi_netfs.c @@ -0,0 +1,57 @@ @@ -770,10 +770,10 @@ index 0000000000..ef371d885e +} diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c new file mode 100644 -index 0000000000..3f61fd2fa5 +index 00000000000..de28badccb0 --- /dev/null +++ b/grub-core/net/efi/http.c -@@ -0,0 +1,419 @@ +@@ -0,0 +1,410 @@ + +#include +#include @@ -802,9 +802,9 @@ index 0000000000..3f61fd2fa5 + + http_config.local_address_is_ipv6 = 1; + sz = sizeof (manual_address); -+ status = efi_call_4 (dev->ip6_config->get_data, dev->ip6_config, -+ GRUB_EFI_IP6_CONFIG_DATA_TYPE_MANUAL_ADDRESS, -+ &sz, &manual_address); ++ status = dev->ip6_config->get_data(dev->ip6_config, ++ GRUB_EFI_IP6_CONFIG_DATA_TYPE_MANUAL_ADDRESS, ++ &sz, &manual_address); + + if (status == GRUB_EFI_NOT_FOUND) + { @@ -834,19 +834,19 @@ index 0000000000..3f61fd2fa5 + http_config.access_point.ipv4_node = &httpv4_node; + } + -+ status = efi_call_2 (http->configure, http, &http_config); ++ status = http->configure(http, &http_config); + + if (status == GRUB_EFI_ALREADY_STARTED) + { + /* XXX: This hangs HTTPS boot */ +#if 0 -+ if (efi_call_2 (http->configure, http, NULL) != GRUB_EFI_SUCCESS) ++ if (http->configure(http, NULL) != GRUB_EFI_SUCCESS) + { + grub_error (GRUB_ERR_IO, N_("couldn't reset http instance")); + grub_print_error (); + return; + } -+ status = efi_call_2 (http->configure, http, &http_config); ++ status = http->configure(http, &http_config); +#endif + return; + } @@ -945,12 +945,9 @@ index 0000000000..3f61fd2fa5 + request_token.message = &request_message; + + request_callback_done = 0; -+ status = efi_call_5 (b->create_event, -+ GRUB_EFI_EVT_NOTIFY_SIGNAL, -+ GRUB_EFI_TPL_CALLBACK, -+ grub_efi_http_request_callback, -+ NULL, -+ &request_token.event); ++ status = b->create_event(GRUB_EFI_EVT_NOTIFY_SIGNAL, GRUB_EFI_TPL_CALLBACK, ++ grub_efi_http_request_callback, NULL, ++ &request_token.event); + + if (status != GRUB_EFI_SUCCESS) + { @@ -958,17 +955,17 @@ index 0000000000..3f61fd2fa5 + return grub_error (GRUB_ERR_IO, "Fail to create an event! status=0x%x\n", status); + } + -+ status = efi_call_2 (http->request, http, &request_token); ++ status = http->request(http, &request_token); + + if (status != GRUB_EFI_SUCCESS) + { -+ efi_call_1 (b->close_event, request_token.event); ++ b->close_event(request_token.event); + grub_free (request_data.url); + return grub_error (GRUB_ERR_IO, "Fail to send a request! status=0x%x\n", status); + } + /* TODO: Add Timeout */ + while (!request_callback_done) -+ efi_call_1(http->poll, http); ++ http->poll(http); + + response_data.status_code = GRUB_EFI_HTTP_STATUS_UNSUPPORTED_STATUS; + response_message.data.response = &response_data; @@ -981,16 +978,13 @@ index 0000000000..3f61fd2fa5 + response_message.body = NULL; + response_token.event = NULL; + -+ status = efi_call_5 (b->create_event, -+ GRUB_EFI_EVT_NOTIFY_SIGNAL, -+ GRUB_EFI_TPL_CALLBACK, -+ grub_efi_http_response_callback, -+ NULL, -+ &response_token.event); ++ status = b->create_event(GRUB_EFI_EVT_NOTIFY_SIGNAL, GRUB_EFI_TPL_CALLBACK, ++ grub_efi_http_response_callback, NULL, ++ &response_token.event); + + if (status != GRUB_EFI_SUCCESS) + { -+ efi_call_1 (b->close_event, request_token.event); ++ b->close_event(request_token.event); + grub_free (request_data.url); + return grub_error (GRUB_ERR_IO, "Fail to create an event! status=0x%x\n", status); + } @@ -1000,28 +994,28 @@ index 0000000000..3f61fd2fa5 + + /* wait for HTTP response */ + response_callback_done = 0; -+ status = efi_call_2 (http->response, http, &response_token); ++ status = http->response(http, &response_token); + + if (status != GRUB_EFI_SUCCESS) + { -+ efi_call_1 (b->close_event, response_token.event); -+ efi_call_1 (b->close_event, request_token.event); ++ b->close_event(response_token.event); ++ b->close_event(request_token.event); + grub_free (request_data.url); + return grub_error (GRUB_ERR_IO, "Fail to receive a response! status=%d\n", (int)status); + } + + /* TODO: Add Timeout */ + while (!response_callback_done) -+ efi_call_1 (http->poll, http); ++ http->poll(http); + + if (response_message.data.response->status_code != GRUB_EFI_HTTP_STATUS_200_OK) + { + grub_efi_http_status_code_t status_code = response_message.data.response->status_code; + + if (response_message.headers) -+ efi_call_1 (b->free_pool, response_message.headers); -+ efi_call_1 (b->close_event, response_token.event); -+ efi_call_1 (b->close_event, request_token.event); ++ b->free_pool(response_message.headers); ++ b->close_event(response_token.event); ++ b->close_event(request_token.event); + grub_free (request_data.url); + if (status_code == GRUB_EFI_HTTP_STATUS_404_NOT_FOUND) + { @@ -1049,9 +1043,9 @@ index 0000000000..3f61fd2fa5 + } + + if (response_message.headers) -+ efi_call_1 (b->free_pool, response_message.headers); -+ efi_call_1 (b->close_event, response_token.event); -+ efi_call_1 (b->close_event, request_token.event); ++ b->free_pool(response_message.headers); ++ b->close_event(response_token.event); ++ b->close_event(request_token.event); + grub_free (request_data.url); + + return GRUB_ERR_NONE; @@ -1076,12 +1070,9 @@ index 0000000000..3f61fd2fa5 + return -1; + } + -+ efi_call_5 (b->create_event, -+ GRUB_EFI_EVT_NOTIFY_SIGNAL, -+ GRUB_EFI_TPL_CALLBACK, -+ grub_efi_http_response_callback, -+ NULL, -+ &response_token.event); ++ b->create_event(GRUB_EFI_EVT_NOTIFY_SIGNAL, GRUB_EFI_TPL_CALLBACK, ++ grub_efi_http_response_callback, NULL, ++ &response_token.event); + + while (len) + { @@ -1096,23 +1087,23 @@ index 0000000000..3f61fd2fa5 + + response_callback_done = 0; + -+ status = efi_call_2 (http->response, http, &response_token); ++ status = http->response(http, &response_token); + if (status != GRUB_EFI_SUCCESS) + { -+ efi_call_1 (b->close_event, response_token.event); ++ b->close_event(response_token.event); + grub_error (GRUB_ERR_IO, "Error! status=%d\n", (int)status); + return -1; + } + + while (!response_callback_done) -+ efi_call_1(http->poll, http); ++ http->poll(http); + + sum += response_message.body_length; + buf += response_message.body_length; + len -= response_message.body_length; + } + -+ efi_call_1 (b->close_event, response_token.event); ++ b->close_event(response_token.event); + + return sum; +} @@ -1195,7 +1186,7 @@ index 0000000000..3f61fd2fa5 + }; diff --git a/grub-core/net/efi/ip4_config.c b/grub-core/net/efi/ip4_config.c new file mode 100644 -index 0000000000..b711a5d945 +index 00000000000..1deba25e79e --- /dev/null +++ b/grub-core/net/efi/ip4_config.c @@ -0,0 +1,398 @@ @@ -1305,17 +1296,17 @@ index 0000000000..b711a5d945 + if (!interface_info) + return NULL; + -+ status = efi_call_4 (ip4_config->get_data, ip4_config, -+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_INTERFACEINFO, -+ &sz, interface_info); ++ status = ip4_config->get_data(ip4_config, ++ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_INTERFACEINFO, ++ &sz, interface_info); + + if (status == GRUB_EFI_BUFFER_TOO_SMALL) + { + grub_free (interface_info); + interface_info = grub_malloc (sz); -+ status = efi_call_4 (ip4_config->get_data, ip4_config, -+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_INTERFACEINFO, -+ &sz, interface_info); ++ status = ip4_config->get_data(ip4_config, ++ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_INTERFACEINFO, ++ &sz, interface_info); + } + + if (status != GRUB_EFI_SUCCESS) @@ -1339,9 +1330,9 @@ index 0000000000..b711a5d945 + if (!manual_address) + return NULL; + -+ status = efi_call_4 (ip4_config->get_data, ip4_config, -+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_MANUAL_ADDRESS, -+ &sz, manual_address); ++ status = ip4_config->get_data(ip4_config, ++ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_MANUAL_ADDRESS, ++ &sz, manual_address); + + if (status != GRUB_EFI_SUCCESS) + { @@ -1546,7 +1537,7 @@ index 0000000000..b711a5d945 + } + } + -+ status = efi_call_4 (dev->ip4_config->set_data, dev->ip4_config, ++ status = dev->ip4_config->set_data(dev->ip4_config, + GRUB_EFI_IP4_CONFIG2_DATA_TYPE_MANUAL_ADDRESS, + sizeof(*address), address); + @@ -1562,9 +1553,9 @@ index 0000000000..b711a5d945 +{ + grub_efi_status_t status; + -+ status = efi_call_4 (dev->ip4_config->set_data, dev->ip4_config, -+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_GATEWAY, -+ sizeof (address->ip4), &address->ip4); ++ status = dev->ip4_config->set_data(dev->ip4_config, ++ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_GATEWAY, ++ sizeof (address->ip4), &address->ip4); + + if (status != GRUB_EFI_SUCCESS) + return 0; @@ -1578,9 +1569,9 @@ index 0000000000..b711a5d945 +{ + grub_efi_status_t status; + -+ status = efi_call_4 (dev->ip4_config->set_data, dev->ip4_config, -+ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER, -+ sizeof (address->ip4), &address->ip4); ++ status = dev->ip4_config->set_data(dev->ip4_config, ++ GRUB_EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER, ++ sizeof (address->ip4), &address->ip4); + + if (status != GRUB_EFI_SUCCESS) + return 0; @@ -1599,7 +1590,7 @@ index 0000000000..b711a5d945 + }; diff --git a/grub-core/net/efi/ip6_config.c b/grub-core/net/efi/ip6_config.c new file mode 100644 -index 0000000000..017c4d05bc +index 00000000000..29a03973265 --- /dev/null +++ b/grub-core/net/efi/ip6_config.c @@ -0,0 +1,422 @@ @@ -1729,7 +1720,7 @@ index 0000000000..017c4d05bc + sz = sizeof (*interface_info) + sizeof (*interface_info->route_table); + interface_info = grub_malloc (sz); + -+ status = efi_call_4 (ip6_config->get_data, ip6_config, ++ status = ip6_config->get_data(ip6_config, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_INTERFACEINFO, + &sz, interface_info); + @@ -1737,7 +1728,7 @@ index 0000000000..017c4d05bc + { + grub_free (interface_info); + interface_info = grub_malloc (sz); -+ status = efi_call_4 (ip6_config->get_data, ip6_config, ++ status = ip6_config->get_data(ip6_config, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_INTERFACEINFO, + &sz, interface_info); + } @@ -1763,7 +1754,7 @@ index 0000000000..017c4d05bc + if (!manual_address) + return NULL; + -+ status = efi_call_4 (ip6_config->get_data, ip6_config, ++ status = ip6_config->get_data(ip6_config, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_MANUAL_ADDRESS, + &sz, manual_address); + @@ -1974,7 +1965,7 @@ index 0000000000..017c4d05bc + } + } + -+ status = efi_call_4 (dev->ip6_config->set_data, dev->ip6_config, ++ status = dev->ip6_config->set_data(dev->ip6_config, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_MANUAL_ADDRESS, + sizeof(*address), address); + @@ -1990,7 +1981,7 @@ index 0000000000..017c4d05bc +{ + grub_efi_status_t status; + -+ status = efi_call_4 (dev->ip6_config->set_data, dev->ip6_config, ++ status = dev->ip6_config->set_data(dev->ip6_config, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_GATEWAY, + sizeof (address->ip6), &address->ip6); + @@ -2006,7 +1997,7 @@ index 0000000000..017c4d05bc + + grub_efi_status_t status; + -+ status = efi_call_4 (dev->ip6_config->set_data, dev->ip6_config, ++ status = dev->ip6_config->set_data(dev->ip6_config, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_DNSSERVER, + sizeof (address->ip6), &address->ip6); + @@ -2027,7 +2018,7 @@ index 0000000000..017c4d05bc + }; diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c new file mode 100644 -index 0000000000..86bce6535d +index 00000000000..1a19ee27144 --- /dev/null +++ b/grub-core/net/efi/net.c @@ -0,0 +1,1428 @@ @@ -2050,15 +2041,15 @@ index 0000000000..86bce6535d + +#define GRUB_EFI_IP6_PREFIX_LENGTH 64 + -+static grub_efi_guid_t ip4_config_guid = GRUB_EFI_IP4_CONFIG2_PROTOCOL_GUID; -+static grub_efi_guid_t ip6_config_guid = GRUB_EFI_IP6_CONFIG_PROTOCOL_GUID; -+static grub_efi_guid_t http_service_binding_guid = GRUB_EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID; -+static grub_efi_guid_t http_guid = GRUB_EFI_HTTP_PROTOCOL_GUID; -+static grub_efi_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID; -+static grub_efi_guid_t dhcp4_service_binding_guid = GRUB_EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID; -+static grub_efi_guid_t dhcp4_guid = GRUB_EFI_DHCP4_PROTOCOL_GUID; -+static grub_efi_guid_t dhcp6_service_binding_guid = GRUB_EFI_DHCP6_SERVICE_BINDING_PROTOCOL_GUID; -+static grub_efi_guid_t dhcp6_guid = GRUB_EFI_DHCP6_PROTOCOL_GUID; ++static grub_guid_t ip4_config_guid = GRUB_EFI_IP4_CONFIG2_PROTOCOL_GUID; ++static grub_guid_t ip6_config_guid = GRUB_EFI_IP6_CONFIG_PROTOCOL_GUID; ++static grub_guid_t http_service_binding_guid = GRUB_EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID; ++static grub_guid_t http_guid = GRUB_EFI_HTTP_PROTOCOL_GUID; ++static grub_guid_t pxe_io_guid = GRUB_EFI_PXE_GUID; ++static grub_guid_t dhcp4_service_binding_guid = GRUB_EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID; ++static grub_guid_t dhcp4_guid = GRUB_EFI_DHCP4_PROTOCOL_GUID; ++static grub_guid_t dhcp6_service_binding_guid = GRUB_EFI_DHCP6_SERVICE_BINDING_PROTOCOL_GUID; ++static grub_guid_t dhcp6_guid = GRUB_EFI_DHCP6_PROTOCOL_GUID; + +struct grub_efi_net_device *net_devices; + @@ -2073,13 +2064,13 @@ index 0000000000..86bce6535d +#define efi_net_interface(m,...) efi_net_interface_ ## m (net_interface, ## __VA_ARGS__) + +static grub_efi_handle_t -+grub_efi_locate_device_path (grub_efi_guid_t *protocol, grub_efi_device_path_t *device_path, ++grub_efi_locate_device_path (grub_guid_t *protocol, grub_efi_device_path_t *device_path, + grub_efi_device_path_t **r_device_path) +{ + grub_efi_handle_t handle; + grub_efi_status_t status; + -+ status = efi_call_3 (grub_efi_system_table->boot_services->locate_device_path, ++ status = grub_efi_system_table->boot_services->locate_device_path( + protocol, &device_path, &handle); + + if (status != GRUB_EFI_SUCCESS) @@ -2721,7 +2712,7 @@ index 0000000000..86bce6535d +} + +static grub_efi_handle_t -+grub_efi_service_binding (grub_efi_handle_t dev, grub_efi_guid_t *service_binding_guid) ++grub_efi_service_binding (grub_efi_handle_t dev, grub_guid_t *service_binding_guid) +{ + grub_efi_service_binding_t *service; + grub_efi_status_t status; @@ -2734,7 +2725,7 @@ index 0000000000..86bce6535d + return NULL; + } + -+ status = efi_call_2 (service->create_child, service, &child_dev); ++ status = service->create_child(service, &child_dev); + if (status != GRUB_EFI_SUCCESS) + { + grub_error (GRUB_ERR_IO, N_("Failed to create child device of http service %x"), status); @@ -2944,7 +2935,7 @@ index 0000000000..86bce6535d + { + grub_efi_ip4_config2_policy_t ip4_policy = GRUB_EFI_IP4_CONFIG2_POLICY_STATIC; + -+ if (efi_call_4 (dev->ip4_config->set_data, dev->ip4_config, ++ if (dev->ip4_config->set_data(dev->ip4_config, + GRUB_EFI_IP4_CONFIG2_DATA_TYPE_POLICY, + sizeof (ip4_policy), &ip4_policy) != GRUB_EFI_SUCCESS) + grub_dprintf ("efinetfs", "could not set GRUB_EFI_IP4_CONFIG2_POLICY_STATIC on dev `%s'", dev->card_name); @@ -2953,7 +2944,7 @@ index 0000000000..86bce6535d + { + grub_efi_ip6_config_policy_t ip6_policy = GRUB_EFI_IP6_CONFIG_POLICY_MANUAL; + -+ if (efi_call_4 (dev->ip6_config->set_data, dev->ip6_config, ++ if (dev->ip6_config->set_data(dev->ip6_config, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_POLICY, + sizeof (ip6_policy), &ip6_policy) != GRUB_EFI_SUCCESS) + grub_dprintf ("efinetfs", "could not set GRUB_EFI_IP6_CONFIG_POLICY_MANUAL on dev `%s'", dev->card_name); @@ -3461,7 +3452,7 @@ index 0000000000..86bce6535d +} diff --git a/grub-core/net/efi/pxe.c b/grub-core/net/efi/pxe.c new file mode 100644 -index 0000000000..531949cba5 +index 00000000000..b84f86ea470 --- /dev/null +++ b/grub-core/net/efi/pxe.c @@ -0,0 +1,424 @@ @@ -3484,7 +3475,7 @@ index 0000000000..531949cba5 + if (!manual_address) + return NULL; + -+ status = efi_call_4 (ip6_config->get_data, ip6_config, ++ status = ip6_config->get_data(ip6_config, + GRUB_EFI_IP6_CONFIG_DATA_TYPE_MANUAL_ADDRESS, + &sz, manual_address); + @@ -3509,7 +3500,7 @@ index 0000000000..531949cba5 + if (!manual_address) + return NULL; + -+ status = efi_call_4 (ip4_config->get_data, ip4_config, ++ status = ip4_config->get_data(ip4_config, + GRUB_EFI_IP4_CONFIG2_DATA_TYPE_MANUAL_ADDRESS, + &sz, manual_address); + @@ -3532,7 +3523,7 @@ index 0000000000..531949cba5 + if (!mode->started) + { + grub_efi_status_t status; -+ status = efi_call_2 (pxe->start, pxe, prefer_ip6); ++ status = pxe->start(pxe, prefer_ip6); + + if (status != GRUB_EFI_SUCCESS) + grub_printf ("Couldn't start PXE\n"); @@ -3555,7 +3546,7 @@ index 0000000000..531949cba5 + grub_efi_pxe_ip_address_t station_ip; + + grub_memcpy (station_ip.v6.addr, manual_address->address, sizeof (station_ip.v6.addr)); -+ status = efi_call_3 (pxe->set_station_ip, pxe, &station_ip, NULL); ++ status = pxe->set_station_ip(pxe, &station_ip, NULL); + + if (status != GRUB_EFI_SUCCESS) + grub_printf ("Couldn't set station ip\n"); @@ -3578,7 +3569,7 @@ index 0000000000..531949cba5 + grub_memcpy (station_ip.v4.addr, manual_address->address, sizeof (station_ip.v4.addr)); + grub_memcpy (subnet_mask.v4.addr, manual_address->subnet_mask, sizeof (subnet_mask.v4.addr)); + -+ status = efi_call_3 (pxe->set_station_ip, pxe, &station_ip, &subnet_mask); ++ status = pxe->set_station_ip(pxe, &station_ip, &subnet_mask); + + if (status != GRUB_EFI_SUCCESS) + grub_printf ("Couldn't set station ip\n"); @@ -3731,7 +3722,7 @@ index 0000000000..531949cba5 + server_ip.v4.addr[i] = grub_strtoul (p, &p, 10); + } + -+ status = efi_call_10 (pxe->mtftp, ++ status = pxe->mtftp( + pxe, + GRUB_EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE, + NULL, @@ -3816,7 +3807,7 @@ index 0000000000..531949cba5 + server_ip.v4.addr[i] = grub_strtoul (p, &p, 10); + } + -+ status = efi_call_10 (pxe->mtftp, ++ status = pxe->mtftp( + pxe, + GRUB_EFI_PXE_BASE_CODE_TFTP_READ_FILE, + buf, @@ -3847,7 +3838,7 @@ index 0000000000..531949cba5 + return 0; + } + -+ status = efi_call_10 (pxe->mtftp, ++ status = pxe->mtftp( + pxe, + GRUB_EFI_PXE_BASE_CODE_TFTP_READ_FILE, + buf2, @@ -3890,7 +3881,7 @@ index 0000000000..531949cba5 + }; + diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 0ce5e675ed..55aed92722 100644 +index fa6b6537142..fdec64d55ee 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -32,6 +32,9 @@ @@ -3903,8 +3894,8 @@ index 0ce5e675ed..55aed92722 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -2033,8 +2036,49 @@ static grub_command_t cmd_addaddr, cmd_deladdr, cmd_addroute, cmd_delroute; - static grub_command_t cmd_lsroutes, cmd_lscards; +@@ -2092,8 +2095,49 @@ static grub_command_t cmd_addaddr, cmd_deladdr, cmd_addroute, cmd_delroute; + static grub_command_t cmd_setvlan, cmd_lsroutes, cmd_lscards; static grub_command_t cmd_lsaddr, cmd_slaac; +#ifdef GRUB_MACHINE_EFI @@ -3953,7 +3944,7 @@ index 0ce5e675ed..55aed92722 100644 grub_register_variable_hook ("net_default_server", defserver_get_env, defserver_set_env); grub_env_export ("net_default_server"); -@@ -2082,10 +2126,37 @@ GRUB_MOD_INIT(net) +@@ -2144,10 +2188,37 @@ GRUB_MOD_INIT(net) grub_net_restore_hw, GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK); grub_net_poll_cards_idle = grub_net_poll_cards_idle_real; @@ -3991,16 +3982,16 @@ index 0ce5e675ed..55aed92722 100644 grub_register_variable_hook ("net_default_server", 0, 0); grub_register_variable_hook ("pxe_default_server", 0, 0); -@@ -2104,4 +2175,7 @@ GRUB_MOD_FINI(net) +@@ -2166,4 +2237,7 @@ GRUB_MOD_FINI(net) grub_net_fini_hw (0); grub_loader_unregister_preboot_hook (fini_hnd); - grub_net_poll_cards_idle = grub_net_poll_cards_idle_real; + grub_net_poll_cards_idle = NULL; +#ifdef GRUB_MACHINE_EFI + init_mode = INIT_MODE_NONE; +#endif } diff --git a/util/grub-mknetdir.c b/util/grub-mknetdir.c -index a2461cda1c..77958dd9dd 100644 +index 46f304c2b47..11c9db11775 100644 --- a/util/grub-mknetdir.c +++ b/util/grub-mknetdir.c @@ -32,13 +32,15 @@ @@ -4055,7 +4046,7 @@ index a2461cda1c..77958dd9dd 100644 { const char *mkimage_target; const char *netmodule; -@@ -156,6 +161,7 @@ process_input_dir (const char *input_dir, enum grub_install_plat platform) +@@ -157,6 +162,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); @@ -4063,7 +4054,7 @@ index a2461cda1c..77958dd9dd 100644 grub_install_make_image_wrap (input_dir, prefix, output, 0, load_cfg, targets[platform].mkimage_target, 0); -@@ -195,7 +201,16 @@ main (int argc, char *argv[]) +@@ -196,7 +202,16 @@ main (int argc, char *argv[]) grub_install_mkdir_p (base); @@ -4082,10 +4073,10 @@ index a2461cda1c..77958dd9dd 100644 if (!grub_install_source_directory) { diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index 0b490195ad..f431f49973 100644 +index 248d6a28ff9..805a9d7adf9 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -622,6 +622,23 @@ typedef union +@@ -668,6 +668,23 @@ typedef union typedef grub_efi_uint64_t grub_efi_physical_address_t; typedef grub_efi_uint64_t grub_efi_virtual_address_t; @@ -4107,9 +4098,9 @@ index 0b490195ad..f431f49973 100644 + grub_efi_pxe_ipv6_address_t v6; +} grub_efi_pxe_ip_address_t; - struct grub_efi_guid - { -@@ -889,6 +906,8 @@ struct grub_efi_ipv6_device_path + /* XXX although the spec does not specify the padding, this actually + must have the padding! */ +@@ -917,6 +934,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; @@ -4118,7 +4109,7 @@ index 0b490195ad..f431f49973 100644 } GRUB_PACKED; typedef struct grub_efi_ipv6_device_path grub_efi_ipv6_device_path_t; -@@ -938,6 +957,15 @@ struct grub_efi_uri_device_path +@@ -975,6 +994,15 @@ struct grub_efi_uri_device_path } GRUB_PACKED; typedef struct grub_efi_uri_device_path grub_efi_uri_device_path_t; @@ -4134,7 +4125,7 @@ index 0b490195ad..f431f49973 100644 #define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10 /* Media Device Path. */ -@@ -1020,6 +1048,23 @@ struct grub_efi_bios_device_path +@@ -1057,6 +1085,23 @@ struct grub_efi_bios_device_path } GRUB_PACKED; typedef struct grub_efi_bios_device_path grub_efi_bios_device_path_t; @@ -4158,7 +4149,7 @@ index 0b490195ad..f431f49973 100644 struct grub_efi_open_protocol_information_entry { grub_efi_handle_t agent_handle; -@@ -1569,23 +1614,27 @@ typedef struct grub_efi_pxe_tftp_error +@@ -1617,23 +1662,27 @@ typedef struct grub_efi_pxe_tftp_error grub_efi_char8_t error_string[127]; } grub_efi_pxe_tftp_error_t; @@ -4200,18 +4191,27 @@ index 0b490195ad..f431f49973 100644 #define GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT 8 typedef struct grub_efi_pxe_ip_filter -@@ -1652,17 +1701,31 @@ typedef struct grub_efi_pxe_mode +@@ -1700,18 +1749,31 @@ typedef struct grub_efi_pxe_mode typedef struct grub_efi_pxe { grub_uint64_t rev; -- void (*start) (void); +- void *start; +- void *stop; +- void *dhcp; +- void *discover; +- void *mftp; +- void *udpwrite; +- void *udpread; +- void *setipfilter; +- void *arp; +- void *setparams; +- void *setstationip; +- void *setpackets; + grub_efi_status_t (*start) (struct grub_efi_pxe *this, grub_efi_boolean_t use_ipv6); - void (*stop) (void); -- void (*dhcp) (void); ++ void (*stop) (void); + grub_efi_status_t (*dhcp) (struct grub_efi_pxe *this, + grub_efi_boolean_t sort_offers); - void (*discover) (void); -- void (*mftp) (void); ++ void (*discover) (void); + grub_efi_status_t (*mtftp) (struct grub_efi_pxe *this, + grub_efi_pxe_base_code_tftp_opcode_t operation, + void *buffer_ptr, @@ -4223,20 +4223,19 @@ index 0b490195ad..f431f49973 100644 + grub_efi_char8_t *filename, + grub_efi_pxe_base_code_mtftp_info_t *info, + grub_efi_boolean_t dont_use_buffer); - void (*udpwrite) (void); - void (*udpread) (void); - void (*setipfilter) (void); - void (*arp) (void); - void (*setparams) (void); -- void (*setstationip) (void); ++ void (*udpwrite) (void); ++ void (*udpread) (void); ++ void (*setipfilter) (void); ++ void (*arp) (void); ++ void (*setparams) (void); + grub_efi_status_t (*set_station_ip) (struct grub_efi_pxe *this, + grub_efi_pxe_ip_address_t *new_station_ip, + grub_efi_pxe_ip_address_t *new_subnet_mask); -+ //void (*setstationip) (void); - void (*setpackets) (void); ++ void (*setpackets) (void); struct grub_efi_pxe_mode *mode; } grub_efi_pxe_t; -@@ -1924,6 +1987,44 @@ struct grub_efi_ip4_config2_protocol + +@@ -2005,6 +2067,44 @@ struct grub_efi_ip4_config2_protocol }; typedef struct grub_efi_ip4_config2_protocol grub_efi_ip4_config2_protocol_t; @@ -4281,7 +4280,7 @@ index 0b490195ad..f431f49973 100644 enum grub_efi_ip6_config_data_type { GRUB_EFI_IP6_CONFIG_DATA_TYPE_INTERFACEINFO, GRUB_EFI_IP6_CONFIG_DATA_TYPE_ALT_INTERFACEID, -@@ -1958,6 +2059,49 @@ struct grub_efi_ip6_config_protocol +@@ -2039,6 +2139,49 @@ struct grub_efi_ip6_config_protocol }; typedef struct grub_efi_ip6_config_protocol grub_efi_ip6_config_protocol_t; @@ -4328,12 +4327,12 @@ index 0b490195ad..f431f49973 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(__riscv) + struct initrd_media_device_path { + grub_efi_vendor_media_device_path_t vendor; + grub_efi_device_path_t end; diff --git a/include/grub/efi/dhcp.h b/include/grub/efi/dhcp.h new file mode 100644 -index 0000000000..fdb88eb810 +index 00000000000..fdb88eb810e --- /dev/null +++ b/include/grub/efi/dhcp.h @@ -0,0 +1,343 @@ @@ -4682,7 +4681,7 @@ index 0000000000..fdb88eb810 +#endif /* ! GRUB_EFI_DHCP_HEADER */ diff --git a/include/grub/efi/http.h b/include/grub/efi/http.h new file mode 100644 -index 0000000000..c5e9a89f50 +index 00000000000..c5e9a89f505 --- /dev/null +++ b/include/grub/efi/http.h @@ -0,0 +1,215 @@ @@ -4903,7 +4902,7 @@ index 0000000000..c5e9a89f50 +#endif /* !GRUB_EFI_HTTP_HEADER */ diff --git a/include/grub/net/efi.h b/include/grub/net/efi.h new file mode 100644 -index 0000000000..de90d223e8 +index 00000000000..de90d223e8e --- /dev/null +++ b/include/grub/net/efi.h @@ -0,0 +1,144 @@ diff --git a/0079-AUDIT-0-http-boot-tracker-bug.patch b/0071-AUDIT-0-http-boot-tracker-bug.patch similarity index 82% rename from 0079-AUDIT-0-http-boot-tracker-bug.patch rename to 0071-AUDIT-0-http-boot-tracker-bug.patch index b487271..db7f9c7 100644 --- a/0079-AUDIT-0-http-boot-tracker-bug.patch +++ b/0071-AUDIT-0-http-boot-tracker-bug.patch @@ -18,11 +18,11 @@ signed code is allowed to be executed. Signed-off-by: Michael Chang --- grub-core/net/efi/net.c | 4 +++- - grub-core/net/http.c | 5 ++++- - 2 files changed, 7 insertions(+), 2 deletions(-) + grub-core/net/http.c | 8 +++++++- + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c -index 86bce6535d..4bb308026c 100644 +index 1a19ee27144..ed04f05ad21 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,20 +38,23 @@ index 86bce6535d..4bb308026c 100644 if (buf) { diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index 12a2632ea5..b52b558d63 100644 +index f389bf03d96..af486198399 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c -@@ -31,7 +31,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); +@@ -29,7 +29,11 @@ - enum - { -- HTTP_PORT = 80 + GRUB_MOD_LICENSE ("GPLv3+"); + +-#define HTTP_PORT ((grub_uint16_t) 80) ++enum ++ { + HTTP_PORT = 80, + HTTP_MAX_CHUNK_SIZE = 0x80000000 - }; ++ }; - -@@ -78,6 +79,8 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len) + typedef struct http_data + { +@@ -82,6 +86,8 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len) if (data->in_chunk_len == 2) { data->chunk_rem = grub_strtoul (ptr, 0, 16); diff --git a/0071-net-read-bracketed-ipv6-addrs-and-port-numbers.patch b/0071-net-read-bracketed-ipv6-addrs-and-port-numbers.patch deleted file mode 100644 index 307e33c..0000000 --- a/0071-net-read-bracketed-ipv6-addrs-and-port-numbers.patch +++ /dev/null @@ -1,270 +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 - -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 | 25 ++++++++++++--- - grub-core/net/net.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++--- - grub-core/net/tftp.c | 8 +++-- - include/grub/net.h | 1 + - 4 files changed, 109 insertions(+), 12 deletions(-) - -diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index b616cf40b1..12a2632ea5 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) - { -@@ -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; -+ char* server = file->device->net->server; -+ int port = file->device->net->port; - - nb = grub_netbuff_alloc (GRUB_NET_TCP_RESERVE_SIZE - + sizeof ("GET ") - 1 - + grub_strlen (data->filename) - + sizeof (" HTTP/1.1\r\nHost: ") - 1 -- + grub_strlen (file->device->net->server) -+ + grub_strlen (server) + sizeof (":XXXXXXXXXX") - + sizeof ("\r\nUser-Agent: " PACKAGE_STRING - "\r\n") - 1 - + sizeof ("Range: bytes=XXXXXXXXXXXXXXXXXXXX" -@@ -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; -- err = grub_netbuff_put (nb, grub_strlen (file->device->net->server)); -+ err = grub_netbuff_put (nb, grub_strlen (server)); - if (err) - { - grub_netbuff_free (nb); -@@ -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)); - -+ if (port) -+ { -+ ptr = nb->tail; -+ grub_snprintf ((char *) ptr, -+ sizeof (":XXXXXXXXXX"), -+ ":%d", -+ port); -+ } -+ - ptr = nb->tail; - err = grub_netbuff_put (nb, - sizeof ("\r\nUser-Agent: " PACKAGE_STRING "\r\n") -@@ -390,8 +403,10 @@ 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, -+ 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, NULL, - file); - if (!data->sock) -diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index a46f82362e..0ce5e675ed 100644 ---- a/grub-core/net/net.c -+++ b/grub-core/net/net.c -@@ -444,6 +444,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] == ':' && ptr[1] != ':') - return 0; -@@ -482,6 +489,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 == ']') -+ ptr++; - if (rest) - *rest = ptr; - return 1; -@@ -1343,8 +1352,10 @@ grub_net_open_real (const char *name) - { - grub_net_app_level_t proto; - const char *protname, *server; -+ char *host; - grub_size_t protnamelen; - int try; -+ int port = 0; - - if (grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) == 0) - { -@@ -1382,6 +1393,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, '['))) -+ { -+ char* ipv6_end = grub_strchr (server, ']'); -+ if(!ipv6_end) -+ { -+ grub_error (GRUB_ERR_NET_BAD_ADDRESS, -+ N_("mismatched [ in address")); -+ return NULL; -+ } -+ /* port number after bracketed ipv6 addr */ -+ if(ipv6_end[1] == ':') -+ { -+ port = grub_strtoul (ipv6_end + 2, NULL, 10); -+ if(port > 65535) -+ { -+ grub_error (GRUB_ERR_NET_BAD_ADDRESS, -+ N_("bad port number")); -+ return NULL; -+ } -+ } -+ host = grub_strndup (ipv6_begin, (ipv6_end - ipv6_begin) + 1); -+ } -+ else -+ { -+ if (grub_strchr (port_start + 1, ':')) -+ { -+ int iplen = grub_strlen (server); -+ /* bracket bare ipv6 addrs */ -+ host = grub_malloc (iplen + 3); -+ if(!host) -+ { -+ return NULL; -+ } -+ host[0] = '['; -+ grub_memcpy (host + 1, server, iplen); -+ host[iplen + 1] = ']'; -+ host[iplen + 2] = '\0'; -+ } -+ else -+ { -+ /* hostname:port or ipv4:port */ -+ port = grub_strtol (port_start + 1, NULL, 10); -+ if(port > 65535) -+ { -+ grub_error (GRUB_ERR_NET_BAD_ADDRESS, -+ N_("bad port number")); -+ return NULL; -+ } -+ host = grub_strndup (server, port_start - server); -+ } -+ } -+ } -+ else -+ { -+ host = grub_strdup (server); -+ } -+ if (!host) -+ { -+ return NULL; -+ } -+ - for (try = 0; try < 2; try++) - { - FOR_NET_APP_LEVEL (proto) -@@ -1391,14 +1468,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; - } -@@ -1473,6 +1549,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 4ab2f5c735..d54b13f09f 100644 ---- a/grub-core/net/tftp.c -+++ b/grub-core/net/tftp.c -@@ -295,6 +295,7 @@ tftp_open (struct grub_file *file, const char *filename) - grub_err_t err; - grub_uint8_t *nbd; - grub_net_network_level_address_t addr; -+ int port = file->device->net->port; - - data = grub_zalloc (sizeof (*data)); - if (!data) -@@ -362,14 +363,17 @@ tftp_open (struct grub_file *file, const char *filename) - err = grub_net_resolve_address (file->device->net->server, &addr); - if (err) - { -- grub_dprintf("tftp", "Address resolution failed: %d\n", err); -+ grub_dprintf ("tftp", "Address resolution failed: %d\n", err); -+ grub_dprintf ("tftp", "file_size is %llu, block_size is %llu\n", -+ (unsigned long long)data->file_size, -+ (unsigned long long)data->block_size); - grub_free (data); - return err; - } - - grub_dprintf("tftp", "opening connection\n"); - data->sock = grub_net_udp_open (addr, -- TFTP_SERVER_PORT, tftp_receive, -+ port ? port : TFTP_SERVER_PORT, tftp_receive, - file); - if (!data->sock) - { -diff --git a/include/grub/net.h b/include/grub/net.h -index af0404db7e..d55d505a03 100644 ---- a/include/grub/net.h -+++ b/include/grub/net.h -@@ -273,6 +273,7 @@ typedef struct grub_net - { - char *server; - char *name; -+ int port; - grub_net_app_level_t protocol; - grub_net_packets_t packs; - grub_off_t offset; diff --git a/0080-grub-editenv-Add-incr-command-to-increment-integer-v.patch b/0072-grub-editenv-Add-incr-command-to-increment-integer-v.patch similarity index 98% rename from 0080-grub-editenv-Add-incr-command-to-increment-integer-v.patch rename to 0072-grub-editenv-Add-incr-command-to-increment-integer-v.patch index 6e2e4e2..f8de42a 100644 --- a/0080-grub-editenv-Add-incr-command-to-increment-integer-v.patch +++ b/0072-grub-editenv-Add-incr-command-to-increment-integer-v.patch @@ -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 db6f187cc6..948eec8a11 100644 +index db6f187cc63..948eec8a114 100644 --- a/util/grub-editenv.c +++ b/util/grub-editenv.c @@ -53,6 +53,9 @@ static struct argp_option options[] = { diff --git a/0081-Add-auto-hide-menu-support.patch b/0073-Add-auto-hide-menu-support.patch similarity index 94% rename from 0081-Add-auto-hide-menu-support.patch rename to 0073-Add-auto-hide-menu-support.patch index a4fbe4a..5b9a0d7 100644 --- a/0081-Add-auto-hide-menu-support.patch +++ b/0073-Add-auto-hide-menu-support.patch @@ -43,10 +43,10 @@ Signed-off-by: Hans de Goede create mode 100644 util/grub.d/01_menu_auto_hide.in diff --git a/Makefile.util.def b/Makefile.util.def -index bda9fd1211..cb8e3c3270 100644 +index 1079add5bbe..5b9f85d4869 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -458,6 +458,12 @@ script = { +@@ -461,6 +461,12 @@ script = { installdir = grubconf; }; @@ -61,7 +61,7 @@ index bda9fd1211..cb8e3c3270 100644 common = util/grub.d/01_users.in; 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 0000000000..ad175870a5 +index 00000000000..ad175870a54 --- /dev/null +++ b/util/grub.d/01_menu_auto_hide.in @@ -0,0 +1,48 @@ @@ -114,7 +114,7 @@ index 0000000000..ad175870a5 +fi +EOF diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in -index 4b27bd2015..3c9431cfcf 100644 +index d7d423b2eaf..18fe02cefd8 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 @@ -125,7 +125,7 @@ index 4b27bd2015..3c9431cfcf 100644 # TRANSLATORS: it refers on the OS residing on device %s onstr="$(gettext_printf "(on %s)" "${DEVICE}")" hints="" -@@ -102,6 +103,7 @@ for OS in ${OSPROBED} ; do +@@ -106,6 +107,7 @@ for OS in ${OSPROBED} ; do case ${BOOT} in chain) @@ -133,7 +133,7 @@ index 4b27bd2015..3c9431cfcf 100644 onstr="$(gettext_printf "(on %s)" "${DEVICE}")" cat << EOF -@@ -132,6 +134,7 @@ EOF +@@ -136,6 +138,7 @@ EOF EOF ;; efi) @@ -141,7 +141,7 @@ index 4b27bd2015..3c9431cfcf 100644 EFIPATH=${DEVICE#*@} DEVICE=${DEVICE%@*} -@@ -176,6 +179,7 @@ EOF +@@ -180,6 +183,7 @@ EOF LINITRD="${LINITRD#/boot}" fi @@ -149,7 +149,7 @@ index 4b27bd2015..3c9431cfcf 100644 onstr="$(gettext_printf "(on %s)" "${DEVICE}")" recovery_params="$(echo "${LPARAMS}" | grep single)" || true counter=1 -@@ -257,6 +261,7 @@ EOF +@@ -261,6 +265,7 @@ EOF done ;; hurd) @@ -157,7 +157,7 @@ index 4b27bd2015..3c9431cfcf 100644 onstr="$(gettext_printf "(on %s)" "${DEVICE}")" cat << EOF menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class hurd --class gnu --class os \$menuentry_id_option 'osprober-gnuhurd-/boot/gnumach.gz-false-$(grub_get_device_id "${DEVICE}")' { -@@ -283,6 +288,7 @@ EOF +@@ -287,6 +292,7 @@ EOF EOF ;; minix) @@ -165,7 +165,7 @@ index 4b27bd2015..3c9431cfcf 100644 cat << EOF menuentry "${LONGNAME} (on ${DEVICE}, Multiboot)" { EOF -@@ -299,3 +305,15 @@ EOF +@@ -303,3 +309,15 @@ EOF ;; esac done diff --git a/0082-Add-grub-set-bootflag-utility.patch b/0074-Add-grub-set-bootflag-utility.patch similarity index 97% rename from 0082-Add-grub-set-bootflag-utility.patch rename to 0074-Add-grub-set-bootflag-utility.patch index 495bb13..f6dc731 100644 --- a/0082-Add-grub-set-bootflag-utility.patch +++ b/0074-Add-grub-set-bootflag-utility.patch @@ -49,10 +49,10 @@ Signed-off-by: Robbie Harwood create mode 100644 docs/man/grub-set-bootflag.h2m diff --git a/Makefile.util.def b/Makefile.util.def -index cb8e3c3270..d066652e9b 100644 +index 5b9f85d4869..01096ded815 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -1429,3 +1429,10 @@ program = { +@@ -1468,3 +1468,10 @@ program = { ldadd = grub-core/lib/gnulib/libgnu.a; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; @@ -65,7 +65,7 @@ index cb8e3c3270..d066652e9b 100644 +}; diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c new file mode 100644 -index 0000000000..d506f7e75b +index 00000000000..d506f7e75bc --- /dev/null +++ b/util/grub-set-bootflag.c @@ -0,0 +1,172 @@ @@ -242,7 +242,7 @@ index 0000000000..d506f7e75b + return 0; +} diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist -index 8f1485d52a..ad235de7fc 100644 +index 5e7126f9878..26ac8765e30 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -15,6 +15,9 @@ EXTRA_DIST += docs/man @@ -257,7 +257,7 @@ index 8f1485d52a..ad235de7fc 100644 diff --git a/docs/grub-boot-success.service b/docs/grub-boot-success.service new file mode 100644 -index 0000000000..80e79584c9 +index 00000000000..80e79584c91 --- /dev/null +++ b/docs/grub-boot-success.service @@ -0,0 +1,6 @@ @@ -269,7 +269,7 @@ index 0000000000..80e79584c9 +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 0000000000..406f172005 +index 00000000000..406f1720056 --- /dev/null +++ b/docs/grub-boot-success.timer @@ -0,0 +1,7 @@ @@ -282,7 +282,7 @@ index 0000000000..406f172005 +OnActiveSec=2min diff --git a/docs/man/grub-set-bootflag.h2m b/docs/man/grub-set-bootflag.h2m new file mode 100644 -index 0000000000..94ec0b92ed +index 00000000000..94ec0b92ede --- /dev/null +++ b/docs/man/grub-set-bootflag.h2m @@ -0,0 +1,2 @@ diff --git a/0083-docs-Add-grub-boot-indeterminate.service-example.patch b/0075-docs-Add-grub-boot-indeterminate.service-example.patch similarity index 97% rename from 0083-docs-Add-grub-boot-indeterminate.service-example.patch rename to 0075-docs-Add-grub-boot-indeterminate.service-example.patch index 96eff36..44f6ad3 100644 --- a/0083-docs-Add-grub-boot-indeterminate.service-example.patch +++ b/0075-docs-Add-grub-boot-indeterminate.service-example.patch @@ -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 0000000000..6c8dcb186b +index 00000000000..6c8dcb186b6 --- /dev/null +++ b/docs/grub-boot-indeterminate.service @@ -0,0 +1,11 @@ diff --git a/0084-gentpl-add-disable-support.patch b/0076-gentpl-add-disable-support.patch similarity index 89% rename from 0084-gentpl-add-disable-support.patch rename to 0076-gentpl-add-disable-support.patch index 3b305e6..949cfe8 100644 --- a/0084-gentpl-add-disable-support.patch +++ b/0076-gentpl-add-disable-support.patch @@ -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 c86550d4f9..f3c5f84f85 100644 +index bfab2113a1d..6cad9b8231f 100644 --- a/gentpl.py +++ b/gentpl.py -@@ -592,11 +592,21 @@ def platform_conditional(platform, closure): +@@ -594,11 +594,21 @@ def platform_conditional(platform, closure): # }; # def foreach_enabled_platform(defn, closure): @@ -35,7 +35,7 @@ index c86550d4f9..f3c5f84f85 100644 for platform in GRUB_PLATFORMS: platform_conditional(platform, closure) -@@ -655,6 +665,8 @@ def first_time(defn, snippet): +@@ -657,6 +667,8 @@ def first_time(defn, snippet): def is_platform_independent(defn): if 'enable' in defn: return False diff --git a/0085-gentpl-add-pc-firmware-type.patch b/0077-gentpl-add-pc-firmware-type.patch similarity index 74% rename from 0085-gentpl-add-pc-firmware-type.patch rename to 0077-gentpl-add-pc-firmware-type.patch index 0bfd2ea..608582a 100644 --- a/0085-gentpl-add-pc-firmware-type.patch +++ b/0077-gentpl-add-pc-firmware-type.patch @@ -9,14 +9,14 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+) diff --git a/gentpl.py b/gentpl.py -index f3c5f84f85..f09b336869 100644 +index 6cad9b8231f..597129a2bc4 100644 --- a/gentpl.py +++ b/gentpl.py -@@ -51,6 +51,7 @@ GROUPS["riscv32"] = [ "riscv32_efi" ] - GROUPS["riscv64"] = [ "riscv64_efi" ] +@@ -52,6 +52,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", - "riscv32_efi", "riscv64_efi" ] + "loongarch64_efi", "riscv32_efi", "riscv64_efi" ] GROUPS["ieee1275"] = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ] diff --git a/0086-efinet-also-use-the-firmware-acceleration-for-http.patch b/0078-efinet-also-use-the-firmware-acceleration-for-http.patch similarity index 96% rename from 0086-efinet-also-use-the-firmware-acceleration-for-http.patch rename to 0078-efinet-also-use-the-firmware-acceleration-for-http.patch index a3a9400..8ce3e01 100644 --- a/0086-efinet-also-use-the-firmware-acceleration-for-http.patch +++ b/0078-efinet-also-use-the-firmware-acceleration-for-http.patch @@ -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 4bb308026c..6603cd83ed 100644 +index ed04f05ad21..1f7e1b63557 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) diff --git a/0087-efi-http-Make-root_url-reflect-the-protocol-hostname.patch b/0079-efi-http-Make-root_url-reflect-the-protocol-hostname.patch similarity index 93% rename from 0087-efi-http-Make-root_url-reflect-the-protocol-hostname.patch rename to 0079-efi-http-Make-root_url-reflect-the-protocol-hostname.patch index 90d9777..6f98f25 100644 --- a/0087-efi-http-Make-root_url-reflect-the-protocol-hostname.patch +++ b/0079-efi-http-Make-root_url-reflect-the-protocol-hostname.patch @@ -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 3f61fd2fa5..243acbaa35 100644 +index de28badccb0..b94dbc68eef 100644 --- a/grub-core/net/efi/http.c +++ b/grub-core/net/efi/http.c @@ -4,6 +4,7 @@ @@ -23,7 +23,7 @@ index 3f61fd2fa5..243acbaa35 100644 static void http_configure (struct grub_efi_net_device *dev, int prefer_ip6) -@@ -351,6 +352,24 @@ grub_efihttp_open (struct grub_efi_net_device *dev, +@@ -342,6 +343,24 @@ grub_efihttp_open (struct grub_efi_net_device *dev, grub_err_t err; grub_off_t size; char *buf; diff --git a/0088-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch b/0080-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch similarity index 87% rename from 0088-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch rename to 0080-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch index 6d2974f..9d8be1e 100644 --- a/0088-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch +++ b/0080-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch @@ -17,11 +17,11 @@ Signed-off-by: Peter Jones 3 files changed, 64 insertions(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac -index 302300711f..008f6c273b 100644 +index fcfbcbb664d..c17e83acf87 100644 --- a/configure.ac +++ b/configure.ac -@@ -849,11 +849,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" +@@ -914,11 +914,23 @@ if test "x$target_cpu" = xloongarch64; then + TARGET_CCASFLAGS="$TARGET_CCASFLAGS -Wa,-mla-global-with-abs" fi +# Should grub utils get the host CFLAGS, or the target CFLAGS? @@ -45,7 +45,7 @@ index 302300711f..008f6c273b 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 -@@ -1954,6 +1966,41 @@ HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include" +@@ -2111,6 +2123,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" @@ -88,19 +88,19 @@ index 302300711f..008f6c273b 100644 GRUB_PLATFORM="${platform}" diff --git a/conf/Makefile.common b/conf/Makefile.common -index 5f0ef96985..2ff9b39357 100644 +index 6262f21a772..54f0f7f7664 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 +@@ -50,24 +50,25 @@ else + endif + endif -CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding --LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d +-LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r -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 ++LDFLAGS_MODULE = $(TARGET_LDFLAGS) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r +CPPFLAGS_MODULE = $(TARGET_CPPFLAGS) $(CPPFLAGS_DEFAULT) $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) +CCASFLAGS_MODULE = $(TARGET_CCASFLAGS) $(CCASFLAGS_DEFAULT) $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) @@ -129,10 +129,10 @@ index 5f0ef96985..2ff9b39357 100644 # Other variables diff --git a/gentpl.py b/gentpl.py -index f09b336869..0e62e14666 100644 +index 597129a2bc4..5826a6b14e8 100644 --- a/gentpl.py +++ b/gentpl.py -@@ -697,10 +697,10 @@ def module(defn, platform): +@@ -699,10 +699,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)) diff --git a/0090-Rework-how-the-fdt-command-builds.patch b/0081-Rework-how-the-fdt-command-builds.patch similarity index 85% rename from 0090-Rework-how-the-fdt-command-builds.patch rename to 0081-Rework-how-the-fdt-command-builds.patch index 8f41272..8c00d38 100644 --- a/0090-Rework-how-the-fdt-command-builds.patch +++ b/0081-Rework-how-the-fdt-command-builds.patch @@ -17,18 +17,18 @@ Signed-off-by: Peter Jones Signed-off-by: Javier Martinez Canillas Signed-off-by: Robbie Harwood --- - grub-core/Makefile.core.def | 5 ++--- + grub-core/Makefile.core.def | 4 ++-- grub-core/lib/fdt.c | 2 -- grub-core/loader/efi/fdt.c | 2 ++ include/grub/fdt.h | 6 ++++++ grub-core/Makefile.am | 1 + - 5 files changed, 11 insertions(+), 5 deletions(-) + 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 12797336c9..4e7d90da76 100644 +index 56eb6a828e8..4629c179e40 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -177,7 +177,6 @@ kernel = { +@@ -188,7 +188,6 @@ kernel = { arm_coreboot = kern/arm/coreboot/init.c; arm_coreboot = kern/arm/coreboot/timer.c; arm_coreboot = kern/arm/coreboot/coreboot.S; @@ -36,7 +36,7 @@ index 12797336c9..4e7d90da76 100644 arm_coreboot = bus/fdt.c; arm_coreboot = term/ps2.c; arm_coreboot = term/arm/pl050.c; -@@ -351,6 +350,8 @@ kernel = { +@@ -370,6 +369,8 @@ kernel = { riscv64 = kern/riscv/cache_flush.S; riscv64 = kern/riscv/dl.c; @@ -45,15 +45,7 @@ index 12797336c9..4e7d90da76 100644 emu = disk/host.c; emu = kern/emu/cache_s.S; emu = kern/emu/hostdisk.c; -@@ -1825,7 +1826,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; -@@ -1837,7 +1837,6 @@ module = { +@@ -1882,7 +1883,6 @@ module = { module = { name = fdt; efi = loader/efi/fdt.c; @@ -62,7 +54,7 @@ index 12797336c9..4e7d90da76 100644 }; diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c -index 0d371c5633..37e04bd69e 100644 +index 73cfa94a2df..fbf749e1d61 100644 --- a/grub-core/lib/fdt.c +++ b/grub-core/lib/fdt.c @@ -21,8 +21,6 @@ @@ -75,7 +67,7 @@ index 0d371c5633..37e04bd69e 100644 #define FDT_BEGIN_NODE 0x00000001 diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c -index c86f283d75..c572415d38 100644 +index 439964b9ca6..e08d8738afc 100644 --- a/grub-core/loader/efi/fdt.c +++ b/grub-core/loader/efi/fdt.c @@ -27,6 +27,8 @@ @@ -88,7 +80,7 @@ index c86f283d75..c572415d38 100644 static void *fdt; diff --git a/include/grub/fdt.h b/include/grub/fdt.h -index e609c7e411..3514aa4a5b 100644 +index e609c7e4111..3514aa4a5b6 100644 --- a/include/grub/fdt.h +++ b/include/grub/fdt.h @@ -19,6 +19,9 @@ @@ -110,7 +102,7 @@ index e609c7e411..3514aa4a5b 100644 + #endif /* ! GRUB_FDT_HEADER */ diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am -index bfd29a3bf0..c2e8a82bce 100644 +index b7192a3da82..7953ba95399 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 diff --git a/0091-Disable-non-wordsize-allocations-on-arm.patch b/0082-Disable-non-wordsize-allocations-on-arm.patch similarity index 93% rename from 0091-Disable-non-wordsize-allocations-on-arm.patch rename to 0082-Disable-non-wordsize-allocations-on-arm.patch index ea09b65..e8c4641 100644 --- a/0091-Disable-non-wordsize-allocations-on-arm.patch +++ b/0082-Disable-non-wordsize-allocations-on-arm.patch @@ -9,10 +9,10 @@ Signed-off-by: Peter Jones 1 file changed, 20 insertions(+) diff --git a/configure.ac b/configure.ac -index 008f6c273b..54462e0892 100644 +index c17e83acf87..3f3a170ab17 100644 --- a/configure.ac +++ b/configure.ac -@@ -1260,6 +1260,26 @@ if test "x$target_cpu" = xarm; then +@@ -1346,6 +1346,26 @@ if test "x$target_cpu" = xarm; then done ]) diff --git a/0092-Prepend-prefix-when-HTTP-path-is-relative.patch b/0083-Prepend-prefix-when-HTTP-path-is-relative.patch similarity index 97% rename from 0092-Prepend-prefix-when-HTTP-path-is-relative.patch rename to 0083-Prepend-prefix-when-HTTP-path-is-relative.patch index 30d8075..ac6c806 100644 --- a/0092-Prepend-prefix-when-HTTP-path-is-relative.patch +++ b/0083-Prepend-prefix-when-HTTP-path-is-relative.patch @@ -16,7 +16,7 @@ Signed-off-by: Robbie Harwood 2 files changed, 71 insertions(+), 21 deletions(-) diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index d1de9fa687..1c540fc8c2 100644 +index 463dafdba02..7347a8de676 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c @@ -131,11 +131,19 @@ grub_set_prefix_and_root (void) @@ -41,7 +41,7 @@ index d1de9fa687..1c540fc8c2 100644 } } diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c -index 243acbaa35..de351b2cd0 100644 +index b94dbc68eef..5e97f5d5e70 100644 --- a/grub-core/net/efi/http.c +++ b/grub-core/net/efi/http.c @@ -9,10 +9,52 @@ @@ -97,7 +97,7 @@ index 243acbaa35..de351b2cd0 100644 grub_efi_http_t *http = dev->http; -@@ -352,32 +394,32 @@ grub_efihttp_open (struct grub_efi_net_device *dev, +@@ -343,32 +385,32 @@ grub_efihttp_open (struct grub_efi_net_device *dev, grub_err_t err; grub_off_t size; char *buf; diff --git a/0093-Make-grub_error-more-verbose.patch b/0084-Make-grub_error-more-verbose.patch similarity index 94% rename from 0093-Make-grub_error-more-verbose.patch rename to 0084-Make-grub_error-more-verbose.patch index 306a3d3..5ad2684 100644 --- a/0093-Make-grub_error-more-verbose.patch +++ b/0084-Make-grub_error-more-verbose.patch @@ -10,7 +10,7 @@ Signed-off-by: Peter Jones 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/grub-core/kern/err.c b/grub-core/kern/err.c -index 53c734de70..aebfe0cf83 100644 +index 53c734de70e..aebfe0cf839 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]; @@ -41,10 +41,10 @@ index 53c734de70..aebfe0cf83 100644 return n; diff --git a/include/grub/err.h b/include/grub/err.h -index b08d5d0de4..c0f90ef07c 100644 +index 1c07034cd60..3c587b9b822 100644 --- a/include/grub/err.h +++ b/include/grub/err.h -@@ -85,8 +85,12 @@ struct grub_error_saved +@@ -86,8 +86,12 @@ struct grub_error_saved extern grub_err_t EXPORT_VAR(grub_errno); extern char EXPORT_VAR(grub_errmsg)[GRUB_MAX_ERRMSG]; diff --git a/0094-Make-reset-an-alias-for-the-reboot-command.patch b/0085-Make-reset-an-alias-for-the-reboot-command.patch similarity index 97% rename from 0094-Make-reset-an-alias-for-the-reboot-command.patch rename to 0085-Make-reset-an-alias-for-the-reboot-command.patch index 22475d6..c86acf1 100644 --- a/0094-Make-reset-an-alias-for-the-reboot-command.patch +++ b/0085-Make-reset-an-alias-for-the-reboot-command.patch @@ -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 46d364c99a..f5cc228363 100644 +index 46d364c99a9..f5cc2283636 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)), diff --git a/0095-Add-a-version-command.patch b/0086-Add-a-version-command.patch similarity index 89% rename from 0095-Add-a-version-command.patch rename to 0086-Add-a-version-command.patch index 18c355c..b8770ee 100644 --- a/0095-Add-a-version-command.patch +++ b/0086-Add-a-version-command.patch @@ -19,10 +19,10 @@ Signed-off-by: Robbie Harwood create mode 100644 grub-core/commands/version.c diff --git a/configure.ac b/configure.ac -index 54462e0892..7b4e1854d3 100644 +index 3f3a170ab17..2175aa56997 100644 --- a/configure.ac +++ b/configure.ac -@@ -284,6 +284,19 @@ AC_SUBST(target_cpu) +@@ -289,6 +289,19 @@ AC_SUBST(target_cpu) AC_SUBST(platform) # Define default variables @@ -43,10 +43,10 @@ index 54462e0892..7b4e1854d3 100644 have_with_bootdir=n AC_ARG_WITH([bootdir], diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 4e7d90da76..4f203533f5 100644 +index 4629c179e40..f26c689723c 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -579,6 +579,11 @@ image = { +@@ -598,6 +598,11 @@ image = { enable = mips_loongson; }; @@ -60,7 +60,7 @@ index 4e7d90da76..4f203533f5 100644 common = lib/disk.c; diff --git a/grub-core/commands/version.c b/grub-core/commands/version.c new file mode 100644 -index 0000000000..de0acb07ba +index 00000000000..de0acb07ba2 --- /dev/null +++ b/grub-core/commands/version.c @@ -0,0 +1,56 @@ @@ -121,14 +121,14 @@ index 0000000000..de0acb07ba + grub_unregister_command (cmd); +} diff --git a/config.h.in b/config.h.in -index 9e8f9911b1..c7e316f0f1 100644 +index 9b1d3997185..d294d2c653f 100644 --- a/config.h.in +++ b/config.h.in -@@ -59,6 +59,7 @@ +@@ -63,6 +63,7 @@ - #define GRUB_TARGET_CPU "@GRUB_TARGET_CPU@" - #define GRUB_PLATFORM "@GRUB_PLATFORM@" -+#define GRUB_RPM_VERSION "@GRUB_RPM_VERSION@" + # define GRUB_TARGET_CPU "@GRUB_TARGET_CPU@" + # define GRUB_PLATFORM "@GRUB_PLATFORM@" ++# define GRUB_RPM_VERSION "@GRUB_RPM_VERSION@" - #define RE_ENABLE_I18N 1 + # define GRUB_STACK_PROTECTOR_INIT @GRUB_STACK_PROTECTOR_INIT@ diff --git a/0096-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch b/0087-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch similarity index 89% rename from 0096-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch rename to 0087-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch index 72c8d30..9ad4036 100644 --- a/0096-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch +++ b/0087-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch @@ -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 0320115662..7cdffe3ebd 100644 +index 21e2395111a..c35ce8915b2 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) @@ -24,7 +24,7 @@ index 0320115662..7cdffe3ebd 100644 if (!accept_diskfilter && is_valid_diskfilter_name (name)) return 0; -@@ -1212,6 +1214,7 @@ insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id, +@@ -1247,6 +1249,7 @@ insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id, the same. */ if (pv->disk && grub_disk_native_sectors (disk) >= pv->part_size) return GRUB_ERR_NONE; @@ -33,10 +33,10 @@ index 0320115662..7cdffe3ebd 100644 if (!pv->disk) return grub_errno; diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c -index f077b5f553..fe8ba6e6c9 100644 +index 3b5ed569133..822005456eb 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c -@@ -855,6 +855,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) +@@ -865,6 +865,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) return 0; } @@ -45,7 +45,7 @@ index f077b5f553..fe8ba6e6c9 100644 grub_free (dup_dp); diff --git a/grub-core/kern/device.c b/grub-core/kern/device.c -index 73b8ecc0c0..f58b58c89d 100644 +index 670e213cf3c..d019637470d 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 73b8ecc0c0..f58b58c89d 100644 { name = grub_env_get ("root"); diff --git a/grub-core/script/script.c b/grub-core/script/script.c -index ec4d4337c6..844e8343ca 100644 +index ec4d4337c66..844e8343ca7 100644 --- a/grub-core/script/script.c +++ b/grub-core/script/script.c @@ -22,6 +22,11 @@ diff --git a/0099-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch b/0088-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch similarity index 77% rename from 0099-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch rename to 0088-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch index 77db523..2868f23 100644 --- a/0099-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch +++ b/0088-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch @@ -9,19 +9,18 @@ Signed-off-by: Peter Jones 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/setup.c | 2 +- - 10 files changed, 17 insertions(+), 16 deletions(-) + 9 files changed, 16 insertions(+), 15 deletions(-) diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c -index 0ff13bcaf8..d278c2921f 100644 +index 16c79bc9488..d145e5796b3 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c -@@ -185,7 +185,7 @@ grub_util_get_image_size (const char *path) +@@ -189,7 +189,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)); @@ -31,10 +30,10 @@ index 0ff13bcaf8..d278c2921f 100644 ret = (size_t) sz; diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c -index 467305b46a..79037c093f 100644 +index 562bd2e3e3f..5fee7f2a1a4 100644 --- a/grub-core/lib/reed_solomon.c +++ b/grub-core/lib/reed_solomon.c -@@ -157,7 +157,7 @@ static void +@@ -162,7 +162,7 @@ static void rs_encode (gf_single_t *data, grub_size_t s, grub_size_t rs) { gf_single_t *rs_polynomial; @@ -43,7 +42,7 @@ index 467305b46a..79037c093f 100644 gf_single_t *m; m = xcalloc (s + rs, sizeof (gf_single_t)); grub_memcpy (m, data, s * sizeof (gf_single_t)); -@@ -324,7 +324,7 @@ static void +@@ -333,7 +333,7 @@ static void encode_block (gf_single_t *ptr, grub_size_t s, gf_single_t *rptr, grub_size_t rs) { @@ -53,7 +52,7 @@ index 467305b46a..79037c093f 100644 { 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 c77d6085cc..42a315031f 100644 +index 2efee2c2aee..902cfee53ae 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, @@ -66,10 +65,10 @@ index c77d6085cc..42a315031f 100644 + 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 28790307e0..9f730b3518 100644 +index 74a48c03026..477fb420992 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) +@@ -233,7 +233,7 @@ grub_find_root_devices_from_btrfs (const char *dir) { int fd; struct btrfs_ioctl_fs_info_args fsi; @@ -78,24 +77,11 @@ index 28790307e0..9f730b3518 100644 char **ret; fd = open (dir, 0); -diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c -index da62f924e3..7bc99ac1c1 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 8386564200..bfcef852d8 100644 +index 25ae52ab6f4..982ce9ed7d8 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c -@@ -323,7 +323,7 @@ cmd_cmp (char *src, char *dest) +@@ -329,7 +329,7 @@ cmd_cmp (char *src, char *dest) read_file (src, cmp_hook, ff); { @@ -105,7 +91,7 @@ index 8386564200..bfcef852d8 100644 fseek (ff, 0, SEEK_END); if (pre != ftell (ff)) diff --git a/util/grub-menulst2cfg.c b/util/grub-menulst2cfg.c -index a39f869394..358d604210 100644 +index b80e15cc36e..1ea2a86e129 100644 --- a/util/grub-menulst2cfg.c +++ b/util/grub-menulst2cfg.c @@ -34,7 +34,7 @@ main (int argc, char **argv) @@ -118,10 +104,10 @@ index a39f869394..358d604210 100644 grub_util_host_init (&argc, &argv); diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c -index 0fe45a6103..3e09240b99 100644 +index 7624d7808b7..e8a914021b2 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, +@@ -143,7 +143,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; @@ -131,7 +117,7 @@ index 0fe45a6103..3e09240b99 100644 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, +@@ -188,7 +189,7 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face, cuttop = cutbottom = cutleft = cutright = 0; else { @@ -140,7 +126,7 @@ index 0fe45a6103..3e09240b99 100644 { 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, +@@ -208,10 +209,10 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face, break; } cutbottom = glyph->bitmap.rows - 1 - cutbottom; @@ -153,7 +139,7 @@ index 0fe45a6103..3e09240b99 100644 { 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, +@@ -230,7 +231,7 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face, break; } cutright = glyph->bitmap.width - 1 - cutright; @@ -162,7 +148,7 @@ index 0fe45a6103..3e09240b99 100644 cutright = 0; } -@@ -262,7 +263,7 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face, +@@ -267,7 +268,7 @@ add_glyph (struct grub_font_info *font_info, FT_UInt glyph_idx, FT_Face face, mask = 0; data = &glyph_info->bitmap[0] - 1; @@ -172,10 +158,10 @@ index 0fe45a6103..3e09240b99 100644 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 c08e46bbb4..c6fac732b4 100644 +index 65c1ca3f8b6..08ae915e8d7 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) +@@ -799,7 +799,7 @@ argp_parser (int key, char *arg, struct argp_state *state) case 't': { @@ -185,7 +171,7 @@ index c08e46bbb4..c6fac732b4 100644 for (i = PRINT_FS; i < ARRAY_SIZE (targets); i++) if (strcmp (arg, targets[i]) == 0) diff --git a/util/setup.c b/util/setup.c -index da5f2c07f5..8b22bb8cca 100644 +index 87a889ff7e3..7aab468b0eb 100644 --- a/util/setup.c +++ b/util/setup.c @@ -406,7 +406,7 @@ SETUP (const char *dir, diff --git a/0100-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch b/0089-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch similarity index 55% rename from 0100-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch rename to 0089-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch index 03b4bbf..668a20c 100644 --- a/0100-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch +++ b/0089-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch @@ -4,33 +4,21 @@ Date: Thu, 11 Jul 2019 18:20:37 +0200 Subject: [PATCH] Don't use -Wno-sign-compare -Wno-conversion -Wno-error, do use -Wextra. +Updated for grub-2.12 which introduced new sign comparison problems: +we're using -Wno-error=sign-compare + Signed-off-by: Peter Jones --- - configure.ac | 14 +++++++++++--- - conf/Makefile.common | 2 +- - 2 files changed, 12 insertions(+), 4 deletions(-) + configure.ac | 8 ++++++++ + conf/Makefile.common | 2 +- + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac -index 7b4e1854d3..490353713a 100644 +index 2175aa56997..81240397384 100644 --- a/configure.ac +++ b/configure.ac -@@ -1452,11 +1452,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" - -@@ -1990,6 +1990,14 @@ if test x"$enable_werror" != xno ; then - HOST_CFLAGS="$HOST_CFLAGS -Werror" +@@ -2147,6 +2147,14 @@ if test x"$enable_werror" != xno ; then + fi fi +AC_ARG_ENABLE([wextra], @@ -45,15 +33,15 @@ index 7b4e1854d3..490353713a 100644 TARGET_CCAS=$TARGET_CC diff --git a/conf/Makefile.common b/conf/Makefile.common -index 2ff9b39357..35e14ff017 100644 +index 54f0f7f7664..e53ff352407 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common -@@ -66,7 +66,7 @@ grubconfdir = $(sysconfdir)/grub.d +@@ -76,7 +76,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 +-CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-error=attributes ++CFLAGS_GNULIB = -Wno-undef -Wno-error=sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-error=attributes CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/lib/gnulib -I$(top_srcdir)/grub-core/lib/gnulib CFLAGS_POSIX = -fno-builtin diff --git a/0089-module-verifier-make-it-possible-to-run-checkers-on-.patch b/0089-module-verifier-make-it-possible-to-run-checkers-on-.patch deleted file mode 100644 index 78c15d6..0000000 --- a/0089-module-verifier-make-it-possible-to-run-checkers-on-.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 0000000000000000000000000000000000000000 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 - grub-module-verifierxx.c - -This makes it so you can treat grub-module-verifierxx.c as a file you can -build directly, so syntax checkers like vim's "syntastic" plugin, which uses -"gcc -x c -fsyntax-only" to build it, will work. - -One still has to do whatever setup is required to make it pick the right -include dirs, which -W options we use, etc., but this makes it so you can do -the checking on the file you're editing, rather than on a different file. - -v2: fix the typo in the #else clause in util/grub-module-verifierXX.c - -Signed-off-by: Peter Jones ---- - util/grub-module-verifier32.c | 2 ++ - util/grub-module-verifier64.c | 2 ++ - util/grub-module-verifierXX.c | 9 +++++++++ - 3 files changed, 13 insertions(+) - -diff --git a/util/grub-module-verifier32.c b/util/grub-module-verifier32.c -index 257229f8f0..ba7d41aafe 100644 ---- a/util/grub-module-verifier32.c -+++ b/util/grub-module-verifier32.c -@@ -1,2 +1,4 @@ - #define MODULEVERIFIER_ELF32 1 -+#ifndef GRUB_MODULE_VERIFIERXX - #include "grub-module-verifierXX.c" -+#endif -diff --git a/util/grub-module-verifier64.c b/util/grub-module-verifier64.c -index 4db6b4bedd..fc23ef800b 100644 ---- a/util/grub-module-verifier64.c -+++ b/util/grub-module-verifier64.c -@@ -1,2 +1,4 @@ - #define MODULEVERIFIER_ELF64 1 -+#ifndef GRUB_MODULE_VERIFIERXX - #include "grub-module-verifierXX.c" -+#endif -diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c -index ceb24309ae..a98e2f9b1a 100644 ---- a/util/grub-module-verifierXX.c -+++ b/util/grub-module-verifierXX.c -@@ -1,3 +1,12 @@ -+#define GRUB_MODULE_VERIFIERXX -+#if !defined(MODULEVERIFIER_ELF32) && !defined(MODULEVERIFIER_ELF64) -+#if __SIZEOF_POINTER__ == 8 -+#include "grub-module-verifier64.c" -+#else -+#include "grub-module-verifier32.c" -+#endif -+#endif -+ - #include - - #include diff --git a/0105-Fix-getroot.c-s-trampolines.patch b/0090-Fix-getroot.c-s-trampolines.patch similarity index 92% rename from 0105-Fix-getroot.c-s-trampolines.patch rename to 0090-Fix-getroot.c-s-trampolines.patch index e744b77..b1f65de 100644 --- a/0105-Fix-getroot.c-s-trampolines.patch +++ b/0090-Fix-getroot.c-s-trampolines.patch @@ -12,10 +12,10 @@ Signed-off-by: Peter Jones 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c -index 9f730b3518..f0c503f43d 100644 +index 477fb420992..b32582eb302 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) +@@ -1261,22 +1261,20 @@ grub_util_get_grub_dev_os (const char *os_dev) return grub_dev; } diff --git a/0106-Do-not-allow-stack-trampolines-anywhere.patch b/0091-Do-not-allow-stack-trampolines-anywhere.patch similarity index 65% rename from 0106-Do-not-allow-stack-trampolines-anywhere.patch rename to 0091-Do-not-allow-stack-trampolines-anywhere.patch index 658c7a4..0c3b298 100644 --- a/0106-Do-not-allow-stack-trampolines-anywhere.patch +++ b/0091-Do-not-allow-stack-trampolines-anywhere.patch @@ -10,10 +10,10 @@ Signed-off-by: Peter Jones 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac -index 490353713a..a02d40a05b 100644 +index 81240397384..ae7683d0693 100644 --- a/configure.ac +++ b/configure.ac -@@ -1998,6 +1998,9 @@ if test x"$enable_wextra" != xno ; then +@@ -2155,6 +2155,9 @@ if test x"$enable_wextra" != xno ; then HOST_CFLAGS="$HOST_CFLAGS -Wextra" fi @@ -24,15 +24,15 @@ index 490353713a..a02d40a05b 100644 TARGET_CCAS=$TARGET_CC diff --git a/conf/Makefile.common b/conf/Makefile.common -index 35e14ff017..0647c53b91 100644 +index e53ff352407..91ff6c905fb 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common -@@ -66,7 +66,7 @@ grubconfdir = $(sysconfdir)/grub.d +@@ -76,7 +76,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 +-CFLAGS_GNULIB = -Wno-undef -Wno-error=sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-error=attributes ++CFLAGS_GNULIB = -Wno-undef -Wno-error=sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-error=attributes -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/0107-Reimplement-boot_counter.patch b/0092-Reimplement-boot_counter.patch similarity index 96% rename from 0107-Reimplement-boot_counter.patch rename to 0092-Reimplement-boot_counter.patch index d018de4..1f0cb96 100644 --- a/0107-Reimplement-boot_counter.patch +++ b/0092-Reimplement-boot_counter.patch @@ -23,10 +23,10 @@ Signed-off-by: Christian Glombek create mode 100644 util/grub.d/01_fallback_counting.in diff --git a/Makefile.util.def b/Makefile.util.def -index d066652e9b..e10fe766d1 100644 +index 01096ded815..0bb47c6d40a 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -458,6 +458,12 @@ script = { +@@ -461,6 +461,12 @@ script = { installdir = grubconf; }; @@ -40,10 +40,10 @@ index d066652e9b..e10fe766d1 100644 name = '01_menu_auto_hide'; common = util/grub.d/01_menu_auto_hide.in; diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 4f203533f5..ea4d59f51b 100644 +index f26c689723c..08c0c67bcf2 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -398,6 +398,11 @@ kernel = { +@@ -417,6 +417,11 @@ kernel = { extra_dist = kern/mips/cache_flush.S; }; @@ -57,7 +57,7 @@ index 4f203533f5..ea4d59f51b 100644 mansection = 1; diff --git a/grub-core/commands/increment.c b/grub-core/commands/increment.c new file mode 100644 -index 0000000000..79cf137656 +index 00000000000..79cf137656c --- /dev/null +++ b/grub-core/commands/increment.c @@ -0,0 +1,105 @@ @@ -168,7 +168,7 @@ index 0000000000..79cf137656 +} diff --git a/util/grub.d/01_fallback_counting.in b/util/grub.d/01_fallback_counting.in new file mode 100644 -index 0000000000..be0e770ea8 +index 00000000000..be0e770ea82 --- /dev/null +++ b/util/grub.d/01_fallback_counting.in @@ -0,0 +1,22 @@ diff --git a/0108-Fix-menu-entry-selection-based-on-ID-and-title.patch b/0093-Fix-menu-entry-selection-based-on-ID-and-title.patch similarity index 99% rename from 0108-Fix-menu-entry-selection-based-on-ID-and-title.patch rename to 0093-Fix-menu-entry-selection-based-on-ID-and-title.patch index af74901..597e0c1 100644 --- a/0108-Fix-menu-entry-selection-based-on-ID-and-title.patch +++ b/0093-Fix-menu-entry-selection-based-on-ID-and-title.patch @@ -24,7 +24,7 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 71 insertions(+), 70 deletions(-) diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index d7a222e681..4a02aadb01 100644 +index 6444ee6f969..b0cfa32ddd8 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -164,12 +164,12 @@ grub_menu_set_timeout (int timeout) diff --git a/0109-Make-the-menu-entry-users-option-argument-to-be-opti.patch b/0094-Make-the-menu-entry-users-option-argument-to-be-opti.patch similarity index 97% rename from 0109-Make-the-menu-entry-users-option-argument-to-be-opti.patch rename to 0094-Make-the-menu-entry-users-option-argument-to-be-opti.patch index 68779eb..e0d36db 100644 --- a/0109-Make-the-menu-entry-users-option-argument-to-be-opti.patch +++ b/0094-Make-the-menu-entry-users-option-argument-to-be-opti.patch @@ -23,7 +23,7 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c -index b194123eb6..b175a1b43b 100644 +index b194123eb67..b175a1b43b7 100644 --- a/grub-core/commands/menuentry.c +++ b/grub-core/commands/menuentry.c @@ -29,7 +29,7 @@ static const struct grub_arg_option options[] = diff --git a/0110-Add-efi-export-env-and-efi-load-env-commands.patch b/0095-Add-efi-export-env-and-efi-load-env-commands.patch similarity index 93% rename from 0110-Add-efi-export-env-and-efi-load-env-commands.patch rename to 0095-Add-efi-export-env-and-efi-load-env-commands.patch index 33d2724..6a5abef 100644 --- a/0110-Add-efi-export-env-and-efi-load-env-commands.patch +++ b/0095-Add-efi-export-env-and-efi-load-env-commands.patch @@ -21,10 +21,10 @@ Signed-off-by: Peter Jones create mode 100644 grub-core/commands/efi/env.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index ea4d59f51b..dc9fea6f44 100644 +index 08c0c67bcf2..4aa20cdfc13 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -820,6 +820,12 @@ module = { +@@ -842,6 +842,12 @@ module = { enable = efi; }; @@ -39,7 +39,7 @@ index ea4d59f51b..dc9fea6f44 100644 efi = commands/efi/efifwsetup.c; diff --git a/grub-core/commands/efi/env.c b/grub-core/commands/efi/env.c new file mode 100644 -index 0000000000..cbd13e03e8 +index 00000000000..45f107ccd5b --- /dev/null +++ b/grub-core/commands/efi/env.c @@ -0,0 +1,168 @@ @@ -74,7 +74,7 @@ index 0000000000..cbd13e03e8 + +GRUB_MOD_LICENSE ("GPLv3+"); + -+static const grub_efi_guid_t grub_env_guid = GRUB_EFI_GRUB_VARIABLE_GUID; ++static const grub_guid_t grub_env_guid = GRUB_EFI_GRUB_VARIABLE_GUID; + +static grub_err_t +grub_efi_export_env(grub_command_t cmd __attribute__ ((unused)), @@ -212,10 +212,10 @@ index 0000000000..cbd13e03e8 + grub_unregister_command (loadenv_cmd); +} diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 2a446f5031..14bc10eb56 100644 +index bf16c4307bc..ef837387368 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -225,6 +225,9 @@ grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid, +@@ -227,6 +227,9 @@ grub_efi_set_variable_with_attributes (const char *var, const grub_guid_t *guid, if (status == GRUB_EFI_SUCCESS) return GRUB_ERR_NONE; @@ -226,10 +226,10 @@ index 2a446f5031..14bc10eb56 100644 } diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c -index 2d12e6188f..0574d8d621 100644 +index b5201974a76..dee3918fd35 100644 --- a/grub-core/kern/efi/init.c +++ b/grub-core/kern/efi/init.c -@@ -85,11 +85,6 @@ stack_protector_init (void) +@@ -106,11 +106,6 @@ stack_protector_init (void) grub_addr_t grub_modbase; @@ -242,7 +242,7 @@ index 2d12e6188f..0574d8d621 100644 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 2e4e78b132..874506da16 100644 +index 2e4e78b132d..874506da169 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) @@ -296,7 +296,7 @@ index 2e4e78b132..874506da16 100644 grub_envblk_iterate (grub_envblk_t envblk, void *hook_data, diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c -index d506f7e75b..a6ccc11383 100644 +index d506f7e75bc..a6ccc113839 100644 --- a/util/grub-set-bootflag.c +++ b/util/grub-set-bootflag.c @@ -25,6 +25,7 @@ @@ -308,12 +308,12 @@ index d506f7e75b..a6ccc11383 100644 #include #include diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 2e0691454b..8dfc89a33b 100644 +index 8d98203a784..6c2c1f36e37 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h -@@ -24,6 +24,11 @@ - #include - #include +@@ -36,6 +36,11 @@ struct linux_arch_kernel_header { + struct grub_pe_image_header pe_image_header; + }; +#define GRUB_EFI_GRUB_VARIABLE_GUID \ + { 0x91376aff, 0xcba6, 0x42be, \ @@ -324,7 +324,7 @@ index 2e0691454b..8dfc89a33b 100644 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 c3e6559217..ab969af246 100644 +index c3e65592170..ab969af2461 100644 --- a/include/grub/lib/envblk.h +++ b/include/grub/lib/envblk.h @@ -22,6 +22,8 @@ diff --git a/0112-Export-all-variables-from-the-initial-context-when-c.patch b/0096-Export-all-variables-from-the-initial-context-when-c.patch similarity index 95% rename from 0112-Export-all-variables-from-the-initial-context-when-c.patch rename to 0096-Export-all-variables-from-the-initial-context-when-c.patch index 214fa4f..a35174b 100644 --- a/0112-Export-all-variables-from-the-initial-context-when-c.patch +++ b/0096-Export-all-variables-from-the-initial-context-when-c.patch @@ -17,7 +17,7 @@ Signed-off-by: Javier Martinez Canillas 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c -index ee53d4a68e..87edd254c4 100644 +index ba185e91599..b4baa4392cd 100644 --- a/grub-core/normal/context.c +++ b/grub-core/normal/context.c @@ -99,7 +99,7 @@ grub_env_new_context (int export_all) @@ -30,7 +30,7 @@ index ee53d4a68e..87edd254c4 100644 int grub_extractor_level = 0; diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index 4a02aadb01..fe2e77a43e 100644 +index b0cfa32ddd8..30ddcea0c11 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) diff --git a/0113-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch b/0097-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch similarity index 96% rename from 0113-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch rename to 0097-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch index 43e8d16..08cc563 100644 --- a/0113-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch +++ b/0097-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch @@ -21,10 +21,10 @@ Signed-off-by: Robbie Harwood rename util/grub.d/{01_menu_auto_hide.in => 12_menu_auto_hide.in} (58%) diff --git a/Makefile.util.def b/Makefile.util.def -index e10fe766d1..b4ce5383b7 100644 +index 0bb47c6d40a..885dc688a60 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -459,14 +459,14 @@ script = { +@@ -462,14 +462,14 @@ script = { }; script = { @@ -43,7 +43,7 @@ index e10fe766d1..b4ce5383b7 100644 installdir = grubconf; }; -@@ -518,6 +518,12 @@ script = { +@@ -521,6 +521,12 @@ script = { condition = COND_HOST_LINUX; }; @@ -60,7 +60,7 @@ diff --git a/util/grub.d/01_fallback_counting.in b/util/grub.d/08_fallback_count similarity index 65% rename from util/grub.d/01_fallback_counting.in rename to util/grub.d/08_fallback_counting.in -index be0e770ea8..2e2c3ff7d3 100644 +index be0e770ea82..2e2c3ff7d31 100644 --- a/util/grub.d/01_fallback_counting.in +++ b/util/grub.d/08_fallback_counting.in @@ -1,15 +1,17 @@ @@ -89,7 +89,7 @@ index be0e770ea8..2e2c3ff7d3 100644 set boot_counter=-1 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 0000000000..6c88d933dd +index 00000000000..6c88d933dde --- /dev/null +++ b/util/grub.d/10_reset_boot_success.in @@ -0,0 +1,25 @@ @@ -122,7 +122,7 @@ diff --git a/util/grub.d/01_menu_auto_hide.in b/util/grub.d/12_menu_auto_hide.in similarity index 58% rename from util/grub.d/01_menu_auto_hide.in rename to util/grub.d/12_menu_auto_hide.in -index ad175870a5..6a7c0fa0d4 100644 +index ad175870a54..6a7c0fa0d43 100644 --- a/util/grub.d/01_menu_auto_hide.in +++ b/util/grub.d/12_menu_auto_hide.in @@ -1,5 +1,8 @@ diff --git a/0114-Don-t-assume-that-boot-commands-will-only-return-on-.patch b/0098-Don-t-assume-that-boot-commands-will-only-return-on-.patch similarity index 98% rename from 0114-Don-t-assume-that-boot-commands-will-only-return-on-.patch rename to 0098-Don-t-assume-that-boot-commands-will-only-return-on-.patch index df36517..06c6581 100644 --- a/0114-Don-t-assume-that-boot-commands-will-only-return-on-.patch +++ b/0098-Don-t-assume-that-boot-commands-will-only-return-on-.patch @@ -17,7 +17,7 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index fe2e77a43e..ec0c92bade 100644 +index 30ddcea0c11..cda10fa8b3f 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) diff --git a/0115-grub-set-bootflag-Update-comment-about-running-as-ro.patch b/0099-grub-set-bootflag-Update-comment-about-running-as-ro.patch similarity index 96% rename from 0115-grub-set-bootflag-Update-comment-about-running-as-ro.patch rename to 0099-grub-set-bootflag-Update-comment-about-running-as-ro.patch index 9ffb3ae..4fa4df4 100644 --- a/0115-grub-set-bootflag-Update-comment-about-running-as-ro.patch +++ b/0099-grub-set-bootflag-Update-comment-about-running-as-ro.patch @@ -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 a6ccc11383..3eb04beb5e 100644 +index a6ccc113839..3eb04beb5e7 100644 --- a/util/grub-set-bootflag.c +++ b/util/grub-set-bootflag.c @@ -18,7 +18,7 @@ diff --git a/0116-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch b/0100-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch similarity index 99% rename from 0116-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch rename to 0100-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch index 11722d1..ab3f79e 100644 --- a/0116-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch +++ b/0100-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch @@ -13,7 +13,7 @@ Signed-off-by: Hans de Goede 1 file changed, 78 insertions(+), 9 deletions(-) diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c -index 3eb04beb5e..3b4c25ca2a 100644 +index 3eb04beb5e7..3b4c25ca2ac 100644 --- a/util/grub-set-bootflag.c +++ b/util/grub-set-bootflag.c @@ -28,7 +28,9 @@ diff --git a/0117-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch b/0101-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch similarity index 98% rename from 0117-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch rename to 0101-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch index 948ff73..a32c146 100644 --- a/0117-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch +++ b/0101-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch @@ -53,7 +53,7 @@ Signed-off-by: Robbie Harwood 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 6c88d933dd..e73f4137b3 100644 +index 6c88d933dde..e73f4137b36 100644 --- a/util/grub.d/10_reset_boot_success.in +++ b/util/grub.d/10_reset_boot_success.in @@ -6,18 +6,18 @@ diff --git a/0118-Add-start-symbol-for-RISC-V.patch b/0102-Add-start-symbol-for-RISC-V.patch similarity index 95% rename from 0118-Add-start-symbol-for-RISC-V.patch rename to 0102-Add-start-symbol-for-RISC-V.patch index 2746fa2..677efae 100644 --- a/0118-Add-start-symbol-for-RISC-V.patch +++ b/0102-Add-start-symbol-for-RISC-V.patch @@ -15,7 +15,7 @@ Signed-off-by: David Abdurachmanov 1 file changed, 1 insertion(+) diff --git a/grub-core/kern/riscv/efi/startup.S b/grub-core/kern/riscv/efi/startup.S -index f2a7b2b1ed..781773136e 100644 +index f2a7b2b1ede..781773136e8 100644 --- a/grub-core/kern/riscv/efi/startup.S +++ b/grub-core/kern/riscv/efi/startup.S @@ -29,6 +29,7 @@ diff --git a/0119-bootstrap.conf-Force-autogen.sh-to-use-python3.patch b/0103-bootstrap.conf-Force-autogen.sh-to-use-python3.patch similarity index 92% rename from 0119-bootstrap.conf-Force-autogen.sh-to-use-python3.patch rename to 0103-bootstrap.conf-Force-autogen.sh-to-use-python3.patch index 8bfc964..c25b28e 100644 --- a/0119-bootstrap.conf-Force-autogen.sh-to-use-python3.patch +++ b/0103-bootstrap.conf-Force-autogen.sh-to-use-python3.patch @@ -19,10 +19,10 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.conf b/bootstrap.conf -index 6b043fc354..52d4af44be 100644 +index 7a7813d2825..60de0597c50 100644 --- a/bootstrap.conf +++ b/bootstrap.conf -@@ -92,7 +92,7 @@ bootstrap_post_import_hook () { +@@ -94,7 +94,7 @@ bootstrap_post_import_hook () { patch -d po -p3 \ < "po/gettext-patches/$patchname.patch" done diff --git a/0120-efi-http-Export-fw-http-_path-variables-to-make-them.patch b/0104-efi-http-Export-fw-http-_path-variables-to-make-them.patch similarity index 95% rename from 0120-efi-http-Export-fw-http-_path-variables-to-make-them.patch rename to 0104-efi-http-Export-fw-http-_path-variables-to-make-them.patch index f745782..55cce24 100644 --- a/0120-efi-http-Export-fw-http-_path-variables-to-make-them.patch +++ b/0104-efi-http-Export-fw-http-_path-variables-to-make-them.patch @@ -25,7 +25,7 @@ Signed-off-by: Javier Martinez Canillas 2 files changed, 2 insertions(+) diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index 1c540fc8c2..b573be6650 100644 +index 7347a8de676..353a62ef1e1 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c @@ -143,6 +143,7 @@ grub_set_prefix_and_root (void) @@ -37,7 +37,7 @@ index 1c540fc8c2..b573be6650 100644 grub_free (fw_path); } diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c -index de351b2cd0..755b7a6d05 100644 +index 5e97f5d5e70..3be86c141f5 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) diff --git a/0121-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch b/0105-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch similarity index 94% rename from 0121-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch rename to 0105-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch index 03d85c2..30d206e 100644 --- a/0121-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch +++ b/0105-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch @@ -43,7 +43,7 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c -index 755b7a6d05..fc8cb25ae0 100644 +index 3be86c141f5..c37c359c713 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, @@ -102,13 +102,13 @@ index 755b7a6d05..fc8cb25ae0 100644 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, +@@ -225,6 +241,9 @@ efihttp_request (grub_efi_http_t *http, char *server, char *name, int use_https, - status = efi_call_2 (http->request, http, &request_token); + status = http->request(http, &request_token); + if (hostname) + grub_free (hostname); + if (status != GRUB_EFI_SUCCESS) { - efi_call_1 (b->close_event, request_token.event); + b->close_event(request_token.event); diff --git a/0122-efi-net-Allow-to-specify-a-port-number-in-addresses.patch b/0106-efi-net-Allow-to-specify-a-port-number-in-addresses.patch similarity index 97% rename from 0122-efi-net-Allow-to-specify-a-port-number-in-addresses.patch rename to 0106-efi-net-Allow-to-specify-a-port-number-in-addresses.patch index 8fe26cd..96ebab3 100644 --- a/0122-efi-net-Allow-to-specify-a-port-number-in-addresses.patch +++ b/0106-efi-net-Allow-to-specify-a-port-number-in-addresses.patch @@ -25,7 +25,7 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c -index 6603cd83ed..84573937b1 100644 +index 1f7e1b63557..4ef3f709ee2 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, diff --git a/0123-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch b/0107-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch similarity index 97% rename from 0123-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch rename to 0107-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch index 2dc7001..eb342e8 100644 --- a/0123-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch +++ b/0107-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch @@ -21,7 +21,7 @@ Signed-off-by: Javier Martinez Canillas 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 b711a5d945..313c818b18 100644 +index 1deba25e79e..fb2fe850d0e 100644 --- a/grub-core/net/efi/ip4_config.c +++ b/grub-core/net/efi/ip4_config.c @@ -56,9 +56,20 @@ int diff --git a/0124-efi-net-Print-a-debug-message-if-parsing-the-address.patch b/0108-efi-net-Print-a-debug-message-if-parsing-the-address.patch similarity index 98% rename from 0124-efi-net-Print-a-debug-message-if-parsing-the-address.patch rename to 0108-efi-net-Print-a-debug-message-if-parsing-the-address.patch index da94e08..8ef8514 100644 --- a/0124-efi-net-Print-a-debug-message-if-parsing-the-address.patch +++ b/0108-efi-net-Print-a-debug-message-if-parsing-the-address.patch @@ -22,7 +22,7 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c -index 84573937b1..a3f0535d43 100644 +index 4ef3f709ee2..a9536c66550 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, diff --git a/0125-kern-term-Also-accept-F8-as-a-user-interrupt-key.patch b/0109-kern-term-Also-accept-F8-as-a-user-interrupt-key.patch similarity index 96% rename from 0125-kern-term-Also-accept-F8-as-a-user-interrupt-key.patch rename to 0109-kern-term-Also-accept-F8-as-a-user-interrupt-key.patch index 8793b0d..3dd525a 100644 --- a/0125-kern-term-Also-accept-F8-as-a-user-interrupt-key.patch +++ b/0109-kern-term-Also-accept-F8-as-a-user-interrupt-key.patch @@ -12,7 +12,7 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/term.c b/grub-core/kern/term.c -index 14d5964983..4d61f4e979 100644 +index 14d59649832..4d61f4e9790 100644 --- a/grub-core/kern/term.c +++ b/grub-core/kern/term.c @@ -144,9 +144,10 @@ grub_key_is_interrupt (int key) diff --git a/0129-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch b/0110-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch similarity index 93% rename from 0129-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch rename to 0110-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch index 7fef93e..2f443d7 100644 --- a/0129-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch +++ b/0110-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch @@ -20,10 +20,10 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index b52b558d63..7f878b5615 100644 +index af486198399..ce2b492c353 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) +@@ -502,13 +502,20 @@ http_open (struct grub_file *file, const char *filename) { grub_err_t err; struct http_data *data; diff --git a/0130-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch b/0111-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch similarity index 95% rename from 0130-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch rename to 0111-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch index f3b10c1..f29706f 100644 --- a/0130-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch +++ b/0111-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch @@ -13,7 +13,7 @@ Signed-off-by: Peter Jones 1 file changed, 2 insertions(+) diff --git a/grub-core/commands/efi/env.c b/grub-core/commands/efi/env.c -index cbd13e03e8..977edb6b06 100644 +index 45f107ccd5b..4080f24fdb8 100644 --- a/grub-core/commands/efi/env.c +++ b/grub-core/commands/efi/env.c @@ -149,6 +149,8 @@ grub_efi_load_env(grub_command_t cmd __attribute__ ((unused)), diff --git a/0111-Make-it-possible-to-subtract-conditions-from-debug.patch b/0111-Make-it-possible-to-subtract-conditions-from-debug.patch deleted file mode 100644 index 15305f8..0000000 --- a/0111-Make-it-possible-to-subtract-conditions-from-debug.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Peter Jones -Date: Thu, 17 Jan 2019 13:10:39 -0500 -Subject: [PATCH] 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 9a2fae6398..578bf51a5f 100644 ---- a/grub-core/kern/misc.c -+++ b/grub-core/kern/misc.c -@@ -164,12 +164,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; diff --git a/0131-efi-dhcp-fix-some-allocation-error-checking.patch b/0112-efi-dhcp-fix-some-allocation-error-checking.patch similarity index 83% rename from 0131-efi-dhcp-fix-some-allocation-error-checking.patch rename to 0112-efi-dhcp-fix-some-allocation-error-checking.patch index 90e7a34..e891757 100644 --- a/0131-efi-dhcp-fix-some-allocation-error-checking.patch +++ b/0112-efi-dhcp-fix-some-allocation-error-checking.patch @@ -9,7 +9,7 @@ Signed-off-by: Peter Jones 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/grub-core/net/efi/dhcp.c b/grub-core/net/efi/dhcp.c -index dbef63d8c0..e5c79b748b 100644 +index ca19902441b..6cc0dad85a7 100644 --- a/grub-core/net/efi/dhcp.c +++ b/grub-core/net/efi/dhcp.c @@ -80,7 +80,7 @@ grub_efi_dhcp4_parse_dns (grub_efi_dhcp4_protocol_t *dhcp4, grub_efi_dhcp4_packe @@ -26,10 +26,10 @@ index dbef63d8c0..e5c79b748b 100644 if (status == GRUB_EFI_BUFFER_TOO_SMALL && count) { - options = grub_malloc (count * sizeof(*options)); -- status = efi_call_4 (dev->dhcp6->parse, dev->dhcp6, mode.ia->reply_packet, &count, options); +- status = dev->dhcp6->parse(dev->dhcp6, mode.ia->reply_packet, &count, options); + options = grub_calloc (count, sizeof(*options)); + if (options) -+ status = efi_call_4 (dev->dhcp6->parse, dev->dhcp6, mode.ia->reply_packet, &count, options); ++ status = dev->dhcp6->parse(dev->dhcp6, mode.ia->reply_packet, &count, options); + else + status = GRUB_EFI_OUT_OF_RESOURCES; } diff --git a/0132-efi-http-fix-some-allocation-error-checking.patch b/0113-efi-http-fix-some-allocation-error-checking.patch similarity index 84% rename from 0132-efi-http-fix-some-allocation-error-checking.patch rename to 0113-efi-http-fix-some-allocation-error-checking.patch index 149ada8..ba34e7f 100644 --- a/0132-efi-http-fix-some-allocation-error-checking.patch +++ b/0113-efi-http-fix-some-allocation-error-checking.patch @@ -9,10 +9,10 @@ Signed-off-by: Peter Jones 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c -index fc8cb25ae0..26647a50fa 100644 +index c37c359c713..0568ea5d43e 100644 --- a/grub-core/net/efi/http.c +++ b/grub-core/net/efi/http.c -@@ -412,8 +412,8 @@ grub_efihttp_open (struct grub_efi_net_device *dev, +@@ -403,8 +403,8 @@ grub_efihttp_open (struct grub_efi_net_device *dev, int type) { grub_err_t err; @@ -23,7 +23,7 @@ index fc8cb25ae0..26647a50fa 100644 char *file_name = NULL; const char *http_path; -@@ -441,8 +441,11 @@ grub_efihttp_open (struct grub_efi_net_device *dev, +@@ -432,8 +432,11 @@ grub_efihttp_open (struct grub_efi_net_device *dev, return err; } diff --git a/0133-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch b/0114-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch similarity index 98% rename from 0133-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch rename to 0114-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch index 6413eb6..c4beaa4 100644 --- a/0133-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch +++ b/0114-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch @@ -13,7 +13,7 @@ Signed-off-by: Peter Jones 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/grub-core/net/efi/ip4_config.c b/grub-core/net/efi/ip4_config.c -index 313c818b18..9725e928f7 100644 +index fb2fe850d0e..e9fc24865ec 100644 --- a/grub-core/net/efi/ip4_config.c +++ b/grub-core/net/efi/ip4_config.c @@ -4,15 +4,20 @@ @@ -82,7 +82,7 @@ index 313c818b18..9725e928f7 100644 char *subnet, *gateway, *mask; grub_uint32_t u32_subnet, u32_gateway; diff --git a/grub-core/net/efi/ip6_config.c b/grub-core/net/efi/ip6_config.c -index 017c4d05bc..a46f6f9b68 100644 +index 29a03973265..050af4fbfd1 100644 --- a/grub-core/net/efi/ip6_config.c +++ b/grub-core/net/efi/ip6_config.c @@ -3,6 +3,7 @@ diff --git a/0137-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch b/0115-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch similarity index 97% rename from 0137-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch rename to 0115-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch index ea92110..d0dd887 100644 --- a/0137-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch +++ b/0115-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch @@ -14,7 +14,7 @@ Signed-off-by: Peter Jones 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/net/efi/ip4_config.c b/grub-core/net/efi/ip4_config.c -index 9725e928f7..cb880fc3e8 100644 +index e9fc24865ec..85a090ec422 100644 --- a/grub-core/net/efi/ip4_config.c +++ b/grub-core/net/efi/ip4_config.c @@ -61,7 +61,8 @@ int diff --git a/0138-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch b/0116-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch similarity index 96% rename from 0138-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch rename to 0116-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch index 915e6d7..1ecbfd8 100644 --- a/0138-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch +++ b/0116-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch @@ -14,7 +14,7 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/net/efi/ip6_config.c b/grub-core/net/efi/ip6_config.c -index a46f6f9b68..1c5415d718 100644 +index 050af4fbfd1..952bda9fa74 100644 --- a/grub-core/net/efi/ip6_config.c +++ b/grub-core/net/efi/ip6_config.c @@ -85,7 +85,7 @@ grub_efi_string_to_ip6_address (const char *val, grub_efi_ipv6_address_t *addres diff --git a/0139-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch b/0117-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch similarity index 97% rename from 0139-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch rename to 0117-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch index fbba65a..fe583d3 100644 --- a/0139-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch +++ b/0117-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch @@ -14,7 +14,7 @@ Signed-off-by: Peter Jones 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c -index a3f0535d43..78e5442fc5 100644 +index a9536c66550..0a1e604b5bd 100644 --- a/grub-core/net/efi/net.c +++ b/grub-core/net/efi/net.c @@ -729,7 +729,7 @@ grub_efi_net_parse_address (const char *address, diff --git a/0140-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch b/0118-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch similarity index 97% rename from 0140-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch rename to 0118-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch index 9b9acfe..ea5be7c 100644 --- a/0140-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch +++ b/0118-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch @@ -14,7 +14,7 @@ Signed-off-by: Peter Jones 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/net/efi/pxe.c b/grub-core/net/efi/pxe.c -index 531949cba5..73e2bb01c1 100644 +index b84f86ea470..e828fb23e96 100644 --- a/grub-core/net/efi/pxe.c +++ b/grub-core/net/efi/pxe.c @@ -187,7 +187,7 @@ parse_ip6 (const char *val, grub_uint64_t *ip, const char **rest) diff --git a/0141-Add-systemd-integration-scripts-to-make-systemctl-re.patch b/0119-Add-systemd-integration-scripts-to-make-systemctl-re.patch similarity index 91% rename from 0141-Add-systemd-integration-scripts-to-make-systemctl-re.patch rename to 0119-Add-systemd-integration-scripts-to-make-systemctl-re.patch index 8cf45c3..ce424e1 100644 --- a/0141-Add-systemd-integration-scripts-to-make-systemctl-re.patch +++ b/0119-Add-systemd-integration-scripts-to-make-systemctl-re.patch @@ -65,10 +65,10 @@ Signed-off-by: Hans de Goede create mode 100644 util/systemd/systemd-integration.sh.in diff --git a/Makefile.util.def b/Makefile.util.def -index b4ce5383b7..6366442129 100644 +index 885dc688a60..8e52e48c780 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -470,6 +470,12 @@ script = { +@@ -473,6 +473,12 @@ script = { installdir = grubconf; }; @@ -81,7 +81,7 @@ index b4ce5383b7..6366442129 100644 script = { name = '01_users'; common = util/grub.d/01_users.in; -@@ -569,6 +575,27 @@ script = { +@@ -578,6 +584,27 @@ script = { installdir = grubconf; }; @@ -110,10 +110,10 @@ index b4ce5383b7..6366442129 100644 mansection = 1; name = grub-mkrescue; diff --git a/conf/Makefile.common b/conf/Makefile.common -index 0647c53b91..9fe5863b2d 100644 +index 91ff6c905fb..c8756d8146f 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common -@@ -63,8 +63,11 @@ CCASFLAGS_LIBRARY = $(UTILS_CCASFLAGS) +@@ -73,8 +73,11 @@ CCASFLAGS_LIBRARY = $(UTILS_CCASFLAGS) # Other variables grubconfdir = $(sysconfdir)/grub.d @@ -123,21 +123,21 @@ index 0647c53b91..9fe5863b2d 100644 +systemdunitdir = ${prefix}/lib/systemd/system +systemd_logind_service_ddir = $(systemdunitdir)/systemd-logind.service.d - CFLAGS_GNULIB = -Wno-undef -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Werror=trampolines -fno-trampolines + CFLAGS_GNULIB = -Wno-undef -Wno-error=sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-error=attributes -Werror=trampolines -fno-trampolines CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/lib/gnulib -I$(top_srcdir)/grub-core/lib/gnulib -@@ -121,6 +124,9 @@ noinst_LIBRARIES = - dist_noinst_DATA = - platform_SCRIPTS = +@@ -133,6 +136,9 @@ platform_SCRIPTS = platform_PROGRAMS = + sbin_SCRIPTS = + sbin_PROGRAMS = +grublibexec_SCRIPTS = +systemdunit_SCRIPTS = +systemd_logind_service_d_SCRIPTS = - TESTS = EXTRA_DIST = + CLEANFILES = diff --git a/util/grub.d/14_menu_show_once.in b/util/grub.d/14_menu_show_once.in new file mode 100755 -index 0000000000..1cd7f36142 +index 00000000000..1cd7f36142b --- /dev/null +++ b/util/grub.d/14_menu_show_once.in @@ -0,0 +1,13 @@ @@ -156,7 +156,7 @@ index 0000000000..1cd7f36142 +EOF diff --git a/util/systemd/10-grub-logind-service.conf.in b/util/systemd/10-grub-logind-service.conf.in new file mode 100644 -index 0000000000..f2d4ac0073 +index 00000000000..f2d4ac00732 --- /dev/null +++ b/util/systemd/10-grub-logind-service.conf.in @@ -0,0 +1,2 @@ @@ -164,7 +164,7 @@ index 0000000000..f2d4ac0073 +Environment=SYSTEMD_REBOOT_TO_BOOT_LOADER_MENU=true diff --git a/util/systemd/grub-systemd-integration.service.in b/util/systemd/grub-systemd-integration.service.in new file mode 100644 -index 0000000000..c81fb594ce +index 00000000000..c81fb594ce1 --- /dev/null +++ b/util/systemd/grub-systemd-integration.service.in @@ -0,0 +1,8 @@ @@ -178,7 +178,7 @@ index 0000000000..c81fb594ce +ExecStart=@libexecdir@/@grubdirname@/systemd-integration.sh diff --git a/util/systemd/systemd-integration.sh.in b/util/systemd/systemd-integration.sh.in new file mode 100644 -index 0000000000..dc1218597b +index 00000000000..dc1218597bc --- /dev/null +++ b/util/systemd/systemd-integration.sh.in @@ -0,0 +1,6 @@ diff --git a/0142-systemd-integration.sh-Also-set-old-menu_show_once-g.patch b/0120-systemd-integration.sh-Also-set-old-menu_show_once-g.patch similarity index 97% rename from 0142-systemd-integration.sh-Also-set-old-menu_show_once-g.patch rename to 0120-systemd-integration.sh-Also-set-old-menu_show_once-g.patch index a16ed68..9021de5 100644 --- a/0142-systemd-integration.sh-Also-set-old-menu_show_once-g.patch +++ b/0120-systemd-integration.sh-Also-set-old-menu_show_once-g.patch @@ -18,7 +18,7 @@ Signed-off-by: Hans de Goede 1 file changed, 5 insertions(+) diff --git a/util/systemd/systemd-integration.sh.in b/util/systemd/systemd-integration.sh.in -index dc1218597b..a4c071c5b0 100644 +index dc1218597bc..a4c071c5b0c 100644 --- a/util/systemd/systemd-integration.sh.in +++ b/util/systemd/systemd-integration.sh.in @@ -4,3 +4,8 @@ TIMEOUT_USEC=$(cat /run/systemd/reboot-to-boot-loader-menu) diff --git a/0143-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch b/0121-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch similarity index 93% rename from 0143-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch rename to 0121-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch index f891a69..6011b33 100644 --- a/0143-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch +++ b/0121-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch @@ -29,10 +29,10 @@ Signed-off-by: Renaud Métrich 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c -index 597111077b..2601438260 100644 +index f8a129eb7f1..2d9ab65aee0 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c -@@ -135,20 +135,28 @@ query_mode (void) +@@ -145,20 +145,28 @@ query_mode (void) int e; e = write_mode (0); @@ -65,7 +65,7 @@ index 597111077b..2601438260 100644 return 0; } -@@ -165,7 +173,13 @@ set_scancodes (void) +@@ -175,7 +183,13 @@ set_scancodes (void) } #if !USE_SCANCODE_SET @@ -80,7 +80,7 @@ index 597111077b..2601438260 100644 return; #else -@@ -266,6 +280,7 @@ grub_keyboard_controller_init (void) +@@ -276,6 +290,7 @@ grub_keyboard_controller_init (void) grub_keyboard_orig_set = 2; #else grub_keyboard_controller_orig = grub_keyboard_controller_read (); @@ -88,7 +88,7 @@ index 597111077b..2601438260 100644 grub_keyboard_orig_set = query_mode (); #endif set_scancodes (); -@@ -275,11 +290,15 @@ grub_keyboard_controller_init (void) +@@ -285,11 +300,15 @@ grub_keyboard_controller_init (void) static grub_err_t grub_keyboard_controller_fini (struct grub_term_input *term __attribute__ ((unused))) { @@ -105,7 +105,7 @@ index 597111077b..2601438260 100644 } diff --git a/include/grub/at_keyboard.h b/include/grub/at_keyboard.h -index bcb4d9ba78..9414dc1b99 100644 +index bcb4d9ba78f..9414dc1b996 100644 --- a/include/grub/at_keyboard.h +++ b/include/grub/at_keyboard.h @@ -19,6 +19,10 @@ diff --git a/0144-grub-install-disable-support-for-EFI-platforms.patch b/0122-grub-install-disable-support-for-EFI-platforms.patch similarity index 81% rename from 0144-grub-install-disable-support-for-EFI-platforms.patch rename to 0122-grub-install-disable-support-for-EFI-platforms.patch index f6a7530..380dbef 100644 --- a/0144-grub-install-disable-support-for-EFI-platforms.patch +++ b/0122-grub-install-disable-support-for-EFI-platforms.patch @@ -21,15 +21,15 @@ Resolves: rhbz#1737444 Signed-off-by: Jan Hlavac [rharwood: drop man page] --- - util/grub-install.c | 37 ++++++++++++++++--------------------- + util/grub-install.c | 41 +++++++++++++++++++---------------------- docs/grub.texi | 7 +++++++ - 2 files changed, 23 insertions(+), 21 deletions(-) + 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/util/grub-install.c b/util/grub-install.c -index a2bec7446c..5babc7af55 100644 +index 66ef9494d9d..828e8722ba5 100644 --- a/util/grub-install.c +++ b/util/grub-install.c -@@ -899,6 +899,22 @@ main (int argc, char *argv[]) +@@ -915,6 +915,25 @@ main (int argc, char *argv[]) platform = grub_install_get_target (grub_install_source_directory); @@ -39,6 +39,9 @@ index a2bec7446c..5babc7af55 100644 + case GRUB_INSTALL_PLATFORM_ARM64_EFI: + case GRUB_INSTALL_PLATFORM_I386_EFI: + case GRUB_INSTALL_PLATFORM_IA64_EFI: ++ case GRUB_INSTALL_PLATFORM_LOONGARCH64_EFI: ++ case GRUB_INSTALL_PLATFORM_RISCV32_EFI: ++ case GRUB_INSTALL_PLATFORM_RISCV64_EFI: + case GRUB_INSTALL_PLATFORM_X86_64_EFI: + is_efi = 1; + grub_util_error (_("this utility cannot be used for EFI platforms" @@ -52,7 +55,7 @@ index a2bec7446c..5babc7af55 100644 { char *platname = grub_install_get_platform_name (platform); fprintf (stderr, _("Installing for %s platform.\n"), platname); -@@ -1011,28 +1027,7 @@ main (int argc, char *argv[]) +@@ -1029,27 +1048,6 @@ main (int argc, char *argv[]) grub_hostfs_init (); grub_host_init (); @@ -62,6 +65,7 @@ index a2bec7446c..5babc7af55 100644 - case GRUB_INSTALL_PLATFORM_X86_64_EFI: - case GRUB_INSTALL_PLATFORM_ARM_EFI: - case GRUB_INSTALL_PLATFORM_ARM64_EFI: +- case GRUB_INSTALL_PLATFORM_LOONGARCH64_EFI: - case GRUB_INSTALL_PLATFORM_RISCV32_EFI: - case GRUB_INSTALL_PLATFORM_RISCV64_EFI: - case GRUB_INSTALL_PLATFORM_IA64_EFI: @@ -76,16 +80,22 @@ index a2bec7446c..5babc7af55 100644 - break; - } - + switch (platform) + { + case GRUB_INSTALL_PLATFORM_I386_IEEE1275: +@@ -1065,7 +1063,6 @@ main (int argc, char *argv[]) + } + /* Find the EFI System Partition. */ - if (is_efi) { grub_fs_t fs; diff --git a/docs/grub.texi b/docs/grub.texi -index 04ed6ac1f0..4870faaa00 100644 +index 44c4e665a0d..1e577d2fee9 100644 --- a/docs/grub.texi +++ b/docs/grub.texi -@@ -6509,6 +6509,13 @@ grub2-install @var{install_device} +@@ -7112,6 +7112,13 @@ grub2-install @var{install_device} The device name @var{install_device} is an OS device name or a GRUB device name. diff --git a/0145-New-with-debug-timestamps-configure-flag-to-prepend-.patch b/0123-New-with-debug-timestamps-configure-flag-to-prepend-.patch similarity index 84% rename from 0145-New-with-debug-timestamps-configure-flag-to-prepend-.patch rename to 0123-New-with-debug-timestamps-configure-flag-to-prepend-.patch index ec5b30b..426d5be 100644 --- a/0145-New-with-debug-timestamps-configure-flag-to-prepend-.patch +++ b/0123-New-with-debug-timestamps-configure-flag-to-prepend-.patch @@ -15,10 +15,10 @@ Signed-off-by: Renaud Métrich 3 files changed, 39 insertions(+) diff --git a/configure.ac b/configure.ac -index a02d40a05b..ab0d326f00 100644 +index ae7683d0693..016cd3d4e0e 100644 --- a/configure.ac +++ b/configure.ac -@@ -1585,6 +1585,17 @@ else +@@ -1686,6 +1686,17 @@ else fi AC_SUBST([BOOT_TIME_STATS]) @@ -33,10 +33,10 @@ index a02d40a05b..ab0d326f00 100644 +fi +AC_SUBST([DEBUG_WITH_TIMESTAMPS]) + - AC_ARG_ENABLE([grub-emu-sdl], - [AS_HELP_STRING([--enable-grub-emu-sdl], - [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])]) -@@ -2136,6 +2147,7 @@ AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1]) + AC_ARG_ENABLE([grub-emu-sdl2], + [AS_HELP_STRING([--enable-grub-emu-sdl2], + [build and install the `grub-emu' debugging utility with SDL2 support (default=guessed)])]) +@@ -2296,6 +2307,7 @@ AM_CONDITIONAL([COND_APPLE_LINKER], [test x$TARGET_APPLE_LINKER = x1]) AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes]) AM_CONDITIONAL([COND_ENABLE_CACHE_STATS], [test x$DISK_CACHE_STATS = x1]) AM_CONDITIONAL([COND_ENABLE_BOOT_TIME_STATS], [test x$BOOT_TIME_STATS = x1]) @@ -44,7 +44,7 @@ index a02d40a05b..ab0d326f00 100644 AM_CONDITIONAL([COND_HAVE_CXX], [test x$HAVE_CXX = xyes]) -@@ -2231,6 +2243,12 @@ else +@@ -2397,6 +2409,12 @@ else echo With boot time statistics: No fi @@ -58,12 +58,12 @@ index a02d40a05b..ab0d326f00 100644 echo efiemu runtime: Yes else diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 578bf51a5f..9f54b6b7d2 100644 +index 779586658cb..d40586b9268 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -25,6 +25,9 @@ - #include - #include +@@ -27,6 +27,9 @@ + #include + #include #include +#if DEBUG_WITH_TIMESTAMPS +#include @@ -71,7 +71,7 @@ index 578bf51a5f..9f54b6b7d2 100644 union printf_arg { -@@ -192,9 +195,26 @@ grub_real_dprintf (const char *file, const int line, const char *condition, +@@ -236,9 +239,26 @@ grub_real_dprintf (const char *file, const int line, const char *condition, const char *fmt, ...) { va_list args; @@ -95,14 +95,14 @@ index 578bf51a5f..9f54b6b7d2 100644 + else + last_had_cr = 0; +#endif - grub_printf ("%s:%d: ", file, line); + grub_printf ("%s:%d:%s: ", file, line, condition); va_start (args, fmt); grub_vprintf (fmt, args); diff --git a/config.h.in b/config.h.in -index c7e316f0f1..c80e3e0aba 100644 +index d294d2c653f..39f4e5472ce 100644 --- a/config.h.in +++ b/config.h.in -@@ -12,6 +12,7 @@ +@@ -16,6 +16,7 @@ /* Define to 1 to enable disk cache statistics. */ #define DISK_CACHE_STATS @DISK_CACHE_STATS@ #define BOOT_TIME_STATS @BOOT_TIME_STATS@ diff --git a/0146-Added-debug-statements-to-grub_disk_open-and-grub_di.patch b/0124-Added-debug-statements-to-grub_disk_open-and-grub_di.patch similarity index 67% rename from 0146-Added-debug-statements-to-grub_disk_open-and-grub_di.patch rename to 0124-Added-debug-statements-to-grub_disk_open-and-grub_di.patch index d26027c..0cd12c4 100644 --- a/0146-Added-debug-statements-to-grub_disk_open-and-grub_di.patch +++ b/0124-Added-debug-statements-to-grub_disk_open-and-grub_di.patch @@ -9,11 +9,11 @@ Content-Transfer-Encoding: 8bit Signed-off-by: Renaud Métrich --- - grub-core/kern/disk.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) + grub-core/kern/disk.c | 4 ++++ + 1 file changed, 4 insertions(+) diff --git a/grub-core/kern/disk.c b/grub-core/kern/disk.c -index e1b0e073e0..05a28ab142 100644 +index 1eda58fe9a1..355b6579d87 100644 --- a/grub-core/kern/disk.c +++ b/grub-core/kern/disk.c @@ -285,6 +285,8 @@ grub_disk_open (const char *name) @@ -25,16 +25,7 @@ index e1b0e073e0..05a28ab142 100644 return disk; } -@@ -292,7 +294,7 @@ void - grub_disk_close (grub_disk_t disk) - { - grub_partition_t part; -- grub_dprintf ("disk", "Closing `%s'.\n", disk->name); -+ grub_dprintf ("disk", "Closing `%s'...\n", disk->name); - - if (disk->dev && disk->dev->disk_close) - (disk->dev->disk_close) (disk); -@@ -306,8 +308,10 @@ grub_disk_close (grub_disk_t disk) +@@ -310,8 +312,10 @@ grub_disk_close (grub_disk_t disk) grub_free (disk->partition); disk->partition = part; } diff --git a/0147-Introduce-function-grub_debug_is_enabled-void-return.patch b/0125-Introduce-function-grub_debug_is_enabled-void-return.patch similarity index 87% rename from 0147-Introduce-function-grub_debug_is_enabled-void-return.patch rename to 0125-Introduce-function-grub_debug_is_enabled-void-return.patch index 9ce5d9d..224d204 100644 --- a/0147-Introduce-function-grub_debug_is_enabled-void-return.patch +++ b/0125-Introduce-function-grub_debug_is_enabled-void-return.patch @@ -14,10 +14,10 @@ Signed-off-by: Renaud Métrich 2 files changed, 14 insertions(+) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index 9f54b6b7d2..a186ad3dd4 100644 +index d40586b9268..d3a493e3552 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -163,6 +163,19 @@ int grub_err_printf (const char *fmt, ...) +@@ -186,6 +186,19 @@ int grub_err_printf (const char *fmt, ...) __attribute__ ((alias("grub_printf"))); #endif @@ -38,10 +38,10 @@ index 9f54b6b7d2..a186ad3dd4 100644 grub_debug_enabled (const char * condition) { diff --git a/include/grub/misc.h b/include/grub/misc.h -index 3adc4036e3..6c4aa85ac5 100644 +index 72aff15750d..3f5f5b61695 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h -@@ -340,6 +340,7 @@ grub_puts (const char *s) +@@ -369,6 +369,7 @@ grub_puts (const char *s) } int EXPORT_FUNC(grub_puts_) (const char *s); diff --git a/0148-Don-t-clear-screen-when-debugging-is-enabled.patch b/0126-Don-t-clear-screen-when-debugging-is-enabled.patch similarity index 80% rename from 0148-Don-t-clear-screen-when-debugging-is-enabled.patch rename to 0126-Don-t-clear-screen-when-debugging-is-enabled.patch index c35d8a3..8cca97c 100644 --- a/0148-Don-t-clear-screen-when-debugging-is-enabled.patch +++ b/0126-Don-t-clear-screen-when-debugging-is-enabled.patch @@ -10,20 +10,18 @@ Signed-off-by: Renaud Métrich [rharwood@redhat.com: rebase fuzz] Signed-off-by: Robbie Harwood --- - grub-core/normal/main.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) + grub-core/normal/main.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index af9792c963..7de9e4c36d 100644 +index b5fa6156549..0ea27d3c534 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c -@@ -215,8 +215,9 @@ grub_normal_init_page (struct grub_term_output *term, - char *msg_formatted; +@@ -216,7 +216,8 @@ grub_normal_init_page (struct grub_term_output *term, grub_uint32_t *unicode_msg; grub_uint32_t *last_position; -- + - grub_term_cls (term); -+ + if (! grub_debug_is_enabled ()) + grub_term_cls (term); diff --git a/0150-grub_file_-instrumentation-new-file-debug-tag.patch b/0127-grub_file_-instrumentation-new-file-debug-tag.patch similarity index 83% rename from 0150-grub_file_-instrumentation-new-file-debug-tag.patch rename to 0127-grub_file_-instrumentation-new-file-debug-tag.patch index 6327899..1d35707 100644 --- a/0150-grub_file_-instrumentation-new-file-debug-tag.patch +++ b/0127-grub_file_-instrumentation-new-file-debug-tag.patch @@ -12,7 +12,7 @@ Signed-off-by: Renaud Métrich 1 file changed, 14 insertions(+) diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c -index 5b58f45cfd..ec10e54fc0 100644 +index 750177248f9..264211b1143 100644 --- a/grub-core/kern/file.c +++ b/grub-core/kern/file.c @@ -66,6 +66,8 @@ grub_file_open (const char *name, enum grub_file_type type) @@ -21,10 +21,10 @@ index 5b58f45cfd..ec10e54fc0 100644 + grub_dprintf ("file", "Opening `%s' ...\n", name); + - /* Reset grub_errno before we start */ + /* Reset grub_errno before we start. */ grub_errno = GRUB_ERR_NONE; -@@ -131,6 +133,8 @@ grub_file_open (const char *name, enum grub_file_type type) +@@ -132,6 +134,8 @@ grub_file_open (const char *name, enum grub_file_type type) if (!file) grub_file_close (last_file); @@ -33,7 +33,7 @@ index 5b58f45cfd..ec10e54fc0 100644 return file; fail: -@@ -141,6 +145,8 @@ grub_file_open (const char *name, enum grub_file_type type) +@@ -143,6 +147,8 @@ grub_file_open (const char *name, enum grub_file_type type) grub_free (file); @@ -42,7 +42,7 @@ index 5b58f45cfd..ec10e54fc0 100644 return 0; } -@@ -172,6 +178,7 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len) +@@ -174,6 +180,7 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len) if (len == 0) return 0; @@ -50,7 +50,7 @@ index 5b58f45cfd..ec10e54fc0 100644 read_hook = file->read_hook; read_hook_data = file->read_hook_data; if (!file->read_hook) -@@ -192,11 +199,18 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len) +@@ -194,11 +201,18 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len) grub_err_t grub_file_close (grub_file_t file) { diff --git a/0127-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch b/0127-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch deleted file mode 100644 index d1c7b17..0000000 --- a/0127-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Sat, 16 May 2020 11:33:18 +0200 -Subject: [PATCH] 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 2052c36eab..e287d042e6 100644 ---- a/grub-core/commands/tpm.c -+++ b/grub-core/commands/tpm.c -@@ -42,7 +42,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 -@@ -50,7 +51,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) - { -@@ -66,15 +66,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 = { diff --git a/0151-ieee1275-Avoiding-many-unecessary-open-close.patch b/0128-ieee1275-Avoiding-many-unecessary-open-close.patch similarity index 94% rename from 0151-ieee1275-Avoiding-many-unecessary-open-close.patch rename to 0128-ieee1275-Avoiding-many-unecessary-open-close.patch index f6c5244..fac8dc7 100644 --- a/0151-ieee1275-Avoiding-many-unecessary-open-close.patch +++ b/0128-ieee1275-Avoiding-many-unecessary-open-close.patch @@ -9,7 +9,7 @@ Signed-off-by: Diego Domingos 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c -index 03674cb477..ea7f78ac7d 100644 +index c6cba0c8aaf..629fc15f284 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -44,7 +44,7 @@ struct ofdisk_hash_ent @@ -94,7 +94,7 @@ index 03674cb477..ea7f78ac7d 100644 if (err) { grub_free (devpath); -@@ -532,13 +555,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) +@@ -528,13 +551,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) static void grub_ofdisk_close (grub_disk_t disk) { @@ -108,7 +108,7 @@ index 03674cb477..ea7f78ac7d 100644 disk->data = 0; } -@@ -685,7 +701,7 @@ grub_ofdisk_init (void) +@@ -681,7 +697,7 @@ grub_ofdisk_init (void) } static grub_err_t @@ -117,7 +117,7 @@ index 03674cb477..ea7f78ac7d 100644 struct ofdisk_hash_ent *op) { struct size_args_ieee1275 -@@ -698,16 +714,6 @@ grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size, +@@ -694,16 +710,6 @@ grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size, grub_ieee1275_cell_t size2; } args_ieee1275; diff --git a/0152-ieee1275-powerpc-implements-fibre-channel-discovery-.patch b/0129-ieee1275-powerpc-implements-fibre-channel-discovery-.patch similarity index 98% rename from 0152-ieee1275-powerpc-implements-fibre-channel-discovery-.patch rename to 0129-ieee1275-powerpc-implements-fibre-channel-discovery-.patch index 04c5c32..9fa02bb 100644 --- a/0152-ieee1275-powerpc-implements-fibre-channel-discovery-.patch +++ b/0129-ieee1275-powerpc-implements-fibre-channel-discovery-.patch @@ -15,7 +15,7 @@ Signed-off-by: Diego Domingos 1 file changed, 49 insertions(+) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c -index a6153d3595..0f5d54e9f2 100644 +index a6153d35954..0f5d54e9f2d 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -350,6 +350,38 @@ of_path_of_ide(const char *sys_devname __attribute__((unused)), const char *devi diff --git a/0153-ieee1275-powerpc-enables-device-mapper-discovery.patch b/0130-ieee1275-powerpc-enables-device-mapper-discovery.patch similarity index 98% rename from 0153-ieee1275-powerpc-enables-device-mapper-discovery.patch rename to 0130-ieee1275-powerpc-enables-device-mapper-discovery.patch index 85dbde7..6f1c21b 100644 --- a/0153-ieee1275-powerpc-enables-device-mapper-discovery.patch +++ b/0130-ieee1275-powerpc-enables-device-mapper-discovery.patch @@ -17,7 +17,7 @@ Signed-off-by: Diego Domingos 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c -index 0f5d54e9f2..cc849d9c94 100644 +index 0f5d54e9f2d..cc849d9c94c 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -37,6 +37,7 @@ diff --git a/0154-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch b/0131-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch similarity index 94% rename from 0154-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch rename to 0131-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch index f938fd1..65646f7 100644 --- a/0154-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch +++ b/0131-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch @@ -35,7 +35,7 @@ Signed-off-by: Robbie Harwood 1 file changed, 96 insertions(+), 25 deletions(-) diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c -index 2601438260..dac0f946fe 100644 +index 2d9ab65aee0..378deb321d9 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -31,6 +31,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); @@ -46,7 +46,7 @@ index 2601438260..dac0f946fe 100644 static int ping_sent; -@@ -76,6 +77,8 @@ at_command (grub_uint8_t data) +@@ -86,6 +87,8 @@ at_command (grub_uint8_t data) break; return 0; } @@ -55,7 +55,7 @@ index 2601438260..dac0f946fe 100644 return (i != GRUB_AT_TRIES); } -@@ -105,6 +108,21 @@ grub_keyboard_controller_read (void) +@@ -115,6 +118,21 @@ grub_keyboard_controller_read (void) #endif @@ -77,7 +77,7 @@ index 2601438260..dac0f946fe 100644 static int write_mode (int mode) { -@@ -113,11 +131,14 @@ write_mode (int mode) +@@ -123,11 +141,14 @@ write_mode (int mode) { grub_uint8_t ack; keyboard_controller_wait_until_ready (); @@ -92,7 +92,7 @@ index 2601438260..dac0f946fe 100644 if (ack == GRUB_AT_NACK) continue; if (ack == GRUB_AT_ACK) -@@ -125,6 +146,9 @@ write_mode (int mode) +@@ -135,6 +156,9 @@ write_mode (int mode) return 0; } @@ -102,7 +102,7 @@ index 2601438260..dac0f946fe 100644 return (i != GRUB_AT_TRIES); } -@@ -132,31 +156,66 @@ static int +@@ -142,31 +166,66 @@ static int query_mode (void) { grub_uint8_t ret; @@ -189,7 +189,7 @@ index 2601438260..dac0f946fe 100644 return 0; } -@@ -165,14 +224,25 @@ set_scancodes (void) +@@ -175,14 +234,25 @@ set_scancodes (void) { /* You must have visited computer museum. Keyboard without scancode set knowledge. Assume XT. */ @@ -219,7 +219,7 @@ index 2601438260..dac0f946fe 100644 if ((grub_keyboard_controller_orig & KEYBOARD_AT_TRANSLATE) == KEYBOARD_AT_TRANSLATE) { grub_dprintf ("atkeyb", "queried set is %d but keyboard in Translate mode, so actually in set 1\n", grub_keyboard_orig_set); ps2_state.current_set = 1; -@@ -261,6 +331,7 @@ grub_at_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused))) +@@ -271,6 +341,7 @@ grub_at_keyboard_getkey (struct grub_term_input *term __attribute__ ((unused))) static void grub_keyboard_controller_init (void) { @@ -227,7 +227,7 @@ index 2601438260..dac0f946fe 100644 ps2_state.at_keyboard_status = 0; /* Drain input buffer. */ while (1) -@@ -282,6 +353,7 @@ grub_keyboard_controller_init (void) +@@ -292,6 +363,7 @@ grub_keyboard_controller_init (void) grub_keyboard_controller_orig = grub_keyboard_controller_read (); grub_dprintf ("atkeyb", "grub_keyboard_controller_orig = 0x%x\n", grub_keyboard_controller_orig); grub_keyboard_orig_set = query_mode (); @@ -235,7 +235,7 @@ index 2601438260..dac0f946fe 100644 #endif set_scancodes (); keyboard_controller_led (ps2_state.led_status); -@@ -329,7 +401,6 @@ grub_at_restore_hw (void) +@@ -339,7 +411,6 @@ grub_at_restore_hw (void) return GRUB_ERR_NONE; } diff --git a/0155-Add-suport-for-signing-grub-with-an-appended-signatu.patch b/0132-Add-suport-for-signing-grub-with-an-appended-signatu.patch similarity index 86% rename from 0155-Add-suport-for-signing-grub-with-an-appended-signatu.patch rename to 0132-Add-suport-for-signing-grub-with-an-appended-signatu.patch index 81660d4..c9a45b1 100644 --- a/0155-Add-suport-for-signing-grub-with-an-appended-signatu.patch +++ b/0132-Add-suport-for-signing-grub-with-an-appended-signatu.patch @@ -34,19 +34,19 @@ under this scheme. Signed-off-by: Daniel Axtens Signed-off-by: Rashmica Gupta --- - util/grub-install-common.c | 18 ++++++++++++++---- + util/grub-install-common.c | 14 ++++++++++++-- util/grub-mkimage.c | 15 +++++++++++++-- util/grub-mkimagexx.c | 39 ++++++++++++++++++++++++++++++++++++++- util/mkimage.c | 13 +++++++------ include/grub/util/install.h | 8 ++++++-- include/grub/util/mkimage.h | 4 ++-- - 6 files changed, 80 insertions(+), 17 deletions(-) + 6 files changed, 78 insertions(+), 15 deletions(-) diff --git a/util/grub-install-common.c b/util/grub-install-common.c -index 4e212e690c..a74fee16e2 100644 +index ce854d86f86..1fa0f7f6f00 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c -@@ -461,10 +461,12 @@ static size_t npubkeys; +@@ -466,10 +466,12 @@ static size_t npubkeys; static char *sbat; static int disable_shim_lock; static grub_compression_t compression; @@ -58,8 +58,8 @@ index 4e212e690c..a74fee16e2 100644 + const char *end; switch (key) { - case 'C': -@@ -562,6 +564,12 @@ grub_install_parse (int key, char *arg) + case GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS: +@@ -567,6 +569,12 @@ grub_install_parse (int key, char *arg) grub_util_error (_("Unrecognized compression `%s'"), arg); case GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE: return 1; @@ -72,24 +72,20 @@ index 4e212e690c..a74fee16e2 100644 default: return 0; } -@@ -661,11 +669,13 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, - " --output '%s' " - " --dtb '%s' " - "--sbat '%s' " -- "--format '%s' --compression '%s' %s %s %s\n", -+ "--format '%s' --compression '%s' " -+ "--appended-signature-size %zu %s %s %s\n", - dir, prefix, - outname, dtb ? : "", sbat ? : "", mkimage_target, -- compnames[compression], note ? "--note" : "", -- disable_shim_lock ? "--disable-shim-lock" : "", s); -+ compnames[compression], appsig_size, -+ disable_shim_lock ? "--disable-shim-lock" : "", -+ note ? "--note" : "", s); - free (s); +@@ -679,9 +687,11 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, + *p = '\0'; - tgt = grub_install_get_image_target (mkimage_target); -@@ -675,7 +685,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, + grub_util_info ("grub-mkimage --directory '%s' --prefix '%s' --output '%s'" +- " --format '%s' --compression '%s'%s%s%s\n", ++ " --format '%s' --compression '%s'" ++ " --appended-signture-size %zu %s%s%s\n", + dir, prefix, outname, + mkimage_target, compnames[compression], ++ appsig_size, + note ? " --note" : "", + disable_shim_lock ? " --disable-shim-lock" : "", s); + free (s); +@@ -693,7 +703,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, @@ -99,7 +95,7 @@ index 4e212e690c..a74fee16e2 100644 while (dc--) grub_install_pop_module (); diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c -index c0d5599370..8a53310548 100644 +index c0d55993702..8a53310548b 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -84,6 +84,7 @@ static struct argp_option options[] = { @@ -153,10 +149,10 @@ index c0d5599370..8a53310548 100644 if (grub_util_file_sync (fp) < 0) grub_util_error (_("cannot sync `%s': %s"), arguments.output ? : "stdout", diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c -index d78fa3e533..393119486d 100644 +index e50b29533c6..9488f052510 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c -@@ -84,6 +84,15 @@ struct grub_ieee1275_note +@@ -85,6 +85,15 @@ struct grub_ieee1275_note struct grub_ieee1275_note_desc descriptor; }; @@ -172,7 +168,7 @@ index d78fa3e533..393119486d 100644 #define GRUB_XEN_NOTE_NAME "Xen" struct fixup_block_list -@@ -207,7 +216,7 @@ grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr) +@@ -208,7 +217,7 @@ 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, @@ -181,7 +177,7 @@ index d78fa3e533..393119486d 100644 Elf_Addr target_addr, struct grub_mkimage_layout *layout) { -@@ -221,6 +230,12 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc +@@ -222,6 +231,12 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc int shnum = 4; int string_size = sizeof (".text") + sizeof ("mods") + 1; @@ -194,7 +190,7 @@ index d78fa3e533..393119486d 100644 if (image_target->id != IMAGE_LOONGSON_ELF) phnum += 2; -@@ -484,6 +499,28 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc +@@ -485,6 +500,28 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc phdr->p_offset = grub_host_to_target32 (header_size + program_size); } @@ -224,10 +220,10 @@ index d78fa3e533..393119486d 100644 char *str_start = (elf_img + sizeof (*ehdr) + phnum * sizeof (*phdr) + shnum * sizeof (*shdr)); diff --git a/util/mkimage.c b/util/mkimage.c -index a26cf76f72..bab1227601 100644 +index 4237383acaf..d33838bec6b 100644 --- a/util/mkimage.c +++ b/util/mkimage.c -@@ -869,8 +869,9 @@ grub_install_generate_image (const char *dir, const char *prefix, +@@ -885,8 +885,9 @@ 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, @@ -239,7 +235,7 @@ index a26cf76f72..bab1227601 100644 { char *kernel_img, *core_img; size_t total_module_size, core_size; -@@ -1773,11 +1774,11 @@ grub_install_generate_image (const char *dir, const char *prefix, +@@ -1810,11 +1811,11 @@ grub_install_generate_image (const char *dir, const char *prefix, else target_addr = image_target->link_addr; if (image_target->voidp_sizeof == 4) @@ -256,7 +252,7 @@ index a26cf76f72..bab1227601 100644 break; } diff --git a/include/grub/util/install.h b/include/grub/util/install.h -index 7df3191f47..cf4531e02b 100644 +index 35cf17a8d93..2720428602b 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -67,6 +67,9 @@ @@ -269,7 +265,7 @@ index 7df3191f47..cf4531e02b 100644 { "verbose", 'v', 0, 0, \ N_("print verbose messages."), 1 } -@@ -128,7 +131,8 @@ enum grub_install_options { +@@ -129,7 +132,8 @@ enum grub_install_options { GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS, GRUB_INSTALL_OPTIONS_DTB, GRUB_INSTALL_OPTIONS_SBAT, @@ -279,7 +275,7 @@ index 7df3191f47..cf4531e02b 100644 }; extern char *grub_install_source_directory; -@@ -188,7 +192,7 @@ grub_install_generate_image (const char *dir, const char *prefix, +@@ -189,7 +193,7 @@ grub_install_generate_image (const char *dir, const char *prefix, size_t npubkeys, char *config_path, const struct grub_install_image_target_desc *image_target, @@ -289,7 +285,7 @@ index 7df3191f47..cf4531e02b 100644 const char *sbat_path, const int disable_shim_lock); diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h -index 3819a67441..6f1da89b9b 100644 +index 3819a67441c..6f1da89b9b6 100644 --- a/include/grub/util/mkimage.h +++ b/include/grub/util/mkimage.h @@ -51,12 +51,12 @@ grub_mkimage_load_image64 (const char *kernel_path, diff --git a/0156-docs-grub-Document-signing-grub-under-UEFI.patch b/0133-docs-grub-Document-signing-grub-under-UEFI.patch similarity index 92% rename from 0156-docs-grub-Document-signing-grub-under-UEFI.patch rename to 0133-docs-grub-Document-signing-grub-under-UEFI.patch index f2b5c17..69c352d 100644 --- a/0156-docs-grub-Document-signing-grub-under-UEFI.patch +++ b/0133-docs-grub-Document-signing-grub-under-UEFI.patch @@ -13,10 +13,10 @@ Signed-off-by: Daniel Axtens 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/grub.texi b/docs/grub.texi -index 4870faaa00..365d1d6931 100644 +index 1e577d2fee9..30d4046a931 100644 --- a/docs/grub.texi +++ b/docs/grub.texi -@@ -5817,6 +5817,7 @@ environment variables and commands are listed in the same order. +@@ -6403,6 +6403,7 @@ environment variables and commands are listed in the same order. * Secure Boot Advanced Targeting:: Embedded information for generation number based revocation * Measured Boot:: Measuring boot components * Lockdown:: Lockdown when booting on a secure setup @@ -24,7 +24,7 @@ index 4870faaa00..365d1d6931 100644 @end menu @node Authentication and authorisation -@@ -5895,7 +5896,7 @@ commands. +@@ -6481,7 +6482,7 @@ commands. GRUB's @file{core.img} can optionally provide enforcement that all files subsequently read from disk are covered by a valid digital signature. @@ -33,7 +33,7 @@ index 4870faaa00..365d1d6931 100644 platform's firmware (e.g., Coreboot) validates @file{core.img}. If environment variable @code{check_signatures} -@@ -6067,6 +6068,25 @@ be restricted and some operations/commands cannot be executed. +@@ -6654,6 +6655,25 @@ be restricted and some operations/commands cannot be executed. The @samp{lockdown} variable is set to @samp{y} when the GRUB is locked down. Otherwise it does not exit. diff --git a/0157-docs-grub-Document-signing-grub-with-an-appended-sig.patch b/0134-docs-grub-Document-signing-grub-with-an-appended-sig.patch similarity index 95% rename from 0157-docs-grub-Document-signing-grub-with-an-appended-sig.patch rename to 0134-docs-grub-Document-signing-grub-with-an-appended-sig.patch index ee3d659..e5c6320 100644 --- a/0157-docs-grub-Document-signing-grub-with-an-appended-sig.patch +++ b/0134-docs-grub-Document-signing-grub-with-an-appended-sig.patch @@ -13,10 +13,10 @@ Signed-off-by: Daniel Axtens 1 file changed, 42 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi -index 365d1d6931..afbde7c1f7 100644 +index 30d4046a931..0ac0a1b3735 100644 --- a/docs/grub.texi +++ b/docs/grub.texi -@@ -6087,6 +6087,48 @@ image works under UEFI secure boot and can maintain the secure-boot chain. It +@@ -6674,6 +6674,48 @@ image works under UEFI secure boot and can maintain the secure-boot chain. It will also be necessary to enrol the public key used into a relevant firmware key database. diff --git a/0158-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch b/0135-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch similarity index 92% rename from 0158-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch rename to 0135-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch index b23ce49..c25927d 100644 --- a/0158-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch +++ b/0135-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch @@ -16,10 +16,10 @@ Signed-off-by: Daniel Axtens 1 file changed, 11 insertions(+) diff --git a/include/grub/dl.h b/include/grub/dl.h -index 2f76e6b043..20d870f2a4 100644 +index 8a3d188d1d1..3f10e27d62c 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h -@@ -245,11 +245,22 @@ grub_dl_get (const char *name) +@@ -244,11 +244,22 @@ grub_dl_get (const char *name) return 0; } diff --git a/0159-pgp-factor-out-rsa_pad.patch b/0136-pgp-factor-out-rsa_pad.patch similarity index 97% rename from 0159-pgp-factor-out-rsa_pad.patch rename to 0136-pgp-factor-out-rsa_pad.patch index 43fd882..6e629a4 100644 --- a/0159-pgp-factor-out-rsa_pad.patch +++ b/0136-pgp-factor-out-rsa_pad.patch @@ -27,10 +27,10 @@ Signed-off-by: Daniel Axtens create mode 100644 include/grub/pkcs1_v15.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index dc9fea6f44..64cc758835 100644 +index 4aa20cdfc13..82f2e169ad1 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -2511,6 +2511,14 @@ module = { +@@ -2568,6 +2568,14 @@ module = { cppflags = '$(CPPFLAGS_GCRY)'; }; @@ -46,7 +46,7 @@ index dc9fea6f44..64cc758835 100644 name = all_video; common = lib/fake_module.c; diff --git a/grub-core/commands/pgp.c b/grub-core/commands/pgp.c -index 5daa1e9d00..2408db4994 100644 +index c6766f044aa..b084dc9a22f 100644 --- a/grub-core/commands/pgp.c +++ b/grub-core/commands/pgp.c @@ -24,6 +24,7 @@ @@ -93,7 +93,7 @@ index 5daa1e9d00..2408db4994 100644 struct grub_pubkey_context diff --git a/grub-core/lib/pkcs1_v15.c b/grub-core/lib/pkcs1_v15.c new file mode 100644 -index 0000000000..dbacd563d0 +index 00000000000..dbacd563d01 --- /dev/null +++ b/grub-core/lib/pkcs1_v15.c @@ -0,0 +1,59 @@ @@ -158,7 +158,7 @@ index 0000000000..dbacd563d0 +} diff --git a/include/grub/pkcs1_v15.h b/include/grub/pkcs1_v15.h new file mode 100644 -index 0000000000..5c338c84a1 +index 00000000000..5c338c84a15 --- /dev/null +++ b/include/grub/pkcs1_v15.h @@ -0,0 +1,27 @@ diff --git a/0160-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch b/0137-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch similarity index 96% rename from 0160-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch rename to 0137-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch index 541474e..732b91c 100644 --- a/0160-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch +++ b/0137-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch @@ -40,7 +40,7 @@ Signed-off-by: Daniel Axtens 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/commands/pgp.c b/grub-core/commands/pgp.c -index 2408db4994..355a43844a 100644 +index b084dc9a22f..a45c2213c4a 100644 --- a/grub-core/commands/pgp.c +++ b/grub-core/commands/pgp.c @@ -147,10 +147,6 @@ const char *hashes[] = { @@ -55,7 +55,7 @@ index 2408db4994..355a43844a 100644 dsa_pad (gcry_mpi_t *hmpi, grub_uint8_t *hval, const gcry_md_spec_t *hash, struct grub_public_subkey *sk); diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c -index ca334d5a40..c578128a59 100644 +index 396f7641080..d53ddbe2c44 100644 --- a/grub-core/lib/crypto.c +++ b/grub-core/lib/crypto.c @@ -121,6 +121,10 @@ grub_md_unregister (gcry_md_spec_t *cipher) diff --git a/0161-posix_wrap-tweaks-in-preparation-for-libtasn1.patch b/0138-posix_wrap-tweaks-in-preparation-for-libtasn1.patch similarity index 89% rename from 0161-posix_wrap-tweaks-in-preparation-for-libtasn1.patch rename to 0138-posix_wrap-tweaks-in-preparation-for-libtasn1.patch index 3176f1b..a473c1d 100644 --- a/0161-posix_wrap-tweaks-in-preparation-for-libtasn1.patch +++ b/0138-posix_wrap-tweaks-in-preparation-for-libtasn1.patch @@ -23,10 +23,10 @@ Signed-off-by: Daniel Axtens 3 files changed, 10 insertions(+) diff --git a/grub-core/lib/posix_wrap/limits.h b/grub-core/lib/posix_wrap/limits.h -index 7217138ffd..591dbf3289 100644 +index 26918c8a01b..4be7b408063 100644 --- a/grub-core/lib/posix_wrap/limits.h +++ b/grub-core/lib/posix_wrap/limits.h -@@ -37,5 +37,6 @@ +@@ -41,5 +41,6 @@ #define LONG_MAX GRUB_LONG_MAX #define CHAR_BIT 8 @@ -34,11 +34,11 @@ index 7217138ffd..591dbf3289 100644 #endif diff --git a/grub-core/lib/posix_wrap/stdlib.h b/grub-core/lib/posix_wrap/stdlib.h -index 7a8d385e97..4634db09f2 100644 +index f5279756abe..14e4efdd0d6 100644 --- a/grub-core/lib/posix_wrap/stdlib.h +++ b/grub-core/lib/posix_wrap/stdlib.h -@@ -58,4 +58,12 @@ abs (int c) - return (c >= 0) ? c : -c; +@@ -64,4 +64,12 @@ abort (void) + grub_abort (); } +#define strtol grub_strtol @@ -51,10 +51,10 @@ index 7a8d385e97..4634db09f2 100644 + #endif diff --git a/grub-core/lib/posix_wrap/sys/types.h b/grub-core/lib/posix_wrap/sys/types.h -index 854eb0122e..f63412c8da 100644 +index eeda543c47e..2f3e865495a 100644 --- a/grub-core/lib/posix_wrap/sys/types.h +++ b/grub-core/lib/posix_wrap/sys/types.h -@@ -51,6 +51,7 @@ typedef grub_uint8_t byte; +@@ -50,6 +50,7 @@ typedef grub_uint8_t byte; typedef grub_addr_t uintptr_t; #define SIZEOF_UNSIGNED_LONG GRUB_CPU_SIZEOF_LONG diff --git a/0162-libtasn1-import-libtasn1-4.16.0.patch b/0139-libtasn1-import-libtasn1-4.16.0.patch similarity index 99% rename from 0162-libtasn1-import-libtasn1-4.16.0.patch rename to 0139-libtasn1-import-libtasn1-4.16.0.patch index 9587661..89552c8 100644 --- a/0162-libtasn1-import-libtasn1-4.16.0.patch +++ b/0139-libtasn1-import-libtasn1-4.16.0.patch @@ -53,7 +53,7 @@ Signed-off-by: Daniel Axtens diff --git a/grub-core/lib/libtasn1/lib/coding.c b/grub-core/lib/libtasn1/lib/coding.c new file mode 100644 -index 0000000000..245ea64cf0 +index 00000000000..245ea64cf0a --- /dev/null +++ b/grub-core/lib/libtasn1/lib/coding.c @@ -0,0 +1,1415 @@ @@ -1474,7 +1474,7 @@ index 0000000000..245ea64cf0 +} diff --git a/grub-core/lib/libtasn1/lib/decoding.c b/grub-core/lib/libtasn1/lib/decoding.c new file mode 100644 -index 0000000000..ff04eb778c +index 00000000000..ff04eb778cb --- /dev/null +++ b/grub-core/lib/libtasn1/lib/decoding.c @@ -0,0 +1,2478 @@ @@ -3958,7 +3958,7 @@ index 0000000000..ff04eb778c +} diff --git a/grub-core/lib/libtasn1/lib/element.c b/grub-core/lib/libtasn1/lib/element.c new file mode 100644 -index 0000000000..997eb2725d +index 00000000000..997eb2725dc --- /dev/null +++ b/grub-core/lib/libtasn1/lib/element.c @@ -0,0 +1,1111 @@ @@ -5075,7 +5075,7 @@ index 0000000000..997eb2725d +} diff --git a/grub-core/lib/libtasn1/lib/errors.c b/grub-core/lib/libtasn1/lib/errors.c new file mode 100644 -index 0000000000..cee74daf79 +index 00000000000..cee74daf795 --- /dev/null +++ b/grub-core/lib/libtasn1/lib/errors.c @@ -0,0 +1,100 @@ @@ -5181,7 +5181,7 @@ index 0000000000..cee74daf79 +} diff --git a/grub-core/lib/libtasn1/lib/gstr.c b/grub-core/lib/libtasn1/lib/gstr.c new file mode 100644 -index 0000000000..e91a3a151c +index 00000000000..e91a3a151c0 --- /dev/null +++ b/grub-core/lib/libtasn1/lib/gstr.c @@ -0,0 +1,74 @@ @@ -5261,7 +5261,7 @@ index 0000000000..e91a3a151c +} diff --git a/grub-core/lib/libtasn1/lib/parser_aux.c b/grub-core/lib/libtasn1/lib/parser_aux.c new file mode 100644 -index 0000000000..d5dbbf8765 +index 00000000000..d5dbbf8765d --- /dev/null +++ b/grub-core/lib/libtasn1/lib/parser_aux.c @@ -0,0 +1,1173 @@ @@ -6440,7 +6440,7 @@ index 0000000000..d5dbbf8765 +} diff --git a/grub-core/lib/libtasn1/lib/structure.c b/grub-core/lib/libtasn1/lib/structure.c new file mode 100644 -index 0000000000..8189c56a4c +index 00000000000..8189c56a4c9 --- /dev/null +++ b/grub-core/lib/libtasn1/lib/structure.c @@ -0,0 +1,1220 @@ @@ -7666,7 +7666,7 @@ index 0000000000..8189c56a4c +} diff --git a/grub-core/lib/libtasn1/lib/element.h b/grub-core/lib/libtasn1/lib/element.h new file mode 100644 -index 0000000000..440a33f4bb +index 00000000000..440a33f4bb1 --- /dev/null +++ b/grub-core/lib/libtasn1/lib/element.h @@ -0,0 +1,40 @@ @@ -7712,7 +7712,7 @@ index 0000000000..440a33f4bb +#endif diff --git a/grub-core/lib/libtasn1/lib/gstr.h b/grub-core/lib/libtasn1/lib/gstr.h new file mode 100644 -index 0000000000..48229844ff +index 00000000000..48229844ff3 --- /dev/null +++ b/grub-core/lib/libtasn1/lib/gstr.h @@ -0,0 +1,47 @@ @@ -7765,7 +7765,7 @@ index 0000000000..48229844ff +#endif /* GSTR_H */ diff --git a/grub-core/lib/libtasn1/lib/int.h b/grub-core/lib/libtasn1/lib/int.h new file mode 100644 -index 0000000000..ea1625786c +index 00000000000..ea1625786c1 --- /dev/null +++ b/grub-core/lib/libtasn1/lib/int.h @@ -0,0 +1,221 @@ @@ -7992,7 +7992,7 @@ index 0000000000..ea1625786c +#endif /* INT_H */ diff --git a/grub-core/lib/libtasn1/lib/parser_aux.h b/grub-core/lib/libtasn1/lib/parser_aux.h new file mode 100644 -index 0000000000..598e684b35 +index 00000000000..598e684b355 --- /dev/null +++ b/grub-core/lib/libtasn1/lib/parser_aux.h @@ -0,0 +1,172 @@ @@ -8170,7 +8170,7 @@ index 0000000000..598e684b35 +#endif diff --git a/grub-core/lib/libtasn1/lib/structure.h b/grub-core/lib/libtasn1/lib/structure.h new file mode 100644 -index 0000000000..99e685da07 +index 00000000000..99e685da07a --- /dev/null +++ b/grub-core/lib/libtasn1/lib/structure.h @@ -0,0 +1,45 @@ @@ -8221,7 +8221,7 @@ index 0000000000..99e685da07 +#endif diff --git a/include/grub/libtasn1.h b/include/grub/libtasn1.h new file mode 100644 -index 0000000000..6fd7a30dc3 +index 00000000000..6fd7a30dc35 --- /dev/null +++ b/include/grub/libtasn1.h @@ -0,0 +1,588 @@ @@ -8815,7 +8815,7 @@ index 0000000000..6fd7a30dc3 +#endif /* LIBTASN1_H */ diff --git a/grub-core/lib/libtasn1/LICENSE b/grub-core/lib/libtasn1/LICENSE new file mode 100644 -index 0000000000..e8b3628db9 +index 00000000000..e8b3628db9b --- /dev/null +++ b/grub-core/lib/libtasn1/LICENSE @@ -0,0 +1,16 @@ @@ -8837,7 +8837,7 @@ index 0000000000..e8b3628db9 +note that the range specifies every single year in that closed interval. diff --git a/grub-core/lib/libtasn1/README.md b/grub-core/lib/libtasn1/README.md new file mode 100644 -index 0000000000..50a8642296 +index 00000000000..50a8642296c --- /dev/null +++ b/grub-core/lib/libtasn1/README.md @@ -0,0 +1,91 @@ diff --git a/0163-libtasn1-disable-code-not-needed-in-grub.patch b/0140-libtasn1-disable-code-not-needed-in-grub.patch similarity index 97% rename from 0163-libtasn1-disable-code-not-needed-in-grub.patch rename to 0140-libtasn1-disable-code-not-needed-in-grub.patch index 84dcbf0..00f5588 100644 --- a/0163-libtasn1-disable-code-not-needed-in-grub.patch +++ b/0140-libtasn1-disable-code-not-needed-in-grub.patch @@ -25,7 +25,7 @@ Signed-off-by: Daniel Axtens 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/grub-core/lib/libtasn1/lib/coding.c b/grub-core/lib/libtasn1/lib/coding.c -index 245ea64cf0..52def59836 100644 +index 245ea64cf0a..52def598368 100644 --- a/grub-core/lib/libtasn1/lib/coding.c +++ b/grub-core/lib/libtasn1/lib/coding.c @@ -30,11 +30,11 @@ @@ -99,7 +99,7 @@ index 245ea64cf0..52def59836 100644 +#endif \ No newline at end of file diff --git a/grub-core/lib/libtasn1/lib/decoding.c b/grub-core/lib/libtasn1/lib/decoding.c -index ff04eb778c..42f9a92b5d 100644 +index ff04eb778cb..42f9a92b5d4 100644 --- a/grub-core/lib/libtasn1/lib/decoding.c +++ b/grub-core/lib/libtasn1/lib/decoding.c @@ -1613,6 +1613,7 @@ asn1_der_decoding (asn1_node * element, const void *ider, int ider_len, @@ -119,7 +119,7 @@ index ff04eb778c..42f9a92b5d 100644 /** * asn1_der_decoding_startEnd: diff --git a/grub-core/lib/libtasn1/lib/element.c b/grub-core/lib/libtasn1/lib/element.c -index 997eb2725d..539008d8e9 100644 +index 997eb2725dc..539008d8e94 100644 --- a/grub-core/lib/libtasn1/lib/element.c +++ b/grub-core/lib/libtasn1/lib/element.c @@ -191,7 +191,7 @@ _asn1_append_sequence_set (asn1_node node, struct node_tail_cache_st *pcache) @@ -141,7 +141,7 @@ index 997eb2725d..539008d8e9 100644 #define PUT_VALUE( ptr, ptr_size, data, data_size) \ *len = data_size; \ diff --git a/grub-core/lib/libtasn1/lib/errors.c b/grub-core/lib/libtasn1/lib/errors.c -index cee74daf79..42785e8622 100644 +index cee74daf795..42785e8622b 100644 --- a/grub-core/lib/libtasn1/lib/errors.c +++ b/grub-core/lib/libtasn1/lib/errors.c @@ -57,6 +57,8 @@ static const libtasn1_error_entry error_algorithms[] = { @@ -162,7 +162,7 @@ index cee74daf79..42785e8622 100644 /** * asn1_strerror: diff --git a/grub-core/lib/libtasn1/lib/structure.c b/grub-core/lib/libtasn1/lib/structure.c -index 8189c56a4c..fcfde01a39 100644 +index 8189c56a4c9..fcfde01a393 100644 --- a/grub-core/lib/libtasn1/lib/structure.c +++ b/grub-core/lib/libtasn1/lib/structure.c @@ -76,7 +76,7 @@ _asn1_find_left (asn1_node_const node) @@ -218,7 +218,7 @@ index 8189c56a4c..fcfde01a39 100644 /** * asn1_dup_node: diff --git a/include/grub/libtasn1.h b/include/grub/libtasn1.h -index 6fd7a30dc3..785eda2ae3 100644 +index 6fd7a30dc35..785eda2ae3f 100644 --- a/include/grub/libtasn1.h +++ b/include/grub/libtasn1.h @@ -319,6 +319,8 @@ typedef struct asn1_data_node_st asn1_data_node_st; diff --git a/0164-libtasn1-changes-for-grub-compatibility.patch b/0141-libtasn1-changes-for-grub-compatibility.patch similarity index 96% rename from 0164-libtasn1-changes-for-grub-compatibility.patch rename to 0141-libtasn1-changes-for-grub-compatibility.patch index 7c756bd..9b2275c 100644 --- a/0164-libtasn1-changes-for-grub-compatibility.patch +++ b/0141-libtasn1-changes-for-grub-compatibility.patch @@ -35,7 +35,7 @@ Signed-off-by: Daniel Axtens 6 files changed, 22 insertions(+), 33 deletions(-) diff --git a/grub-core/lib/libtasn1/lib/decoding.c b/grub-core/lib/libtasn1/lib/decoding.c -index 42f9a92b5d..7856858b27 100644 +index 42f9a92b5d4..7856858b272 100644 --- a/grub-core/lib/libtasn1/lib/decoding.c +++ b/grub-core/lib/libtasn1/lib/decoding.c @@ -32,7 +32,8 @@ @@ -71,7 +71,7 @@ index 42f9a92b5d..7856858b27 100644 result = asn1_create_element (definitions, name, &aux); if (result == ASN1_SUCCESS) diff --git a/grub-core/lib/libtasn1/lib/element.c b/grub-core/lib/libtasn1/lib/element.c -index 539008d8e9..ed761ff56b 100644 +index 539008d8e94..ed761ff56bd 100644 --- a/grub-core/lib/libtasn1/lib/element.c +++ b/grub-core/lib/libtasn1/lib/element.c @@ -30,9 +30,10 @@ @@ -87,7 +87,7 @@ index 539008d8e9..ed761ff56b 100644 _asn1_hierarchical_name (asn1_node_const node, char *name, int name_size) { diff --git a/grub-core/lib/libtasn1/lib/gstr.c b/grub-core/lib/libtasn1/lib/gstr.c -index e91a3a151c..e33875c2c7 100644 +index e91a3a151c0..e33875c2c7c 100644 --- a/grub-core/lib/libtasn1/lib/gstr.c +++ b/grub-core/lib/libtasn1/lib/gstr.c @@ -36,13 +36,13 @@ _asn1_str_cat (char *dest, size_t dest_tot_size, const char *src) @@ -107,7 +107,7 @@ index e91a3a151c..e33875c2c7 100644 } } diff --git a/grub-core/lib/libtasn1/lib/parser_aux.c b/grub-core/lib/libtasn1/lib/parser_aux.c -index d5dbbf8765..89c9be69dc 100644 +index d5dbbf8765d..89c9be69dc2 100644 --- a/grub-core/lib/libtasn1/lib/parser_aux.c +++ b/grub-core/lib/libtasn1/lib/parser_aux.c @@ -26,7 +26,8 @@ @@ -139,7 +139,7 @@ index d5dbbf8765..89c9be69dc 100644 temp[start + count] = '0' + (char) r; count++; diff --git a/grub-core/lib/libtasn1/lib/int.h b/grub-core/lib/libtasn1/lib/int.h -index ea1625786c..4a568efee9 100644 +index ea1625786c1..4a568efee9c 100644 --- a/grub-core/lib/libtasn1/lib/int.h +++ b/grub-core/lib/libtasn1/lib/int.h @@ -35,7 +35,7 @@ @@ -161,7 +161,7 @@ index ea1625786c..4a568efee9 100644 #if SIZEOF_UNSIGNED_LONG_INT == 8 # define _asn1_strtou64(n,e,b) strtoul((const char *) n, e, b) diff --git a/include/grub/libtasn1.h b/include/grub/libtasn1.h -index 785eda2ae3..28dbf16c4e 100644 +index 785eda2ae3f..28dbf16c4e0 100644 --- a/include/grub/libtasn1.h +++ b/include/grub/libtasn1.h @@ -38,29 +38,15 @@ diff --git a/0165-libtasn1-compile-into-asn1-module.patch b/0142-libtasn1-compile-into-asn1-module.patch similarity index 94% rename from 0165-libtasn1-compile-into-asn1-module.patch rename to 0142-libtasn1-compile-into-asn1-module.patch index 0fb433f..bdd6f63 100644 --- a/0165-libtasn1-compile-into-asn1-module.patch +++ b/0142-libtasn1-compile-into-asn1-module.patch @@ -14,12 +14,12 @@ Signed-off-by: Daniel Axtens create mode 100644 grub-core/lib/libtasn1_wrap/wrap.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 64cc758835..ea92468fa2 100644 +index 82f2e169ad1..05b976d9a77 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -2577,3 +2577,18 @@ module = { - common = commands/i386/wrmsr.c; - enable = x86; +@@ -2646,3 +2646,18 @@ module = { + efi = commands/bli.c; + enable = efi; }; + +module = { @@ -38,7 +38,7 @@ index 64cc758835..ea92468fa2 100644 +}; diff --git a/grub-core/lib/libtasn1_wrap/wrap.c b/grub-core/lib/libtasn1_wrap/wrap.c new file mode 100644 -index 0000000000..622ba942e3 +index 00000000000..622ba942e33 --- /dev/null +++ b/grub-core/lib/libtasn1_wrap/wrap.c @@ -0,0 +1,26 @@ diff --git a/0166-test_asn1-test-module-for-libtasn1.patch b/0143-test_asn1-test-module-for-libtasn1.patch similarity index 99% rename from 0166-test_asn1-test-module-for-libtasn1.patch rename to 0143-test_asn1-test-module-for-libtasn1.patch index 6cc13bd..23f4bbf 100644 --- a/0166-test_asn1-test-module-for-libtasn1.patch +++ b/0143-test_asn1-test-module-for-libtasn1.patch @@ -18,6 +18,9 @@ This doesn't test the full decoder but that will be exercised in test suites for coming patch sets. Signed-off-by: Daniel Axtens + +[pjones updated the Makefile.util.def part to have "testcase = native;" +syntax.] --- Makefile.util.def | 6 + grub-core/Makefile.core.def | 13 ++ @@ -51,27 +54,27 @@ Signed-off-by: Daniel Axtens create mode 100644 tests/test_asn1.in diff --git a/Makefile.util.def b/Makefile.util.def -index 6366442129..d04b3fe68a 100644 +index 8e52e48c780..ef344f5aa8c 100644 --- a/Makefile.util.def +++ b/Makefile.util.def -@@ -1289,6 +1289,12 @@ script = { - common = tests/syslinux_test.in; +@@ -1328,6 +1328,12 @@ script = { + common = tests/luks2_test.in; }; +script = { -+ testcase; ++ testcase = native; + name = test_asn1; + common = tests/test_asn1.in; +}; + program = { - testcase; + testcase = native; name = example_unit_test; diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index ea92468fa2..a32e6ada59 100644 +index 05b976d9a77..0e65fefb195 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -2592,3 +2592,16 @@ module = { +@@ -2661,3 +2661,16 @@ module = { // -Wno-type-limits comes from libtasn1's configure.ac cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB) -I$(srcdir)/lib/libtasn1/lib -Wno-type-limits'; }; @@ -90,7 +93,7 @@ index ea92468fa2..a32e6ada59 100644 +}; diff --git a/grub-core/lib/libtasn1_wrap/tests/CVE-2018-1000654.c b/grub-core/lib/libtasn1_wrap/tests/CVE-2018-1000654.c new file mode 100644 -index 0000000000..534e304521 +index 00000000000..534e304521e --- /dev/null +++ b/grub-core/lib/libtasn1_wrap/tests/CVE-2018-1000654.c @@ -0,0 +1,61 @@ @@ -157,7 +160,7 @@ index 0000000000..534e304521 +} diff --git a/grub-core/lib/libtasn1_wrap/tests/Test_overflow.c b/grub-core/lib/libtasn1_wrap/tests/Test_overflow.c new file mode 100644 -index 0000000000..f48aea0ef8 +index 00000000000..f48aea0ef8b --- /dev/null +++ b/grub-core/lib/libtasn1_wrap/tests/Test_overflow.c @@ -0,0 +1,138 @@ @@ -301,7 +304,7 @@ index 0000000000..f48aea0ef8 +} diff --git a/grub-core/lib/libtasn1_wrap/tests/Test_simple.c b/grub-core/lib/libtasn1_wrap/tests/Test_simple.c new file mode 100644 -index 0000000000..9f01006ddf +index 00000000000..9f01006ddf4 --- /dev/null +++ b/grub-core/lib/libtasn1_wrap/tests/Test_simple.c @@ -0,0 +1,207 @@ @@ -514,7 +517,7 @@ index 0000000000..9f01006ddf +} diff --git a/grub-core/lib/libtasn1_wrap/tests/Test_strings.c b/grub-core/lib/libtasn1_wrap/tests/Test_strings.c new file mode 100644 -index 0000000000..dbe1474b20 +index 00000000000..dbe1474b204 --- /dev/null +++ b/grub-core/lib/libtasn1_wrap/tests/Test_strings.c @@ -0,0 +1,150 @@ @@ -670,7 +673,7 @@ index 0000000000..dbe1474b20 +} diff --git a/grub-core/lib/libtasn1_wrap/tests/object-id-decoding.c b/grub-core/lib/libtasn1_wrap/tests/object-id-decoding.c new file mode 100644 -index 0000000000..d367bbfb5a +index 00000000000..d367bbfb5a7 --- /dev/null +++ b/grub-core/lib/libtasn1_wrap/tests/object-id-decoding.c @@ -0,0 +1,116 @@ @@ -792,7 +795,7 @@ index 0000000000..d367bbfb5a +} diff --git a/grub-core/lib/libtasn1_wrap/tests/object-id-encoding.c b/grub-core/lib/libtasn1_wrap/tests/object-id-encoding.c new file mode 100644 -index 0000000000..3a83b58c59 +index 00000000000..3a83b58c59f --- /dev/null +++ b/grub-core/lib/libtasn1_wrap/tests/object-id-encoding.c @@ -0,0 +1,120 @@ @@ -918,7 +921,7 @@ index 0000000000..3a83b58c59 +} diff --git a/grub-core/lib/libtasn1_wrap/tests/octet-string.c b/grub-core/lib/libtasn1_wrap/tests/octet-string.c new file mode 100644 -index 0000000000..d8a049e8df +index 00000000000..d8a049e8df0 --- /dev/null +++ b/grub-core/lib/libtasn1_wrap/tests/octet-string.c @@ -0,0 +1,211 @@ @@ -1135,7 +1138,7 @@ index 0000000000..d8a049e8df +} diff --git a/grub-core/lib/libtasn1_wrap/tests/reproducers.c b/grub-core/lib/libtasn1_wrap/tests/reproducers.c new file mode 100644 -index 0000000000..dc7268d4c6 +index 00000000000..dc7268d4c6c --- /dev/null +++ b/grub-core/lib/libtasn1_wrap/tests/reproducers.c @@ -0,0 +1,81 @@ @@ -1222,7 +1225,7 @@ index 0000000000..dc7268d4c6 +} diff --git a/grub-core/lib/libtasn1_wrap/wrap_tests.c b/grub-core/lib/libtasn1_wrap/wrap_tests.c new file mode 100644 -index 0000000000..75fcd21f0d +index 00000000000..75fcd21f0d5 --- /dev/null +++ b/grub-core/lib/libtasn1_wrap/wrap_tests.c @@ -0,0 +1,75 @@ @@ -1303,7 +1306,7 @@ index 0000000000..75fcd21f0d +} diff --git a/grub-core/lib/libtasn1_wrap/tests/CVE-2018-1000654-1_asn1_tab.h b/grub-core/lib/libtasn1_wrap/tests/CVE-2018-1000654-1_asn1_tab.h new file mode 100644 -index 0000000000..1e7d3d64f5 +index 00000000000..1e7d3d64f55 --- /dev/null +++ b/grub-core/lib/libtasn1_wrap/tests/CVE-2018-1000654-1_asn1_tab.h @@ -0,0 +1,32 @@ @@ -1341,7 +1344,7 @@ index 0000000000..1e7d3d64f5 +}; diff --git a/grub-core/lib/libtasn1_wrap/tests/CVE-2018-1000654-2_asn1_tab.h b/grub-core/lib/libtasn1_wrap/tests/CVE-2018-1000654-2_asn1_tab.h new file mode 100644 -index 0000000000..e2561e5ec6 +index 00000000000..e2561e5ec6d --- /dev/null +++ b/grub-core/lib/libtasn1_wrap/tests/CVE-2018-1000654-2_asn1_tab.h @@ -0,0 +1,36 @@ @@ -1383,7 +1386,7 @@ index 0000000000..e2561e5ec6 +}; diff --git a/grub-core/lib/libtasn1_wrap/wrap_tests.h b/grub-core/lib/libtasn1_wrap/wrap_tests.h new file mode 100644 -index 0000000000..555e56dd20 +index 00000000000..555e56dd202 --- /dev/null +++ b/grub-core/lib/libtasn1_wrap/wrap_tests.h @@ -0,0 +1,38 @@ @@ -1426,10 +1429,10 @@ index 0000000000..555e56dd20 + +#endif diff --git a/.gitignore b/.gitignore -index 208d1d2325..1d005887e7 100644 +index a18787dcfe6..f2e8e1e42d7 100644 --- a/.gitignore +++ b/.gitignore -@@ -264,6 +264,7 @@ widthspec.bin +@@ -268,6 +268,7 @@ widthspec.bin /stamp-h1 /syslinux_test /tar_test @@ -1439,7 +1442,7 @@ index 208d1d2325..1d005887e7 100644 /tests/syslinux/ubuntu10.04_grub.cfg diff --git a/tests/test_asn1.in b/tests/test_asn1.in new file mode 100644 -index 0000000000..8173c5c270 +index 00000000000..8173c5c270e --- /dev/null +++ b/tests/test_asn1.in @@ -0,0 +1,12 @@ diff --git a/0167-grub-install-support-embedding-x509-certificates.patch b/0144-grub-install-support-embedding-x509-certificates.patch similarity index 90% rename from 0167-grub-install-support-embedding-x509-certificates.patch rename to 0144-grub-install-support-embedding-x509-certificates.patch index c4c35f4..9ebbeb0 100644 --- a/0167-grub-install-support-embedding-x509-certificates.patch +++ b/0144-grub-install-support-embedding-x509-certificates.patch @@ -20,7 +20,7 @@ Signed-off-by: Daniel Axtens 6 files changed, 80 insertions(+), 9 deletions(-) diff --git a/grub-core/commands/pgp.c b/grub-core/commands/pgp.c -index 355a43844a..b81ac0ae46 100644 +index a45c2213c4a..847a5046a5c 100644 --- a/grub-core/commands/pgp.c +++ b/grub-core/commands/pgp.c @@ -944,7 +944,7 @@ GRUB_MOD_INIT(pgp) @@ -33,10 +33,10 @@ index 355a43844a..b81ac0ae46 100644 pseudo_file.fs = &pseudo_fs; diff --git a/util/grub-install-common.c b/util/grub-install-common.c -index a74fee16e2..c603f5b308 100644 +index 1fa0f7f6f00..b58539111da 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c -@@ -460,6 +460,8 @@ static char **pubkeys; +@@ -465,6 +465,8 @@ static char **pubkeys; static size_t npubkeys; static char *sbat; static int disable_shim_lock; @@ -45,7 +45,7 @@ index a74fee16e2..c603f5b308 100644 static grub_compression_t compression; static size_t appsig_size; -@@ -501,6 +503,12 @@ grub_install_parse (int key, char *arg) +@@ -506,6 +508,12 @@ grub_install_parse (int key, char *arg) case GRUB_INSTALL_OPTIONS_DISABLE_SHIM_LOCK: disable_shim_lock = 1; return 1; @@ -58,18 +58,18 @@ index a74fee16e2..c603f5b308 100644 case GRUB_INSTALL_OPTIONS_VERBOSITY: verbosity++; -@@ -627,6 +635,9 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, +@@ -636,6 +644,9 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, for (pk = pubkeys; pk < pubkeys + npubkeys; pk++) - slen += 20 + grub_strlen (*pk); + slen += sizeof (" --pubkey ''") + grub_strlen (*pk); + for (pk = x509keys; pk < x509keys + nx509keys; pk++) + slen += 10 + grub_strlen (*pk); + for (md = modules.entries; *md; md++) - { - slen += 10 + grub_strlen (*md); -@@ -655,6 +666,14 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, - *p++ = ' '; + slen += sizeof (" ''") + grub_strlen (*md); + +@@ -676,6 +687,14 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, + *p++ = '\''; } + for (pk = x509keys; pk < x509keys + nx509keys; pk++) @@ -82,8 +82,8 @@ index a74fee16e2..c603f5b308 100644 + for (md = modules.entries; *md; md++) { - *p++ = '\''; -@@ -684,7 +703,9 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, + *p++ = ' '; +@@ -702,7 +721,9 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, grub_install_generate_image (dir, prefix, fp, outname, modules.entries, memdisk_path, @@ -95,7 +95,7 @@ index a74fee16e2..c603f5b308 100644 disable_shim_lock); while (dc--) diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c -index 8a53310548..e1f1112784 100644 +index 8a53310548b..e1f1112784a 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -75,7 +75,8 @@ static struct argp_option options[] = { @@ -142,10 +142,10 @@ index 8a53310548..e1f1112784 100644 arguments.appsig_size, arguments.comp, arguments.dtb, arguments.sbat, diff --git a/util/mkimage.c b/util/mkimage.c -index bab1227601..8319e8dfbd 100644 +index d33838bec6b..e2bb4d4cd05 100644 --- a/util/mkimage.c +++ b/util/mkimage.c -@@ -867,7 +867,8 @@ void +@@ -883,7 +883,8 @@ void grub_install_generate_image (const char *dir, const char *prefix, FILE *out, const char *outname, char *mods[], char *memdisk_path, char **pubkey_paths, @@ -155,7 +155,7 @@ index bab1227601..8319e8dfbd 100644 const struct grub_install_image_target_desc *image_target, int note, size_t appsig_size, grub_compression_t comp, const char *dtb_path, const char *sbat_path, -@@ -913,6 +914,19 @@ grub_install_generate_image (const char *dir, const char *prefix, +@@ -929,6 +930,19 @@ grub_install_generate_image (const char *dir, const char *prefix, } } @@ -175,7 +175,7 @@ index bab1227601..8319e8dfbd 100644 if (memdisk_path) { memdisk_size = ALIGN_UP(grub_util_get_image_size (memdisk_path), 512); -@@ -1034,7 +1048,7 @@ grub_install_generate_image (const char *dir, const char *prefix, +@@ -1050,7 +1064,7 @@ grub_install_generate_image (const char *dir, const char *prefix, curs = grub_util_get_image_size (pubkey_paths[i]); header = (struct grub_module_header *) (kernel_img + offset); @@ -184,7 +184,7 @@ index bab1227601..8319e8dfbd 100644 header->size = grub_host_to_target32 (curs + sizeof (*header)); offset += sizeof (*header); -@@ -1043,6 +1057,26 @@ grub_install_generate_image (const char *dir, const char *prefix, +@@ -1059,6 +1073,26 @@ grub_install_generate_image (const char *dir, const char *prefix, } } @@ -212,7 +212,7 @@ index bab1227601..8319e8dfbd 100644 { struct grub_module_header *header; diff --git a/include/grub/kernel.h b/include/grub/kernel.h -index 55849777ea..98edc0863f 100644 +index 55849777eaa..98edc0863f6 100644 --- a/include/grub/kernel.h +++ b/include/grub/kernel.h @@ -30,7 +30,9 @@ enum @@ -227,7 +227,7 @@ index 55849777ea..98edc0863f 100644 /* The module header. */ diff --git a/include/grub/util/install.h b/include/grub/util/install.h -index cf4531e02b..51f3b13ac1 100644 +index 2720428602b..59eabb9bb86 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -67,6 +67,8 @@ @@ -239,7 +239,7 @@ index cf4531e02b..51f3b13ac1 100644 { "appended-signature-size", GRUB_INSTALL_OPTIONS_APPENDED_SIGNATURE_SIZE,\ "SIZE", 0, N_("Add a note segment reserving SIZE bytes for an appended signature"), \ 1}, \ -@@ -188,8 +190,9 @@ void +@@ -189,8 +191,9 @@ void grub_install_generate_image (const char *dir, const char *prefix, FILE *out, const char *outname, char *mods[], diff --git a/0168-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch b/0145-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch similarity index 99% rename from 0168-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch rename to 0145-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch index 0ebc6c7..7b7d70c 100644 --- a/0168-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch +++ b/0145-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch @@ -22,7 +22,7 @@ Signed-off-by: Daniel Axtens diff --git a/grub-core/commands/appendedsig/gnutls_asn1_tab.c b/grub-core/commands/appendedsig/gnutls_asn1_tab.c new file mode 100644 -index 0000000000..ddd1314e63 +index 00000000000..ddd1314e63b --- /dev/null +++ b/grub-core/commands/appendedsig/gnutls_asn1_tab.c @@ -0,0 +1,121 @@ @@ -149,7 +149,7 @@ index 0000000000..ddd1314e63 +}; diff --git a/grub-core/commands/appendedsig/pkix_asn1_tab.c b/grub-core/commands/appendedsig/pkix_asn1_tab.c new file mode 100644 -index 0000000000..adef69d95c +index 00000000000..adef69d95ce --- /dev/null +++ b/grub-core/commands/appendedsig/pkix_asn1_tab.c @@ -0,0 +1,484 @@ diff --git a/0169-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch b/0146-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch similarity index 99% rename from 0169-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch rename to 0146-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch index 5a13d5b..04bf1df 100644 --- a/0169-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch +++ b/0146-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch @@ -29,7 +29,7 @@ Signed-off-by: Daniel Axtens diff --git a/grub-core/commands/appendedsig/asn1util.c b/grub-core/commands/appendedsig/asn1util.c new file mode 100644 -index 0000000000..eff095a9df +index 00000000000..eff095a9df2 --- /dev/null +++ b/grub-core/commands/appendedsig/asn1util.c @@ -0,0 +1,102 @@ @@ -137,7 +137,7 @@ index 0000000000..eff095a9df +} diff --git a/grub-core/commands/appendedsig/pkcs7.c b/grub-core/commands/appendedsig/pkcs7.c new file mode 100644 -index 0000000000..dc6afe203f +index 00000000000..dc6afe203f7 --- /dev/null +++ b/grub-core/commands/appendedsig/pkcs7.c @@ -0,0 +1,305 @@ @@ -448,7 +448,7 @@ index 0000000000..dc6afe203f +} diff --git a/grub-core/commands/appendedsig/x509.c b/grub-core/commands/appendedsig/x509.c new file mode 100644 -index 0000000000..2b38b3670a +index 00000000000..2b38b3670a2 --- /dev/null +++ b/grub-core/commands/appendedsig/x509.c @@ -0,0 +1,958 @@ @@ -1412,7 +1412,7 @@ index 0000000000..2b38b3670a +} diff --git a/grub-core/commands/appendedsig/appendedsig.h b/grub-core/commands/appendedsig/appendedsig.h new file mode 100644 -index 0000000000..9792ef3901 +index 00000000000..9792ef3901e --- /dev/null +++ b/grub-core/commands/appendedsig/appendedsig.h @@ -0,0 +1,110 @@ diff --git a/0170-appended-signatures-support-verifying-appended-signa.patch b/0147-appended-signatures-support-verifying-appended-signa.patch similarity index 98% rename from 0170-appended-signatures-support-verifying-appended-signa.patch rename to 0147-appended-signatures-support-verifying-appended-signa.patch index 9e90d3b..0144264 100644 --- a/0170-appended-signatures-support-verifying-appended-signa.patch +++ b/0147-appended-signatures-support-verifying-appended-signa.patch @@ -30,10 +30,10 @@ Signed-off-by: Robbie Harwood create mode 100644 grub-core/commands/appendedsig/appendedsig.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index a32e6ada59..6404384d90 100644 +index 0e65fefb195..ebe98551960 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -980,6 +980,18 @@ module = { +@@ -1009,6 +1009,18 @@ module = { cppflags = '-I$(srcdir)/lib/posix_wrap'; }; @@ -54,7 +54,7 @@ index a32e6ada59..6404384d90 100644 common = commands/hdparm.c; diff --git a/grub-core/commands/appendedsig/appendedsig.c b/grub-core/commands/appendedsig/appendedsig.c new file mode 100644 -index 0000000000..bf8b18b620 +index 00000000000..1b8a8078061 --- /dev/null +++ b/grub-core/commands/appendedsig/appendedsig.c @@ -0,0 +1,645 @@ @@ -462,7 +462,7 @@ index 0000000000..bf8b18b620 + } + + return grub_error (GRUB_ERR_BAD_ARGUMENT, -+ N_("No certificate number %d found - only %d certificates in the store"), ++ N_("No certificate number %lu found - only %lu certificates in the store"), + cert_num, i - 1); +} + @@ -704,7 +704,7 @@ index 0000000000..bf8b18b620 + grub_unregister_command (cmd_distrust); +} diff --git a/include/grub/file.h b/include/grub/file.h -index 31567483cc..96827a4f89 100644 +index a5bf3a792d6..d678de06325 100644 --- a/include/grub/file.h +++ b/include/grub/file.h @@ -80,6 +80,8 @@ enum grub_file_type diff --git a/0171-appended-signatures-verification-tests.patch b/0148-appended-signatures-verification-tests.patch similarity index 99% rename from 0171-appended-signatures-verification-tests.patch rename to 0148-appended-signatures-verification-tests.patch index b39a5af..7c4ae86 100644 --- a/0171-appended-signatures-verification-tests.patch +++ b/0148-appended-signatures-verification-tests.patch @@ -17,10 +17,10 @@ Signed-off-by: Daniel Axtens create mode 100644 grub-core/tests/appended_signatures.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 6404384d90..9ea5fb38f1 100644 +index ebe98551960..c81c9107249 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -2162,6 +2162,12 @@ module = { +@@ -2211,6 +2211,12 @@ module = { common = tests/setjmp_test.c; }; @@ -35,7 +35,7 @@ index 6404384d90..9ea5fb38f1 100644 common = tests/signature_test.c; diff --git a/grub-core/tests/appended_signature_test.c b/grub-core/tests/appended_signature_test.c new file mode 100644 -index 0000000000..88a485200d +index 00000000000..88a485200d8 --- /dev/null +++ b/grub-core/tests/appended_signature_test.c @@ -0,0 +1,281 @@ @@ -321,7 +321,7 @@ index 0000000000..88a485200d + +GRUB_FUNCTIONAL_TEST (appended_signature_test, appended_signature_test); diff --git a/grub-core/tests/lib/functional_test.c b/grub-core/tests/lib/functional_test.c -index 96781fb39b..403fa5c789 100644 +index 96781fb39b5..403fa5c789a 100644 --- a/grub-core/tests/lib/functional_test.c +++ b/grub-core/tests/lib/functional_test.c @@ -73,6 +73,7 @@ grub_functional_all_tests (grub_extcmd_context_t ctxt __attribute__ ((unused)), @@ -334,7 +334,7 @@ index 96781fb39b..403fa5c789 100644 grub_dl_load ("ctz_test"); diff --git a/grub-core/tests/appended_signatures.h b/grub-core/tests/appended_signatures.h new file mode 100644 -index 0000000000..aa3dc6278e +index 00000000000..aa3dc6278e3 --- /dev/null +++ b/grub-core/tests/appended_signatures.h @@ -0,0 +1,557 @@ diff --git a/0172-appended-signatures-documentation.patch b/0149-appended-signatures-documentation.patch similarity index 91% rename from 0172-appended-signatures-documentation.patch rename to 0149-appended-signatures-documentation.patch index eb58046..c212ed3 100644 --- a/0172-appended-signatures-documentation.patch +++ b/0149-appended-signatures-documentation.patch @@ -13,10 +13,10 @@ Signed-off-by: Daniel Axtens 1 file changed, 182 insertions(+), 17 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi -index afbde7c1f7..4816be8561 100644 +index 0ac0a1b3735..eab81718a59 100644 --- a/docs/grub.texi +++ b/docs/grub.texi -@@ -3214,6 +3214,7 @@ These variables have special meaning to GRUB. +@@ -3275,6 +3275,7 @@ These variables have special meaning to GRUB. @menu * biosnum:: @@ -24,7 +24,7 @@ index afbde7c1f7..4816be8561 100644 * check_signatures:: * chosen:: * cmdpath:: -@@ -3273,11 +3274,18 @@ For an alternative approach which also changes BIOS drive mappings for the +@@ -3339,11 +3340,18 @@ For an alternative approach which also changes BIOS drive mappings for the chain-loaded system, @pxref{drivemap}. @@ -45,23 +45,23 @@ index afbde7c1f7..4816be8561 100644 @node chosen @subsection chosen -@@ -3994,6 +4002,7 @@ you forget a command, you can run the command @command{help} +@@ -4362,6 +4370,7 @@ you forget a command, you can run the command @command{help} * date:: Display or set current date and time * devicetree:: Load a device tree blob * distrust:: Remove a pubkey from trusted keys +* distrust_certificate:: Remove a certificate from the list of trusted certificates * drivemap:: Map a drive to another * echo:: Display a line of text - * eval:: Evaluate agruments as GRUB commands -@@ -4010,6 +4019,7 @@ you forget a command, you can run the command @command{help} + * efitextmode:: Set/Get text output mode resolution +@@ -4378,6 +4387,7 @@ you forget a command, you can run the command @command{help} + * hexdump:: Show raw contents of a file or memory + * insmod:: Insert a module * keystatus:: Check key modifier status - * linux:: Load a Linux kernel - * linux16:: Load a Linux kernel (16-bit mode) +* list_certificates:: List trusted certificates * list_env:: List variables in environment block * list_trusted:: List trusted public keys * load_env:: Load variables from environment block -@@ -4047,8 +4057,10 @@ you forget a command, you can run the command @command{help} +@@ -4416,8 +4426,10 @@ you forget a command, you can run the command @command{help} * test:: Check file types and compare values * true:: Do nothing, successfully * trust:: Add public key to list of trusted keys @@ -71,8 +71,8 @@ index afbde7c1f7..4816be8561 100644 +* verify_appended:: Verify appended digital signature * verify_detached:: Verify detached digital signature * videoinfo:: List available video modes - @comment * xen_*:: Xen boot commands for AArch64 -@@ -4376,9 +4388,28 @@ These keys are used to validate signatures when environment variable + * wrmsr:: Write values to model-specific registers +@@ -4757,9 +4769,28 @@ These keys are used to validate signatures when environment variable @code{check_signatures} is set to @code{enforce} (@pxref{check_signatures}), and by some invocations of @command{verify_detached} (@pxref{verify_detached}). @xref{Using @@ -102,7 +102,7 @@ index afbde7c1f7..4816be8561 100644 @node drivemap @subsection drivemap -@@ -4636,6 +4667,21 @@ This command is only available on x86 systems. +@@ -5036,6 +5067,21 @@ only if checking key modifier status is supported. @end deffn @@ -124,7 +124,7 @@ index afbde7c1f7..4816be8561 100644 @node list_env @subsection list_env -@@ -4655,7 +4701,7 @@ The output is in GPG's v4 key fingerprint format (i.e., the output of +@@ -5055,7 +5101,7 @@ The output is in GPG's v4 key fingerprint format (i.e., the output of @code{gpg --fingerprint}). The least significant four bytes (last eight hexadecimal digits) can be used as an argument to @command{distrust} (@pxref{distrust}). @@ -133,7 +133,7 @@ index afbde7c1f7..4816be8561 100644 these keys. @end deffn -@@ -4690,8 +4736,13 @@ When used with care, @option{--skip-sig} and the whitelist enable an +@@ -5090,8 +5136,13 @@ When used with care, @option{--skip-sig} and the whitelist enable an administrator to configure a system to boot only signed configurations, but to allow the user to select from among multiple configurations, and to enable ``one-shot'' boot attempts and @@ -148,7 +148,7 @@ index afbde7c1f7..4816be8561 100644 @end deffn -@@ -4987,7 +5038,7 @@ read. It is possible to modify a digitally signed environment block +@@ -5462,7 +5513,7 @@ read. It is possible to modify a digitally signed environment block file from within GRUB using this command, such that its signature will no longer be valid on subsequent boots. Care should be taken in such advanced configurations to avoid rendering the system @@ -157,7 +157,7 @@ index afbde7c1f7..4816be8561 100644 @end deffn -@@ -5387,11 +5438,32 @@ signatures when environment variable @code{check_signatures} is set to +@@ -5878,11 +5929,32 @@ signatures when environment variable @code{check_signatures} is set to must itself be properly signed. The @option{--skip-sig} option can be used to disable signature-checking when reading @var{pubkey_file} itself. It is expected that @option{--skip-sig} is useful for testing @@ -191,7 +191,7 @@ index afbde7c1f7..4816be8561 100644 @node unset @subsection unset -@@ -5410,6 +5482,18 @@ only on PC BIOS platforms. +@@ -5901,6 +5973,18 @@ only on PC BIOS platforms. @end deffn @end ignore @@ -210,7 +210,7 @@ index afbde7c1f7..4816be8561 100644 @node verify_detached @subsection verify_detached -@@ -5428,7 +5512,7 @@ tried. +@@ -5919,7 +6003,7 @@ tried. Exit code @code{$?} is set to 0 if the signature validates successfully. If validation fails, it is set to a non-zero value. @@ -219,7 +219,7 @@ index afbde7c1f7..4816be8561 100644 @end deffn @node videoinfo -@@ -5811,13 +5895,14 @@ environment variables and commands are listed in the same order. +@@ -6397,13 +6481,14 @@ environment variables and commands are listed in the same order. @chapter Security @menu @@ -241,7 +241,7 @@ index afbde7c1f7..4816be8561 100644 @end menu @node Authentication and authorisation -@@ -5891,8 +5976,8 @@ generating configuration files with authentication. You can use +@@ -6477,8 +6562,8 @@ generating configuration files with authentication. You can use adding @kbd{set superusers=} and @kbd{password} or @kbd{password_pbkdf2} commands. @@ -252,7 +252,7 @@ index afbde7c1f7..4816be8561 100644 GRUB's @file{core.img} can optionally provide enforcement that all files subsequently read from disk are covered by a valid digital signature. -@@ -5985,6 +6070,86 @@ or BIOS) configuration to cause the machine to boot from a different +@@ -6571,6 +6656,86 @@ or BIOS) configuration to cause the machine to boot from a different (attacker-controlled) device. GRUB is at best only one link in a secure boot chain. diff --git a/0149-kern-file-Fix-error-handling-in-grub_file_open.patch b/0149-kern-file-Fix-error-handling-in-grub_file_open.patch deleted file mode 100644 index e444325..0000000 --- a/0149-kern-file-Fix-error-handling-in-grub_file_open.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Steve McIntyre -Date: Tue, 6 Dec 2022 01:45:11 +0000 -Subject: [PATCH] kern/file: Fix error handling in grub_file_open() - -grub_file_open() calls grub_file_get_device_name(), but doesn't check -the return. Instead, it checks if grub_errno is set. - -However, nothing initialises grub_errno here when grub_file_open() -starts. This means that trying to open one file that doesn't exist and -then trying to open another file that does will (incorrectly) also -fail to open that second file. - -Let's fix that. - -Signed-off-by: Steve McIntyre ---- - grub-core/kern/file.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c -index 58454458c4..5b58f45cfd 100644 ---- a/grub-core/kern/file.c -+++ b/grub-core/kern/file.c -@@ -66,6 +66,9 @@ grub_file_open (const char *name, enum grub_file_type type) - const char *file_name; - grub_file_filter_id_t filter; - -+ /* Reset grub_errno before we start */ -+ grub_errno = GRUB_ERR_NONE; -+ - device_name = grub_file_get_device_name (name); - if (grub_errno) - goto fail; diff --git a/0173-ieee1275-enter-lockdown-based-on-ibm-secure-boot.patch b/0150-ieee1275-enter-lockdown-based-on-ibm-secure-boot.patch similarity index 84% rename from 0173-ieee1275-enter-lockdown-based-on-ibm-secure-boot.patch rename to 0150-ieee1275-enter-lockdown-based-on-ibm-secure-boot.patch index c90cc7e..a8fdba3 100644 --- a/0173-ieee1275-enter-lockdown-based-on-ibm-secure-boot.patch +++ b/0150-ieee1275-enter-lockdown-based-on-ibm-secure-boot.patch @@ -15,10 +15,10 @@ Signed-off-by: Daniel Axtens 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 9ea5fb38f1..4a57de975e 100644 +index c81c9107249..c748a37b4c5 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -323,6 +323,7 @@ kernel = { +@@ -337,6 +337,7 @@ kernel = { powerpc_ieee1275 = kern/powerpc/cache.S; powerpc_ieee1275 = kern/powerpc/dl.c; powerpc_ieee1275 = kern/powerpc/compiler-rt.S; @@ -27,18 +27,18 @@ index 9ea5fb38f1..4a57de975e 100644 sparc64_ieee1275 = kern/sparc64/cache.S; sparc64_ieee1275 = kern/sparc64/dl.c; diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 937c1bc44c..fc7d971272 100644 +index c4d6962197b..85d50e2965f 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c -@@ -44,6 +44,7 @@ - #ifdef __sparc__ - #include +@@ -49,6 +49,7 @@ + #if defined(__powerpc__) || defined(__i386__) + #include #endif +#include - /* The minimal heap size we can live with. */ - #define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024) -@@ -271,6 +272,30 @@ grub_parse_cmdline (void) + /* The maximum heap size we're going to claim at boot. Not used by sparc. */ + #ifdef __i386__ +@@ -893,6 +894,30 @@ grub_parse_cmdline (void) } } @@ -69,7 +69,7 @@ index 937c1bc44c..fc7d971272 100644 grub_addr_t grub_modbase; void -@@ -296,6 +321,8 @@ grub_machine_init (void) +@@ -918,6 +943,8 @@ grub_machine_init (void) #else grub_install_get_time_ms (grub_rtc_get_time_ms); #endif @@ -79,7 +79,7 @@ index 937c1bc44c..fc7d971272 100644 void diff --git a/include/grub/lockdown.h b/include/grub/lockdown.h -index 40531fa823..ebfee4bf06 100644 +index 40531fa823b..ebfee4bf06e 100644 --- a/include/grub/lockdown.h +++ b/include/grub/lockdown.h @@ -24,7 +24,8 @@ @@ -93,10 +93,10 @@ index 40531fa823..ebfee4bf06 100644 EXPORT_FUNC (grub_lockdown) (void); extern int diff --git a/docs/grub.texi b/docs/grub.texi -index 4816be8561..a4da9c2a1b 100644 +index eab81718a59..096a3cde075 100644 --- a/docs/grub.texi +++ b/docs/grub.texi -@@ -6227,8 +6227,8 @@ Measured boot is currently only supported on EFI platforms. +@@ -6814,8 +6814,8 @@ platforms. @section Lockdown when booting on a secure setup The GRUB can be locked down when booted on a secure boot environment, for example diff --git a/0151-ieee1275-drop-HEAP_MAX_ADDR-HEAP_MIN_SIZE.patch b/0151-ieee1275-drop-HEAP_MAX_ADDR-HEAP_MIN_SIZE.patch new file mode 100644 index 0000000..3ca5139 --- /dev/null +++ b/0151-ieee1275-drop-HEAP_MAX_ADDR-HEAP_MIN_SIZE.patch @@ -0,0 +1,46 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Daniel Axtens +Date: Wed, 14 Apr 2021 20:10:23 +1000 +Subject: [PATCH] ieee1275: drop HEAP_MAX_ADDR, HEAP_MIN_SIZE + +HEAP_MAX_ADDR is confusing. Currently it is set to 32MB, except +on ieee1275 on x86, where it is 64MB. + +There is a comment which purports to explain it: + +/* If possible, we will avoid claiming heap above this address, because it + seems to cause relocation problems with OSes that link at 4 MiB */ + +This doesn't make a lot of sense when the constants are well above 4MB +already. It was not always this way. Prior to +commit 7b5d0fe4440c ("Increase heap limit") in 2010, HEAP_MAX_SIZE and +HEAP_MAX_ADDR were indeed 4MB. However, when the constants were increased +the comment was left unchanged. + +It's been over a decade. It doesn't seem like we have problems with +claims over 4MB on powerpc or x86 ieee1275. (sparc does things completely +differently and never used the constant.) + +Drop the constant and the check. + +The only use of HEAP_MIN_SIZE was to potentially override the +HEAP_MAX_ADDR check. It is now unused. Remove it. + +Signed-off-by: Daniel Axtens +--- + grub-core/kern/ieee1275/init.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c +index 85d50e2965f..8ce1a0f09ee 100644 +--- a/grub-core/kern/ieee1275/init.c ++++ b/grub-core/kern/ieee1275/init.c +@@ -51,7 +51,7 @@ + #endif + #include + +-/* The maximum heap size we're going to claim at boot. Not used by sparc. */ ++/* The maximum heap size we're going to claim. Not used by sparc. */ + #ifdef __i386__ + #define HEAP_MAX_SIZE (unsigned long) (64 * 1024 * 1024) + #else /* __powerpc__ */ diff --git a/0175-appendedsig-x509-Also-handle-the-Extended-Key-Usage-.patch b/0152-appendedsig-x509-Also-handle-the-Extended-Key-Usage-.patch similarity index 99% rename from 0175-appendedsig-x509-Also-handle-the-Extended-Key-Usage-.patch rename to 0152-appendedsig-x509-Also-handle-the-Extended-Key-Usage-.patch index 5728f26..a237a21 100644 --- a/0175-appendedsig-x509-Also-handle-the-Extended-Key-Usage-.patch +++ b/0152-appendedsig-x509-Also-handle-the-Extended-Key-Usage-.patch @@ -23,7 +23,7 @@ Signed-off-by: Daniel Axtens 3 files changed, 201 insertions(+), 3 deletions(-) diff --git a/grub-core/commands/appendedsig/x509.c b/grub-core/commands/appendedsig/x509.c -index 2b38b3670a..42ec65c54a 100644 +index 2b38b3670a2..42ec65c54aa 100644 --- a/grub-core/commands/appendedsig/x509.c +++ b/grub-core/commands/appendedsig/x509.c @@ -47,6 +47,12 @@ const char *keyUsage_oid = "2.5.29.15"; @@ -156,7 +156,7 @@ index 2b38b3670a..42ec65c54a 100644 cleanup_value: diff --git a/grub-core/tests/appended_signature_test.c b/grub-core/tests/appended_signature_test.c -index 88a485200d..dbba061662 100644 +index 88a485200d8..dbba0616621 100644 --- a/grub-core/tests/appended_signature_test.c +++ b/grub-core/tests/appended_signature_test.c @@ -111,6 +111,22 @@ static struct grub_procfs_entry certificate_printable_der_entry = { @@ -225,7 +225,7 @@ index 88a485200d..dbba061662 100644 GRUB_FUNCTIONAL_TEST (appended_signature_test, appended_signature_test); diff --git a/grub-core/tests/appended_signatures.h b/grub-core/tests/appended_signatures.h -index aa3dc6278e..2e5ebd7d8b 100644 +index aa3dc6278e3..2e5ebd7d8bd 100644 --- a/grub-core/tests/appended_signatures.h +++ b/grub-core/tests/appended_signatures.h @@ -555,3 +555,84 @@ unsigned char certificate_printable_der[] = { diff --git a/0176-ieee1275-ofdisk-retry-on-open-failure.patch b/0153-ieee1275-ofdisk-retry-on-open-failure.patch similarity index 93% rename from 0176-ieee1275-ofdisk-retry-on-open-failure.patch rename to 0153-ieee1275-ofdisk-retry-on-open-failure.patch index 9149773..160f0c9 100644 --- a/0176-ieee1275-ofdisk-retry-on-open-failure.patch +++ b/0153-ieee1275-ofdisk-retry-on-open-failure.patch @@ -16,7 +16,7 @@ Signed-off-by: Diego Domingos 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c -index ea7f78ac7d..55346849d3 100644 +index 629fc15f284..b413822bb87 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -225,7 +225,9 @@ dev_iterate (const struct grub_ieee1275_devalias *alias) @@ -50,7 +50,7 @@ index ea7f78ac7d..55346849d3 100644 if (! last_ihandle) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); last_devpath = op->open_path; -@@ -571,7 +575,7 @@ grub_ofdisk_prepare (grub_disk_t disk, grub_disk_addr_t sector) +@@ -567,7 +571,7 @@ grub_ofdisk_prepare (grub_disk_t disk, grub_disk_addr_t sector) last_ihandle = 0; last_devpath = NULL; @@ -58,8 +58,8 @@ index ea7f78ac7d..55346849d3 100644 + RETRY_IEEE1275_OFDISK_OPEN(disk->data, &last_ihandle); if (! last_ihandle) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); - last_devpath = disk->data; -@@ -598,12 +602,23 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector, + last_devpath = disk->data; +@@ -594,12 +598,23 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector, return err; grub_ieee1275_read (last_ihandle, buf, size << disk->log_sector_size, &actual); @@ -85,7 +85,7 @@ index ea7f78ac7d..55346849d3 100644 } diff --git a/include/grub/ieee1275/ofdisk.h b/include/grub/ieee1275/ofdisk.h -index 2f69e3f191..7d2d540930 100644 +index 2f69e3f191d..7d2d5409305 100644 --- a/include/grub/ieee1275/ofdisk.h +++ b/include/grub/ieee1275/ofdisk.h @@ -22,4 +22,12 @@ diff --git a/0178-efinet-Add-DHCP-proxy-support.patch b/0154-efinet-Add-DHCP-proxy-support.patch similarity index 80% rename from 0178-efinet-Add-DHCP-proxy-support.patch rename to 0154-efinet-Add-DHCP-proxy-support.patch index eed2dbb..6d1b6da 100644 --- a/0178-efinet-Add-DHCP-proxy-support.patch +++ b/0154-efinet-Add-DHCP-proxy-support.patch @@ -10,14 +10,14 @@ server ack packet. Currently that case is not handled, add support for it. Signed-off-by: Ian Page Hands Signed-off-by: Robbie Harwood --- - grub-core/net/drivers/efi/efinet.c | 25 +++++++++++++++++++++++-- - 1 file changed, 23 insertions(+), 2 deletions(-) + grub-core/net/drivers/efi/efinet.c | 22 +++++++++++++++++++++- + 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c -index e11d759f19..1a24f38a21 100644 +index 225dc896da0..83005ea9f88 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c -@@ -850,10 +850,31 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, +@@ -871,12 +871,32 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, else { grub_dprintf ("efinet", "using ipv4 and dhcp\n"); @@ -42,12 +42,12 @@ index e11d759f19..1a24f38a21 100644 + } + } + - grub_net_configure_by_dhcp_ack (card->name, card, 0, - (struct grub_net_bootp_packet *) -- packet_buf, -- packet_bufsz, -+ &pxe_mode->dhcp_ack, -+ sizeof (pxe_mode->dhcp_ack), - 1, device, path); + inter = grub_net_configure_by_dhcp_ack (card->name, card, 0, + (struct grub_net_bootp_packet *) + packet_buf, + packet_bufsz, + 1, device, path); +- grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path); - } + if (inter != NULL) + { diff --git a/0180-Don-t-update-the-cmdline-when-generating-legacy-menu.patch b/0155-Don-t-update-the-cmdline-when-generating-legacy-menu.patch similarity index 92% rename from 0180-Don-t-update-the-cmdline-when-generating-legacy-menu.patch rename to 0155-Don-t-update-the-cmdline-when-generating-legacy-menu.patch index b2783d1..47eca89 100644 --- a/0180-Don-t-update-the-cmdline-when-generating-legacy-menu.patch +++ b/0155-Don-t-update-the-cmdline-when-generating-legacy-menu.patch @@ -20,10 +20,10 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index e490e1a43a..865af3d6c4 100644 +index b8bc37e92aa..360ce26e5f9 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in -@@ -256,7 +256,9 @@ if [ -z "\${kernelopts}" ]; then +@@ -258,7 +258,9 @@ if [ -z "\${kernelopts}" ]; then fi EOF diff --git a/0181-Suppress-gettext-error-message.patch b/0156-Suppress-gettext-error-message.patch similarity index 96% rename from 0181-Suppress-gettext-error-message.patch rename to 0156-Suppress-gettext-error-message.patch index 64b219a..e248495 100644 --- a/0181-Suppress-gettext-error-message.patch +++ b/0156-Suppress-gettext-error-message.patch @@ -14,7 +14,7 @@ Signed-off-by: Paulo Flabiano Smorigo 1 file changed, 7 insertions(+) diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c -index 4d02e62c10..7ec81ca0b4 100644 +index 7a1c14e4f33..631af7a946b 100644 --- a/grub-core/gettext/gettext.c +++ b/grub-core/gettext/gettext.c @@ -424,6 +424,13 @@ grub_gettext_init_ext (struct grub_gettext_context *ctx, diff --git a/0182-grub-set-password-Always-use-boot-grub2-user.cfg-as-.patch b/0157-grub-set-password-Always-use-boot-grub2-user.cfg-as-.patch similarity index 97% rename from 0182-grub-set-password-Always-use-boot-grub2-user.cfg-as-.patch rename to 0157-grub-set-password-Always-use-boot-grub2-user.cfg-as-.patch index b5d5e5c..7ecea22 100644 --- a/0182-grub-set-password-Always-use-boot-grub2-user.cfg-as-.patch +++ b/0157-grub-set-password-Always-use-boot-grub2-user.cfg-as-.patch @@ -15,7 +15,7 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/util/grub-set-password.in b/util/grub-set-password.in -index c0b5ebbfdc..d8005e5a14 100644 +index c0b5ebbfdc5..d8005e5a142 100644 --- a/util/grub-set-password.in +++ b/util/grub-set-password.in @@ -1,11 +1,6 @@ diff --git a/0186-normal-main-Discover-the-device-to-read-the-config-f.patch b/0158-normal-main-Discover-the-device-to-read-the-config-f.patch similarity index 98% rename from 0186-normal-main-Discover-the-device-to-read-the-config-f.patch rename to 0158-normal-main-Discover-the-device-to-read-the-config-f.patch index 2c9ca3a..d642026 100644 --- a/0186-normal-main-Discover-the-device-to-read-the-config-f.patch +++ b/0158-normal-main-Discover-the-device-to-read-the-config-f.patch @@ -26,7 +26,7 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 7de9e4c36d..8f5fd81003 100644 +index 0ea27d3c534..fc3ed551cec 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -337,18 +337,13 @@ grub_enter_normal_mode (const char *config) diff --git a/0187-powerpc-adjust-setting-of-prefix-for-signed-binary-c.patch b/0159-powerpc-adjust-setting-of-prefix-for-signed-binary-c.patch similarity index 92% rename from 0187-powerpc-adjust-setting-of-prefix-for-signed-binary-c.patch rename to 0159-powerpc-adjust-setting-of-prefix-for-signed-binary-c.patch index b9bc140..61bb0b5 100644 --- a/0187-powerpc-adjust-setting-of-prefix-for-signed-binary-c.patch +++ b/0159-powerpc-adjust-setting-of-prefix-for-signed-binary-c.patch @@ -21,21 +21,19 @@ Signed-off-by: Daniel Axtens [rharwood@redhat.com: squash in fixup commit] Signed-off-by: Robbie Harwood --- - grub-core/kern/main.c | 49 ++++++++++++++++++++++++++++++++++++++++++++----- - 1 file changed, 44 insertions(+), 5 deletions(-) + grub-core/kern/main.c | 47 +++++++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index b573be6650..3fc3401472 100644 +index 353a62ef1e1..dbd4f596fbe 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c -@@ -216,13 +216,52 @@ grub_set_prefix_and_root (void) - if (device) +@@ -217,12 +217,51 @@ grub_set_prefix_and_root (void) { char *prefix_set; -- + - prefix_set = grub_xasprintf ("(%s)%s", device, path ? : ""); - if (prefix_set) -+ +#ifdef __powerpc__ + /* We have to be careful here on powerpc-ieee1275 + signed grub. We + will have signed something with a prefix that doesn't have a device diff --git a/0190-powerpc-ieee1275-load-grub-at-4MB-not-2MB.patch b/0160-powerpc-ieee1275-load-grub-at-4MB-not-2MB.patch similarity index 97% rename from 0190-powerpc-ieee1275-load-grub-at-4MB-not-2MB.patch rename to 0160-powerpc-ieee1275-load-grub-at-4MB-not-2MB.patch index 216418b..a6b31cc 100644 --- a/0190-powerpc-ieee1275-load-grub-at-4MB-not-2MB.patch +++ b/0160-powerpc-ieee1275-load-grub-at-4MB-not-2MB.patch @@ -79,10 +79,10 @@ Signed-off-by: Robbie Harwood 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 4a57de975e..08ac0fb15f 100644 +index c748a37b4c5..ceb15879272 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -89,7 +89,7 @@ kernel = { +@@ -99,7 +99,7 @@ kernel = { i386_xen_pvh_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x100000'; mips_loongson_ldflags = '-Wl,-Ttext,0x80200000'; @@ -92,7 +92,7 @@ index 4a57de975e..08ac0fb15f 100644 mips_arc_ldflags = '-Wl,-Ttext,$(TARGET_LINK_ADDR)'; mips_qemu_mips_ldflags = '-Wl,-Ttext,0x80200000'; diff --git a/include/grub/offsets.h b/include/grub/offsets.h -index 871e1cd4c3..69211aa798 100644 +index 871e1cd4c38..69211aa798b 100644 --- a/include/grub/offsets.h +++ b/include/grub/offsets.h @@ -63,7 +63,7 @@ diff --git a/0161-Add-Fedora-location-of-DejaVu-SANS-font.patch b/0161-Add-Fedora-location-of-DejaVu-SANS-font.patch new file mode 100644 index 0000000..63bbc18 --- /dev/null +++ b/0161-Add-Fedora-location-of-DejaVu-SANS-font.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: fluteze +Date: Sat, 27 Nov 2021 10:54:44 -0600 +Subject: [PATCH] Add Fedora location of DejaVu SANS font + +In Fedora 35, and possibly earlier, grub would fail to configure with a +complaint about DejaVu being "not found" even though it was installed. +The DejaVu sans font search path is updated to reflect the +distribution's current install path. + +Signed-off-by: Erik Edwards +[rharwood@redhat.com: slight commit message edits] +Signed-off-by: Robbie Harwood +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 016cd3d4e0e..d223fe3ef6e 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1924,7 +1924,7 @@ if test "x$with_dejavufont" = x; then + # search in well-known directories + if test x"$starfield_excuse" = x; then + for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do +- for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype /usr/pkg/share/fonts/X11/TTF /usr/local/share/fonts/dejavu /usr/X11R6/lib/X11/fonts/TTF; do ++ for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype /usr/pkg/share/fonts/X11/TTF /usr/local/share/fonts/dejavu /usr/X11R6/lib/X11/fonts/TTF /usr/share/fonts/dejavu-sans-fonts; do + if test -f "$dir/DejaVuSans.$ext"; then + DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext" + break 2 diff --git a/0205-efi-new-connectefi-command.patch b/0162-efi-new-connectefi-command.patch similarity index 94% rename from 0205-efi-new-connectefi-command.patch rename to 0162-efi-new-connectefi-command.patch index f80de22..f36d9ca 100644 --- a/0205-efi-new-connectefi-command.patch +++ b/0162-efi-new-connectefi-command.patch @@ -64,10 +64,10 @@ Signed-off-by: Robbie Harwood create mode 100644 grub-core/commands/efi/connectefi.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index ec1ec5083b..741a033978 100644 +index ceb15879272..c9dcfa00e85 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -836,6 +836,12 @@ module = { +@@ -861,6 +861,12 @@ module = { enable = efi; }; @@ -82,7 +82,7 @@ index ec1ec5083b..741a033978 100644 common = commands/blocklist.c; diff --git a/grub-core/commands/efi/connectefi.c b/grub-core/commands/efi/connectefi.c new file mode 100644 -index 0000000000..8ab75bd51b +index 00000000000..0f840ea0575 --- /dev/null +++ b/grub-core/commands/efi/connectefi.c @@ -0,0 +1,205 @@ @@ -165,7 +165,7 @@ index 0000000000..8ab75bd51b + +typedef struct searched_item +{ -+ grub_efi_guid_t guid; ++ grub_guid_t guid; + const char *name; + searched_item_flags flags; +} searched_items; @@ -292,7 +292,7 @@ index 0000000000..8ab75bd51b + grub_unregister_command (cmd); +} diff --git a/grub-core/commands/efi/lsefi.c b/grub-core/commands/efi/lsefi.c -index d1ce99af43..f2d2430e66 100644 +index 7b8316d4184..3635cd99b75 100644 --- a/grub-core/commands/efi/lsefi.c +++ b/grub-core/commands/efi/lsefi.c @@ -19,6 +19,7 @@ @@ -304,7 +304,7 @@ index d1ce99af43..f2d2430e66 100644 #include #include diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c -index fe8ba6e6c9..062143dfff 100644 +index 822005456eb..af69cc3bc8a 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -396,6 +396,19 @@ enumerate_disks (void) @@ -328,10 +328,10 @@ index fe8ba6e6c9..062143dfff 100644 grub_efidisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data, grub_disk_pull_t pull) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 14bc10eb56..7fcca69c17 100644 +index ef837387368..412a2073f41 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -95,6 +95,19 @@ grub_efi_locate_handle (grub_efi_locate_search_type_t search_type, +@@ -96,6 +96,19 @@ grub_efi_locate_handle (grub_efi_locate_search_type_t search_type, return buffer; } @@ -344,15 +344,15 @@ index 14bc10eb56..7fcca69c17 100644 + grub_efi_boot_services_t *b; + + b = grub_efi_system_table->boot_services; -+ return efi_call_4 (b->connect_controller, controller_handle, ++ return b->connect_controller(controller_handle, + driver_image_handle, remaining_device_path, recursive); +} + void * grub_efi_open_protocol (grub_efi_handle_t handle, - grub_efi_guid_t *protocol, + grub_guid_t *protocol, diff --git a/include/grub/efi/disk.h b/include/grub/efi/disk.h -index 254475c842..6845c2f1fd 100644 +index 254475c8428..6845c2f1fd8 100644 --- a/include/grub/efi/disk.h +++ b/include/grub/efi/disk.h @@ -27,6 +27,8 @@ grub_efi_handle_t @@ -365,11 +365,11 @@ index 254475c842..6845c2f1fd 100644 void grub_efidisk_fini (void); diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 8dfc89a33b..ec52083c49 100644 +index 6c2c1f36e37..736d6f25694 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h -@@ -41,6 +41,11 @@ EXPORT_FUNC(grub_efi_locate_handle) (grub_efi_locate_search_type_t search_type, - grub_efi_guid_t *protocol, +@@ -53,6 +53,11 @@ EXPORT_FUNC(grub_efi_locate_handle) (grub_efi_locate_search_type_t search_type, + grub_guid_t *protocol, void *search_key, grub_efi_uintn_t *num_handles); +grub_efi_status_t @@ -378,13 +378,13 @@ index 8dfc89a33b..ec52083c49 100644 + grub_efi_device_path_protocol_t *remaining_device_path, + grub_efi_boolean_t recursive); void *EXPORT_FUNC(grub_efi_open_protocol) (grub_efi_handle_t handle, - grub_efi_guid_t *protocol, + grub_guid_t *protocol, grub_efi_uint32_t attributes); diff --git a/NEWS b/NEWS -index 73b8492bc4..d7c1d23aed 100644 +index 3101309621b..e3cfcd569c2 100644 --- a/NEWS +++ b/NEWS -@@ -98,7 +98,7 @@ New in 2.02: +@@ -118,7 +118,7 @@ New in 2.02: * Prefer pmtimer for TSC calibration. * New/improved platform support: diff --git a/0210-powerpc-prefix-detection-support-device-names-with-c.patch b/0163-powerpc-prefix-detection-support-device-names-with-c.patch similarity index 98% rename from 0210-powerpc-prefix-detection-support-device-names-with-c.patch rename to 0163-powerpc-prefix-detection-support-device-names-with-c.patch index 1c16fd3..5744413 100644 --- a/0210-powerpc-prefix-detection-support-device-names-with-c.patch +++ b/0163-powerpc-prefix-detection-support-device-names-with-c.patch @@ -30,7 +30,7 @@ Signed-off-by: Daniel Axtens 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index 993b8a8598..e94a2f78fb 100644 +index dbd4f596fbe..8e89763f43b 100644 --- a/grub-core/kern/main.c +++ b/grub-core/kern/main.c @@ -242,14 +242,29 @@ grub_set_prefix_and_root (void) diff --git a/0211-make-ofdisk_retries-optional.patch b/0164-make-ofdisk_retries-optional.patch similarity index 98% rename from 0211-make-ofdisk_retries-optional.patch rename to 0164-make-ofdisk_retries-optional.patch index fce9702..791c0a6 100644 --- a/0211-make-ofdisk_retries-optional.patch +++ b/0164-make-ofdisk_retries-optional.patch @@ -24,7 +24,7 @@ so the default number of retries will be used instead. 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/grub/ieee1275/ofdisk.h b/include/grub/ieee1275/ofdisk.h -index 7d2d540930..0074d55eee 100644 +index 7d2d5409305..0074d55eee4 100644 --- a/include/grub/ieee1275/ofdisk.h +++ b/include/grub/ieee1275/ofdisk.h @@ -25,7 +25,12 @@ extern void grub_ofdisk_fini (void); diff --git a/0246-misc-Make-grub_min-and-grub_max-more-resilient.patch b/0165-misc-Make-grub_min-and-grub_max-more-resilient.patch similarity index 94% rename from 0246-misc-Make-grub_min-and-grub_max-more-resilient.patch rename to 0165-misc-Make-grub_min-and-grub_max-more-resilient.patch index eb2e8fd..a9afc99 100644 --- a/0246-misc-Make-grub_min-and-grub_max-more-resilient.patch +++ b/0165-misc-Make-grub_min-and-grub_max-more-resilient.patch @@ -24,10 +24,10 @@ Signed-off-by: Peter Jones 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c -index f2318e0d16..87f6e31aa6 100644 +index 1edad05948c..8d370b0b3f5 100644 --- a/grub-core/loader/multiboot_elfxx.c +++ b/grub-core/loader/multiboot_elfxx.c -@@ -35,9 +35,7 @@ +@@ -45,9 +45,7 @@ #endif #include @@ -39,7 +39,7 @@ index f2318e0d16..87f6e31aa6 100644 #pragma GCC diagnostic ignored "-Wcast-align" diff --git a/include/grub/misc.h b/include/grub/misc.h -index 6c4aa85ac5..cf84aec1db 100644 +index 3f5f5b61695..252bdb161eb 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -35,6 +35,14 @@ @@ -57,7 +57,7 @@ index 6c4aa85ac5..cf84aec1db 100644 #define grub_dprintf(condition, ...) grub_real_dprintf(GRUB_FILE, __LINE__, condition, __VA_ARGS__) void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n); -@@ -498,8 +506,21 @@ void EXPORT_FUNC(grub_real_boot_time) (const char *file, +@@ -525,8 +533,21 @@ void EXPORT_FUNC(grub_real_boot_time) (const char *file, #define grub_boot_time(...) #endif diff --git a/0247-ReiserFS-switch-to-using-grub_min-grub_max.patch b/0166-ReiserFS-switch-to-using-grub_min-grub_max.patch similarity index 99% rename from 0247-ReiserFS-switch-to-using-grub_min-grub_max.patch rename to 0166-ReiserFS-switch-to-using-grub_min-grub_max.patch index 0707af3..76d44ac 100644 --- a/0247-ReiserFS-switch-to-using-grub_min-grub_max.patch +++ b/0166-ReiserFS-switch-to-using-grub_min-grub_max.patch @@ -13,7 +13,7 @@ Signed-off-by: Peter Jones 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/grub-core/fs/reiserfs.c b/grub-core/fs/reiserfs.c -index af6a226a7f..b8253da7fe 100644 +index 36b26ac98a0..42818c37622 100644 --- a/grub-core/fs/reiserfs.c +++ b/grub-core/fs/reiserfs.c @@ -42,16 +42,6 @@ diff --git a/0248-misc-make-grub_boot_time-also-call-grub_dprintf-boot.patch b/0167-misc-make-grub_boot_time-also-call-grub_dprintf-boot.patch similarity index 76% rename from 0248-misc-make-grub_boot_time-also-call-grub_dprintf-boot.patch rename to 0167-misc-make-grub_boot_time-also-call-grub_dprintf-boot.patch index a7ac6f2..9293ba9 100644 --- a/0248-misc-make-grub_boot_time-also-call-grub_dprintf-boot.patch +++ b/0167-misc-make-grub_boot_time-also-call-grub_dprintf-boot.patch @@ -13,29 +13,27 @@ in DEBUG, regardless of BOOT_TIME_STATS. Signed-off-by: Peter Jones --- - grub-core/kern/misc.c | 3 ++- + grub-core/kern/misc.c | 1 + include/grub/misc.h | 2 +- - 2 files changed, 3 insertions(+), 2 deletions(-) + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index a186ad3dd4..cb45461402 100644 +index d3a493e3552..f607244e7ae 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -1334,7 +1334,8 @@ grub_real_boot_time (const char *file, - n->next = 0; +@@ -1438,6 +1438,7 @@ grub_real_boot_time (const char *file, va_start (args, fmt); -- n->msg = grub_xvasprintf (fmt, args); -+ n->msg = grub_xvasprintf (fmt, args); + n->msg = grub_xvasprintf (fmt, args); + grub_dprintf ("boot", "%s\n", n->msg); va_end (args); *boot_time_last = n; diff --git a/include/grub/misc.h b/include/grub/misc.h -index cf84aec1db..faae0ae860 100644 +index 252bdb161eb..c3c735371dc 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h -@@ -503,7 +503,7 @@ void EXPORT_FUNC(grub_real_boot_time) (const char *file, +@@ -530,7 +530,7 @@ void EXPORT_FUNC(grub_real_boot_time) (const char *file, const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 3, 4))); #define grub_boot_time(...) grub_real_boot_time(GRUB_FILE, __LINE__, __VA_ARGS__) #else diff --git a/0249-modules-make-.module_license-read-only.patch b/0168-modules-make-.module_license-read-only.patch similarity index 97% rename from 0249-modules-make-.module_license-read-only.patch rename to 0168-modules-make-.module_license-read-only.patch index ba3b313..368386d 100644 --- a/0249-modules-make-.module_license-read-only.patch +++ b/0168-modules-make-.module_license-read-only.patch @@ -16,7 +16,7 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grub/dl.h b/include/grub/dl.h -index 20d870f2a4..618ae6f474 100644 +index 3f10e27d62c..216f8b903ac 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -121,7 +121,7 @@ grub_mod_fini (void) diff --git a/0250-modules-strip-.llvm_addrsig-sections-and-similar.patch b/0169-modules-strip-.llvm_addrsig-sections-and-similar.patch similarity index 97% rename from 0250-modules-strip-.llvm_addrsig-sections-and-similar.patch rename to 0169-modules-strip-.llvm_addrsig-sections-and-similar.patch index 9f26115..c86b999 100644 --- a/0250-modules-strip-.llvm_addrsig-sections-and-similar.patch +++ b/0169-modules-strip-.llvm_addrsig-sections-and-similar.patch @@ -21,7 +21,7 @@ Signed-off-by: Peter Jones 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in -index 1250589b3f..c2c5280d75 100644 +index e57c4d9205c..337753c574c 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -57,8 +57,11 @@ if test x@TARGET_APPLE_LINKER@ != x1; then diff --git a/0251-modules-Don-t-allocate-space-for-non-allocable-secti.patch b/0170-modules-Don-t-allocate-space-for-non-allocable-secti.patch similarity index 92% rename from 0251-modules-Don-t-allocate-space-for-non-allocable-secti.patch rename to 0170-modules-Don-t-allocate-space-for-non-allocable-secti.patch index d07d838..19c7fdd 100644 --- a/0251-modules-Don-t-allocate-space-for-non-allocable-secti.patch +++ b/0170-modules-Don-t-allocate-space-for-non-allocable-secti.patch @@ -20,10 +20,10 @@ Signed-off-by: Peter Jones 1 file changed, 3 insertions(+) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index f304494574..aef8af8aa7 100644 +index 931f6e41442..832c6188df4 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c -@@ -289,6 +289,9 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) +@@ -281,6 +281,9 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) i < e->e_shnum; i++, s = (const Elf_Shdr *)((const char *) s + e->e_shentsize)) { diff --git a/0254-modules-load-module-sections-at-page-aligned-address.patch b/0171-modules-load-module-sections-at-page-aligned-address.patch similarity index 90% rename from 0254-modules-load-module-sections-at-page-aligned-address.patch rename to 0171-modules-load-module-sections-at-page-aligned-address.patch index eb171f5..8ace83d 100644 --- a/0254-modules-load-module-sections-at-page-aligned-address.patch +++ b/0171-modules-load-module-sections-at-page-aligned-address.patch @@ -71,7 +71,7 @@ Signed-off-by: Peter Jones 13 files changed, 139 insertions(+), 11 deletions(-) diff --git a/grub-core/kern/arm/dl.c b/grub-core/kern/arm/dl.c -index eab9d17ff2..9260737936 100644 +index eab9d17ff2d..92607379366 100644 --- a/grub-core/kern/arm/dl.c +++ b/grub-core/kern/arm/dl.c @@ -278,3 +278,16 @@ grub_arch_dl_check_header (void *ehdr) @@ -92,7 +92,7 @@ index eab9d17ff2..9260737936 100644 +#endif +} diff --git a/grub-core/kern/arm64/dl.c b/grub-core/kern/arm64/dl.c -index 512e5a80b0..0d4a26857f 100644 +index a2b5789a9dd..95c6d5bf4e5 100644 --- a/grub-core/kern/arm64/dl.c +++ b/grub-core/kern/arm64/dl.c @@ -196,3 +196,16 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, @@ -113,19 +113,19 @@ index 512e5a80b0..0d4a26857f 100644 +#endif +} diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index aef8af8aa7..8c7aacef39 100644 +index 832c6188df4..775b367287e 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c -@@ -277,7 +277,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) +@@ -268,7 +268,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) { unsigned i; const Elf_Shdr *s; - grub_size_t tsize = 0, talign = 1; + grub_size_t tsize = 0, talign = 1, arch_addralign = 1; - #if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv) + #if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv) && \ + !defined (__loongarch__) grub_size_t tramp; - grub_size_t got; -@@ -285,16 +285,24 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) +@@ -277,16 +277,24 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) #endif char *ptr; @@ -152,8 +152,8 @@ index aef8af8aa7..8c7aacef39 100644 + talign = sh_addralign; } - #if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv) -@@ -323,6 +331,9 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) + #if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv) && \ +@@ -316,6 +324,9 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) i < e->e_shnum; i++, s = (Elf_Shdr *)((char *) s + e->e_shentsize)) { @@ -163,7 +163,7 @@ index aef8af8aa7..8c7aacef39 100644 if (s->sh_flags & SHF_ALLOC) { grub_dl_segment_t seg; -@@ -335,17 +346,19 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) +@@ -328,17 +339,19 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) { void *addr; @@ -186,7 +186,7 @@ index aef8af8aa7..8c7aacef39 100644 break; } -@@ -354,7 +367,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) +@@ -347,7 +360,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) else seg->addr = 0; @@ -196,7 +196,7 @@ index aef8af8aa7..8c7aacef39 100644 seg->next = mod->segment; mod->segment = seg; diff --git a/grub-core/kern/emu/full.c b/grub-core/kern/emu/full.c -index e8d63b1f5f..1de1c28eb0 100644 +index e8d63b1f5f9..1de1c28eb09 100644 --- a/grub-core/kern/emu/full.c +++ b/grub-core/kern/emu/full.c @@ -67,3 +67,16 @@ grub_arch_dl_init_linker (void) @@ -217,7 +217,7 @@ index e8d63b1f5f..1de1c28eb0 100644 +#endif +} diff --git a/grub-core/kern/i386/dl.c b/grub-core/kern/i386/dl.c -index 1346da5cc9..d6b4681fc9 100644 +index 1346da5cc91..d6b4681fc93 100644 --- a/grub-core/kern/i386/dl.c +++ b/grub-core/kern/i386/dl.c @@ -79,3 +79,16 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, @@ -238,7 +238,7 @@ index 1346da5cc9..d6b4681fc9 100644 +#endif +} diff --git a/grub-core/kern/ia64/dl.c b/grub-core/kern/ia64/dl.c -index db59300fea..92d82c5750 100644 +index db59300fea3..92d82c57505 100644 --- a/grub-core/kern/ia64/dl.c +++ b/grub-core/kern/ia64/dl.c @@ -148,3 +148,12 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, @@ -255,7 +255,7 @@ index db59300fea..92d82c5750 100644 + return 1; +} diff --git a/grub-core/kern/mips/dl.c b/grub-core/kern/mips/dl.c -index 5d7d299c74..6d83bd71e9 100644 +index 5b02f97fca7..db411899dbe 100644 --- a/grub-core/kern/mips/dl.c +++ b/grub-core/kern/mips/dl.c @@ -272,3 +272,11 @@ grub_arch_dl_init_linker (void) @@ -271,7 +271,7 @@ index 5d7d299c74..6d83bd71e9 100644 + return 1; +} diff --git a/grub-core/kern/powerpc/dl.c b/grub-core/kern/powerpc/dl.c -index cdd61b305f..5d9ba2e158 100644 +index 7b6418eabd7..0eb8bc5bd31 100644 --- a/grub-core/kern/powerpc/dl.c +++ b/grub-core/kern/powerpc/dl.c @@ -167,3 +167,12 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, @@ -288,10 +288,10 @@ index cdd61b305f..5d9ba2e158 100644 + return 1; +} diff --git a/grub-core/kern/riscv/dl.c b/grub-core/kern/riscv/dl.c -index f26b12aaa4..aa18f9e990 100644 +index 896653bb41c..1fa085b4acf 100644 --- a/grub-core/kern/riscv/dl.c +++ b/grub-core/kern/riscv/dl.c -@@ -343,3 +343,16 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, +@@ -344,3 +344,16 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, return GRUB_ERR_NONE; } @@ -309,7 +309,7 @@ index f26b12aaa4..aa18f9e990 100644 +#endif +} diff --git a/grub-core/kern/sparc64/dl.c b/grub-core/kern/sparc64/dl.c -index f3d960186b..f054f08241 100644 +index f3d960186ba..f054f08241d 100644 --- a/grub-core/kern/sparc64/dl.c +++ b/grub-core/kern/sparc64/dl.c @@ -189,3 +189,12 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, @@ -326,7 +326,7 @@ index f3d960186b..f054f08241 100644 + return 1; +} diff --git a/grub-core/kern/x86_64/dl.c b/grub-core/kern/x86_64/dl.c -index e5a8bdcf4f..a105dc50ce 100644 +index e5a8bdcf4f9..a105dc50cea 100644 --- a/grub-core/kern/x86_64/dl.c +++ b/grub-core/kern/x86_64/dl.c @@ -119,3 +119,16 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, @@ -347,10 +347,10 @@ index e5a8bdcf4f..a105dc50ce 100644 +#endif +} diff --git a/include/grub/dl.h b/include/grub/dl.h -index 618ae6f474..f36ed5cb17 100644 +index 216f8b903ac..9f86765c8e9 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h -@@ -280,6 +280,8 @@ grub_err_t grub_arch_dl_check_header (void *ehdr); +@@ -279,6 +279,8 @@ grub_err_t grub_arch_dl_check_header (void *ehdr); grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, Elf_Shdr *s, grub_dl_segment_t seg); @@ -360,10 +360,10 @@ index 618ae6f474..f36ed5cb17 100644 #if defined (_mips) diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi -index 19f708ee66..7b2455a8fe 100644 +index 04c6678cb6b..8ad5494f5ce 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi -@@ -755,9 +755,9 @@ declare startup asm file ($cpu_$platform_startup) as well as any other files +@@ -996,9 +996,9 @@ declare startup asm file ($cpu_$platform_startup) as well as any other files (e.g. init.c and callwrap.S) (e.g. $cpu_$platform = kern/$cpu/$platform/init.c). At this stage you will also need to add dummy dl.c and cache.S with functions grub_err_t grub_arch_dl_check_header (void *ehdr), grub_err_t @@ -375,4 +375,4 @@ index 19f708ee66..7b2455a8fe 100644 +*address, grub_size_t len) (cache.S). They won't be used for now. You will need to create directory include/$cpu/$platform and a file - include/$cpu/types.h. The later folowing this template: + include/$cpu/types.h. The latter following this template: diff --git a/0255-nx-add-memory-attribute-get-set-API.patch b/0172-nx-add-memory-attribute-get-set-API.patch similarity index 89% rename from 0255-nx-add-memory-attribute-get-set-API.patch rename to 0172-nx-add-memory-attribute-get-set-API.patch index 91c9d2f..6a47341 100644 --- a/0255-nx-add-memory-attribute-get-set-API.patch +++ b/0172-nx-add-memory-attribute-get-set-API.patch @@ -29,10 +29,10 @@ Signed-off-by: Robbie Harwood 5 files changed, 226 insertions(+) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 7fcca69c17..4ac2b2754e 100644 +index 412a2073f41..cdfc11565c7 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c -@@ -1096,3 +1096,39 @@ grub_efi_compare_device_paths (const grub_efi_device_path_t *dp1, +@@ -1130,3 +1130,39 @@ grub_efi_find_configuration_table (const grub_guid_t *target_guid) return 0; } @@ -73,10 +73,10 @@ index 7fcca69c17..4ac2b2754e 100644 + return err; +} diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index e84961d078..2c33758ed7 100644 +index 6a6fba89184..df443f434d4 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c -@@ -738,3 +738,134 @@ grub_efi_get_ram_base(grub_addr_t *base_addr) +@@ -687,3 +687,134 @@ grub_efi_get_ram_base(grub_addr_t *base_addr) return GRUB_ERR_NONE; } #endif @@ -124,7 +124,7 @@ index e84961d078..2c33758ed7 100644 +{ + grub_efi_memory_attribute_protocol_t *proto; + grub_efi_physical_address_t physaddr = addr; -+ grub_efi_guid_t protocol_guid = GRUB_EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID; ++ grub_guid_t protocol_guid = GRUB_EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID; + grub_efi_status_t efi_status; + + proto = grub_efi_locate_protocol (&protocol_guid, 0); @@ -138,7 +138,7 @@ index e84961d078..2c33758ed7 100644 + return 0; + } + -+ efi_status = efi_call_4(proto->get_memory_attributes, ++ efi_status = proto->get_memory_attributes( + proto, physaddr, size, attrs); + *attrs = uefi_mem_attrs_to_grub_mem_attrs (*attrs); + @@ -151,7 +151,7 @@ index e84961d078..2c33758ed7 100644 +{ + grub_efi_memory_attribute_protocol_t *proto; + grub_efi_physical_address_t physaddr = addr; -+ grub_efi_guid_t protocol_guid = GRUB_EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID; ++ grub_guid_t protocol_guid = GRUB_EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID; + grub_efi_status_t efi_status = GRUB_EFI_SUCCESS; + grub_uint64_t before = 0, after = 0, uefi_set_attrs, uefi_clear_attrs; + grub_err_t err; @@ -183,10 +183,10 @@ index e84961d078..2c33758ed7 100644 + uefi_clear_attrs = grub_mem_attrs_to_uefi_mem_attrs (clear_attrs); + grub_dprintf ("nx", "translating clear_attrs from 0x%lx to 0x%lx\n", clear_attrs, uefi_clear_attrs); + if (uefi_set_attrs) -+ efi_status = efi_call_4(proto->set_memory_attributes, ++ efi_status = proto->set_memory_attributes( + proto, physaddr, size, uefi_set_attrs); + if (efi_status == GRUB_EFI_SUCCESS && uefi_clear_attrs) -+ efi_status = efi_call_4(proto->clear_memory_attributes, ++ efi_status = proto->clear_memory_attributes( + proto, physaddr, size, uefi_clear_attrs); + + err = grub_get_mem_attrs (addr, size, &after); @@ -212,11 +212,11 @@ index e84961d078..2c33758ed7 100644 + return grub_efi_status_to_err (efi_status); +} diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h -index f431f49973..464842ba37 100644 +index 805a9d7adf9..76c88fbdcb0 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h -@@ -363,6 +363,11 @@ - { 0x89, 0x29, 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a } \ +@@ -389,6 +389,11 @@ + {0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f } \ } +#define GRUB_EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID \ @@ -227,7 +227,7 @@ index f431f49973..464842ba37 100644 struct grub_efi_sal_system_table { grub_uint32_t signature; -@@ -2102,6 +2107,26 @@ struct grub_efi_ip6_config_manual_address { +@@ -2182,6 +2187,26 @@ struct grub_efi_ip6_config_manual_address { }; typedef struct grub_efi_ip6_config_manual_address grub_efi_ip6_config_manual_address_t; @@ -251,14 +251,14 @@ index f431f49973..464842ba37 100644 +}; +typedef struct grub_efi_memory_attribute_protocol grub_efi_memory_attribute_protocol_t; + - #if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \ - || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) \ - || defined(__riscv) + struct initrd_media_device_path { + grub_efi_vendor_media_device_path_t vendor; + grub_efi_device_path_t end; diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index ec52083c49..34825c4adc 100644 +index 736d6f25694..3670eddc52b 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h -@@ -164,4 +164,6 @@ struct grub_net_card; +@@ -189,4 +189,6 @@ struct grub_net_card; grub_efi_handle_t grub_efinet_get_device_handle (struct grub_net_card *card); @@ -266,18 +266,18 @@ index ec52083c49..34825c4adc 100644 + #endif /* ! GRUB_EFI_EFI_HEADER */ diff --git a/include/grub/mm.h b/include/grub/mm.h -index 9c38dd3ca5..d81623d226 100644 +index f3bf87fa0f9..8ee1fc7171c 100644 --- a/include/grub/mm.h +++ b/include/grub/mm.h -@@ -22,6 +22,7 @@ - +@@ -23,6 +23,7 @@ + #include #include #include +#include #include #ifndef NULL -@@ -38,6 +39,37 @@ void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size); +@@ -56,6 +57,37 @@ void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size); void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size); #endif diff --git a/0256-nx-set-page-permissions-for-loaded-modules.patch b/0173-nx-set-page-permissions-for-loaded-modules.patch similarity index 81% rename from 0256-nx-set-page-permissions-for-loaded-modules.patch rename to 0173-nx-set-page-permissions-for-loaded-modules.patch index 9e0aebb..416caed 100644 --- a/0256-nx-set-page-permissions-for-loaded-modules.patch +++ b/0173-nx-set-page-permissions-for-loaded-modules.patch @@ -16,15 +16,15 @@ Signed-off-by: Peter Jones [rharwood: arm tgptr -> tgaddr] Signed-off-by: Robbie Harwood --- - grub-core/kern/dl.c | 120 +++++++++++++++++++++++++++++++++++++++------------- - include/grub/dl.h | 44 +++++++++++++++++++ - 2 files changed, 134 insertions(+), 30 deletions(-) + grub-core/kern/dl.c | 102 +++++++++++++++++++++++++++++++++++++++++++++------- + include/grub/dl.h | 44 +++++++++++++++++++++++ + 2 files changed, 133 insertions(+), 13 deletions(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 8c7aacef39..d5de80186f 100644 +index 775b367287e..25666ae383f 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c -@@ -285,6 +285,8 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) +@@ -277,6 +277,8 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) #endif char *ptr; @@ -33,7 +33,7 @@ index 8c7aacef39..d5de80186f 100644 arch_addralign = grub_arch_dl_min_alignment (); for (i = 0, s = (const Elf_Shdr *)((const char *) e + e->e_shoff); -@@ -384,6 +386,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) +@@ -378,6 +380,7 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) ptr += got; #endif @@ -41,31 +41,7 @@ index 8c7aacef39..d5de80186f 100644 return GRUB_ERR_NONE; } -@@ -517,23 +520,6 @@ grub_dl_find_section (Elf_Ehdr *e, const char *name) - return s; - return NULL; - } --static long --grub_dl_find_section_index (Elf_Ehdr *e, const char *name) --{ -- Elf_Shdr *s; -- const char *str; -- unsigned i; -- -- s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shstrndx * e->e_shentsize); -- str = (char *) e + s->sh_offset; -- -- for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); -- i < e->e_shnum; -- i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) -- if (grub_strcmp (str + s->sh_name, name) == 0) -- return (long)i; -- return -1; --} - - /* Me, Vladimir Serbinenko, hereby I add this module check as per new - GNU module policy. Note that this license check is informative only. -@@ -662,6 +648,7 @@ grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr) +@@ -645,6 +648,7 @@ grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr) Elf_Shdr *s; unsigned i; @@ -73,7 +49,7 @@ index 8c7aacef39..d5de80186f 100644 for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff); i < e->e_shnum; i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize)) -@@ -670,24 +657,95 @@ grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr) +@@ -653,22 +657,92 @@ grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr) grub_dl_segment_t seg; grub_err_t err; @@ -102,8 +78,8 @@ index 8c7aacef39..d5de80186f 100644 } + grub_dprintf ("modules", "done relocating symbols for \"%s\"\n", mod->name); - return GRUB_ERR_NONE; - } ++ return GRUB_ERR_NONE; ++} + +static grub_err_t +grub_dl_set_mem_attrs (grub_dl_t mod, void *ehdr) @@ -175,13 +151,10 @@ index 8c7aacef39..d5de80186f 100644 + grub_dprintf ("modules", "done updating module memory attributes for \"%s\"\n", + mod->name); + -+ return GRUB_ERR_NONE; -+} -+ - static void - grub_dl_print_gdb_info (grub_dl_t mod, Elf_Ehdr *e) - { -@@ -753,6 +811,7 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size) + return GRUB_ERR_NONE; + } + +@@ -705,6 +779,7 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size) mod->ref_count = 1; grub_dprintf ("modules", "relocating to %p\n", mod); @@ -189,7 +162,7 @@ index 8c7aacef39..d5de80186f 100644 /* Me, Vladimir Serbinenko, hereby I add this module check as per new GNU module policy. Note that this license check is informative only. Modules have to be licensed under GPLv3 or GPLv3+ (optionally -@@ -766,7 +825,8 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size) +@@ -718,7 +793,8 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size) || grub_dl_resolve_dependencies (mod, e) || grub_dl_load_segments (mod, e) || grub_dl_resolve_symbols (mod, e) @@ -200,7 +173,7 @@ index 8c7aacef39..d5de80186f 100644 mod->fini = 0; grub_dl_unload (mod); diff --git a/include/grub/dl.h b/include/grub/dl.h -index f36ed5cb17..45ac8e339f 100644 +index 9f86765c8e9..1e1262a283b 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -27,6 +27,7 @@ @@ -211,7 +184,7 @@ index f36ed5cb17..45ac8e339f 100644 #endif /* -@@ -268,6 +269,49 @@ grub_dl_is_persistent (grub_dl_t mod) +@@ -267,6 +268,49 @@ grub_dl_is_persistent (grub_dl_t mod) return mod->persistent; } diff --git a/0174-ieee1275-drop-HEAP_MAX_ADDR-HEAP_MIN_SIZE.patch b/0174-ieee1275-drop-HEAP_MAX_ADDR-HEAP_MIN_SIZE.patch deleted file mode 100644 index a40caea..0000000 --- a/0174-ieee1275-drop-HEAP_MAX_ADDR-HEAP_MIN_SIZE.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Wed, 14 Apr 2021 20:10:23 +1000 -Subject: [PATCH] ieee1275: drop HEAP_MAX_ADDR, HEAP_MIN_SIZE - -HEAP_MAX_ADDR is confusing. Currently it is set to 32MB, except -on ieee1275 on x86, where it is 64MB. - -There is a comment which purports to explain it: - -/* If possible, we will avoid claiming heap above this address, because it - seems to cause relocation problems with OSes that link at 4 MiB */ - -This doesn't make a lot of sense when the constants are well above 4MB -already. It was not always this way. Prior to -commit 7b5d0fe4440c ("Increase heap limit") in 2010, HEAP_MAX_SIZE and -HEAP_MAX_ADDR were indeed 4MB. However, when the constants were increased -the comment was left unchanged. - -It's been over a decade. It doesn't seem like we have problems with -claims over 4MB on powerpc or x86 ieee1275. (sparc does things completely -differently and never used the constant.) - -Drop the constant and the check. - -The only use of HEAP_MIN_SIZE was to potentially override the -HEAP_MAX_ADDR check. It is now unused. Remove it. - -Signed-off-by: Daniel Axtens ---- - grub-core/kern/ieee1275/init.c | 17 ----------------- - 1 file changed, 17 deletions(-) - -diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index fc7d971272..0dcd114ce5 100644 ---- a/grub-core/kern/ieee1275/init.c -+++ b/grub-core/kern/ieee1275/init.c -@@ -46,9 +46,6 @@ - #endif - #include - --/* The minimal heap size we can live with. */ --#define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024) -- - /* The maximum heap size we're going to claim */ - #ifdef __i386__ - #define HEAP_MAX_SIZE (unsigned long) (64 * 1024 * 1024) -@@ -56,14 +53,6 @@ - #define HEAP_MAX_SIZE (unsigned long) (32 * 1024 * 1024) - #endif - --/* If possible, we will avoid claiming heap above this address, because it -- seems to cause relocation problems with OSes that link at 4 MiB */ --#ifdef __i386__ --#define HEAP_MAX_ADDR (unsigned long) (64 * 1024 * 1024) --#else --#define HEAP_MAX_ADDR (unsigned long) (32 * 1024 * 1024) --#endif -- - extern char _end[]; - - #ifdef __sparc__ -@@ -185,12 +174,6 @@ heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, - if (*total + len > HEAP_MAX_SIZE) - len = HEAP_MAX_SIZE - *total; - -- /* Avoid claiming anything above HEAP_MAX_ADDR, if possible. */ -- if ((addr < HEAP_MAX_ADDR) && /* if it's too late, don't bother */ -- (addr + len > HEAP_MAX_ADDR) && /* if it wasn't available anyway, don't bother */ -- (*total + (HEAP_MAX_ADDR - addr) > HEAP_MIN_SIZE)) /* only limit ourselves when we can afford to */ -- len = HEAP_MAX_ADDR - addr; -- - /* In theory, firmware should already prevent this from happening by not - listing our own image in /memory/available. The check below is intended - as a safeguard in case that doesn't happen. However, it doesn't protect diff --git a/0258-nx-set-the-nx-compatible-flag-in-EFI-grub-images.patch b/0174-nx-set-the-nx-compatible-flag-in-EFI-grub-images.patch similarity index 63% rename from 0258-nx-set-the-nx-compatible-flag-in-EFI-grub-images.patch rename to 0174-nx-set-the-nx-compatible-flag-in-EFI-grub-images.patch index 7da75a8..c2a4c04 100644 --- a/0258-nx-set-the-nx-compatible-flag-in-EFI-grub-images.patch +++ b/0174-nx-set-the-nx-compatible-flag-in-EFI-grub-images.patch @@ -17,18 +17,32 @@ GRUB_PE32_NX_COMPAT, and changes grub-mkimage to set that flag. Signed-off-by: Peter Jones --- - util/mkimage.c | 1 + - 1 file changed, 1 insertion(+) + util/mkimage.c | 1 + + include/grub/efi/pe32.h | 2 ++ + 2 files changed, 3 insertions(+) diff --git a/util/mkimage.c b/util/mkimage.c -index 8319e8dfbd..c3d33aaac8 100644 +index e2bb4d4cd05..425d920ff92 100644 --- a/util/mkimage.c +++ b/util/mkimage.c -@@ -1418,6 +1418,7 @@ grub_install_generate_image (const char *dir, const char *prefix, - section = (struct grub_pe32_section_table *)(o64 + 1); - } - +@@ -1438,6 +1438,7 @@ grub_install_generate_image (const char *dir, const char *prefix, + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdangling-pointer" + #endif + PE_OHDR (o32, o64, dll_characteristics) = grub_host_to_target16 (GRUB_PE32_NX_COMPAT); PE_OHDR (o32, o64, header_size) = grub_host_to_target32 (header_size); PE_OHDR (o32, o64, entry_addr) = grub_host_to_target32 (layout.start_address); PE_OHDR (o32, o64, image_base) = 0; +diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h +index 4e6e9d254bd..9887e14b278 100644 +--- a/include/grub/efi/pe32.h ++++ b/include/grub/efi/pe32.h +@@ -231,6 +231,8 @@ struct grub_pe64_optional_header + + #define GRUB_PE32_SUBSYSTEM_EFI_APPLICATION 10 + ++#define GRUB_PE32_NX_COMPAT 0x0100 ++ + #define GRUB_PE32_NUM_DATA_DIRECTORIES 16 + + struct grub_pe32_section_table diff --git a/0260-grub_fs_probe-dprint-errors-from-filesystems.patch b/0175-grub_fs_probe-dprint-errors-from-filesystems.patch similarity index 89% rename from 0260-grub_fs_probe-dprint-errors-from-filesystems.patch rename to 0175-grub_fs_probe-dprint-errors-from-filesystems.patch index 1455ae4..fdd2932 100644 --- a/0260-grub_fs_probe-dprint-errors-from-filesystems.patch +++ b/0175-grub_fs_probe-dprint-errors-from-filesystems.patch @@ -30,7 +30,7 @@ Signed-off-by: Robbie Harwood 1 file changed, 1 insertion(+) diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c -index c698295bcb..b58e2ae1d2 100644 +index 7ad0aaf4e29..f25bace620b 100644 --- a/grub-core/kern/fs.c +++ b/grub-core/kern/fs.c @@ -74,6 +74,7 @@ grub_fs_probe (grub_device_t device) @@ -39,5 +39,5 @@ index c698295bcb..b58e2ae1d2 100644 + grub_dprintf ("fs", _("error: %s.\n"), grub_errmsg); grub_error_push (); - grub_dprintf ("fs", "%s detection failed.\n", p->name); - grub_error_pop (); + /* The grub_error_push() does not touch grub_errmsg. */ + grub_dprintf ("fs", _("error: %s.\n"), grub_errmsg); diff --git a/0262-Make-debug-file-show-which-file-filters-get-run.patch b/0176-Make-debug-file-show-which-file-filters-get-run.patch similarity index 97% rename from 0262-Make-debug-file-show-which-file-filters-get-run.patch rename to 0176-Make-debug-file-show-which-file-filters-get-run.patch index 78bc095..3bd69d8 100644 --- a/0262-Make-debug-file-show-which-file-filters-get-run.patch +++ b/0176-Make-debug-file-show-which-file-filters-get-run.patch @@ -15,7 +15,7 @@ Signed-off-by: Peter Jones 1 file changed, 11 insertions(+) diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c -index db938e099d..868ce3b63e 100644 +index 264211b1143..1794d022fb0 100644 --- a/grub-core/kern/file.c +++ b/grub-core/kern/file.c @@ -30,6 +30,14 @@ void (*EXPORT_VAR (grub_grubnet_fini)) (void); diff --git a/0267-BLS-create-etc-kernel-cmdline-during-mkconfig.patch b/0177-BLS-create-etc-kernel-cmdline-during-mkconfig.patch similarity index 92% rename from 0267-BLS-create-etc-kernel-cmdline-during-mkconfig.patch rename to 0177-BLS-create-etc-kernel-cmdline-during-mkconfig.patch index 50ba0fb..05e8325 100644 --- a/0267-BLS-create-etc-kernel-cmdline-during-mkconfig.patch +++ b/0177-BLS-create-etc-kernel-cmdline-during-mkconfig.patch @@ -9,10 +9,10 @@ Signed-off-by: Robbie Harwood 1 file changed, 6 insertions(+) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 865af3d6c4..9ebff661a9 100644 +index 360ce26e5f9..a6568caf7d1 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in -@@ -161,6 +161,12 @@ update_bls_cmdline() +@@ -163,6 +163,12 @@ update_bls_cmdline() local cmdline="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" local -a files=($(get_sorted_bls)) diff --git a/0268-squish-don-t-dup-rhgb-quiet-check-mtimes.patch b/0178-squish-don-t-dup-rhgb-quiet-check-mtimes.patch similarity index 94% rename from 0268-squish-don-t-dup-rhgb-quiet-check-mtimes.patch rename to 0178-squish-don-t-dup-rhgb-quiet-check-mtimes.patch index 67073ec..fa279f1 100644 --- a/0268-squish-don-t-dup-rhgb-quiet-check-mtimes.patch +++ b/0178-squish-don-t-dup-rhgb-quiet-check-mtimes.patch @@ -9,10 +9,10 @@ Signed-off-by: Robbie Harwood 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 9ebff661a9..41c6cb1dc2 100644 +index a6568caf7d1..079bb9a0961 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in -@@ -161,10 +161,16 @@ update_bls_cmdline() +@@ -163,10 +163,16 @@ update_bls_cmdline() local cmdline="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" local -a files=($(get_sorted_bls)) diff --git a/0179-fs-ext2-Ignore-checksum-seed-incompat-feature.patch b/0179-fs-ext2-Ignore-checksum-seed-incompat-feature.patch deleted file mode 100644 index 3d7c641..0000000 --- a/0179-fs-ext2-Ignore-checksum-seed-incompat-feature.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Fri, 11 Jun 2021 00:01:29 +0200 -Subject: [PATCH] fs/ext2: Ignore checksum seed incompat feature - -This incompat feature is used to denote that the filesystem stored its -metadata checksum seed in the superblock. This is used to allow tune2fs -to change the UUID on a mounted metadata_csum filesystem without having -to rewrite all the disk metadata. - -But GRUB doesn't use the metadata checksum in anyway, so can just ignore -this feature if is enabled. This is consistent with GRUB filesystem code -in general which just does a best effort to access the filesystem's data. - -It may be removed from the ignored list in the future if supports to do -metadata checksumming verification is added to the read-only FS driver. - -Suggested-by: Eric Sandeen -Suggested-by: Lukas Czerner -Signed-off-by: Javier Martinez Canillas ---- - grub-core/fs/ext2.c | 10 +++++++++- - 1 file changed, 9 insertions(+), 1 deletion(-) - -diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c -index e7dd78e663..731d346f88 100644 ---- a/grub-core/fs/ext2.c -+++ b/grub-core/fs/ext2.c -@@ -103,6 +103,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_CSUM_SEED 0x2000 - #define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000 - - /* The set of back-incompatible features this driver DOES support. Add (OR) -@@ -123,9 +124,16 @@ GRUB_MOD_LICENSE ("GPLv3+"); - * mmp: Not really back-incompatible - was added as such to - * avoid multiple read-write mounts. Safe to ignore for this - * RO driver. -+ * checksum seed: Not really back-incompatible - was added to allow tools -+ * such as tune2fs to change the UUID on a mounted metadata -+ * checksummed filesystem. Safe to ignore for now since the -+ * driver doesn't support checksum verification. But it must -+ * be removed from this list if that support is added later. -+ * - */ - #define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER \ -- | EXT4_FEATURE_INCOMPAT_MMP) -+ | EXT4_FEATURE_INCOMPAT_MMP \ -+ | EXT4_FEATURE_INCOMPAT_CSUM_SEED) - - - #define EXT3_JOURNAL_MAGIC_NUMBER 0xc03b3998U diff --git a/0269-squish-give-up-on-rhgb-quiet.patch b/0179-squish-give-up-on-rhgb-quiet.patch similarity index 91% rename from 0269-squish-give-up-on-rhgb-quiet.patch rename to 0179-squish-give-up-on-rhgb-quiet.patch index 5858c91..c1cbf6d 100644 --- a/0269-squish-give-up-on-rhgb-quiet.patch +++ b/0179-squish-give-up-on-rhgb-quiet.patch @@ -9,10 +9,10 @@ Signed-off-by: Robbie Harwood 1 file changed, 4 deletions(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 41c6cb1dc2..5d1fa072f2 100644 +index 079bb9a0961..2dddc39816f 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in -@@ -166,10 +166,6 @@ update_bls_cmdline() +@@ -168,10 +168,6 @@ update_bls_cmdline() # anaconda has the correct information to create this during install; # afterward, grubby will take care of syncing on updates. If the user # has modified /etc/default/grub, try to cope. diff --git a/0270-squish-BLS-only-write-etc-kernel-cmdline-if-writable.patch b/0180-squish-BLS-only-write-etc-kernel-cmdline-if-writable.patch similarity index 96% rename from 0270-squish-BLS-only-write-etc-kernel-cmdline-if-writable.patch rename to 0180-squish-BLS-only-write-etc-kernel-cmdline-if-writable.patch index d5ac923..2c5c7c5 100644 --- a/0270-squish-BLS-only-write-etc-kernel-cmdline-if-writable.patch +++ b/0180-squish-BLS-only-write-etc-kernel-cmdline-if-writable.patch @@ -32,10 +32,10 @@ Fixes: https://github.com/fedora-silverblue/issue-tracker/issues/322 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 5d1fa072f2..4795a63b4c 100644 +index 2dddc39816f..11c19304f8b 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in -@@ -161,12 +161,13 @@ update_bls_cmdline() +@@ -163,12 +163,13 @@ update_bls_cmdline() local cmdline="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" local -a files=($(get_sorted_bls)) diff --git a/0271-blscfg-Don-t-root-device-in-emu-builds.patch b/0181-blscfg-Don-t-root-device-in-emu-builds.patch similarity index 95% rename from 0271-blscfg-Don-t-root-device-in-emu-builds.patch rename to 0181-blscfg-Don-t-root-device-in-emu-builds.patch index 3fe8baf..d61b1b2 100644 --- a/0271-blscfg-Don-t-root-device-in-emu-builds.patch +++ b/0181-blscfg-Don-t-root-device-in-emu-builds.patch @@ -13,7 +13,7 @@ Signed-off-by: Robbie Harwood 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index e907a6a5d2..dbd0899acf 100644 +index e907a6a5d28..dbd0899acf3 100644 --- a/grub-core/commands/blscfg.c +++ b/grub-core/commands/blscfg.c @@ -41,7 +41,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); diff --git a/0309-ppc64le-signed-boot-media-changes.patch b/0182-ppc64le-signed-boot-media-changes.patch similarity index 92% rename from 0309-ppc64le-signed-boot-media-changes.patch rename to 0182-ppc64le-signed-boot-media-changes.patch index bd71437..f92570e 100644 --- a/0309-ppc64le-signed-boot-media-changes.patch +++ b/0182-ppc64le-signed-boot-media-changes.patch @@ -46,22 +46,20 @@ Signed-off-by: Robbie Harwood wip --- - grub-core/disk/mdraid1x_linux.c | 8 +++++++- + grub-core/disk/mdraid1x_linux.c | 6 ++++++ grub-core/disk/mdraid_linux.c | 5 +++++ grub-core/kern/ieee1275/openfw.c | 2 +- grub-core/normal/main.c | 5 +++++ - 4 files changed, 18 insertions(+), 2 deletions(-) + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/mdraid1x_linux.c b/grub-core/disk/mdraid1x_linux.c -index 38444b02c7..08c57ae16e 100644 +index 72e5cb6f481..3b5b6c42342 100644 --- a/grub-core/disk/mdraid1x_linux.c +++ b/grub-core/disk/mdraid1x_linux.c -@@ -129,7 +129,13 @@ grub_mdraid_detect (grub_disk_t disk, - grub_uint32_t level; +@@ -130,6 +130,12 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_diskfilter_vg *array; char *uuid; -- -+ + +#ifdef __powerpc__ + /* Firmware will yell at us for reading too far. */ + if (minor_version == 0) @@ -70,9 +68,9 @@ index 38444b02c7..08c57ae16e 100644 + if (size == GRUB_DISK_SIZE_UNKNOWN && minor_version == 0) continue; - + diff --git a/grub-core/disk/mdraid_linux.c b/grub-core/disk/mdraid_linux.c -index e40216f511..98fcfb1be6 100644 +index e40216f5111..98fcfb1be69 100644 --- a/grub-core/disk/mdraid_linux.c +++ b/grub-core/disk/mdraid_linux.c @@ -189,6 +189,11 @@ grub_mdraid_detect (grub_disk_t disk, @@ -88,7 +86,7 @@ index e40216f511..98fcfb1be6 100644 size = grub_disk_native_sectors (disk); if (size == GRUB_DISK_SIZE_UNKNOWN) diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c -index 3a6689abb1..0278054c61 100644 +index e2ecc65d2d8..65616254e02 100644 --- a/grub-core/kern/ieee1275/openfw.c +++ b/grub-core/kern/ieee1275/openfw.c @@ -499,7 +499,7 @@ grub_ieee1275_encode_devname (const char *path) @@ -101,7 +99,7 @@ index 3a6689abb1..0278054c61 100644 unsigned int partno = grub_strtoul (partition, 0, 0); diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index 8f5fd81003..d59145f861 100644 +index fc3ed551cec..e903f291732 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -372,6 +372,7 @@ grub_try_normal_prefix (const char *prefix) diff --git a/0310-core-Fix-several-implicit-function-declarations.patch b/0183-core-Fix-several-implicit-function-declarations.patch similarity index 93% rename from 0310-core-Fix-several-implicit-function-declarations.patch rename to 0183-core-Fix-several-implicit-function-declarations.patch index 48c5bb0..a814033 100644 --- a/0310-core-Fix-several-implicit-function-declarations.patch +++ b/0183-core-Fix-several-implicit-function-declarations.patch @@ -17,7 +17,7 @@ Related to: 3 files changed, 3 insertions(+) diff --git a/grub-core/commands/efi/connectefi.c b/grub-core/commands/efi/connectefi.c -index 8ab75bd51b..3752ae17ed 100644 +index 0f840ea0575..6c397f8f508 100644 --- a/grub-core/commands/efi/connectefi.c +++ b/grub-core/commands/efi/connectefi.c @@ -21,6 +21,7 @@ @@ -29,7 +29,7 @@ index 8ab75bd51b..3752ae17ed 100644 #include #include diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index 57d2721719..5f956b743e 100644 +index ce2b492c353..40df19426c8 100644 --- a/grub-core/net/http.c +++ b/grub-core/net/http.c @@ -26,6 +26,7 @@ @@ -41,7 +41,7 @@ index 57d2721719..5f956b743e 100644 GRUB_MOD_LICENSE ("GPLv3+"); diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c -index dac0f946fe..de3e4abe44 100644 +index 378deb321d9..e667d0a862c 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -25,6 +25,7 @@ diff --git a/0183-templates-Check-for-EFI-at-runtime-instead-of-config.patch b/0183-templates-Check-for-EFI-at-runtime-instead-of-config.patch deleted file mode 100644 index 265b967..0000000 --- a/0183-templates-Check-for-EFI-at-runtime-instead-of-config.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 6 Jul 2021 00:38:40 +0200 -Subject: [PATCH] templates: Check for EFI at runtime instead of config - generation time - -The 30_uefi-firmware template checks if an OsIndicationsSupported UEFI var -exists and EFI_OS_INDICATIONS_BOOT_TO_FW_UI bit is set, to decide whether -a "fwsetup" menu entry would be added or not to the GRUB menu. - -But this has the problem that it will only work if the configuration file -was created on an UEFI machine that supports booting to a firmware UI. - -This for example doesn't support creating GRUB config files when executing -on systems that support both UEFI and legacy BIOS booting. Since creating -the config file from legacy BIOS wouldn't allow to access the firmware UI. - -To prevent this, make the template to unconditionally create the grub.cfg -snippet but check at runtime if was booted through UEFI to decide if this -entry should be added. That way it won't be added when booting with BIOS. - -There's no need to check if EFI_OS_INDICATIONS_BOOT_TO_FW_UI bit is set, -since that's already done by the "fwsetup" command when is executed. - -Resolves: rhbz#1823864 - -Signed-off-by: Javier Martinez Canillas ---- - util/grub.d/30_uefi-firmware.in | 21 ++++++++------------- - 1 file changed, 8 insertions(+), 13 deletions(-) - -diff --git a/util/grub.d/30_uefi-firmware.in b/util/grub.d/30_uefi-firmware.in -index d344d3883d..b6041b55e2 100644 ---- a/util/grub.d/30_uefi-firmware.in -+++ b/util/grub.d/30_uefi-firmware.in -@@ -26,19 +26,14 @@ export TEXTDOMAINDIR="@localedir@" - - . "$pkgdatadir/grub-mkconfig_lib" - --EFI_VARS_DIR=/sys/firmware/efi/efivars --EFI_GLOBAL_VARIABLE=8be4df61-93ca-11d2-aa0d-00e098032b8c --OS_INDICATIONS="$EFI_VARS_DIR/OsIndicationsSupported-$EFI_GLOBAL_VARIABLE" -+LABEL="UEFI Firmware Settings" - --if [ -e "$OS_INDICATIONS" ] && \ -- [ "$(( $(printf 0x%x \'"$(cat $OS_INDICATIONS | cut -b5)"\') & 1 ))" = 1 ]; then -- LABEL="UEFI Firmware Settings" -+gettext_printf "Adding boot menu entry for UEFI Firmware Settings ...\n" >&2 - -- gettext_printf "Adding boot menu entry for UEFI Firmware Settings ...\n" >&2 -- -- cat << EOF --menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' { -- fwsetup --} --EOF -+cat << EOF -+if [ "\$grub_platform" = "efi" ]; then -+ menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' { -+ fwsetup -+ } - fi -+EOF diff --git a/0184-efi-Print-an-error-if-boot-to-firmware-setup-is-not-.patch b/0184-efi-Print-an-error-if-boot-to-firmware-setup-is-not-.patch deleted file mode 100644 index 3b1a219..0000000 --- a/0184-efi-Print-an-error-if-boot-to-firmware-setup-is-not-.patch +++ /dev/null @@ -1,92 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Javier Martinez Canillas -Date: Tue, 6 Jul 2021 01:10:18 +0200 -Subject: [PATCH] efi: Print an error if boot to firmware setup is not - supported - -The "fwsetup" command is only registered if the firmware supports booting -to the firmware setup UI. But it could be possible that the GRUB config -already contains a "fwsetup" entry, because it was generated in a machine -that has support for this feature. - -To prevent users getting a "can't find command `fwsetup`" error if it is -not supported by the firmware, let's just always register the command but -print a more accurate message if the firmware doesn't support this option. - -Resolves: rhbz#1823864 - -Signed-off-by: Javier Martinez Canillas ---- - grub-core/commands/efi/efifwsetup.c | 43 ++++++++++++++++++++----------------- - 1 file changed, 23 insertions(+), 20 deletions(-) - -diff --git a/grub-core/commands/efi/efifwsetup.c b/grub-core/commands/efi/efifwsetup.c -index eaca032838..328c45e82e 100644 ---- a/grub-core/commands/efi/efifwsetup.c -+++ b/grub-core/commands/efi/efifwsetup.c -@@ -27,6 +27,25 @@ - - GRUB_MOD_LICENSE ("GPLv3+"); - -+static grub_efi_boolean_t -+efifwsetup_is_supported (void) -+{ -+ grub_efi_uint64_t *os_indications_supported = NULL; -+ grub_size_t oi_size = 0; -+ grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID; -+ -+ grub_efi_get_variable ("OsIndicationsSupported", &global, &oi_size, -+ (void **) &os_indications_supported); -+ -+ if (!os_indications_supported) -+ return 0; -+ -+ if (*os_indications_supported & GRUB_EFI_OS_INDICATIONS_BOOT_TO_FW_UI) -+ return 1; -+ -+ return 0; -+} -+ - static grub_err_t - grub_cmd_fwsetup (grub_command_t cmd __attribute__ ((unused)), - int argc __attribute__ ((unused)), -@@ -38,6 +57,10 @@ grub_cmd_fwsetup (grub_command_t cmd __attribute__ ((unused)), - grub_size_t oi_size; - grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID; - -+ if (!efifwsetup_is_supported ()) -+ return grub_error (GRUB_ERR_INVALID_COMMAND, -+ N_("Reboot to firmware setup is not supported")); -+ - grub_efi_get_variable ("OsIndications", &global, &oi_size, - (void **) &old_os_indications); - -@@ -56,28 +79,8 @@ grub_cmd_fwsetup (grub_command_t cmd __attribute__ ((unused)), - - static grub_command_t cmd = NULL; - --static grub_efi_boolean_t --efifwsetup_is_supported (void) --{ -- grub_efi_uint64_t *os_indications_supported = NULL; -- grub_size_t oi_size = 0; -- grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID; -- -- grub_efi_get_variable ("OsIndicationsSupported", &global, &oi_size, -- (void **) &os_indications_supported); -- -- if (!os_indications_supported) -- return 0; -- -- if (*os_indications_supported & GRUB_EFI_OS_INDICATIONS_BOOT_TO_FW_UI) -- return 1; -- -- return 0; --} -- - GRUB_MOD_INIT (efifwsetup) - { -- if (efifwsetup_is_supported ()) - cmd = grub_register_command ("fwsetup", grub_cmd_fwsetup, NULL, - N_("Reboot into firmware setup menu.")); - diff --git a/0184-ieee1275-request-memory-with-ibm-client-architecture.patch b/0184-ieee1275-request-memory-with-ibm-client-architecture.patch new file mode 100644 index 0000000..bd59885 --- /dev/null +++ b/0184-ieee1275-request-memory-with-ibm-client-architecture.patch @@ -0,0 +1,109 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Daniel Axtens +Date: Mon, 6 Feb 2023 10:03:20 -0500 +Subject: [PATCH] ieee1275: request memory with ibm, + client-architecture-support + +On PowerVM, the first time we boot a Linux partition, we may only get +256MB of real memory area, even if the partition has more memory. + +This isn't enough to reliably verify a kernel. Fortunately, the Power +Architecture Platform Reference (PAPR) defines a method we can call to ask +for more memory: the broad and powerful ibm,client-architecture-support +(CAS) method. + +CAS can do an enormous amount of things on a PAPR platform: as well as +asking for memory, you can set the supported processor level, the interrupt +controller, hash vs radix mmu, and so on. + +If: + + - we are running under what we think is PowerVM (compatible property of / + begins with "IBM"), and + + - the full amount of RMA is less than 512MB (as determined by the reg + property of /memory) + +then call CAS as follows: (refer to the Linux on Power Architecture +Reference, LoPAR, which is public, at B.5.2.3): + + - Use the "any" PVR value and supply 2 option vectors. + + - Set option vector 1 (PowerPC Server Processor Architecture Level) + to "ignore". + + - Set option vector 2 with default or Linux-like options, including a + min-rma-size of 512MB. + + - Set option vector 3 to request Floating Point, VMX and Decimal Floating + point, but don't abort the boot if we can't get them. + + - Set option vector 4 to request a minimum VP percentage to 1%, which is + what Linux requests, and is below the default of 10%. Without this, + some systems with very large or very small configurations fail to boot. + +This will cause a CAS reboot and the partition will restart with 512MB +of RMA. Importantly, grub will notice the 512MB and not call CAS again. + +Notes about the choices of parameters: + + - A partition can be configured with only 256MB of memory, which would + mean this request couldn't be satisfied, but PFW refuses to load with + only 256MB of memory, so it's a bit moot. SLOF will run fine with 256MB, + but we will never call CAS under qemu/SLOF because /compatible won't + begin with "IBM".) + + - unspecified CAS vectors take on default values. Some of these values + might restrict the ability of certain hardware configurations to boot. + This is why we need to specify the VP percentage in vector 4, which is + in turn why we need to specify vector 3. + +Finally, we should have enough memory to verify a kernel, and we will +reach Linux. One of the first things Linux does while still running under +OpenFirmware is to call CAS with a much fuller set of options (including +asking for 512MB of memory). Linux includes a much more restrictive set of +PVR values and processor support levels, and this CAS invocation will likely +induce another reboot. On this reboot grub will again notice the higher RMA, +and not call CAS. We will get to Linux again, Linux will call CAS again, but +because the values are now set for Linux this will not induce another CAS +reboot and we will finally boot all the way to userspace. + +On all subsequent boots, everything will be configured with 512MB of RMA, +so there will be no further CAS reboots from grub. (phyp is super sticky +with the RMA size - it persists even on cold boots. So if you've ever booted +Linux in a partition, you'll probably never have grub call CAS. It'll only +ever fire the first time a partition loads grub, or if you deliberately lower +the amount of memory your partition has below 512MB.) + +Signed-off-by: Daniel Axtens +Signed-off-by: Stefan Berger +Reviewed-by: Daniel Kiper +(cherry picked from commit d5571590b7de61887efac1c298901455697ba307) +--- + grub-core/kern/ieee1275/init.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c +index 8ce1a0f09ee..13e8a5b4bb8 100644 +--- a/grub-core/kern/ieee1275/init.c ++++ b/grub-core/kern/ieee1275/init.c +@@ -850,6 +850,19 @@ grub_claim_heap (void) + } + #endif + ++#if defined(__powerpc__) ++ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CAN_TRY_CAS_FOR_MORE_MEMORY)) ++ { ++ grub_uint64_t rma_size; ++ grub_err_t err; ++ ++ err = grub_ieee1275_total_mem (&rma_size); ++ /* if we have an error, don't call CAS, just hope for the best */ ++ if (err == GRUB_ERR_NONE && rma_size < (512 * 1024 * 1024)) ++ grub_ieee1275_ibm_cas (); ++ } ++#endif ++ + grub_machine_mmap_iterate (heap_init, &total); + } + #endif diff --git a/0323-hostdisk-work-around-proc-not-reporting-size.patch b/0185-hostdisk-work-around-proc-not-reporting-size.patch similarity index 93% rename from 0323-hostdisk-work-around-proc-not-reporting-size.patch rename to 0185-hostdisk-work-around-proc-not-reporting-size.patch index 5f2fa08..72715ae 100644 --- a/0323-hostdisk-work-around-proc-not-reporting-size.patch +++ b/0185-hostdisk-work-around-proc-not-reporting-size.patch @@ -15,7 +15,7 @@ Signed-off-by: Robbie Harwood 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c -index 868ce3b63e..4ea6d1ce95 100644 +index 1794d022fb0..75510df7c92 100644 --- a/grub-core/kern/file.c +++ b/grub-core/kern/file.c @@ -172,26 +172,30 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len) @@ -62,10 +62,10 @@ index 868ce3b63e..4ea6d1ce95 100644 read_hook_data = file->read_hook_data; if (!file->read_hook) diff --git a/grub-core/lib/progress.c b/grub-core/lib/progress.c -index 4b7cbbca6d..f3226b6898 100644 +index 4f4389dd586..eb1b7d13cfd 100644 --- a/grub-core/lib/progress.c +++ b/grub-core/lib/progress.c -@@ -71,7 +71,7 @@ grub_file_progress_hook_real (grub_disk_addr_t sector __attribute__ ((unused)), +@@ -72,7 +72,7 @@ grub_file_progress_hook_real (grub_disk_addr_t sector __attribute__ ((unused)), * 100ULL * 1000ULL, now - file->last_progress_time, 0); @@ -75,7 +75,7 @@ index 4b7cbbca6d..f3226b6898 100644 else percent = grub_divmod64 (100 * file->progress_offset, diff --git a/grub-core/osdep/unix/hostdisk.c b/grub-core/osdep/unix/hostdisk.c -index 3a00d7451a..e5f4b4d5f9 100644 +index 3a00d7451a5..e5f4b4d5f9c 100644 --- a/grub-core/osdep/unix/hostdisk.c +++ b/grub-core/osdep/unix/hostdisk.c @@ -71,6 +71,12 @@ grub_util_get_fd_size (grub_util_fd_t fd, const char *name, unsigned *log_secsiz diff --git a/0324-blscfg-check-for-mounted-boot-in-emu.patch b/0186-blscfg-check-for-mounted-boot-in-emu.patch similarity index 99% rename from 0324-blscfg-check-for-mounted-boot-in-emu.patch rename to 0186-blscfg-check-for-mounted-boot-in-emu.patch index 69ebe15..54b3cf0 100644 --- a/0324-blscfg-check-for-mounted-boot-in-emu.patch +++ b/0186-blscfg-check-for-mounted-boot-in-emu.patch @@ -14,7 +14,7 @@ Signed-off-by: Robbie Harwood 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c -index dbd0899acf..6e398fc175 100644 +index dbd0899acf3..6e398fc1757 100644 --- a/grub-core/commands/blscfg.c +++ b/grub-core/commands/blscfg.c @@ -40,8 +40,9 @@ GRUB_MOD_LICENSE ("GPLv3+"); diff --git a/0329-grub_dl_set_mem_attrs-fix-format-string.patch b/0187-grub_dl_set_mem_attrs-fix-format-string.patch similarity index 97% rename from 0329-grub_dl_set_mem_attrs-fix-format-string.patch rename to 0187-grub_dl_set_mem_attrs-fix-format-string.patch index ee50591..646c609 100644 --- a/0329-grub_dl_set_mem_attrs-fix-format-string.patch +++ b/0187-grub_dl_set_mem_attrs-fix-format-string.patch @@ -23,7 +23,7 @@ Signed-off-by: Laszlo Ersek 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index ab9101a5ad..a97f4a8b13 100644 +index 25666ae383f..101e0794dd8 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -733,7 +733,8 @@ grub_dl_set_mem_attrs (grub_dl_t mod, void *ehdr) diff --git a/0188-fs-xfs-Fix-unreadable-filesystem-with-v4-superblock.patch b/0188-fs-xfs-Fix-unreadable-filesystem-with-v4-superblock.patch deleted file mode 100644 index 7fc40f1..0000000 --- a/0188-fs-xfs-Fix-unreadable-filesystem-with-v4-superblock.patch +++ /dev/null @@ -1,118 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Erwan Velu -Date: Wed, 25 Aug 2021 15:31:52 +0200 -Subject: [PATCH] fs/xfs: Fix unreadable filesystem with v4 superblock - -The commit 8b1e5d193 (fs/xfs: Add bigtime incompat feature support) -introduced the bigtime support by adding some features in v3 inodes. -This change extended grub_xfs_inode struct by 76 bytes but also changed -the computation of XFS_V2_INODE_SIZE and XFS_V3_INODE_SIZE. Prior this -commit, XFS_V2_INODE_SIZE was 100 bytes. After the commit it's 84 bytes -XFS_V2_INODE_SIZE becomes 16 bytes too small. - -As a result, the data structures aren't properly aligned and the GRUB -generates "attempt to read or write outside of partition" errors when -trying to read the XFS filesystem: - - GNU GRUB version 2.11 - .... - grub> set debug=efi,gpt,xfs - grub> insmod part_gpt - grub> ls (hd0,gpt1)/ - partmap/gpt.c:93: Read a valid GPT header - partmap/gpt.c:115: GPT entry 0: start=4096, length=1953125 - fs/xfs.c:931: Reading sb - fs/xfs.c:270: Validating superblock - fs/xfs.c:295: XFS v4 superblock detected - fs/xfs.c:962: Reading root ino 128 - fs/xfs.c:515: Reading inode (128) - 64, 0 - fs/xfs.c:515: Reading inode (739521961424144223) - 344365866970255880, 3840 - error: attempt to read or write outside of partition. - -This commit change the XFS_V2_INODE_SIZE computation by subtracting 76 -bytes instead of 92 bytes from the actual size of grub_xfs_inode struct. -This 76 bytes value comes from added members: - 20 grub_uint8_t unused5 - 1 grub_uint64_t flags2 - 48 grub_uint8_t unused6 - -This patch explicitly splits the v2 and v3 parts of the structure. -The unused4 is still ending of the v2 structures and the v3 starts -at unused5. Thanks to this we will avoid future corruptions of v2 -or v3 inodes. - -The XFS_V2_INODE_SIZE is returning to its expected size and the -filesystem is back to a readable state: - - GNU GRUB version 2.11 - .... - grub> set debug=efi,gpt,xfs - grub> insmod part_gpt - grub> ls (hd0,gpt1)/ - partmap/gpt.c:93: Read a valid GPT header - partmap/gpt.c:115: GPT entry 0: start=4096, length=1953125 - fs/xfs.c:931: Reading sb - fs/xfs.c:270: Validating superblock - fs/xfs.c:295: XFS v4 superblock detected - fs/xfs.c:962: Reading root ino 128 - fs/xfs.c:515: Reading inode (128) - 64, 0 - fs/xfs.c:515: Reading inode (128) - 64, 0 - fs/xfs.c:931: Reading sb - fs/xfs.c:270: Validating superblock - fs/xfs.c:295: XFS v4 superblock detected - fs/xfs.c:962: Reading root ino 128 - fs/xfs.c:515: Reading inode (128) - 64, 0 - fs/xfs.c:515: Reading inode (128) - 64, 0 - fs/xfs.c:515: Reading inode (128) - 64, 0 - fs/xfs.c:515: Reading inode (131) - 64, 768 - efi/ fs/xfs.c:515: Reading inode (3145856) - 1464904, 0 - grub2/ fs/xfs.c:515: Reading inode (132) - 64, 1024 - grub/ fs/xfs.c:515: Reading inode (139) - 64, 2816 - grub> - -Fixes: 8b1e5d193 (fs/xfs: Add bigtime incompat feature support) - -Signed-off-by: Erwan Velu -Tested-by: Carlos Maiolino -Reviewed-by: Daniel Kiper -(cherry picked from commit a4b495520e4dc41a896a8b916a64eda9970c50ea) ---- - grub-core/fs/xfs.c | 14 ++++++++++---- - 1 file changed, 10 insertions(+), 4 deletions(-) - -diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c -index 0f524c3a8a..e3816d1ec4 100644 ---- a/grub-core/fs/xfs.c -+++ b/grub-core/fs/xfs.c -@@ -192,6 +192,11 @@ struct grub_xfs_time_legacy - grub_uint32_t nanosec; - } GRUB_PACKED; - -+/* -+ * The struct grub_xfs_inode layout was taken from the -+ * struct xfs_dinode_core which is described here: -+ * https://mirrors.edge.kernel.org/pub/linux/utils/fs/xfs/docs/xfs_filesystem_structure.pdf -+ */ - struct grub_xfs_inode - { - grub_uint8_t magic[2]; -@@ -208,14 +213,15 @@ struct grub_xfs_inode - grub_uint32_t nextents; - grub_uint16_t unused3; - grub_uint8_t fork_offset; -- grub_uint8_t unused4[37]; -+ grub_uint8_t unused4[17]; /* Last member of inode v2. */ -+ grub_uint8_t unused5[20]; /* First member of inode v3. */ - grub_uint64_t flags2; -- grub_uint8_t unused5[48]; -+ grub_uint8_t unused6[48]; /* Last member of inode v3. */ - } GRUB_PACKED; - - #define XFS_V3_INODE_SIZE sizeof(struct grub_xfs_inode) --/* Size of struct grub_xfs_inode until fork_offset (included). */ --#define XFS_V2_INODE_SIZE (XFS_V3_INODE_SIZE - 92) -+/* Size of struct grub_xfs_inode v2, up to unused4 member included. */ -+#define XFS_V2_INODE_SIZE (XFS_V3_INODE_SIZE - 76) - - struct grub_xfs_dirblock_tail - { diff --git a/0330-grub_dl_set_mem_attrs-add-self-check-for-the-tramp-G.patch b/0188-grub_dl_set_mem_attrs-add-self-check-for-the-tramp-G.patch similarity index 99% rename from 0330-grub_dl_set_mem_attrs-add-self-check-for-the-tramp-G.patch rename to 0188-grub_dl_set_mem_attrs-add-self-check-for-the-tramp-G.patch index b95e678..6543a9e 100644 --- a/0330-grub_dl_set_mem_attrs-add-self-check-for-the-tramp-G.patch +++ b/0188-grub_dl_set_mem_attrs-add-self-check-for-the-tramp-G.patch @@ -110,7 +110,7 @@ Signed-off-by: Laszlo Ersek 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index a97f4a8b13..3b66fa410e 100644 +index 101e0794dd8..bad0ad4b945 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -682,7 +682,7 @@ grub_dl_set_mem_attrs (grub_dl_t mod, void *ehdr) diff --git a/0189-Print-module-name-on-license-check-failure.patch b/0189-Print-module-name-on-license-check-failure.patch deleted file mode 100644 index 5c30859..0000000 --- a/0189-Print-module-name-on-license-check-failure.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robbie Harwood -Date: Tue, 12 Oct 2021 12:34:23 -0400 -Subject: [PATCH] Print module name on license check failure - -At the very least, this will make it easier to track down the problem -module - or, if something else has gone wrong, provide more information -for debugging. - -Signed-off-by: Robbie Harwood ---- - grub-core/kern/dl.c | 10 ++++++---- - 1 file changed, 6 insertions(+), 4 deletions(-) - -diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 9557254035..f304494574 100644 ---- a/grub-core/kern/dl.c -+++ b/grub-core/kern/dl.c -@@ -528,14 +528,16 @@ grub_dl_find_section_index (Elf_Ehdr *e, const char *name) - Be sure to understand your license obligations. - */ - static grub_err_t --grub_dl_check_license (Elf_Ehdr *e) -+grub_dl_check_license (grub_dl_t mod, Elf_Ehdr *e) - { - Elf_Shdr *s = grub_dl_find_section (e, ".module_license"); - if (s && (grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3") == 0 - || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3+") == 0 - || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv2+") == 0)) - return GRUB_ERR_NONE; -- return grub_error (GRUB_ERR_BAD_MODULE, "incompatible license"); -+ return grub_error (GRUB_ERR_BAD_MODULE, -+ "incompatible license in module %s: %s", mod->name, -+ (char *) e + s->sh_offset); - } - - static grub_err_t -@@ -743,8 +745,8 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size) - constitutes linking) and GRUB core being licensed under GPLv3+. - Be sure to understand your license obligations. - */ -- if (grub_dl_check_license (e) -- || grub_dl_resolve_name (mod, e) -+ if (grub_dl_resolve_name (mod, e) -+ || grub_dl_check_license (mod, e) - || grub_dl_resolve_dependencies (mod, e) - || grub_dl_load_segments (mod, e) - || grub_dl_resolve_symbols (mod, e) diff --git a/0331-grub_dl_load_segments-page-align-the-tramp-GOT-areas.patch b/0189-grub_dl_load_segments-page-align-the-tramp-GOT-areas.patch similarity index 88% rename from 0331-grub_dl_load_segments-page-align-the-tramp-GOT-areas.patch rename to 0189-grub_dl_load_segments-page-align-the-tramp-GOT-areas.patch index f29609d..9ccf412 100644 --- a/0331-grub_dl_load_segments-page-align-the-tramp-GOT-areas.patch +++ b/0189-grub_dl_load_segments-page-align-the-tramp-GOT-areas.patch @@ -16,12 +16,12 @@ Signed-off-by: Laszlo Ersek 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 3b66fa410e..f3cdb9e0ba 100644 +index bad0ad4b945..c55f0ecf931 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c -@@ -280,7 +280,9 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) - grub_size_t tsize = 0, talign = 1, arch_addralign = 1; - #if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv) +@@ -272,7 +272,9 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) + #if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv) && \ + !defined (__loongarch__) grub_size_t tramp; + grub_size_t tramp_align; grub_size_t got; @@ -29,7 +29,7 @@ index 3b66fa410e..f3cdb9e0ba 100644 grub_err_t err; #endif char *ptr; -@@ -311,12 +313,18 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) +@@ -304,12 +306,18 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) err = grub_arch_dl_get_tramp_got_size (e, &tramp, &got); if (err) return err; @@ -54,10 +54,10 @@ index 3b66fa410e..f3cdb9e0ba 100644 #endif #ifdef GRUB_MACHINE_EMU -@@ -376,11 +384,11 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) - } +@@ -370,11 +378,11 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e) } - #if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv) + #if !defined (__i386__) && !defined (__x86_64__) && !defined(__riscv) && \ + !defined (__loongarch__) - ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, GRUB_ARCH_DL_TRAMP_ALIGN); + ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, tramp_align); mod->tramp = ptr; diff --git a/0332-emu-Add-switch-root-to-grub-emu.patch b/0190-emu-Add-switch-root-to-grub-emu.patch similarity index 98% rename from 0332-emu-Add-switch-root-to-grub-emu.patch rename to 0190-emu-Add-switch-root-to-grub-emu.patch index 2a0f34b..3fabaae 100644 --- a/0332-emu-Add-switch-root-to-grub-emu.patch +++ b/0190-emu-Add-switch-root-to-grub-emu.patch @@ -17,7 +17,7 @@ Signed-off-by: Nicolas Frayer 5 files changed, 223 insertions(+), 8 deletions(-) diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c -index 68e2b283bb..ccb2863f5b 100644 +index 38c1576a2ef..61b3181775b 100644 --- a/grub-core/kern/emu/main.c +++ b/grub-core/kern/emu/main.c @@ -108,6 +108,7 @@ static struct argp_option options[] = { @@ -40,7 +40,7 @@ index 68e2b283bb..ccb2863f5b 100644 { /* Too many arguments. */ diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c -index 02d27c3440..4b5123ef96 100644 +index d145e5796b3..7b9731b7efa 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c @@ -40,6 +40,7 @@ @@ -68,7 +68,7 @@ index 02d27c3440..4b5123ef96 100644 + return switchroot; +} diff --git a/grub-core/loader/emu/linux.c b/grub-core/loader/emu/linux.c -index 7de3f7f861..6feb0412c5 100644 +index 7de3f7f8610..6feb0412c58 100644 --- a/grub-core/loader/emu/linux.c +++ b/grub-core/loader/emu/linux.c @@ -15,7 +15,6 @@ @@ -303,7 +303,7 @@ index 7de3f7f861..6feb0412c5 100644 grub_free (initrd_param); diff --git a/include/grub/emu/exec.h b/include/grub/emu/exec.h -index 1b61b4a2e5..e82f13215e 100644 +index 1b61b4a2e5d..e82f13215e0 100644 --- a/include/grub/emu/exec.h +++ b/include/grub/emu/exec.h @@ -36,7 +36,7 @@ grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file, @@ -316,7 +316,7 @@ index 1b61b4a2e5..e82f13215e 100644 int grub_util_exec_redirect_null (const char *const *argv); diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h -index 01056954b9..f3a712a8b2 100644 +index 01056954b96..f3a712a8b2f 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h @@ -59,6 +59,8 @@ void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format diff --git a/0191-grub-mkconfig-restore-umask-for-grub.cfg.patch b/0191-grub-mkconfig-restore-umask-for-grub.cfg.patch deleted file mode 100644 index 76b73f5..0000000 --- a/0191-grub-mkconfig-restore-umask-for-grub.cfg.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Michael Chang via Grub-devel -Date: Fri, 3 Dec 2021 16:13:28 +0800 -Subject: [PATCH] grub-mkconfig: restore umask for grub.cfg - -Since commit: - - ab2e53c8a grub-mkconfig: Honor a symlink when generating configuration -by grub-mkconfig - -has inadvertently discarded umask for creating grub.cfg in the process -of grub-mkconfig. The resulting wrong permission (0644) would allow -unprivileged users to read grub's configuration file content. This -presents a low confidentiality risk as grub.cfg may contain non-secured -plain-text passwords. - -This patch restores the missing umask and set the file mode of creation -to 0600 preventing unprivileged access. - -Fixes: CVE-2021-3981 - -Signed-off-by: Michael Chang ---- - util/grub-mkconfig.in | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index f55339a3f6..520a672cd2 100644 ---- a/util/grub-mkconfig.in -+++ b/util/grub-mkconfig.in -@@ -311,7 +311,9 @@ and /etc/grub.d/* files or please file a bug report with - exit 1 - else - # none of the children aborted with error, install the new grub.cfg -+ oldumask=$(umask); umask 077 - cat ${grub_cfg}.new > ${grub_cfg} -+ umask $oldumask - rm -f ${grub_cfg}.new - fi - fi diff --git a/0333-util-Enable-default-kernel-for-updates.patch b/0191-util-Enable-default-kernel-for-updates.patch similarity index 97% rename from 0333-util-Enable-default-kernel-for-updates.patch rename to 0191-util-Enable-default-kernel-for-updates.patch index ac9ef0b..5682df0 100644 --- a/0333-util-Enable-default-kernel-for-updates.patch +++ b/0191-util-Enable-default-kernel-for-updates.patch @@ -14,7 +14,7 @@ Signed-off-by: Marta Lewandowska 1 file changed, 8 insertions(+) diff --git a/util/grub-get-kernel-settings.in b/util/grub-get-kernel-settings.in -index 7e87dfccc0e4..f71bc64360b0 100644 +index 7e87dfccc0e..f71bc64360b 100644 --- a/util/grub-get-kernel-settings.in +++ b/util/grub-get-kernel-settings.in @@ -68,6 +68,14 @@ if test -f /etc/sysconfig/kernel ; then diff --git a/0334-efi-http-change-uint32_t-to-uintn_t.patch b/0192-efi-http-change-uint32_t-to-uintn_t.patch similarity index 95% rename from 0334-efi-http-change-uint32_t-to-uintn_t.patch rename to 0192-efi-http-change-uint32_t-to-uintn_t.patch index f970eb1..ec22c36 100644 --- a/0334-efi-http-change-uint32_t-to-uintn_t.patch +++ b/0192-efi-http-change-uint32_t-to-uintn_t.patch @@ -13,7 +13,7 @@ Signed-off-by: Nicolas Frayer 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/grub/efi/http.h b/include/grub/efi/http.h -index c5e9a89f5050..ad164ba1913d 100644 +index c5e9a89f505..ad164ba1913 100644 --- a/include/grub/efi/http.h +++ b/include/grub/efi/http.h @@ -171,9 +171,9 @@ typedef struct { diff --git a/0192-fs-btrfs-Use-full-btrfs-bootloader-area.patch b/0192-fs-btrfs-Use-full-btrfs-bootloader-area.patch deleted file mode 100644 index 3f7198f..0000000 --- a/0192-fs-btrfs-Use-full-btrfs-bootloader-area.patch +++ /dev/null @@ -1,160 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Michael Chang -Date: Mon, 13 Dec 2021 14:25:49 +0800 -Subject: [PATCH] fs/btrfs: Use full btrfs bootloader area - -Up to now GRUB can only embed to the first 64 KiB before primary -superblock of btrfs, effectively limiting the GRUB core size. That -could consequently pose restrictions to feature enablement like -advanced zstd compression. - -This patch attempts to utilize full unused area reserved by btrfs for -the bootloader outlined in the document [1]: - - The first 1MiB on each device is unused with the exception of primary - superblock that is on the offset 64KiB and spans 4KiB. - -Apart from that, adjacent sectors to superblock and first block group -are not used for embedding in case of overflow and logged access to -adjacent sectors could be useful for tracing it up. - -This patch has been tested to provide out of the box support for btrfs -zstd compression with which GRUB has been installed to the partition. - -[1] https://btrfs.wiki.kernel.org/index.php/Manpage/btrfs(5)#BOOTLOADER_SUPPORT - -Signed-off-by: Michael Chang -Reviewed-by: Daniel Kiper -(cherry picked from commit b0f06a81c6f31b6fa20be67a96b6683bba8210c9) ---- - grub-core/fs/btrfs.c | 90 ++++++++++++++++++++++++++++++++++++++++++++-------- - include/grub/disk.h | 2 ++ - 2 files changed, 79 insertions(+), 13 deletions(-) - -diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 4cc86e9b79..07c0ff874b 100644 ---- a/grub-core/fs/btrfs.c -+++ b/grub-core/fs/btrfs.c -@@ -2476,6 +2476,33 @@ grub_btrfs_label (grub_device_t device, char **label) - } - - #ifdef GRUB_UTIL -+ -+struct embed_region { -+ unsigned int start; -+ unsigned int secs; -+}; -+ -+/* -+ * https://btrfs.wiki.kernel.org/index.php/Manpage/btrfs(5)#BOOTLOADER_SUPPORT -+ * The first 1 MiB on each device is unused with the exception of primary -+ * superblock that is on the offset 64 KiB and spans 4 KiB. -+ */ -+ -+static const struct { -+ struct embed_region available; -+ struct embed_region used[6]; -+} btrfs_head = { -+ .available = {0, GRUB_DISK_KiB_TO_SECTORS (1024)}, /* The first 1 MiB. */ -+ .used = { -+ {0, 1}, /* boot.S. */ -+ {GRUB_DISK_KiB_TO_SECTORS (64) - 1, 1}, /* Overflow guard. */ -+ {GRUB_DISK_KiB_TO_SECTORS (64), GRUB_DISK_KiB_TO_SECTORS (4)}, /* 4 KiB superblock. */ -+ {GRUB_DISK_KiB_TO_SECTORS (68), 1}, /* Overflow guard. */ -+ {GRUB_DISK_KiB_TO_SECTORS (1024) - 1, 1}, /* Overflow guard. */ -+ {0, 0} /* Array terminator. */ -+ } -+}; -+ - static grub_err_t - grub_btrfs_embed (grub_device_t device __attribute__ ((unused)), - unsigned int *nsectors, -@@ -2483,25 +2510,62 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)), - grub_embed_type_t embed_type, - grub_disk_addr_t **sectors) - { -- unsigned i; -+ unsigned int i, j, n = 0; -+ const struct embed_region *u; -+ grub_disk_addr_t *map; - - if (embed_type != GRUB_EMBED_PCBIOS) - return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "BtrFS currently supports only PC-BIOS embedding"); - -- if (64 * 2 - 1 < *nsectors) -- return grub_error (GRUB_ERR_OUT_OF_RANGE, -- N_("your core.img is unusually large. " -- "It won't fit in the embedding area")); -- -- *nsectors = 64 * 2 - 1; -- if (*nsectors > max_nsectors) -- *nsectors = max_nsectors; -- *sectors = grub_calloc (*nsectors, sizeof (**sectors)); -- if (!*sectors) -+ map = grub_calloc (btrfs_head.available.secs, sizeof (*map)); -+ if (map == NULL) - return grub_errno; -- for (i = 0; i < *nsectors; i++) -- (*sectors)[i] = i + 1; -+ -+ /* -+ * Populating the map array so that it can be used to index if a disk -+ * address is available to embed: -+ * - 0: available, -+ * - 1: unavailable. -+ */ -+ for (u = btrfs_head.used; u->secs; ++u) -+ { -+ unsigned int end = u->start + u->secs; -+ -+ if (end > btrfs_head.available.secs) -+ end = btrfs_head.available.secs; -+ for (i = u->start; i < end; ++i) -+ map[i] = 1; -+ } -+ -+ /* Adding up n until it matches total size of available embedding area. */ -+ for (i = 0; i < btrfs_head.available.secs; ++i) -+ if (map[i] == 0) -+ n++; -+ -+ if (n < *nsectors) -+ { -+ grub_free (map); -+ return grub_error (GRUB_ERR_OUT_OF_RANGE, -+ N_("your core.img is unusually large. " -+ "It won't fit in the embedding area")); -+ } -+ -+ if (n > max_nsectors) -+ n = max_nsectors; -+ -+ /* -+ * Populating the array so that it can used to index disk block address for -+ * an image file's offset to be embedded on disk (the unit is in sectors): -+ * - i: The disk block address relative to btrfs_head.available.start, -+ * - j: The offset in image file. -+ */ -+ for (i = 0, j = 0; i < btrfs_head.available.secs && j < n; ++i) -+ if (map[i] == 0) -+ map[j++] = btrfs_head.available.start + i; -+ -+ *nsectors = n; -+ *sectors = map; - - return GRUB_ERR_NONE; - } -diff --git a/include/grub/disk.h b/include/grub/disk.h -index f95aca929a..06210a7049 100644 ---- a/include/grub/disk.h -+++ b/include/grub/disk.h -@@ -182,6 +182,8 @@ typedef struct grub_disk_memberlist *grub_disk_memberlist_t; - /* Return value of grub_disk_native_sectors() in case disk size is unknown. */ - #define GRUB_DISK_SIZE_UNKNOWN 0xffffffffffffffffULL - -+#define GRUB_DISK_KiB_TO_SECTORS(x) ((x) << (10 - GRUB_DISK_SECTOR_BITS)) -+ - /* Convert sector number from one sector size to another. */ - static inline grub_disk_addr_t - grub_convert_sector (grub_disk_addr_t sector, diff --git a/0193-Add-Fedora-location-of-DejaVu-SANS-font.patch b/0193-Add-Fedora-location-of-DejaVu-SANS-font.patch deleted file mode 100644 index 070fc24..0000000 --- a/0193-Add-Fedora-location-of-DejaVu-SANS-font.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: fluteze -Date: Sat, 27 Nov 2021 10:54:44 -0600 -Subject: [PATCH] Add Fedora location of DejaVu SANS font - -In Fedora 35, and possibly earlier, grub would fail to configure with a -complaint about DejaVu being "not found" even though it was installed. -The DejaVu sans font search path is updated to reflect the -distribution's current install path. - -Signed-off-by: Erik Edwards -[rharwood@redhat.com: slight commit message edits] -Signed-off-by: Robbie Harwood ---- - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index ab0d326f00..40c4338bce 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1784,7 +1784,7 @@ fi - - if test x"$starfield_excuse" = x; then - for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do -- for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do -+ for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype /usr/share/fonts/dejavu-sans-fonts; do - if test -f "$dir/DejaVuSans.$ext"; then - DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext" - break 2 diff --git a/0335-Add-Install-section-to-aux-systemd-units.patch b/0193-Add-Install-section-to-aux-systemd-units.patch similarity index 93% rename from 0335-Add-Install-section-to-aux-systemd-units.patch rename to 0193-Add-Install-section-to-aux-systemd-units.patch index c726850..6981225 100644 --- a/0335-Add-Install-section-to-aux-systemd-units.patch +++ b/0193-Add-Install-section-to-aux-systemd-units.patch @@ -18,7 +18,7 @@ via presets or manually instead. 3 files changed, 9 insertions(+) diff --git a/docs/grub-boot-indeterminate.service b/docs/grub-boot-indeterminate.service -index 6c8dcb186b63..5bcb474a3d31 100644 +index 6c8dcb186b6..5bcb474a3d3 100644 --- a/docs/grub-boot-indeterminate.service +++ b/docs/grub-boot-indeterminate.service @@ -9,3 +9,6 @@ Before=system-update-pre.target @@ -29,7 +29,7 @@ index 6c8dcb186b63..5bcb474a3d31 100644 +[Install] +WantedBy=system-update.target diff --git a/docs/grub-boot-success.timer b/docs/grub-boot-success.timer -index 406f17200560..1d124cccc146 100644 +index 406f1720056..1d124cccc14 100644 --- a/docs/grub-boot-success.timer +++ b/docs/grub-boot-success.timer @@ -5,3 +5,6 @@ ConditionVirtualization=!container @@ -40,7 +40,7 @@ index 406f17200560..1d124cccc146 100644 +[Install] +WantedBy=timers.target diff --git a/util/systemd/grub-systemd-integration.service.in b/util/systemd/grub-systemd-integration.service.in -index c81fb594ce17..22ca1ca4885e 100644 +index c81fb594ce1..22ca1ca4885 100644 --- a/util/systemd/grub-systemd-integration.service.in +++ b/util/systemd/grub-systemd-integration.service.in @@ -6,3 +6,6 @@ ConditionPathExists=/run/systemd/reboot-to-boot-loader-menu diff --git a/0337-Fix-missing-include-in-ofdisk.c.patch b/0194-Fix-missing-include-in-ofdisk.c.patch similarity index 95% rename from 0337-Fix-missing-include-in-ofdisk.c.patch rename to 0194-Fix-missing-include-in-ofdisk.c.patch index 84a1240..a2b9047 100644 --- a/0337-Fix-missing-include-in-ofdisk.c.patch +++ b/0194-Fix-missing-include-in-ofdisk.c.patch @@ -15,7 +15,7 @@ Signed-off-by: Peter Jones 1 file changed, 1 insertion(+) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c -index 5534684..6e33d5d 100644 +index b413822bb87..57624fde55c 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -24,6 +24,7 @@ diff --git a/0194-normal-menu-Don-t-show-Booting-s-msg-when-auto-booti.patch b/0194-normal-menu-Don-t-show-Booting-s-msg-when-auto-booti.patch deleted file mode 100644 index 200cd51..0000000 --- a/0194-normal-menu-Don-t-show-Booting-s-msg-when-auto-booti.patch +++ /dev/null @@ -1,90 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Fri, 28 Jan 2022 11:30:32 +0100 -Subject: [PATCH] normal/menu: Don't show "Booting `%s'" msg when auto-booting - with TIMEOUT_STYLE_HIDDEN - -When the user has asked the menu code to be hidden/quiet and the current -entry is being autobooted because the timeout has expired don't show -the "Booting `%s'" msg. - -This is necessary to let flicker-free boots really be flicker free, -otherwise the "Booting `%s'" msg will kick the EFI fb into text mode -and show the msg, breaking the flicker-free experience. - -Signed-off-by: Hans de Goede ---- - grub-core/normal/menu.c | 24 ++++++++++++++++-------- - 1 file changed, 16 insertions(+), 8 deletions(-) - -diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c -index ec0c92bade..c8516a5a08 100644 ---- a/grub-core/normal/menu.c -+++ b/grub-core/normal/menu.c -@@ -606,13 +606,15 @@ print_countdown (struct grub_term_coordinate *pos, int n) - entry to be executed is a result of an automatic default selection because - of the timeout. */ - static int --run_menu (grub_menu_t menu, int nested, int *auto_boot) -+run_menu (grub_menu_t menu, int nested, int *auto_boot, int *notify_boot) - { - grub_uint64_t saved_time; - int default_entry, current_entry; - int timeout; - enum timeout_style timeout_style; - -+ *notify_boot = 1; -+ - default_entry = get_entry_number (menu, "default"); - - /* If DEFAULT_ENTRY is not within the menu entries, fall back to -@@ -687,6 +689,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) - if (timeout == 0) - { - *auto_boot = 1; -+ *notify_boot = timeout_style != TIMEOUT_STYLE_HIDDEN; - return default_entry; - } - -@@ -840,12 +843,16 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) - - /* Callback invoked immediately before a menu entry is executed. */ - static void --notify_booting (grub_menu_entry_t entry, -- void *userdata __attribute__((unused))) -+notify_booting (grub_menu_entry_t entry, void *userdata) - { -- grub_printf (" "); -- grub_printf_ (N_("Booting `%s'"), entry->title); -- grub_printf ("\n\n"); -+ int *notify_boot = userdata; -+ -+ if (*notify_boot) -+ { -+ grub_printf (" "); -+ grub_printf_ (N_("Booting `%s'"), entry->title); -+ grub_printf ("\n\n"); -+ } - } - - /* Callback invoked when a default menu entry executed because of a timeout -@@ -893,8 +900,9 @@ show_menu (grub_menu_t menu, int nested, int autobooted) - int boot_entry; - grub_menu_entry_t e; - int auto_boot; -+ int notify_boot; - -- boot_entry = run_menu (menu, nested, &auto_boot); -+ boot_entry = run_menu (menu, nested, &auto_boot, ¬ify_boot); - if (boot_entry < 0) - break; - -@@ -906,7 +914,7 @@ show_menu (grub_menu_t menu, int nested, int autobooted) - - if (auto_boot) - grub_menu_execute_with_fallback (menu, e, autobooted, -- &execution_callback, 0); -+ &execution_callback, ¬ify_boot); - else - grub_menu_execute_entry (e, 0); - if (autobooted) diff --git a/0195-EFI-suppress-the-Welcome-to-GRUB-message-in-EFI-buil.patch b/0195-EFI-suppress-the-Welcome-to-GRUB-message-in-EFI-buil.patch deleted file mode 100644 index 0f99c22..0000000 --- a/0195-EFI-suppress-the-Welcome-to-GRUB-message-in-EFI-buil.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Fri, 28 Jan 2022 11:30:33 +0100 -Subject: [PATCH] EFI: suppress the "Welcome to GRUB!" message in EFI builds - -Grub EFI builds are now often used in combination with flicker-free -boot, but this breaks with upstream grub because the "Welcome to GRUB!" -message will kick the EFI fb into text mode and show the msg, -breaking the flicker-free experience. - -EFI systems are so fast, that when the menu or the countdown are enabled -the message will be immediately overwritten, so in these cases not -printing the message does not matter. - -And in case when the timeout_style is set to TIMEOUT_STYLE_HIDDEN, -the user has asked grub to be quiet (for example to allow flickfree -boot) annd thus the message should not be printed. - -Signed-off-by: Hans de Goede ---- - grub-core/kern/main.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c -index 3fc3401472..993b8a8598 100644 ---- a/grub-core/kern/main.c -+++ b/grub-core/kern/main.c -@@ -317,10 +317,13 @@ grub_main (void) - - grub_boot_time ("After machine init."); - -+ /* This breaks flicker-free boot on EFI systems, so disable it there. */ -+#ifndef GRUB_MACHINE_EFI - /* Hello. */ - grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); - grub_printf ("Welcome to GRUB!\n\n"); - grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); -+#endif - - /* Init verifiers API. */ - grub_verifiers_init (); diff --git a/0348-add-flag-to-only-search-root-dev.patch b/0195-add-flag-to-only-search-root-dev.patch similarity index 88% rename from 0348-add-flag-to-only-search-root-dev.patch rename to 0195-add-flag-to-only-search-root-dev.patch index 8ae8875..9061f39 100644 --- a/0348-add-flag-to-only-search-root-dev.patch +++ b/0195-add-flag-to-only-search-root-dev.patch @@ -15,10 +15,10 @@ Signed-off-by: Marta Lewandowska 5 files changed, 74 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c -index 57d26ced8a8e..819231751c38 100644 +index 263f1501cdf..db8692ffbfb 100644 --- a/grub-core/commands/search.c +++ b/grub-core/commands/search.c -@@ -85,6 +85,42 @@ iterate_device (const char *name, void *data) +@@ -86,6 +86,42 @@ iterate_device (const char *name, void *data) grub_device_close (dev); } @@ -62,7 +62,7 @@ index 57d26ced8a8e..819231751c38 100644 #define compare_fn grub_strcasecmp #else diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c -index 0b62acf85359..06b5f51eefb5 100644 +index 318581f3b1e..4fe6440c65b 100644 --- a/grub-core/commands/search_wrap.c +++ b/grub-core/commands/search_wrap.c @@ -41,6 +41,7 @@ static const struct grub_arg_option options[] = @@ -92,10 +92,10 @@ index 0b62acf85359..06b5f51eefb5 100644 grub_search_label (id, var, flags, hints, nhints); else if (state[SEARCH_FS_UUID].set) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c -index cb454614022f..c0ac7fee6cc2 100644 +index f607244e7ae..96ab7c96b52 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -619,6 +619,36 @@ grub_reverse (char *str) +@@ -645,6 +645,36 @@ grub_reverse (char *str) } } @@ -133,24 +133,24 @@ index cb454614022f..c0ac7fee6cc2 100644 grub_uint64_t grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r) diff --git a/include/grub/misc.h b/include/grub/misc.h -index faae0ae8606c..981526644d29 100644 +index c3c735371dc..3e9a00f0a9c 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h -@@ -314,6 +314,7 @@ void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n); +@@ -343,6 +343,7 @@ char *EXPORT_FUNC(grub_strdup) (const char *s) WARN_UNUSED_RESULT; + char *EXPORT_FUNC(grub_strndup) (const char *s, grub_size_t n) WARN_UNUSED_RESULT; + void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n); grub_size_t EXPORT_FUNC(grub_strlen) (const char *s) WARN_UNUSED_RESULT; - int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))); - int EXPORT_FUNC(grub_printf_) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))); +void EXPORT_FUNC(grub_str_sep) (const char *s, char *p, char delim, char *r); /* Replace all `ch' characters of `input' with `with' and copy the result into `output'; return EOS address of `output'. */ diff --git a/include/grub/search.h b/include/grub/search.h -index 4190aeb2cbf5..321d1400e451 100644 +index ffd2411ca1a..9343c66b134 100644 --- a/include/grub/search.h +++ b/include/grub/search.h -@@ -22,7 +22,8 @@ - enum search_flags +@@ -23,7 +23,8 @@ enum search_flags { + SEARCH_FLAGS_NONE = 0, SEARCH_FLAGS_NO_FLOPPY = 1, - SEARCH_FLAGS_EFIDISK_ONLY = 2 + SEARCH_FLAGS_EFIDISK_ONLY = 2, diff --git a/0196-EFI-console-Do-not-set-colorstate-until-the-first-te.patch b/0196-EFI-console-Do-not-set-colorstate-until-the-first-te.patch deleted file mode 100644 index ade6aae..0000000 --- a/0196-EFI-console-Do-not-set-colorstate-until-the-first-te.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Fri, 28 Jan 2022 12:43:48 +0100 -Subject: [PATCH] EFI: console: Do not set colorstate until the first text - output - -GRUB_MOD_INIT(normal) does an unconditional: - -grub_env_set ("color_normal", "light-gray/black"); - -which triggers a grub_term_setcolorstate() call. The original version -of the "efi/console: Do not set text-mode until we actually need it" patch: -https://lists.gnu.org/archive/html/grub-devel/2018-03/msg00125.html - -Protected against this by caching the requested state in -grub_console_setcolorstate () and then only applying it when the first -text output actually happens. During refactoring to move the -grub_console_setcolorstate () up higher in the grub-core/term/efi/console.c -file the code to cache the color-state + bail early was accidentally -dropped. - -Restore the cache the color-state + bail early behavior from the original. - -Cc: Javier Martinez Canillas -Fixes: 2d7c3abd871f ("efi/console: Do not set text-mode until we actually need it") -Signed-off-by: Hans de Goede ---- - grub-core/term/efi/console.c | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c -index 2f1ae85ba7..c44b2ac318 100644 ---- a/grub-core/term/efi/console.c -+++ b/grub-core/term/efi/console.c -@@ -82,6 +82,16 @@ grub_console_setcolorstate (struct grub_term_output *term - { - grub_efi_simple_text_output_interface_t *o; - -+ if (grub_efi_is_finished || text_mode != GRUB_TEXT_MODE_AVAILABLE) -+ { -+ /* -+ * Cache colorstate changes before the first text-output, this avoids -+ * "color_normal" environment writes causing a switch to textmode. -+ */ -+ text_colorstate = state; -+ return; -+ } -+ - if (grub_efi_is_finished) - return; - diff --git a/0196-cryptdisk-fix-incorrect-sign-comparison.patch b/0196-cryptdisk-fix-incorrect-sign-comparison.patch new file mode 100644 index 0000000..dbb4fc2 --- /dev/null +++ b/0196-cryptdisk-fix-incorrect-sign-comparison.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 8 Jan 2024 15:44:27 -0500 +Subject: [PATCH] cryptdisk: fix incorrect sign comparison + +grub_util_get_fd_size() returns a signed integer, but we're assigning it +to an unsigned integer and then testing against -1. That's wrong. + +This patch makes the variable a signed integer. + +Signed-off-by: Peter Jones +--- + grub-core/disk/cryptodisk.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c +index 2246af51b6a..98e176a139c 100644 +--- a/grub-core/disk/cryptodisk.c ++++ b/grub-core/disk/cryptodisk.c +@@ -721,7 +721,7 @@ grub_cryptodisk_open (const char *name, grub_disk_t disk) + #ifdef GRUB_UTIL + if (dev->cheat) + { +- grub_uint64_t cheat_dev_size; ++ grub_int64_t cheat_dev_size; + unsigned int cheat_log_sector_size; + + if (!GRUB_UTIL_FD_IS_VALID (dev->cheat_fd)) diff --git a/0197-EFI-console-Do-not-set-cursor-until-the-first-text-o.patch b/0197-EFI-console-Do-not-set-cursor-until-the-first-text-o.patch deleted file mode 100644 index 5fab5db..0000000 --- a/0197-EFI-console-Do-not-set-cursor-until-the-first-text-o.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Fri, 28 Jan 2022 12:43:49 +0100 -Subject: [PATCH] EFI: console: Do not set cursor until the first text output - -To allow flickerfree boot the EFI console code does not call -grub_efi_set_text_mode (1) until some text is actually output. - -Depending on if the output text is because of an error loading -e.g. the .cfg file; or because of showing the menu the cursor needs -to be on or off when the first text is shown. - -So far the cursor was hardcoded to being on, but this is causing -drawing artifacts + slow drawing of the menu as reported here: -https://bugzilla.redhat.com/show_bug.cgi?id=1946969 - -Handle the cursorstate in the same way as the colorstate to fix this, -when no text has been output yet, just cache the cursorstate and -then use the last set value when the first text is output. - -Fixes: 2d7c3abd871f ("efi/console: Do not set text-mode until we actually need it") -Signed-off-by: Hans de Goede ---- - grub-core/term/efi/console.c | 19 ++++++++++++++++--- - 1 file changed, 16 insertions(+), 3 deletions(-) - -diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c -index c44b2ac318..a3622e4fe5 100644 ---- a/grub-core/term/efi/console.c -+++ b/grub-core/term/efi/console.c -@@ -31,7 +31,15 @@ typedef enum { - } - grub_text_mode; - -+typedef enum { -+ GRUB_CURSOR_MODE_UNDEFINED = -1, -+ GRUB_CURSOR_MODE_OFF = 0, -+ GRUB_CURSUR_MODE_ON -+} -+grub_cursor_mode; -+ - static grub_text_mode text_mode = GRUB_TEXT_MODE_UNDEFINED; -+static grub_cursor_mode cursor_mode = GRUB_CURSOR_MODE_UNDEFINED; - static grub_term_color_state text_colorstate = GRUB_TERM_COLOR_UNDEFINED; - - static grub_uint32_t -@@ -119,8 +127,12 @@ grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)), - { - grub_efi_simple_text_output_interface_t *o; - -- if (grub_efi_is_finished) -- return; -+ if (grub_efi_is_finished || text_mode != GRUB_TEXT_MODE_AVAILABLE) -+ { -+ /* Cache cursor changes before the first text-output */ -+ cursor_mode = on; -+ return; -+ } - - o = grub_efi_system_table->con_out; - efi_call_2 (o->enable_cursor, o, on); -@@ -143,7 +155,8 @@ grub_prepare_for_text_output (struct grub_term_output *term) - return GRUB_ERR_BAD_DEVICE; - } - -- grub_console_setcursor (term, 1); -+ if (cursor_mode != GRUB_CURSOR_MODE_UNDEFINED) -+ grub_console_setcursor (term, cursor_mode); - if (text_colorstate != GRUB_TERM_COLOR_UNDEFINED) - grub_console_setcolorstate (term, text_colorstate); - text_mode = GRUB_TEXT_MODE_AVAILABLE; diff --git a/0197-grub-install-fix-a-sign-comparison-error.patch b/0197-grub-install-fix-a-sign-comparison-error.patch new file mode 100644 index 0000000..7b63b08 --- /dev/null +++ b/0197-grub-install-fix-a-sign-comparison-error.patch @@ -0,0 +1,25 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 8 Jan 2024 15:45:57 -0500 +Subject: [PATCH] grub-install: fix a sign comparison error + +This is a trivial sign comparison fix. + +Signed-off-by: Peter Jones +--- + util/grub-install-common.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/util/grub-install-common.c b/util/grub-install-common.c +index b58539111da..67afc2eedf4 100644 +--- a/util/grub-install-common.c ++++ b/util/grub-install-common.c +@@ -368,7 +368,7 @@ char *grub_install_themes_directory = NULL; + int + grub_install_is_short_mbrgap_supported (void) + { +- int i, j; ++ unsigned int i, j; + static const char *whitelist[] = + { + "part_msdos", "biosdisk", "affs", "afs", "bfs", "archelp", diff --git a/0198-Use-visual-indentation-in-config.h.in.patch b/0198-Use-visual-indentation-in-config.h.in.patch deleted file mode 100644 index 978eb07..0000000 --- a/0198-Use-visual-indentation-in-config.h.in.patch +++ /dev/null @@ -1,93 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robbie Harwood -Date: Wed, 15 Dec 2021 15:46:13 -0500 -Subject: [PATCH] Use visual indentation in config.h.in - -Signed-off-by: Robbie Harwood -(cherry picked from commit de8051f34de0aa55c921a510974e5bb27e39c17b) -[rharwood: GRUB_RPM_CONFIG presence] ---- - config.h.in | 58 +++++++++++++++++++++++++++++----------------------------- - 1 file changed, 29 insertions(+), 29 deletions(-) - -diff --git a/config.h.in b/config.h.in -index c80e3e0aba..f2ed0066ec 100644 ---- a/config.h.in -+++ b/config.h.in -@@ -23,47 +23,47 @@ - #define MINILZO_CFG_SKIP_LZO1X_DECOMPRESS 1 - - #if defined (GRUB_BUILD) --#undef ENABLE_NLS --#define BUILD_SIZEOF_LONG @BUILD_SIZEOF_LONG@ --#define BUILD_SIZEOF_VOID_P @BUILD_SIZEOF_VOID_P@ --#if defined __APPLE__ --# if defined __BIG_ENDIAN__ --# define BUILD_WORDS_BIGENDIAN 1 --# else --# define BUILD_WORDS_BIGENDIAN 0 --# endif --#else --#define BUILD_WORDS_BIGENDIAN @BUILD_WORDS_BIGENDIAN@ --#endif -+# undef ENABLE_NLS -+# define BUILD_SIZEOF_LONG @BUILD_SIZEOF_LONG@ -+# define BUILD_SIZEOF_VOID_P @BUILD_SIZEOF_VOID_P@ -+# if defined __APPLE__ -+# if defined __BIG_ENDIAN__ -+# define BUILD_WORDS_BIGENDIAN 1 -+# else -+# define BUILD_WORDS_BIGENDIAN 0 -+# endif -+# else /* !defined __APPLE__ */ -+# define BUILD_WORDS_BIGENDIAN @BUILD_WORDS_BIGENDIAN@ -+# endif /* !defined __APPLE__ */ - #elif defined (GRUB_UTIL) || !defined (GRUB_MACHINE) --#include --#else --#define HAVE_FONT_SOURCE @HAVE_FONT_SOURCE@ -+# include -+#else /* !defined GRUB_UTIL && defined GRUB_MACHINE */ -+# define HAVE_FONT_SOURCE @HAVE_FONT_SOURCE@ - /* Define if C symbols get an underscore after compilation. */ --#define HAVE_ASM_USCORE @HAVE_ASM_USCORE@ -+# define HAVE_ASM_USCORE @HAVE_ASM_USCORE@ - /* Define it to one of __bss_start, edata and _edata. */ --#define BSS_START_SYMBOL @BSS_START_SYMBOL@ -+# define BSS_START_SYMBOL @BSS_START_SYMBOL@ - /* Define it to either end or _end. */ --#define END_SYMBOL @END_SYMBOL@ -+# define END_SYMBOL @END_SYMBOL@ - /* Name of package. */ --#define PACKAGE "@PACKAGE@" -+# define PACKAGE "@PACKAGE@" - /* Version number of package. */ --#define VERSION "@VERSION@" -+# define VERSION "@VERSION@" - /* Define to the full name and version of this package. */ --#define PACKAGE_STRING "@PACKAGE_STRING@" -+# define PACKAGE_STRING "@PACKAGE_STRING@" - /* Define to the version of this package. */ --#define PACKAGE_VERSION "@PACKAGE_VERSION@" -+# define PACKAGE_VERSION "@PACKAGE_VERSION@" - /* Define to the full name of this package. */ --#define PACKAGE_NAME "@PACKAGE_NAME@" -+# define PACKAGE_NAME "@PACKAGE_NAME@" - /* Define to the address where bug reports for this package should be sent. */ --#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" -+# define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" - --#define GRUB_TARGET_CPU "@GRUB_TARGET_CPU@" --#define GRUB_PLATFORM "@GRUB_PLATFORM@" --#define GRUB_RPM_VERSION "@GRUB_RPM_VERSION@" -+# define GRUB_TARGET_CPU "@GRUB_TARGET_CPU@" -+# define GRUB_PLATFORM "@GRUB_PLATFORM@" -+# define GRUB_RPM_VERSION "@GRUB_RPM_VERSION@" - --#define RE_ENABLE_I18N 1 -+# define RE_ENABLE_I18N 1 - --#define _GNU_SOURCE 1 -+# define _GNU_SOURCE 1 - - #endif diff --git a/0198-grub-mount-work-around-bad-integer-comparison.patch b/0198-grub-mount-work-around-bad-integer-comparison.patch new file mode 100644 index 0000000..d303801 --- /dev/null +++ b/0198-grub-mount-work-around-bad-integer-comparison.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 8 Jan 2024 15:54:31 -0500 +Subject: [PATCH] grub-mount: work around bad integer comparison. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +gcc says: + + util/grub-mount.c: In function ‘fuse_read’: + util/grub-mount.c:273:11: error: comparison of integer expressions of different signedness: ‘off_t’ {aka ‘long int’} and ‘grub_off_t’ {aka ‘long unsigned int’} [-Werror=sign-compare] + 273 | if (off > file->size) + | ^ + +This is happening because grub_off_t is unsigned but the system's off_t is +signed. + +That's too much work to fix today, so this patch works around it with +tests and typecasting. + +Signed-off-by: Peter Jones +--- + util/grub-mount.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/util/grub-mount.c b/util/grub-mount.c +index bf4c8b891be..d369e21666e 100644 +--- a/util/grub-mount.c ++++ b/util/grub-mount.c +@@ -269,11 +269,17 @@ fuse_read (const char *path, char *buf, size_t sz, off_t off, + { + grub_file_t file = files[fi->fh]; + grub_ssize_t size; ++ grub_off_t offset; + +- if (off > file->size) ++ if (off < 0) + return -EINVAL; + +- file->offset = off; ++ if ((grub_off_t)off > file->size) ++ return -EINVAL; ++ ++ offset = (grub_off_t)off; ++ ++ file->offset = offset; + + size = grub_file_read (file, buf, sz); + if (size < 0) diff --git a/0199-Where-present-ensure-config-util.h-precedes-config.h.patch b/0199-Where-present-ensure-config-util.h-precedes-config.h.patch deleted file mode 100644 index 22c2d9c..0000000 --- a/0199-Where-present-ensure-config-util.h-precedes-config.h.patch +++ /dev/null @@ -1,275 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robbie Harwood -Date: Tue, 22 Feb 2022 16:57:54 -0500 -Subject: [PATCH] Where present, ensure config-util.h precedes config.h - -gnulib defines go in config-util.h, and we need to know whether to -provide duplicates in config.h or not. - -Signed-off-by: Robbie Harwood -(cherry picked from commit 46e82b28e1a75703d0424c7e13d009171310c6cd) -[rharwood: gensymlist isn't part of tarballs] ---- - grub-core/disk/host.c | 2 +- - grub-core/kern/emu/argp_common.c | 2 +- - grub-core/kern/emu/main.c | 2 +- - grub-core/osdep/aros/config.c | 2 +- - grub-core/osdep/basic/emunet.c | 2 +- - grub-core/osdep/basic/init.c | 2 +- - grub-core/osdep/haiku/getroot.c | 2 +- - grub-core/osdep/linux/emunet.c | 2 +- - grub-core/osdep/unix/config.c | 2 +- - grub-core/osdep/unix/cputime.c | 2 +- - grub-core/osdep/unix/dl.c | 2 +- - grub-core/osdep/unix/emuconsole.c | 2 +- - grub-core/osdep/unix/getroot.c | 2 +- - grub-core/osdep/windows/config.c | 2 +- - grub-core/osdep/windows/cputime.c | 2 +- - grub-core/osdep/windows/dl.c | 2 +- - grub-core/osdep/windows/emuconsole.c | 2 +- - grub-core/osdep/windows/init.c | 2 +- - 18 files changed, 18 insertions(+), 18 deletions(-) - -diff --git a/grub-core/disk/host.c b/grub-core/disk/host.c -index c151d225df..f34529f86a 100644 ---- a/grub-core/disk/host.c -+++ b/grub-core/disk/host.c -@@ -20,8 +20,8 @@ - /* When using the disk, make a reference to this module. Otherwise - the user will end up with a useless module :-). */ - --#include - #include -+#include - - #include - #include -diff --git a/grub-core/kern/emu/argp_common.c b/grub-core/kern/emu/argp_common.c -index 1668858703..8cb4608c3d 100644 ---- a/grub-core/kern/emu/argp_common.c -+++ b/grub-core/kern/emu/argp_common.c -@@ -17,8 +17,8 @@ - * along with GRUB. If not, see . - */ - --#include - #include -+#include - - #pragma GCC diagnostic ignored "-Wmissing-prototypes" - #pragma GCC diagnostic ignored "-Wmissing-declarations" -diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c -index 55ea5a11cc..12277c34d2 100644 ---- a/grub-core/kern/emu/main.c -+++ b/grub-core/kern/emu/main.c -@@ -16,8 +16,8 @@ - * along with GRUB. If not, see . - */ - --#include - #include -+#include - - #include - #include -diff --git a/grub-core/osdep/aros/config.c b/grub-core/osdep/aros/config.c -index c82d0ea8e7..55f5728efc 100644 ---- a/grub-core/osdep/aros/config.c -+++ b/grub-core/osdep/aros/config.c -@@ -16,8 +16,8 @@ - * along with GRUB. If not, see . - */ - --#include - #include -+#include - - #include - #include -diff --git a/grub-core/osdep/basic/emunet.c b/grub-core/osdep/basic/emunet.c -index 6362e5cfbb..dbfd316d61 100644 ---- a/grub-core/osdep/basic/emunet.c -+++ b/grub-core/osdep/basic/emunet.c -@@ -16,8 +16,8 @@ - * along with GRUB. If not, see . - */ - --#include - #include -+#include - - #include - #include -diff --git a/grub-core/osdep/basic/init.c b/grub-core/osdep/basic/init.c -index c54c710dbc..b104c7e162 100644 ---- a/grub-core/osdep/basic/init.c -+++ b/grub-core/osdep/basic/init.c -@@ -16,8 +16,8 @@ - * along with GRUB. If not, see . - */ - --#include - #include -+#include - - #include - #include -diff --git a/grub-core/osdep/haiku/getroot.c b/grub-core/osdep/haiku/getroot.c -index 4e123c0903..927a1ebc94 100644 ---- a/grub-core/osdep/haiku/getroot.c -+++ b/grub-core/osdep/haiku/getroot.c -@@ -1,5 +1,5 @@ --#include - #include -+#include - #include - #include - #include -diff --git a/grub-core/osdep/linux/emunet.c b/grub-core/osdep/linux/emunet.c -index 19b188f09e..d5a6417355 100644 ---- a/grub-core/osdep/linux/emunet.c -+++ b/grub-core/osdep/linux/emunet.c -@@ -16,8 +16,8 @@ - * along with GRUB. If not, see . - */ - --#include - #include -+#include - - #include - #include -diff --git a/grub-core/osdep/unix/config.c b/grub-core/osdep/unix/config.c -index 46a881530c..0ce0e309ac 100644 ---- a/grub-core/osdep/unix/config.c -+++ b/grub-core/osdep/unix/config.c -@@ -16,8 +16,8 @@ - * along with GRUB. If not, see . - */ - --#include - #include -+#include - - #include - #include -diff --git a/grub-core/osdep/unix/cputime.c b/grub-core/osdep/unix/cputime.c -index cff359a3b9..fb6ff55a1a 100644 ---- a/grub-core/osdep/unix/cputime.c -+++ b/grub-core/osdep/unix/cputime.c -@@ -1,5 +1,5 @@ --#include - #include -+#include - - #include - #include -diff --git a/grub-core/osdep/unix/dl.c b/grub-core/osdep/unix/dl.c -index 562b101a28..99b189bc1c 100644 ---- a/grub-core/osdep/unix/dl.c -+++ b/grub-core/osdep/unix/dl.c -@@ -16,8 +16,8 @@ - * along with GRUB. If not, see . - */ - --#include - #include -+#include - - #include - #include -diff --git a/grub-core/osdep/unix/emuconsole.c b/grub-core/osdep/unix/emuconsole.c -index 7308798efe..cac159424d 100644 ---- a/grub-core/osdep/unix/emuconsole.c -+++ b/grub-core/osdep/unix/emuconsole.c -@@ -17,8 +17,8 @@ - * along with GRUB. If not, see . - */ - --#include - #include -+#include - - #include - #include -diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c -index 46d7116c6e..4f436284ce 100644 ---- a/grub-core/osdep/unix/getroot.c -+++ b/grub-core/osdep/unix/getroot.c -@@ -16,8 +16,8 @@ - * along with GRUB. If not, see . - */ - --#include - #include -+#include - - #include - #include -diff --git a/grub-core/osdep/windows/config.c b/grub-core/osdep/windows/config.c -index 928ab1a49b..2bb8a2fd88 100644 ---- a/grub-core/osdep/windows/config.c -+++ b/grub-core/osdep/windows/config.c -@@ -16,8 +16,8 @@ - * along with GRUB. If not, see . - */ - --#include - #include -+#include - - #include - #include -diff --git a/grub-core/osdep/windows/cputime.c b/grub-core/osdep/windows/cputime.c -index 3568aa2d35..5d06d79dd5 100644 ---- a/grub-core/osdep/windows/cputime.c -+++ b/grub-core/osdep/windows/cputime.c -@@ -1,5 +1,5 @@ --#include - #include -+#include - - #include - #include -diff --git a/grub-core/osdep/windows/dl.c b/grub-core/osdep/windows/dl.c -index eec6a24ad7..8eab7057e4 100644 ---- a/grub-core/osdep/windows/dl.c -+++ b/grub-core/osdep/windows/dl.c -@@ -16,8 +16,8 @@ - * along with GRUB. If not, see . - */ - --#include - #include -+#include - - #include - #include -diff --git a/grub-core/osdep/windows/emuconsole.c b/grub-core/osdep/windows/emuconsole.c -index 4fb3693cc0..17a44de469 100644 ---- a/grub-core/osdep/windows/emuconsole.c -+++ b/grub-core/osdep/windows/emuconsole.c -@@ -16,8 +16,8 @@ - * along with GRUB. If not, see . - */ - --#include - #include -+#include - - #include - #include -diff --git a/grub-core/osdep/windows/init.c b/grub-core/osdep/windows/init.c -index 6297de6326..51a9647dde 100644 ---- a/grub-core/osdep/windows/init.c -+++ b/grub-core/osdep/windows/init.c -@@ -16,8 +16,8 @@ - * along with GRUB. If not, see . - */ - --#include - #include -+#include - #include - #include - #include diff --git a/0199-power-Fix-use-after-free-in-get_slave_from_dm.patch b/0199-power-Fix-use-after-free-in-get_slave_from_dm.patch new file mode 100644 index 0000000..b4520e7 --- /dev/null +++ b/0199-power-Fix-use-after-free-in-get_slave_from_dm.patch @@ -0,0 +1,32 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 8 Jan 2024 16:03:54 -0500 +Subject: [PATCH] power: Fix use after free in get_slave_from_dm() + +Signed-off-by: Peter Jones +--- + grub-core/osdep/linux/ofpath.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c +index cc849d9c94c..72772c87a66 100644 +--- a/grub-core/osdep/linux/ofpath.c ++++ b/grub-core/osdep/linux/ofpath.c +@@ -775,6 +775,8 @@ get_slave_from_dm(const char * device){ + + device_path = grub_xasprintf ("/sys/block/%s/slaves", curr_device); + dp = opendir(device_path); ++ if (dp == NULL) ++ grub_util_warn (_("cannot open directory `%s'"), device_path); + free(device_path); + + if (dp != NULL) +@@ -800,8 +802,6 @@ get_slave_from_dm(const char * device){ + } + closedir (dp); + } +- else +- grub_util_warn (_("cannot open directory `%s'"), device_path); + } + + free (directory); diff --git a/0200-Drop-gnulib-fix-base64.patch.patch b/0200-Drop-gnulib-fix-base64.patch.patch deleted file mode 100644 index 054e476..0000000 --- a/0200-Drop-gnulib-fix-base64.patch.patch +++ /dev/null @@ -1,140 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robbie Harwood -Date: Thu, 28 Oct 2021 15:07:50 -0400 -Subject: [PATCH] Drop gnulib fix-base64.patch - -Originally added in 9fbdec2f6b4fa8b549daa4d49134d1fe89d95ef9 and -subsequently modified in 552c9fd08122a3036c724ce96dfe68aa2f75705f, -fix-base64.patch handled two problems we have using gnulib, which are -exerciesd by the base64 module but not directly caused by it. - -First, grub2 defines its own bool type, while gnulib expects the -equivalent of stdbool.h to be present. Rather than patching gnulib, -instead use gnulib's stdbool module to provide a bool type if needed. -(Suggested by Simon Josefsson.) - -Second, our config.h doesn't always inherit config-util.h, which is -where gnulib-related options like _GL_ATTRIBUTE_CONST end up. -fix-base64.h worked around this by defining the attribute away, but this -workaround is better placed in config.h itself, not a gnulib patch. - -Signed-off-by: Robbie Harwood -(cherry picked from commit 54fd1c3301dd15f6b6212c12887265e8a6cbc076) ---- - grub-core/lib/posix_wrap/sys/types.h | 7 +++---- - grub-core/lib/xzembed/xz.h | 5 +---- - bootstrap.conf | 3 ++- - conf/Makefile.extra-dist | 1 - - config.h.in | 4 ++++ - grub-core/lib/gnulib-patches/fix-base64.patch | 21 --------------------- - 6 files changed, 10 insertions(+), 31 deletions(-) - delete mode 100644 grub-core/lib/gnulib-patches/fix-base64.patch - -diff --git a/grub-core/lib/posix_wrap/sys/types.h b/grub-core/lib/posix_wrap/sys/types.h -index f63412c8da..2f3e865495 100644 ---- a/grub-core/lib/posix_wrap/sys/types.h -+++ b/grub-core/lib/posix_wrap/sys/types.h -@@ -23,11 +23,10 @@ - - #include - -+/* Provided by gnulib if not present. */ -+#include -+ - typedef grub_ssize_t ssize_t; --#ifndef GRUB_POSIX_BOOL_DEFINED --typedef enum { false = 0, true = 1 } bool; --#define GRUB_POSIX_BOOL_DEFINED 1 --#endif - - typedef grub_uint8_t uint8_t; - typedef grub_uint16_t uint16_t; -diff --git a/grub-core/lib/xzembed/xz.h b/grub-core/lib/xzembed/xz.h -index f7b32d8003..d1417039aa 100644 ---- a/grub-core/lib/xzembed/xz.h -+++ b/grub-core/lib/xzembed/xz.h -@@ -29,10 +29,7 @@ - #include - #include - #include -- --#ifndef GRUB_POSIX_BOOL_DEFINED --typedef enum { false = 0, true = 1 } bool; --#endif -+#include - - /** - * enum xz_ret - Return codes -diff --git a/bootstrap.conf b/bootstrap.conf -index 52d4af44be..645e3a459c 100644 ---- a/bootstrap.conf -+++ b/bootstrap.conf -@@ -35,6 +35,7 @@ gnulib_modules=" - realloc-gnu - regex - save-cwd -+ stdbool - " - - gnulib_tool_option_extras="\ -@@ -79,7 +80,7 @@ cp -a INSTALL INSTALL.grub - - bootstrap_post_import_hook () { - set -e -- for patchname in fix-base64 fix-null-deref fix-null-state-deref fix-regcomp-uninit-token \ -+ for patchname in fix-null-deref fix-null-state-deref fix-regcomp-uninit-token \ - fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width no-abort; do - patch -d grub-core/lib/gnulib -p2 \ - < "grub-core/lib/gnulib-patches/$patchname.patch" -diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist -index ad235de7fc..f4791dc6ca 100644 ---- a/conf/Makefile.extra-dist -+++ b/conf/Makefile.extra-dist -@@ -31,7 +31,6 @@ EXTRA_DIST += grub-core/gensymlist.sh - EXTRA_DIST += grub-core/genemuinit.sh - EXTRA_DIST += grub-core/genemuinitheader.sh - --EXTRA_DIST += grub-core/lib/gnulib-patches/fix-base64.patch - EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-deref.patch - EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-state-deref.patch - EXTRA_DIST += grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch -diff --git a/config.h.in b/config.h.in -index f2ed0066ec..9c7b4afaaa 100644 ---- a/config.h.in -+++ b/config.h.in -@@ -66,4 +66,8 @@ - - # define _GNU_SOURCE 1 - -+# ifndef _GL_INLINE_HEADER_BEGIN -+# define _GL_ATTRIBUTE_CONST __attribute__ ((const)) -+# endif /* !_GL_INLINE_HEADER_BEGIN */ -+ - #endif -diff --git a/grub-core/lib/gnulib-patches/fix-base64.patch b/grub-core/lib/gnulib-patches/fix-base64.patch -deleted file mode 100644 -index 985db12797..0000000000 ---- a/grub-core/lib/gnulib-patches/fix-base64.patch -+++ /dev/null -@@ -1,21 +0,0 @@ --diff --git a/lib/base64.h b/lib/base64.h --index 9cd0183b8..185a2afa1 100644 ----- a/lib/base64.h --+++ b/lib/base64.h --@@ -21,8 +21,14 @@ -- /* Get size_t. */ -- # include -- ---/* Get bool. */ ---# include --+#ifndef GRUB_POSIX_BOOL_DEFINED --+typedef enum { false = 0, true = 1 } bool; --+#define GRUB_POSIX_BOOL_DEFINED 1 --+#endif --+ --+#ifndef _GL_ATTRIBUTE_CONST --+# define _GL_ATTRIBUTE_CONST /* empty */ --+#endif -- -- # ifdef __cplusplus -- extern "C" { diff --git a/0200-Fix-some-sign-comparison-errors.patch b/0200-Fix-some-sign-comparison-errors.patch new file mode 100644 index 0000000..a3e5b25 --- /dev/null +++ b/0200-Fix-some-sign-comparison-errors.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 8 Jan 2024 19:08:33 -0500 +Subject: [PATCH] Fix some sign comparison errors + +Signed-off-by: Peter Jones +--- + grub-core/loader/i386/pc/truecrypt.c | 2 +- + grub-core/loader/multiboot_elfxx.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/loader/i386/pc/truecrypt.c b/grub-core/loader/i386/pc/truecrypt.c +index bae1ad031b3..7bf801603f4 100644 +--- a/grub-core/loader/i386/pc/truecrypt.c ++++ b/grub-core/loader/i386/pc/truecrypt.c +@@ -176,7 +176,7 @@ grub_cmd_truecrypt (grub_command_t cmd __attribute__ ((unused)), + + edx = (dh << 8) | grub_get_root_biosnumber (); + +- destaddr = ALIGN_DOWN (grub_min (0x90000, grub_mmap_get_lower ()) ++ destaddr = ALIGN_DOWN (grub_min (0x90000ull, grub_mmap_get_lower ()) + - truecryptmemsize, 64 * 1024); + + { +diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c +index 8d370b0b3f5..24480df5053 100644 +--- a/grub-core/loader/multiboot_elfxx.c ++++ b/grub-core/loader/multiboot_elfxx.c +@@ -99,7 +99,7 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld) + return err; + + /* FIXME: Should we support program headers at strange locations? */ +- phlimit = grub_min (MULTIBOOT_SEARCH, grub_file_size (mld->file)); ++ phlimit = grub_min ((grub_off_t)MULTIBOOT_SEARCH, grub_file_size (mld->file)); + if ((grub_off_t) ehdr->e_phoff + phnum * ehdr->e_phentsize > phlimit) + return grub_error (GRUB_ERR_BAD_OS, "program header at a too high offset"); + diff --git a/0201-Drop-gnulib-no-abort.patch.patch b/0201-Drop-gnulib-no-abort.patch.patch deleted file mode 100644 index a12789f..0000000 --- a/0201-Drop-gnulib-no-abort.patch.patch +++ /dev/null @@ -1,97 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robbie Harwood -Date: Wed, 5 Jan 2022 16:42:11 -0500 -Subject: [PATCH] Drop gnulib no-abort.patch - -Originally added in db7337a3d353a817ffe9eb4a3702120527100be9, this -patched out all relevant invocations of abort() in gnulib. While it was -not documented why at the time, testing suggests that there's no abort() -implementation available for gnulib to use. - -gnulib's position is that the use of abort() is correct here, since it -happens when input violates a "shall" from POSIX. Additionally, the -code in question is probably not reachable. Since abort() is more -friendly to user-space, they prefer to make no change, so we can just -carry a define instead. (Suggested by Paul Eggert.) - -Signed-off-by: Robbie Harwood -(cherry picked from commit 5137c8eb3ec11c3217acea1a93a3f88f3fa4cbca) ---- - bootstrap.conf | 2 +- - conf/Makefile.extra-dist | 1 - - config.h.in | 3 +++ - grub-core/lib/gnulib-patches/no-abort.patch | 26 -------------------------- - 4 files changed, 4 insertions(+), 28 deletions(-) - delete mode 100644 grub-core/lib/gnulib-patches/no-abort.patch - -diff --git a/bootstrap.conf b/bootstrap.conf -index 645e3a459c..71ce943c7d 100644 ---- a/bootstrap.conf -+++ b/bootstrap.conf -@@ -81,7 +81,7 @@ cp -a INSTALL INSTALL.grub - bootstrap_post_import_hook () { - set -e - for patchname in fix-null-deref fix-null-state-deref fix-regcomp-uninit-token \ -- fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width no-abort; do -+ fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width; do - patch -d grub-core/lib/gnulib -p2 \ - < "grub-core/lib/gnulib-patches/$patchname.patch" - done -diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist -index f4791dc6ca..5eef708338 100644 ---- a/conf/Makefile.extra-dist -+++ b/conf/Makefile.extra-dist -@@ -38,7 +38,6 @@ EXTRA_DIST += grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch - EXTRA_DIST += grub-core/lib/gnulib-patches/fix-uninit-structure.patch - EXTRA_DIST += grub-core/lib/gnulib-patches/fix-unused-value.patch - EXTRA_DIST += grub-core/lib/gnulib-patches/fix-width.patch --EXTRA_DIST += grub-core/lib/gnulib-patches/no-abort.patch - - EXTRA_DIST += grub-core/lib/libgcrypt - EXTRA_DIST += grub-core/lib/libgcrypt-grub/mpi/generic -diff --git a/config.h.in b/config.h.in -index 9c7b4afaaa..c3134309c6 100644 ---- a/config.h.in -+++ b/config.h.in -@@ -68,6 +68,9 @@ - - # ifndef _GL_INLINE_HEADER_BEGIN - # define _GL_ATTRIBUTE_CONST __attribute__ ((const)) -+ -+/* We don't have an abort() for gnulib to call in regexp. */ -+# define abort __builtin_unreachable - # endif /* !_GL_INLINE_HEADER_BEGIN */ - - #endif -diff --git a/grub-core/lib/gnulib-patches/no-abort.patch b/grub-core/lib/gnulib-patches/no-abort.patch -deleted file mode 100644 -index e469c4762e..0000000000 ---- a/grub-core/lib/gnulib-patches/no-abort.patch -+++ /dev/null -@@ -1,26 +0,0 @@ --diff --git a/lib/regcomp.c b/lib/regcomp.c --index cc85f35ac..de45ebb5c 100644 ----- a/lib/regcomp.c --+++ b/lib/regcomp.c --@@ -528,9 +528,9 @@ regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf, -- to this routine. If we are given anything else, or if other regex -- code generates an invalid error code, then the program has a bug. -- Dump core so we can fix it. */ --- abort (); --- --- msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]); --+ msg = gettext ("unknown regexp error"); --+ else --+ msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]); -- -- msg_size = strlen (msg) + 1; /* Includes the null. */ -- --@@ -1136,7 +1136,7 @@ optimize_utf8 (re_dfa_t *dfa) -- } -- break; -- default: --- abort (); --+ break; -- } -- -- if (mb_chars || has_period) diff --git a/0201-normal-Fix-a-discarded-const.patch b/0201-normal-Fix-a-discarded-const.patch new file mode 100644 index 0000000..57598db --- /dev/null +++ b/0201-normal-Fix-a-discarded-const.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 8 Jan 2024 19:12:15 -0500 +Subject: [PATCH] normal: Fix a discarded const. + +Signed-off-by: Peter Jones +--- + grub-core/normal/main.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c +index e903f291732..803b9656d36 100644 +--- a/grub-core/normal/main.c ++++ b/grub-core/normal/main.c +@@ -406,7 +406,7 @@ grub_try_normal_dev (const char *name, void *data) + static grub_err_t + grub_try_normal_discover (void) + { +- char *prefix = grub_env_get ("prefix"); ++ const char *prefix = grub_env_get ("prefix"); + grub_err_t err = GRUB_ERR_FILE_NOT_FOUND; + + if (!prefix) diff --git a/0202-Update-gnulib-version-and-drop-most-gnulib-patches.patch b/0202-Update-gnulib-version-and-drop-most-gnulib-patches.patch deleted file mode 100644 index c2c50f1..0000000 --- a/0202-Update-gnulib-version-and-drop-most-gnulib-patches.patch +++ /dev/null @@ -1,832 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robbie Harwood -Date: Wed, 15 Dec 2021 15:07:50 -0500 -Subject: [PATCH] Update gnulib version and drop most gnulib patches - -In addition to the changes carried in our gnulib patches, several -Coverity and code hygiene fixes that were previously downstream are also -included in this 3-year gnulib increment. - -Unfortunately, fix-width.patch is retained. - -Bump minimum autoconf version from 2.63 to 2.64 and automake from 1.11 -to 1.14, as required by gnulib. - -Sync bootstrap script itself with gnulib. - -Update regexp module for new dynarray dependency. - -Fix various new warnings. - -Signed-off-by: Robbie Harwood -(cherry picked from commit deb18ff931c3133c2aa536a92bd92e50d6615303) -[rharwood: backport around requirements in INSTALL] ---- - configure.ac | 2 +- - grub-core/Makefile.core.def | 3 + - grub-core/disk/luks2.c | 4 +- - grub-core/lib/posix_wrap/limits.h | 6 +- - include/grub/compiler.h | 4 +- - include/grub/list.h | 2 +- - INSTALL | 2 +- - bootstrap | 291 ++++++++++++--------- - bootstrap.conf | 22 +- - conf/Makefile.extra-dist | 6 - - config.h.in | 68 +++++ - grub-core/lib/gnulib-patches/fix-null-deref.patch | 13 - - .../lib/gnulib-patches/fix-null-state-deref.patch | 12 - - .../gnulib-patches/fix-regcomp-uninit-token.patch | 15 -- - .../gnulib-patches/fix-regexec-null-deref.patch | 12 - - .../lib/gnulib-patches/fix-uninit-structure.patch | 11 - - .../lib/gnulib-patches/fix-unused-value.patch | 14 - - 17 files changed, 262 insertions(+), 225 deletions(-) - delete mode 100644 grub-core/lib/gnulib-patches/fix-null-deref.patch - delete mode 100644 grub-core/lib/gnulib-patches/fix-null-state-deref.patch - delete mode 100644 grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch - delete mode 100644 grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch - delete mode 100644 grub-core/lib/gnulib-patches/fix-uninit-structure.patch - delete mode 100644 grub-core/lib/gnulib-patches/fix-unused-value.patch - -diff --git a/configure.ac b/configure.ac -index 40c4338bce..79f45ef1e1 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -49,7 +49,7 @@ AC_CANONICAL_TARGET - program_prefix="${save_program_prefix}" - - AM_INIT_AUTOMAKE([1.11]) --AC_PREREQ(2.63) -+AC_PREREQ(2.64) - AC_CONFIG_SRCDIR([include/grub/dl.h]) - AC_CONFIG_HEADER([config-util.h]) - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 08ac0fb15f..ec1ec5083b 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -762,6 +762,9 @@ module = { - name = regexp; - common = commands/regexp.c; - common = commands/wildcard.c; -+ common = lib/gnulib/malloc/dynarray_finalize.c; -+ common = lib/gnulib/malloc/dynarray_emplace_enlarge.c; -+ common = lib/gnulib/malloc/dynarray_resize.c; - common = lib/gnulib/regex.c; - cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)'; - cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)'; -diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c -index 371a53b837..c917a5f91e 100644 ---- a/grub-core/disk/luks2.c -+++ b/grub-core/disk/luks2.c -@@ -389,7 +389,7 @@ luks2_verify_key (grub_luks2_digest_t *d, grub_uint8_t *candidate_key, - { - grub_uint8_t candidate_digest[GRUB_CRYPTODISK_MAX_KEYLEN]; - grub_uint8_t digest[GRUB_CRYPTODISK_MAX_KEYLEN], salt[GRUB_CRYPTODISK_MAX_KEYLEN]; -- grub_size_t saltlen = sizeof (salt), digestlen = sizeof (digest); -+ idx_t saltlen = sizeof (salt), digestlen = sizeof (digest); - const gcry_md_spec_t *hash; - gcry_err_code_t gcry_ret; - -@@ -428,7 +428,7 @@ luks2_decrypt_key (grub_uint8_t *out_key, - grub_uint8_t area_key[GRUB_CRYPTODISK_MAX_KEYLEN]; - grub_uint8_t salt[GRUB_CRYPTODISK_MAX_KEYLEN]; - grub_uint8_t *split_key = NULL; -- grub_size_t saltlen = sizeof (salt); -+ idx_t saltlen = sizeof (salt); - char cipher[32], *p; - const gcry_md_spec_t *hash; - gcry_err_code_t gcry_ret; -diff --git a/grub-core/lib/posix_wrap/limits.h b/grub-core/lib/posix_wrap/limits.h -index 591dbf3289..4be7b40806 100644 ---- a/grub-core/lib/posix_wrap/limits.h -+++ b/grub-core/lib/posix_wrap/limits.h -@@ -25,7 +25,11 @@ - #define USHRT_MAX GRUB_USHRT_MAX - #define UINT_MAX GRUB_UINT_MAX - #define ULONG_MAX GRUB_ULONG_MAX --#define SIZE_MAX GRUB_SIZE_MAX -+ -+/* gnulib also defines this type */ -+#ifndef SIZE_MAX -+# define SIZE_MAX GRUB_SIZE_MAX -+#endif - - #define SCHAR_MIN GRUB_SCHAR_MIN - #define SCHAR_MAX GRUB_SCHAR_MAX -diff --git a/include/grub/compiler.h b/include/grub/compiler.h -index ebafec6895..441a9eca07 100644 ---- a/include/grub/compiler.h -+++ b/include/grub/compiler.h -@@ -30,10 +30,10 @@ - - /* Does this compiler support compile-time error attributes? */ - #if GNUC_PREREQ(4,3) --# define ATTRIBUTE_ERROR(msg) \ -+# define GRUB_ATTRIBUTE_ERROR(msg) \ - __attribute__ ((__error__ (msg))) - #else --# define ATTRIBUTE_ERROR(msg) __attribute__ ((noreturn)) -+# define GRUB_ATTRIBUTE_ERROR(msg) __attribute__ ((noreturn)) - #endif - - #if GNUC_PREREQ(4,4) -diff --git a/include/grub/list.h b/include/grub/list.h -index b13acb9624..21f4b4b44a 100644 ---- a/include/grub/list.h -+++ b/include/grub/list.h -@@ -40,7 +40,7 @@ void EXPORT_FUNC(grub_list_remove) (grub_list_t item); - - static inline void * - grub_bad_type_cast_real (int line, const char *file) -- ATTRIBUTE_ERROR ("bad type cast between incompatible grub types"); -+ GRUB_ATTRIBUTE_ERROR ("bad type cast between incompatible grub types"); - - static inline void * - grub_bad_type_cast_real (int line, const char *file) -diff --git a/INSTALL b/INSTALL -index 79a0af7d93..ee9f536f76 100644 ---- a/INSTALL -+++ b/INSTALL -@@ -42,7 +42,7 @@ If you use a development snapshot or want to hack on GRUB you may - need the following. - - * Python 2.6 or later --* Autoconf 2.63 or later -+* Autoconf 2.64 or later - * Automake 1.11 or later - - Prerequisites for make-check: -diff --git a/bootstrap b/bootstrap -index 5b08e7e2d4..dc2238f4ad 100755 ---- a/bootstrap -+++ b/bootstrap -@@ -1,10 +1,10 @@ - #! /bin/sh - # Print a version string. --scriptversion=2019-01-04.17; # UTC -+scriptversion=2022-01-26.05; # UTC - - # Bootstrap this package from checked-out sources. - --# Copyright (C) 2003-2019 Free Software Foundation, Inc. -+# Copyright (C) 2003-2022 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 -@@ -47,7 +47,7 @@ PERL="${PERL-perl}" - - me=$0 - --default_gnulib_url=git://git.sv.gnu.org/gnulib -+default_gnulib_url=https://git.savannah.gnu.org/git/gnulib.git - - usage() { - cat </dev/null) -+if test -z "$package"; then -+ package=$(sed -n "$extract_package_name" configure.ac) \ -+ || die 'cannot find package name in configure.ac' -+fi - gnulib_name=lib$package - - build_aux=build-aux -@@ -290,6 +313,116 @@ find_tool () - eval "export $find_tool_envvar" - } - -+# Strip blank and comment lines to leave significant entries. -+gitignore_entries() { -+ sed '/^#/d; /^$/d' "$@" -+} -+ -+# If $STR is not already on a line by itself in $FILE, insert it at the start. -+# Entries are inserted at the start of the ignore list to ensure existing -+# entries starting with ! are not overridden. Such entries support -+# whitelisting exceptions after a more generic blacklist pattern. -+insert_if_absent() { -+ file=$1 -+ str=$2 -+ test -f $file || touch $file -+ test -r $file || die "Error: failed to read ignore file: $file" -+ duplicate_entries=$(gitignore_entries $file | sort | uniq -d) -+ if [ "$duplicate_entries" ] ; then -+ die "Error: Duplicate entries in $file: " $duplicate_entries -+ fi -+ linesold=$(gitignore_entries $file | wc -l) -+ linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l) -+ if [ $linesold != $linesnew ] ; then -+ { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \ -+ || die "insert_if_absent $file $str: failed" -+ fi -+} -+ -+# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with -+# insert_if_absent. -+insert_vc_ignore() { -+ vc_ignore_file="$1" -+ pattern="$2" -+ case $vc_ignore_file in -+ *.gitignore) -+ # A .gitignore entry that does not start with '/' applies -+ # recursively to subdirectories, so prepend '/' to every -+ # .gitignore entry. -+ pattern=$(echo "$pattern" | sed s,^,/,);; -+ esac -+ insert_if_absent "$vc_ignore_file" "$pattern" -+} -+ -+symlink_to_dir() -+{ -+ src=$1/$2 -+ dst=${3-$2} -+ -+ test -f "$src" && { -+ -+ # If the destination directory doesn't exist, create it. -+ # This is required at least for "lib/uniwidth/cjk.h". -+ dst_dir=$(dirname "$dst") -+ if ! test -d "$dst_dir"; then -+ mkdir -p "$dst_dir" -+ -+ # If we've just created a directory like lib/uniwidth, -+ # tell version control system(s) it's ignorable. -+ # FIXME: for now, this does only one level -+ parent=$(dirname "$dst_dir") -+ for dot_ig in x $vc_ignore; do -+ test $dot_ig = x && continue -+ ig=$parent/$dot_ig -+ insert_vc_ignore $ig "${dst_dir##*/}" -+ done -+ fi -+ -+ if $copy; then -+ { -+ test ! -h "$dst" || { -+ echo "$me: rm -f $dst" && -+ rm -f "$dst" -+ } -+ } && -+ test -f "$dst" && -+ cmp -s "$src" "$dst" || { -+ echo "$me: cp -fp $src $dst" && -+ cp -fp "$src" "$dst" -+ } -+ else -+ # Leave any existing symlink alone, if it already points to the source, -+ # so that broken build tools that care about symlink times -+ # aren't confused into doing unnecessary builds. Conversely, if the -+ # existing symlink's timestamp is older than the source, make it afresh, -+ # so that broken tools aren't confused into skipping needed builds. See -+ # . -+ test -h "$dst" && -+ src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 && -+ dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 && -+ test "$src_i" = "$dst_i" && -+ both_ls=$(ls -dt "$src" "$dst") && -+ test "X$both_ls" = "X$dst$nl$src" || { -+ dot_dots= -+ case $src in -+ /*) ;; -+ *) -+ case /$dst/ in -+ *//* | */../* | */./* | /*/*/*/*/*/) -+ die "invalid symlink calculation: $src -> $dst";; -+ /*/*/*/*/) dot_dots=../../../;; -+ /*/*/*/) dot_dots=../../;; -+ /*/*/) dot_dots=../;; -+ esac;; -+ esac -+ -+ echo "$me: ln -fs $dot_dots$src $dst" && -+ ln -fs "$dot_dots$src" "$dst" -+ } -+ fi -+ } -+} -+ - # Override the default configuration, if necessary. - # Make sure that bootstrap.conf is sourced from the current directory - # if we were invoked as "sh bootstrap". -@@ -320,6 +453,12 @@ do - --help) - usage - exit;; -+ --version) -+ set -e -+ echo "bootstrap $scriptversion" -+ echo "$copyright" -+ exit 0 -+ ;; - --gnulib-srcdir=*) - GNULIB_SRCDIR=${option#--gnulib-srcdir=};; - --skip-po) -@@ -335,7 +474,7 @@ do - --no-git) - use_git=false;; - *) -- die "$option: unknown option";; -+ bootstrap_option_hook $option || die "$option: unknown option";; - esac - done - -@@ -346,47 +485,6 @@ if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then - die "Bootstrapping from a non-checked-out distribution is risky." - fi - --# Strip blank and comment lines to leave significant entries. --gitignore_entries() { -- sed '/^#/d; /^$/d' "$@" --} -- --# If $STR is not already on a line by itself in $FILE, insert it at the start. --# Entries are inserted at the start of the ignore list to ensure existing --# entries starting with ! are not overridden. Such entries support --# whitelisting exceptions after a more generic blacklist pattern. --insert_if_absent() { -- file=$1 -- str=$2 -- test -f $file || touch $file -- test -r $file || die "Error: failed to read ignore file: $file" -- duplicate_entries=$(gitignore_entries $file | sort | uniq -d) -- if [ "$duplicate_entries" ] ; then -- die "Error: Duplicate entries in $file: " $duplicate_entries -- fi -- linesold=$(gitignore_entries $file | wc -l) -- linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l) -- if [ $linesold != $linesnew ] ; then -- { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \ -- || die "insert_if_absent $file $str: failed" -- fi --} -- --# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with --# insert_if_absent. --insert_vc_ignore() { -- vc_ignore_file="$1" -- pattern="$2" -- case $vc_ignore_file in -- *.gitignore) -- # A .gitignore entry that does not start with '/' applies -- # recursively to subdirectories, so prepend '/' to every -- # .gitignore entry. -- pattern=$(echo "$pattern" | sed s,^,/,);; -- esac -- insert_if_absent "$vc_ignore_file" "$pattern" --} -- - # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac. - found_aux_dir=no - grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \ -@@ -665,9 +763,25 @@ if $use_gnulib; then - shallow= - if test -z "$GNULIB_REVISION"; then - git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2' -+ git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \ -+ || cleanup_gnulib -+ else -+ git fetch -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2' -+ mkdir -p "$gnulib_path" -+ # Only want a shallow checkout of $GNULIB_REVISION, but git does not -+ # support cloning by commit hash. So attempt a shallow fetch by commit -+ # hash to minimize the amount of data downloaded and changes needed to -+ # be processed, which can drastically reduce download and processing -+ # time for checkout. If the fetch by commit fails, a shallow fetch can -+ # not be performed because we do not know what the depth of the commit -+ # is without fetching all commits. So fallback to fetching all commits. -+ git -C "$gnulib_path" init -+ git -C "$gnulib_path" remote add origin ${GNULIB_URL:-$default_gnulib_url} -+ git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \ -+ || git -C "$gnulib_path" fetch origin \ -+ || cleanup_gnulib -+ git -C "$gnulib_path" reset --hard FETCH_HEAD - fi -- git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \ -- || cleanup_gnulib - - trap - 1 2 13 15 - fi -@@ -784,75 +898,6 @@ case $SKIP_PO in - fi;; - esac - --symlink_to_dir() --{ -- src=$1/$2 -- dst=${3-$2} -- -- test -f "$src" && { -- -- # If the destination directory doesn't exist, create it. -- # This is required at least for "lib/uniwidth/cjk.h". -- dst_dir=$(dirname "$dst") -- if ! test -d "$dst_dir"; then -- mkdir -p "$dst_dir" -- -- # If we've just created a directory like lib/uniwidth, -- # tell version control system(s) it's ignorable. -- # FIXME: for now, this does only one level -- parent=$(dirname "$dst_dir") -- for dot_ig in x $vc_ignore; do -- test $dot_ig = x && continue -- ig=$parent/$dot_ig -- insert_vc_ignore $ig "${dst_dir##*/}" -- done -- fi -- -- if $copy; then -- { -- test ! -h "$dst" || { -- echo "$me: rm -f $dst" && -- rm -f "$dst" -- } -- } && -- test -f "$dst" && -- cmp -s "$src" "$dst" || { -- echo "$me: cp -fp $src $dst" && -- cp -fp "$src" "$dst" -- } -- else -- # Leave any existing symlink alone, if it already points to the source, -- # so that broken build tools that care about symlink times -- # aren't confused into doing unnecessary builds. Conversely, if the -- # existing symlink's timestamp is older than the source, make it afresh, -- # so that broken tools aren't confused into skipping needed builds. See -- # . -- test -h "$dst" && -- src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 && -- dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 && -- test "$src_i" = "$dst_i" && -- both_ls=$(ls -dt "$src" "$dst") && -- test "X$both_ls" = "X$dst$nl$src" || { -- dot_dots= -- case $src in -- /*) ;; -- *) -- case /$dst/ in -- *//* | */../* | */./* | /*/*/*/*/*/) -- die "invalid symlink calculation: $src -> $dst";; -- /*/*/*/*/) dot_dots=../../../;; -- /*/*/*/) dot_dots=../../;; -- /*/*/) dot_dots=../;; -- esac;; -- esac -- -- echo "$me: ln -fs $dot_dots$src $dst" && -- ln -fs "$dot_dots$src" "$dst" -- } -- fi -- } --} -- - version_controlled_file() { - parent=$1 - file=$2 -@@ -970,7 +1015,7 @@ bootstrap_post_import_hook \ - # Uninitialized submodules are listed with an initial dash. - if $use_git && git submodule | grep '^-' >/dev/null; then - die "some git submodules are not initialized. " \ -- "Run 'git submodule init' and bootstrap again." -+ "Run 'git submodule update --init' and bootstrap again." - fi - - # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some -@@ -1064,7 +1109,7 @@ bootstrap_epilogue - - echo "$0: done. Now you can run './configure'." - --# Local variables: -+# Local Variables: - # eval: (add-hook 'before-save-hook 'time-stamp) - # time-stamp-start: "scriptversion=" - # time-stamp-format: "%:y-%02m-%02d.%02H" -diff --git a/bootstrap.conf b/bootstrap.conf -index 71ce943c7d..e4e5f3750a 100644 ---- a/bootstrap.conf -+++ b/bootstrap.conf -@@ -1,6 +1,6 @@ - # Bootstrap configuration. - --# Copyright (C) 2006-2019 Free Software Foundation, Inc. -+# Copyright (C) 2006-2022 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 -@@ -16,11 +16,10 @@ - # along with this program. If not, see . - - --GNULIB_REVISION=d271f868a8df9bbec29049d01e056481b7a1a263 -+GNULIB_REVISION=9f48fb992a3d7e96610c4ce8be969cff2d61a01b - - # gnulib modules used by this package. --# mbswidth is used by gnulib-fix-width.diff's changes to argp rather than --# directly. -+# mbswidth is used by fix-width.diff's changes to argp rather than directly. - gnulib_modules=" - argp - base64 -@@ -67,8 +66,8 @@ SKIP_PO=t - - # Build prerequisites - buildreq="\ --autoconf 2.63 --automake 1.11 -+autoconf 2.64 -+automake 1.14 - gettext 0.18.3 - git 1.5.5 - tar - -@@ -80,11 +79,12 @@ cp -a INSTALL INSTALL.grub - - bootstrap_post_import_hook () { - set -e -- for patchname in fix-null-deref fix-null-state-deref fix-regcomp-uninit-token \ -- fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width; do -- patch -d grub-core/lib/gnulib -p2 \ -- < "grub-core/lib/gnulib-patches/$patchname.patch" -- done -+ -+ # Instead of patching our gnulib and therefore maintaining a fork, submit -+ # changes to gnulib and update the hash above when they've merged. Do not -+ # add new patches here. -+ patch -d grub-core/lib/gnulib -p2 < grub-core/lib/gnulib-patches/fix-width.patch -+ - for patchname in \ - 0001-Support-POTFILES-shell \ - 0002-Handle-gettext_printf-shell-function \ -diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist -index 5eef708338..26ac8765e3 100644 ---- a/conf/Makefile.extra-dist -+++ b/conf/Makefile.extra-dist -@@ -31,12 +31,6 @@ EXTRA_DIST += grub-core/gensymlist.sh - EXTRA_DIST += grub-core/genemuinit.sh - EXTRA_DIST += grub-core/genemuinitheader.sh - --EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-deref.patch --EXTRA_DIST += grub-core/lib/gnulib-patches/fix-null-state-deref.patch --EXTRA_DIST += grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch --EXTRA_DIST += grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch --EXTRA_DIST += grub-core/lib/gnulib-patches/fix-uninit-structure.patch --EXTRA_DIST += grub-core/lib/gnulib-patches/fix-unused-value.patch - EXTRA_DIST += grub-core/lib/gnulib-patches/fix-width.patch - - EXTRA_DIST += grub-core/lib/libgcrypt -diff --git a/config.h.in b/config.h.in -index c3134309c6..512d1bbe13 100644 ---- a/config.h.in -+++ b/config.h.in -@@ -67,10 +67,78 @@ - # define _GNU_SOURCE 1 - - # ifndef _GL_INLINE_HEADER_BEGIN -+/* gnulib gets configured against the host, not the target, and the rest of -+ * our buildsystem works around that. This is difficult to avoid as gnulib's -+ * detection requires a more capable system than our target. Instead, we -+ * reach in and set values appropriately - intentionally setting more than the -+ * bare minimum. If, when updating gnulib, something breaks, there's probably -+ * a change needed here or in grub-core/Makefile.core.def. */ -+# define SIZE_MAX ((size_t) -1) -+# define _GL_ATTRIBUTE_ALLOC_SIZE(args) \ -+ __attribute__ ((__alloc_size__ args)) -+# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) -+# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) -+# define _GL_ATTRIBUTE_COLD __attribute__ ((cold)) - # define _GL_ATTRIBUTE_CONST __attribute__ ((const)) -+# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute ((__malloc__ (f, i))) -+# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1) -+# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__)) -+# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg))) -+# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE \ -+ __attribute__ ((externally_visible)) -+# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) -+# define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__)) -+# define _GL_ATTRIBUTE_MALLOC __attribute__ ((malloc)) -+# define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED -+# define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__)) -+# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__)) -+# define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__)) -+# define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args)) -+# define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__)) -+# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) -+# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) -+# define _GL_ATTRIBUTE_RETURNS_NONNULL \ -+ __attribute__ ((__returns_nonnull__)) -+# define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos)) -+# define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) -+# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg))) -+# define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2))) -+# define _GL_GNUC_PREREQ GNUC_PREREQ -+# define _GL_INLINE inline -+# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED -+ -+/* We can't use __has_attribute for these because gcc-5.1 is too old for -+ * that. Everything above is present in that version, though. */ -+# if __GNUC__ >= 7 -+# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((fallthrough)) -+# else -+# define _GL_ATTRIBUTE_FALLTHROUGH /* empty */ -+# endif -+ -+# ifndef ASM_FILE -+typedef __INT_FAST32_TYPE__ int_fast32_t; -+typedef __UINT_FAST32_TYPE__ uint_fast32_t; -+# endif -+ -+/* Ensure ialloc nests static/non-static inline properly. */ -+# define IALLOC_INLINE static inline -+ -+/* gnulib uses these for blocking out warnings they can't/won't fix. gnulib -+ * also makes the decision about whether to provide a declaration for -+ * reallocarray() at compile-time, so this is a convenient place to override - -+ * it's used by the ialloc module, which is used by base64. */ -+# define _GL_INLINE_HEADER_BEGIN _Pragma ("GCC diagnostic push") \ -+ void * \ -+ reallocarray (void *ptr, unsigned int nmemb, unsigned int size); -+# define _GL_INLINE_HEADER_END _Pragma ("GCC diagnostic pop") - - /* We don't have an abort() for gnulib to call in regexp. */ - # define abort __builtin_unreachable - # endif /* !_GL_INLINE_HEADER_BEGIN */ - -+/* gnulib doesn't build cleanly with older compilers. */ -+# if __GNUC__ < 11 -+_Pragma ("GCC diagnostic ignored \"-Wtype-limits\"") -+# endif -+ - #endif -diff --git a/grub-core/lib/gnulib-patches/fix-null-deref.patch b/grub-core/lib/gnulib-patches/fix-null-deref.patch -deleted file mode 100644 -index 8fafa153a4..0000000000 ---- a/grub-core/lib/gnulib-patches/fix-null-deref.patch -+++ /dev/null -@@ -1,13 +0,0 @@ --diff --git a/lib/argp-parse.c b/lib/argp-parse.c --index 6dec57310..900adad54 100644 ----- a/lib/argp-parse.c --+++ b/lib/argp-parse.c --@@ -940,7 +940,7 @@ weak_alias (__argp_parse, argp_parse) -- void * -- __argp_input (const struct argp *argp, const struct argp_state *state) -- { --- if (state) --+ if (state && state->pstate) -- { -- struct group *group; -- struct parser *parser = state->pstate; -diff --git a/grub-core/lib/gnulib-patches/fix-null-state-deref.patch b/grub-core/lib/gnulib-patches/fix-null-state-deref.patch -deleted file mode 100644 -index 813ec09c8a..0000000000 ---- a/grub-core/lib/gnulib-patches/fix-null-state-deref.patch -+++ /dev/null -@@ -1,12 +0,0 @@ ----- a/lib/argp-help.c 2020-10-28 14:32:19.189215988 +0000 --+++ b/lib/argp-help.c 2020-10-28 14:38:21.204673940 +0000 --@@ -145,7 +145,8 @@ -- if (*(int *)((char *)upptr + up->uparams_offs) >= upptr->rmargin) -- { -- __argp_failure (state, 0, 0, --- dgettext (state->root_argp->argp_domain, --+ dgettext (state == NULL ? NULL --+ : state->root_argp->argp_domain, -- "\ -- ARGP_HELP_FMT: %s value is less than or equal to %s"), -- "rmargin", up->name); -diff --git a/grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch b/grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch -deleted file mode 100644 -index 02e06315df..0000000000 ---- a/grub-core/lib/gnulib-patches/fix-regcomp-uninit-token.patch -+++ /dev/null -@@ -1,15 +0,0 @@ ----- a/lib/regcomp.c 2020-11-24 17:06:08.159223858 +0000 --+++ b/lib/regcomp.c 2020-11-24 17:06:15.630253923 +0000 --@@ -3808,11 +3808,7 @@ -- create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, -- re_token_type_t type) -- { --- re_token_t t; ---#if defined GCC_LINT || defined lint --- memset (&t, 0, sizeof t); ---#endif --- t.type = type; --+ re_token_t t = { .type = type }; -- return create_token_tree (dfa, left, right, &t); -- } -- -diff --git a/grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch b/grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch -deleted file mode 100644 -index db6dac9c9e..0000000000 ---- a/grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch -+++ /dev/null -@@ -1,12 +0,0 @@ ----- a/lib/regexec.c 2020-10-21 14:25:35.310195912 +0000 --+++ b/lib/regexec.c 2020-11-05 10:55:09.621542984 +0000 --@@ -1692,6 +1692,9 @@ -- { -- Idx top = mctx->state_log_top; -- --+ if (mctx->state_log == NULL) --+ return REG_NOERROR; --+ -- if ((next_state_log_idx >= mctx->input.bufs_len -- && mctx->input.bufs_len < mctx->input.len) -- || (next_state_log_idx >= mctx->input.valid_len -diff --git a/grub-core/lib/gnulib-patches/fix-uninit-structure.patch b/grub-core/lib/gnulib-patches/fix-uninit-structure.patch -deleted file mode 100644 -index 7b4d9f67af..0000000000 ---- a/grub-core/lib/gnulib-patches/fix-uninit-structure.patch -+++ /dev/null -@@ -1,11 +0,0 @@ ----- a/lib/regcomp.c 2020-10-22 13:49:06.770168928 +0000 --+++ b/lib/regcomp.c 2020-10-22 13:50:37.026528298 +0000 --@@ -3662,7 +3662,7 @@ -- Idx alloc = 0; -- #endif /* not RE_ENABLE_I18N */ -- reg_errcode_t ret; --- re_token_t br_token; --+ re_token_t br_token = {0}; -- bin_tree_t *tree; -- -- sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); -diff --git a/grub-core/lib/gnulib-patches/fix-unused-value.patch b/grub-core/lib/gnulib-patches/fix-unused-value.patch -deleted file mode 100644 -index ba51f1bf22..0000000000 ---- a/grub-core/lib/gnulib-patches/fix-unused-value.patch -+++ /dev/null -@@ -1,14 +0,0 @@ ----- a/lib/regexec.c 2020-10-21 14:25:35.310195912 +0000 --+++ b/lib/regexec.c 2020-10-21 14:32:07.961765604 +0000 --@@ -828,7 +828,11 @@ -- break; -- if (__glibc_unlikely (err != REG_NOMATCH)) -- goto free_return; --+#ifdef DEBUG --+ /* Only used for assertion below when DEBUG is set, otherwise --+ it will be over-written when we loop around. */ -- match_last = -1; --+#endif -- } -- else -- break; /* We found a match. */ diff --git a/0202-at_keyboard-mark-grub_keyboard_controller_write-unus.patch b/0202-at_keyboard-mark-grub_keyboard_controller_write-unus.patch new file mode 100644 index 0000000..058340d --- /dev/null +++ b/0202-at_keyboard-mark-grub_keyboard_controller_write-unus.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Mon, 8 Jan 2024 19:14:06 -0500 +Subject: [PATCH] at_keyboard: mark grub_keyboard_controller_write unused + +It's used sometimes and not others by #ifdef, so mark it unused so the +compiler doesn't complain. + +Signed-off-by: Peter Jones +--- + grub-core/term/at_keyboard.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c +index e667d0a862c..d2b716b5b4f 100644 +--- a/grub-core/term/at_keyboard.c ++++ b/grub-core/term/at_keyboard.c +@@ -93,7 +93,7 @@ at_command (grub_uint8_t data) + return (i != GRUB_AT_TRIES); + } + +-static void ++static void __attribute__((__unused__)) + grub_keyboard_controller_write (grub_uint8_t c) + { + at_command (KEYBOARD_COMMAND_WRITE); +@@ -170,7 +170,7 @@ query_mode (void) + grub_uint64_t endtime; + unsigned i; + int e; +- char *envvar; ++ const char *envvar; + + for (i = 0; i < GRUB_AT_TRIES; i++) { + grub_dprintf ("atkeyb", "query_mode: sending command to controller\n"); diff --git a/0203-Fix-another-minor-sign-comparison-error.patch b/0203-Fix-another-minor-sign-comparison-error.patch new file mode 100644 index 0000000..24c343c --- /dev/null +++ b/0203-Fix-another-minor-sign-comparison-error.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Tue, 9 Jan 2024 14:37:25 -0500 +Subject: [PATCH] Fix another minor sign comparison error. + +Signed-off-by: Peter Jones +--- + grub-core/kern/mm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c +index 1aeeba9e27e..819bc5126a6 100644 +--- a/grub-core/kern/mm.c ++++ b/grub-core/kern/mm.c +@@ -505,7 +505,7 @@ grub_memalign (grub_size_t align, grub_size_t size) + goto fail; + + /* Preallocate some extra space if heap growth is small. */ +- grow = grub_max (grow, GRUB_MM_HEAP_GROW_EXTRA); ++ grow = grub_max (grow, (grub_size_t)GRUB_MM_HEAP_GROW_EXTRA); + + /* Align up heap growth to make it friendly to CPU/MMU. */ + if (grow > ~(grub_size_t) (GRUB_MM_HEAP_GROW_ALIGN - 1)) diff --git a/0203-commands-search-Fix-bug-stopping-iteration-when-no-f.patch b/0203-commands-search-Fix-bug-stopping-iteration-when-no-f.patch deleted file mode 100644 index 4f7feb9..0000000 --- a/0203-commands-search-Fix-bug-stopping-iteration-when-no-f.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Renaud=20M=C3=A9trich?= -Date: Tue, 8 Feb 2022 08:39:10 +0100 -Subject: [PATCH] commands/search: Fix bug stopping iteration when --no-floppy - is used -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -When using --no-floppy and a floppy was encountered, iterate_device() -was returning 1, causing the iteration to stop instead of continuing. - -Signed-off-by: Renaud Métrich -Reviewed-by: Daniel Kiper -(cherry picked from commit 68ba54c2298604146be83cae144dafd1cfd1fe2d) -Signed-off-by: Robbie Harwood ---- - grub-core/commands/search.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c -index ed090b3af8..51656e361c 100644 ---- a/grub-core/commands/search.c -+++ b/grub-core/commands/search.c -@@ -64,7 +64,7 @@ iterate_device (const char *name, void *data) - /* Skip floppy drives when requested. */ - if (ctx->no_floppy && - name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9') -- return 1; -+ return 0; - - #ifdef DO_SEARCH_FS_UUID - #define compare_fn grub_strcasecmp diff --git a/0204-Track-explicit-module-dependencies-in-Makefile.core..patch b/0204-Track-explicit-module-dependencies-in-Makefile.core..patch new file mode 100644 index 0000000..c5311c1 --- /dev/null +++ b/0204-Track-explicit-module-dependencies-in-Makefile.core..patch @@ -0,0 +1,124 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Oliver Steffen +Date: Wed, 28 Feb 2024 13:36:00 +0100 +Subject: [PATCH] Track explicit module dependencies in Makefile.core.def + +Add a new keyword, "depends", to the module definition syntax +used in Makefile.core.def. This allows specifying explicit module +dependencies together with the module definition. + +Make use of this new keyword in the bli module definition. + +Signed-off-by: Oliver Steffen +Reviewed-by: Daniel Kiper +Tested-by: Oskari Pirhonen +--- + grub-core/Makefile.core.def | 1 + + .gitignore | 1 - + conf/Makefile.common | 1 + + gentpl.py | 7 +++++++ + grub-core/Makefile.am | 9 ++++++--- + grub-core/genmoddep.awk | 2 +- + 6 files changed, 16 insertions(+), 5 deletions(-) + +diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def +index c9dcfa00e85..a5a3ee31800 100644 +--- a/grub-core/Makefile.core.def ++++ b/grub-core/Makefile.core.def +@@ -2670,6 +2670,7 @@ module = { + name = bli; + efi = commands/bli.c; + enable = efi; ++ depends = part_gpt; + }; + + module = { +diff --git a/.gitignore b/.gitignore +index f2e8e1e42d7..c603c15d66c 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -11,7 +11,6 @@ + *.img + *.log + *.lst +-!/grub-core/extra_deps.lst + *.marker + *.mod + *.o +diff --git a/conf/Makefile.common b/conf/Makefile.common +index c8756d8146f..9feac7434da 100644 +--- a/conf/Makefile.common ++++ b/conf/Makefile.common +@@ -115,6 +115,7 @@ MOD_FILES = + MODULE_FILES = + MARKER_FILES = + KERNEL_HEADER_FILES = ++EXTRA_DEPS = + + bin_SCRIPTS = + bin_PROGRAMS = +diff --git a/gentpl.py b/gentpl.py +index 5826a6b14e8..0f8d009ef21 100644 +--- a/gentpl.py ++++ b/gentpl.py +@@ -642,6 +642,9 @@ def platform_values(defn, platform, suffix): + def extra_dist(defn): + return foreach_value(defn, "extra_dist", lambda value: value + " ") + ++def extra_dep(defn): ++ return foreach_value(defn, "depends", lambda value: value + " ") ++ + def platform_sources(defn, p): return platform_values(defn, p, "") + def platform_nodist_sources(defn, p): return platform_values(defn, p, "_nodist") + +@@ -712,6 +715,10 @@ def module(defn, platform): + gvar_add("MOD_FILES", name + ".mod") + gvar_add("MARKER_FILES", name + ".marker") + gvar_add("CLEANFILES", name + ".marker") ++ ++ for dep in defn.find_all("depends"): ++ gvar_add("EXTRA_DEPS", "depends " + name + " " + dep + ":") ++ + output(""" + """ + name + """.marker: $(""" + cname(defn) + """_SOURCES) $(nodist_""" + cname(defn) + """_SOURCES) + $(TARGET_CPP) -DGRUB_LST_GENERATOR $(CPPFLAGS_MARKER) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(""" + cname(defn) + """_CPPFLAGS) $(CPPFLAGS) $^ > $@.new || (rm -f $@; exit 1) +diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am +index 7953ba95399..77f8329cd43 100644 +--- a/grub-core/Makefile.am ++++ b/grub-core/Makefile.am +@@ -456,8 +456,11 @@ crypto.lst: $(srcdir)/lib/libgcrypt-grub/cipher/crypto.lst + platform_DATA += crypto.lst + CLEANFILES += crypto.lst + +-syminfo.lst: gensyminfo.sh kernel_syms.lst $(top_srcdir)/grub-core/extra_deps.lst $(MODULE_FILES) +- cat kernel_syms.lst $(top_srcdir)/grub-core/extra_deps.lst > $@.new ++extra_deps.lst: ++ @echo $(EXTRA_DEPS) | sed "s/\s*:\s*/\n/g" > $@ ++ ++syminfo.lst: gensyminfo.sh kernel_syms.lst extra_deps.lst $(MODULE_FILES) ++ cat kernel_syms.lst extra_deps.lst > $@.new + for m in $(MODULE_FILES); do \ + sh $< $$m >> $@.new || exit 1; \ + done +@@ -467,7 +470,7 @@ syminfo.lst: gensyminfo.sh kernel_syms.lst $(top_srcdir)/grub-core/extra_deps.ls + moddep.lst: syminfo.lst genmoddep.awk video.lst + cat $< | sort | $(AWK) -f $(srcdir)/genmoddep.awk > $@ || (rm -f $@; exit 1) + platform_DATA += moddep.lst +-CLEANFILES += config.log syminfo.lst moddep.lst ++CLEANFILES += config.log syminfo.lst moddep.lst extra_deps.lst + + $(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) build-grub-module-verifier$(BUILD_EXEEXT) + TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@ +diff --git a/grub-core/genmoddep.awk b/grub-core/genmoddep.awk +index cc987a53aa8..ab457cb2b56 100644 +--- a/grub-core/genmoddep.awk ++++ b/grub-core/genmoddep.awk +@@ -35,7 +35,7 @@ BEGIN { + for (i = 3; i <= NF; i++) { + modtab[$2] = modtab[$2] " " $i; + } +- } ++ } else if ($1 == "") {} #Skip empty lines + else { + printf "error: %u: unrecognized input format\n", NR >"/dev/stderr"; + error++; diff --git a/0204-search-new-efidisk-only-option-on-EFI-systems.patch b/0204-search-new-efidisk-only-option-on-EFI-systems.patch deleted file mode 100644 index 3f6194a..0000000 --- a/0204-search-new-efidisk-only-option-on-EFI-systems.patch +++ /dev/null @@ -1,168 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Renaud=20M=C3=A9trich?= -Date: Tue, 8 Feb 2022 08:39:11 +0100 -Subject: [PATCH] search: new --efidisk-only option on EFI systems -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -When using 'search' on EFI systems, we sometimes want to exclude devices -that are not EFI disks (e.g. md, lvm). -This is typically used when wanting to chainload when having a software -raid (md) for EFI partition: -with no option, 'search --file /EFI/redhat/shimx64.efi' sets root envvar -to 'md/boot_efi' which cannot be used for chainloading since there is no -effective EFI device behind. - -This commit also refactors handling of --no-floppy option. - -Signed-off-by: Renaud Métrich -[rharwood: apply rmetrich's flags initialization fix] -Signed-off-by: Robbie Harwood ---- - grub-core/commands/search.c | 27 +++++++++++++++++++++++---- - grub-core/commands/search_wrap.c | 18 ++++++++++++------ - include/grub/search.h | 15 ++++++++++++--- - 3 files changed, 47 insertions(+), 13 deletions(-) - -diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c -index 51656e361c..57d26ced8a 100644 ---- a/grub-core/commands/search.c -+++ b/grub-core/commands/search.c -@@ -47,7 +47,7 @@ struct search_ctx - { - const char *key; - const char *var; -- int no_floppy; -+ enum search_flags flags; - char **hints; - unsigned nhints; - int count; -@@ -62,10 +62,29 @@ iterate_device (const char *name, void *data) - int found = 0; - - /* Skip floppy drives when requested. */ -- if (ctx->no_floppy && -+ if (ctx->flags & SEARCH_FLAGS_NO_FLOPPY && - name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9') - return 0; - -+ /* Limit to EFI disks when requested. */ -+ if (ctx->flags & SEARCH_FLAGS_EFIDISK_ONLY) -+ { -+ grub_device_t dev; -+ dev = grub_device_open (name); -+ if (! dev) -+ { -+ grub_errno = GRUB_ERR_NONE; -+ return 0; -+ } -+ if (! dev->disk || dev->disk->dev->id != GRUB_DISK_DEVICE_EFIDISK_ID) -+ { -+ grub_device_close (dev); -+ grub_errno = GRUB_ERR_NONE; -+ return 0; -+ } -+ grub_device_close (dev); -+ } -+ - #ifdef DO_SEARCH_FS_UUID - #define compare_fn grub_strcasecmp - #else -@@ -261,13 +280,13 @@ try (struct search_ctx *ctx) - } - - void --FUNC_NAME (const char *key, const char *var, int no_floppy, -+FUNC_NAME (const char *key, const char *var, enum search_flags flags, - char **hints, unsigned nhints) - { - struct search_ctx ctx = { - .key = key, - .var = var, -- .no_floppy = no_floppy, -+ .flags = flags, - .hints = hints, - .nhints = nhints, - .count = 0, -diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c -index 47fc8eb996..0b62acf853 100644 ---- a/grub-core/commands/search_wrap.c -+++ b/grub-core/commands/search_wrap.c -@@ -40,6 +40,7 @@ static const struct grub_arg_option options[] = - N_("Set a variable to the first device found."), N_("VARNAME"), - ARG_TYPE_STRING}, - {"no-floppy", 'n', 0, N_("Do not probe any floppy drive."), 0, 0}, -+ {"efidisk-only", 0, 0, N_("Only probe EFI disks."), 0, 0}, - {"hint", 'h', GRUB_ARG_OPTION_REPEATABLE, - N_("First try the device HINT. If HINT ends in comma, " - "also try subpartitions"), N_("HINT"), ARG_TYPE_STRING}, -@@ -73,6 +74,7 @@ enum options - SEARCH_FS_UUID, - SEARCH_SET, - SEARCH_NO_FLOPPY, -+ SEARCH_EFIDISK_ONLY, - SEARCH_HINT, - SEARCH_HINT_IEEE1275, - SEARCH_HINT_BIOS, -@@ -89,6 +91,7 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args) - const char *id = 0; - int i = 0, j = 0, nhints = 0; - char **hints = NULL; -+ enum search_flags flags = 0; - - if (state[SEARCH_HINT].set) - for (i = 0; state[SEARCH_HINT].args[i]; i++) -@@ -180,15 +183,18 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args) - goto out; - } - -+ if (state[SEARCH_NO_FLOPPY].set) -+ flags |= SEARCH_FLAGS_NO_FLOPPY; -+ -+ if (state[SEARCH_EFIDISK_ONLY].set) -+ flags |= SEARCH_FLAGS_EFIDISK_ONLY; -+ - if (state[SEARCH_LABEL].set) -- grub_search_label (id, var, state[SEARCH_NO_FLOPPY].set, -- hints, nhints); -+ grub_search_label (id, var, flags, hints, nhints); - else if (state[SEARCH_FS_UUID].set) -- grub_search_fs_uuid (id, var, state[SEARCH_NO_FLOPPY].set, -- hints, nhints); -+ grub_search_fs_uuid (id, var, flags, hints, nhints); - else if (state[SEARCH_FILE].set) -- grub_search_fs_file (id, var, state[SEARCH_NO_FLOPPY].set, -- hints, nhints); -+ grub_search_fs_file (id, var, flags, hints, nhints); - else - grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type"); - -diff --git a/include/grub/search.h b/include/grub/search.h -index d80347df34..4190aeb2cb 100644 ---- a/include/grub/search.h -+++ b/include/grub/search.h -@@ -19,11 +19,20 @@ - #ifndef GRUB_SEARCH_HEADER - #define GRUB_SEARCH_HEADER 1 - --void grub_search_fs_file (const char *key, const char *var, int no_floppy, -+enum search_flags -+ { -+ SEARCH_FLAGS_NO_FLOPPY = 1, -+ SEARCH_FLAGS_EFIDISK_ONLY = 2 -+ }; -+ -+void grub_search_fs_file (const char *key, const char *var, -+ enum search_flags flags, - char **hints, unsigned nhints); --void grub_search_fs_uuid (const char *key, const char *var, int no_floppy, -+void grub_search_fs_uuid (const char *key, const char *var, -+ enum search_flags flags, - char **hints, unsigned nhints); --void grub_search_label (const char *key, const char *var, int no_floppy, -+void grub_search_label (const char *key, const char *var, -+ enum search_flags flags, - char **hints, unsigned nhints); - - #endif diff --git a/0205-Revert-mm-Assert-that-we-preserve-header-vs-region-a.patch b/0205-Revert-mm-Assert-that-we-preserve-header-vs-region-a.patch new file mode 100644 index 0000000..1a224b3 --- /dev/null +++ b/0205-Revert-mm-Assert-that-we-preserve-header-vs-region-a.patch @@ -0,0 +1,75 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Leo Sandoval +Date: Fri, 8 Mar 2024 16:54:43 -0600 +Subject: [PATCH] Revert "mm: Assert that we preserve header vs region + alignment" +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This reverts commit 1df8fe66c57087eb33bd6dc69f786ed124615aa7. + +This is temporal while we find the reason for + +In file included from ../../include/grub/mm_private.h:23, + from ../../include/grub/relocator_private.h:24, + from ../../grub-core/lib/efi/relocator.c:20: +../../include/grub/mm_private.h: In function ‘grub_mm_size_sanity_check’: +../../include/grub/misc.h:36:56: error: duplicate case value + 36 | #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; } + | ^~~~ +../../include/grub/mm_private.h:105:3: note: in expansion of macro ‘COMPILE_TIME_ASSERT’ + 105 | COMPILE_TIME_ASSERT ((sizeof (struct grub_mm_region) % + | ^~~~~~~~~~~~~~~~~~~ +../../include/grub/misc.h:36:48: note: previously used here + 36 | #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; } + | ^~~~ +../../include/grub/mm_private.h:105:3: note: in expansion of macro ‘COMPILE_TIME_ASSERT’ + 105 | COMPILE_TIME_ASSERT ((sizeof (struct grub_mm_region) % + | ^~~~~~~~~~~~~~~~~~~ +../../include/grub/misc.h:36:56: error: duplicate case value + 36 | #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; } + | ^~~~ +../../include/grub/mm_private.h:112:3: note: in expansion of macro ‘COMPILE_TIME_ASSERT’ + 112 | COMPILE_TIME_ASSERT (sizeof (struct grub_mm_header) == GRUB_MM_ALIGN); + | ^~~~~~~~~~~~~~~~~~~ +../../include/grub/misc.h:36:48: note: previously used here + 36 | #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; } + | ^~~~ +../../include/grub/mm_private.h:112:3: note: in expansion of macro ‘COMPILE_TIME_ASSERT’ + 112 | COMPILE_TIME_ASSERT (sizeof (struct grub_mm_header) == GRUB_MM_ALIGN); + | ^~~~~~~~~~~~~~~~~~~ +--- + include/grub/mm_private.h | 14 -------------- + 1 file changed, 14 deletions(-) + +diff --git a/include/grub/mm_private.h b/include/grub/mm_private.h +index 96c2d816be6..2481ee1fa20 100644 +--- a/include/grub/mm_private.h ++++ b/include/grub/mm_private.h +@@ -20,7 +20,6 @@ + #define GRUB_MM_PRIVATE_H 1 + + #include +-#include + + /* For context, see kern/mm.c */ + +@@ -99,17 +98,4 @@ typedef struct grub_mm_region + extern grub_mm_region_t EXPORT_VAR (grub_mm_base); + #endif + +-static inline void +-grub_mm_size_sanity_check (void) { +- /* Ensure we preserve alignment when doing h = (grub_mm_header_t) (r + 1). */ +- COMPILE_TIME_ASSERT ((sizeof (struct grub_mm_region) % +- sizeof (struct grub_mm_header)) == 0); +- +- /* +- * GRUB_MM_ALIGN is supposed to represent cell size, and a mm_header is +- * supposed to be 1 cell. +- */ +- COMPILE_TIME_ASSERT (sizeof (struct grub_mm_header) == GRUB_MM_ALIGN); +-} +- + #endif diff --git a/0206-make-use-the-_CPU-variety-of-build-flags-for-PROGRAM.patch b/0206-make-use-the-_CPU-variety-of-build-flags-for-PROGRAM.patch new file mode 100644 index 0000000..4f56149 --- /dev/null +++ b/0206-make-use-the-_CPU-variety-of-build-flags-for-PROGRAM.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 13 Mar 2024 15:11:15 -0600 +Subject: [PATCH] make: use the _CPU variety of build flags for PROGRAM and + LIBRARY + +Signed-off-by: Peter Jones +--- + conf/Makefile.common | 15 +++++++-------- + 1 file changed, 7 insertions(+), 8 deletions(-) + +diff --git a/conf/Makefile.common b/conf/Makefile.common +index 9feac7434da..f8c2f6bd881 100644 +--- a/conf/Makefile.common ++++ b/conf/Makefile.common +@@ -60,15 +60,14 @@ LDFLAGS_IMAGE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S + CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) + CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) + +-CFLAGS_PROGRAM = $(UTILS_CFLAGS) +-LDFLAGS_PROGRAM = $(UTILS_LDFLAGS) +-CPPFLAGS_PROGRAM = $(UTILS_CPPFLAGS) +-CCASFLAGS_PROGRAM = $(UTILS_CCASFLAGS) ++CFLAGS_PROGRAM = $(CFLAGS_CPU) ++LDFLAGS_PROGRAM = $(LDFLAGS_CPU) ++CPPFLAGS_PROGRAM = $(CPPFLAGS_CPU) ++CCASFLAGS_PROGRAM = $(CCASFLAGS_CPU) + +-CFLAGS_LIBRARY = $(UTILS_CFLAGS) +-LDFLAGS_LIBRARY = $(UTILS_LDFLAGS) +-CPPFLAGS_LIBRARY = $(UTILS_CPPFLAGS) +-CCASFLAGS_LIBRARY = $(UTILS_CCASFLAGS) ++CFLAGS_LIBRARY = $(CFLAGS_CPU) ++CPPFLAGS_LIBRARY = $(CPPFLAGS_CPU) ++CCASFLAGS_LIBRARY = $(CCASFLAGS_CPU) + + # Other variables + diff --git a/0207-Work-around-extra_deps.lst-issue.patch b/0207-Work-around-extra_deps.lst-issue.patch new file mode 100644 index 0000000..0481cd5 --- /dev/null +++ b/0207-Work-around-extra_deps.lst-issue.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Wed, 13 Mar 2024 14:06:43 -0400 +Subject: [PATCH] Work around extra_deps.lst issue + +--- + grub-core/Makefile.am | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am +index 77f8329cd43..aa172391fdf 100644 +--- a/grub-core/Makefile.am ++++ b/grub-core/Makefile.am +@@ -460,6 +460,10 @@ extra_deps.lst: + @echo $(EXTRA_DEPS) | sed "s/\s*:\s*/\n/g" > $@ + + syminfo.lst: gensyminfo.sh kernel_syms.lst extra_deps.lst $(MODULE_FILES) ++ if ! [ -f extra_deps.lst ] ; then \ ++ echo Missing extra_deps.lst ; \ ++ echo $(EXTRA_DEPS) | sed "s/\s*:\s*/\n/g" > extra_deps.lst ; \ ++ fi + cat kernel_syms.lst extra_deps.lst > $@.new + for m in $(MODULE_FILES); do \ + sh $< $$m >> $@.new || exit 1; \ diff --git a/0207-grub-core-loader-arm64-linux.c-do-not-validate-kerne.patch b/0207-grub-core-loader-arm64-linux.c-do-not-validate-kerne.patch deleted file mode 100644 index 5b450f9..0000000 --- a/0207-grub-core-loader-arm64-linux.c-do-not-validate-kerne.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dimitri John Ledkov -Date: Fri, 4 Mar 2022 11:29:31 +0100 -Subject: [PATCH] grub-core/loader/arm64/linux.c: do not validate kernel twice - -Call to grub_file_open(, GRUB_FILE_TYPE_LINUX_KERNEL) already passes -the kernel file through shim-lock verifier when secureboot is on. Thus -there is no need to validate the kernel image again. And when doing so -again, duplicate PCR measurement is performed, breaking measurements -compatibility with 2.04+linuxefi. - -This patch must not be ported to older editions of grub code bases -that do not have verifiers framework, or it is not builtin, or -shim-lock-verifier is an optional module. - -Signed-off-by: Dimitri John Ledkov ---- - grub-core/loader/arm64/linux.c | 13 ------------- - 1 file changed, 13 deletions(-) - -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index f18d90bd74..d2af47c2c0 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -34,7 +34,6 @@ - #include - #include - #include --#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -341,7 +340,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - grub_off_t filelen; - grub_uint32_t align; - void *kernel = NULL; -- int rc; - - grub_dl_ref (my_mod); - -@@ -370,17 +368,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - goto fail; - } - -- if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) -- { -- 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; -- } -- } -- - if (grub_arch_efi_linux_check_image (kernel) != GRUB_ERR_NONE) - goto fail; - if (parse_pe_header (kernel, &kernel_size, &handover_offset, &align) != GRUB_ERR_NONE) diff --git a/0208-include-proper-attribute-for-an-EFI-API-call-definit.patch b/0208-include-proper-attribute-for-an-EFI-API-call-definit.patch new file mode 100644 index 0000000..ad965b6 --- /dev/null +++ b/0208-include-proper-attribute-for-an-EFI-API-call-definit.patch @@ -0,0 +1,42 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Leo Sandoval +Date: Thu, 21 Mar 2024 16:27:25 -0600 +Subject: [PATCH] include proper attribute for an EFI API call definition +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Otherwise we observe the following issue + +../../grub-core/net/efi/http.c: In function ‘efihttp_request’: +../../grub-core/net/efi/http.c:233:28: error: passing argument 3 of ‘b->create_event’ from incompatible pointer type [-Wincompatible-pointer-types] + 233 | grub_efi_http_request_callback, NULL, + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | | + | void (*)(void *, void *) +../../grub-core/net/efi/http.c:233:28: note: expected ‘void (__attribute__((ms_abi)) *)(void *, void *)’ but argument is of type ‘void (*)(void *, void *)’ +--- + grub-core/net/efi/http.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c +index 0568ea5d43e..6fecb261c55 100644 +--- a/grub-core/net/efi/http.c ++++ b/grub-core/net/efi/http.c +@@ -131,14 +131,14 @@ static grub_efi_boolean_t request_callback_done; + static grub_efi_boolean_t response_callback_done; + + static void +-grub_efi_http_request_callback (grub_efi_event_t event __attribute__ ((unused)), ++__grub_efi_api grub_efi_http_request_callback (grub_efi_event_t event __attribute__ ((unused)), + void *context __attribute__ ((unused))) + { + request_callback_done = 1; + } + + static void +-grub_efi_http_response_callback (grub_efi_event_t event __attribute__ ((unused)), ++__grub_efi_api grub_efi_http_response_callback (grub_efi_event_t event __attribute__ ((unused)), + void *context __attribute__ ((unused))) + { + response_callback_done = 1; diff --git a/0209-cast-grub_error-status-parameter.patch b/0209-cast-grub_error-status-parameter.patch new file mode 100644 index 0000000..0cea65b --- /dev/null +++ b/0209-cast-grub_error-status-parameter.patch @@ -0,0 +1,67 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Leo Sandoval +Date: Fri, 22 Mar 2024 12:12:02 -0600 +Subject: [PATCH] cast grub_error status parameter +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +For some reason, the compiler concludes that the status variable is +ultimately a 'long unsigned int' but status is a 'unsigned' (not a +long) so temporally cast it to unsigned otherwise we see the following + +../../grub-core/net/efi/http.c: In function ‘efihttp_request’: +../../grub-core/net/efi/http.c:251:39: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘grub_efi_status_t’ {aka ‘long unsigned int’} [-Wformat=] + 251 | return grub_error (GRUB_ERR_IO, "Fail to send a request! status=0x%x\n", status); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ + | | + | grub_efi_status_t {aka long unsigned int} +--- + grub-core/net/efi/http.c | 6 +++--- + grub-core/net/efi/net.c | 2 +- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c +index 6fecb261c55..5bdb47548f8 100644 +--- a/grub-core/net/efi/http.c ++++ b/grub-core/net/efi/http.c +@@ -236,7 +236,7 @@ efihttp_request (grub_efi_http_t *http, char *server, char *name, int use_https, + if (status != GRUB_EFI_SUCCESS) + { + grub_free (request_data.url); +- return grub_error (GRUB_ERR_IO, "Fail to create an event! status=0x%x\n", status); ++ return grub_error (GRUB_ERR_IO, "Fail to create an event! status=0x%x\n", (unsigned) status); + } + + status = http->request(http, &request_token); +@@ -248,7 +248,7 @@ efihttp_request (grub_efi_http_t *http, char *server, char *name, int use_https, + { + b->close_event(request_token.event); + grub_free (request_data.url); +- return grub_error (GRUB_ERR_IO, "Fail to send a request! status=0x%x\n", status); ++ return grub_error (GRUB_ERR_IO, "Fail to send a request! status=0x%x\n", (unsigned) status); + } + /* TODO: Add Timeout */ + while (!request_callback_done) +@@ -273,7 +273,7 @@ efihttp_request (grub_efi_http_t *http, char *server, char *name, int use_https, + { + b->close_event(request_token.event); + grub_free (request_data.url); +- return grub_error (GRUB_ERR_IO, "Fail to create an event! status=0x%x\n", status); ++ return grub_error (GRUB_ERR_IO, "Fail to create an event! status=0x%x\n", (unsigned) status); + } + + response_token.status = GRUB_EFI_SUCCESS; +diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c +index 0a1e604b5bd..1b13603a63c 100644 +--- a/grub-core/net/efi/net.c ++++ b/grub-core/net/efi/net.c +@@ -706,7 +706,7 @@ grub_efi_service_binding (grub_efi_handle_t dev, grub_guid_t *service_binding_gu + status = service->create_child(service, &child_dev); + if (status != GRUB_EFI_SUCCESS) + { +- grub_error (GRUB_ERR_IO, N_("Failed to create child device of http service %x"), status); ++ grub_error (GRUB_ERR_IO, N_("Failed to create child device of http service %x"), (unsigned) status); + return NULL; + } + diff --git a/0210-remove-unused-varible.patch b/0210-remove-unused-varible.patch new file mode 100644 index 0000000..2a10b10 --- /dev/null +++ b/0210-remove-unused-varible.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Leo Sandoval +Date: Fri, 22 Mar 2024 14:20:06 -0600 +Subject: [PATCH] remove unused varible +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Otherwise compiler complains with: + +../../grub-core/commands/efi/connectefi.c:143:20: error: unused variable ‘j’ [-Werror=unused-variable] + 143 | unsigned j; + | ^ + +Signed-off-by: Leo Sandoval +--- + grub-core/commands/efi/connectefi.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/grub-core/commands/efi/connectefi.c b/grub-core/commands/efi/connectefi.c +index 6c397f8f508..9d02f2780f6 100644 +--- a/grub-core/commands/efi/connectefi.c ++++ b/grub-core/commands/efi/connectefi.c +@@ -140,7 +140,6 @@ loop: + { + grub_efi_handle_t handle = handles[i]; + grub_efi_status_t status; +- unsigned j; + + /* Skip already handled handles */ + if (is_in_list (handle)) diff --git a/0211-cast-grub_net_bootp_packet-pointer.patch b/0211-cast-grub_net_bootp_packet-pointer.patch new file mode 100644 index 0000000..b98d9b2 --- /dev/null +++ b/0211-cast-grub_net_bootp_packet-pointer.patch @@ -0,0 +1,42 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Leo Sandoval +Date: Fri, 22 Mar 2024 18:28:17 -0600 +Subject: [PATCH] cast grub_net_bootp_packet pointer +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Otherwise compiler complains with: + +../../grub-core/net/drivers/efi/efinet.c: In function ‘grub_efi_net_config_real’: +../../grub-core/net/drivers/efi/efinet.c:876:28: error: cannot convert to a pointer type + 876 | dhcp_ack = (struct grub_net_bootp_packet *) pxe_mode->dhcp_ack; + | ^~~~~~~~~~~~~~~~~~~~~ +../../grub-core/net/drivers/efi/efinet.c:881:57: error: initialization of ‘struct grub_net_bootp_packet *’ from incompatible pointer type ‘grub_efi_pxe_packet_t *’ [-Wincompatible-pointer-types] + 881 | struct grub_net_bootp_packet *proxy_offer = &pxe_mode->proxy_offer; + | ^ + +Signed-off-by: Leo Sandoval +--- + grub-core/net/drivers/efi/efinet.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c +index 83005ea9f88..4591d0757ec 100644 +--- a/grub-core/net/drivers/efi/efinet.c ++++ b/grub-core/net/drivers/efi/efinet.c +@@ -872,12 +872,12 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, + { + grub_dprintf ("efinet", "using ipv4 and dhcp\n"); + +- struct grub_net_bootp_packet *dhcp_ack = &pxe_mode->dhcp_ack; ++ struct grub_net_bootp_packet *dhcp_ack = (struct grub_net_bootp_packet *) &pxe_mode->dhcp_ack; + + if (pxe_mode->proxy_offer_received) + { + grub_dprintf ("efinet", "proxy offer receive"); +- struct grub_net_bootp_packet *proxy_offer = &pxe_mode->proxy_offer; ++ struct grub_net_bootp_packet *proxy_offer = (struct grub_net_bootp_packet *) &pxe_mode->proxy_offer; + + if (proxy_offer && dhcp_ack->boot_file[0] == '\0') + { diff --git a/0212-libtasn1-fix-string-overflow-warning.patch b/0212-libtasn1-fix-string-overflow-warning.patch new file mode 100644 index 0000000..50d151a --- /dev/null +++ b/0212-libtasn1-fix-string-overflow-warning.patch @@ -0,0 +1,56 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Leo Sandoval +Date: Thu, 11 Jan 2024 12:05:20 -0600 +Subject: [PATCH] libtasn1: fix string overflow warning + +Patched also at the libtasn1 project with commit + + c54e523d9dacdb7eec7f20964df12df9b80f467c + Author: Simo Sorce + AuthorDate: Tue May 11 14:18:10 2021 -0400 + Commit: Simo Sorce + CommitDate: Tue May 11 14:26:04 2021 -0400 + + Parent: 890a8a9 Fix resource leak (node) + Contained: master + Follows: v4.16.0 (48) + Precedes: v4.17.0 (5) + + Fix String overflow warning + + Scanner Output + -------------- + rror: COMPILER_WARNING (CWE-758): [#def2] + libtasn1-4.16.0/lib/element.c: scope_hint: In function '_asn1_append_sequence_set' + libtasn1-4.16.0/lib/element.c:186:7: warning[-Wstringop-overflow=]: '_asn1_ltostr' accessing 22 bytes in a region of size 21 + # 186 | _asn1_ltostr (n, temp + 1); + # | ^~~~~~~~~~~~~~~~~~~~~~~~~~ + libtasn1-4.16.0/lib/element.c:186:7: note: referencing argument 2 of type 'char *' + libtasn1-4.16.0/lib/element.c:30: included_from: Included from here. + libtasn1-4.16.0/lib/parser_aux.h:70:7: note: in a call to function '_asn1_ltostr' + # 70 | char *_asn1_ltostr (int64_t v, char str[LTOSTR_MAX_SIZE]); + # | ^~~~~~~~~~~~ + # 184| n++; + # 185| temp[0] = '?'; + # 186|-> _asn1_ltostr (n, temp + 1); + # 187| } + # 188| _asn1_set_name (p2, temp); + +Signed-off-by: Leo Sandoval +--- + grub-core/lib/libtasn1/lib/element.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/lib/libtasn1/lib/element.c b/grub-core/lib/libtasn1/lib/element.c +index ed761ff56bd..8cc73455aee 100644 +--- a/grub-core/lib/libtasn1/lib/element.c ++++ b/grub-core/lib/libtasn1/lib/element.c +@@ -143,7 +143,7 @@ int + _asn1_append_sequence_set (asn1_node node, struct node_tail_cache_st *pcache) + { + asn1_node p, p2; +- char temp[LTOSTR_MAX_SIZE]; ++ char temp[LTOSTR_MAX_SIZE + 1]; + long n; + + if (!node || !(node->down)) diff --git a/0004-Add-support-for-Linux-EFI-stub-loading.patch b/0213-Add-support-for-Linux-EFI-stub-loading.patch similarity index 55% rename from 0004-Add-support-for-Linux-EFI-stub-loading.patch rename to 0213-Add-support-for-Linux-EFI-stub-loading.patch index 745973e..c930f1c 100644 --- a/0004-Add-support-for-Linux-EFI-stub-loading.patch +++ b/0213-Add-support-for-Linux-EFI-stub-loading.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Matthew Garrett -Date: Tue, 10 Jul 2012 11:58:52 -0400 +Date: Mon, 1 Apr 2024 13:20:18 -0600 Subject: [PATCH] Add support for Linux EFI stub loading. Also: @@ -26,32 +26,25 @@ grub-2.00-no-insmod-on-sb.patch), but this should be more correct. It moves the check into grub_dl_load_file. --- grub-core/Makefile.core.def | 16 +- - grub-core/kern/dl.c | 21 +++ - grub-core/kern/efi/efi.c | 28 ++++ + grub-core/kern/dl.c | 22 +++ grub-core/kern/efi/mm.c | 32 ++++ - grub-core/loader/arm64/linux.c | 118 +++++++------- - grub-core/loader/arm64/xen_boot.c | 1 - - grub-core/loader/efi/linux.c | 70 ++++++++ + grub-core/loader/efi/linux.c | 47 ++++++ grub-core/loader/i386/efi/linux.c | 335 ++++++++++++++++++++++++++++++++++++++ grub-core/loader/i386/pc/linux.c | 10 +- - include/grub/arm/linux.h | 9 + - include/grub/arm64/linux.h | 9 + - include/grub/efi/efi.h | 7 +- + include/grub/efi/efi.h | 3 + include/grub/efi/linux.h | 31 ++++ - 13 files changed, 618 insertions(+), 69 deletions(-) - create mode 100644 grub-core/loader/efi/linux.c + 8 files changed, 485 insertions(+), 11 deletions(-) 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 8022e1c0a7..45d3edaa4d 100644 +index a5a3ee31800..3f6e944d6a5 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def -@@ -1734,13 +1734,6 @@ module = { - enable = i386_pc; +@@ -1831,12 +1831,6 @@ module = { }; -- + -module = { - name = linux16; - common = loader/i386/pc/linux.c; @@ -61,37 +54,47 @@ index 8022e1c0a7..45d3edaa4d 100644 module = { name = ntldr; i386_pc = loader/i386/pc/ntldr.c; -@@ -1796,7 +1789,9 @@ module = { +@@ -1892,10 +1886,9 @@ module = { module = { name = linux; - x86 = loader/i386/linux.c; -+ 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; -@@ -1811,9 +1806,14 @@ module = { - arm64 = loader/arm64/linux.c; - riscv32 = loader/riscv/linux.c; - riscv64 = loader/riscv/linux.c; -+ emu = loader/emu/linux.c; +- i386_pc = lib/i386/pc/vesa_modes_table.c; ++ i386_pc = loader/i386/pc/linux.c; + i386_xen_pvh = lib/i386/pc/vesa_modes_table.c; + mips = loader/mips/linux.c; + powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c; +@@ -1908,11 +1901,14 @@ module = { + loongarch64 = loader/efi/linux.c; + riscv32 = loader/efi/linux.c; + riscv64 = loader/efi/linux.c; +- i386_efi = loader/efi/linux.c; +- x86_64_efi = loader/efi/linux.c; ++ i386_efi = loader/i386/efi/linux.c; ++ x86_64_efi = loader/i386/efi/linux.c; + emu = loader/emu/linux.c; + fdt = lib/fdt.c; -+ common = loader/linux.c; common = lib/cmdline.c; - enable = noemu; -+ + efi = loader/efi/linux.c; ++ efi = loader/i386/linux.c; }; module = { diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index 48f8a79073..b714937095 100644 +index c55f0ecf931..d48d4131ba7 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c -@@ -38,6 +38,14 @@ +@@ -32,12 +32,21 @@ + #include + #include + #include ++#include + + /* Platforms where modules are in a readonly area of memory. */ + #if defined(GRUB_MACHINE_QEMU) #define GRUB_MODULES_MACHINE_READONLY #endif @@ -106,12 +109,12 @@ index 48f8a79073..b714937095 100644 #pragma GCC diagnostic ignored "-Wcast-align" -@@ -695,6 +703,19 @@ grub_dl_load_file (const char *filename) +@@ -861,6 +870,19 @@ grub_dl_load_file (const char *filename) void *core = 0; grub_dl_t mod = 0; +#ifdef GRUB_MACHINE_EFI -+ if (grub_efi_secure_boot ()) ++ if (grub_efi_get_secureboot ()) + { +#if 0 + /* This is an error, but grub2-mkconfig still generates a pile of @@ -126,50 +129,11 @@ index 48f8a79073..b714937095 100644 grub_boot_time ("Loading module %s", 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 8cff7be028..35b8f67060 100644 ---- a/grub-core/kern/efi/efi.c -+++ b/grub-core/kern/efi/efi.c -@@ -286,6 +286,34 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, - return grub_efi_get_variable_with_attributes (var, guid, datasize_out, data_out, NULL); - } - -+grub_efi_boolean_t -+grub_efi_secure_boot (void) -+{ -+ grub_efi_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID; -+ grub_size_t datasize; -+ char *secure_boot = NULL; -+ char *setup_mode = NULL; -+ grub_efi_boolean_t ret = 0; -+ -+ secure_boot = grub_efi_get_variable("SecureBoot", &efi_var_guid, &datasize); -+ -+ if (datasize != 1 || !secure_boot) -+ goto out; -+ -+ setup_mode = grub_efi_get_variable("SetupMode", &efi_var_guid, &datasize); -+ -+ if (datasize != 1 || !setup_mode) -+ goto out; -+ -+ if (*secure_boot && !*setup_mode) -+ ret = 1; -+ -+ out: -+ grub_free (secure_boot); -+ grub_free (setup_mode); -+ return ret; -+} -+ - #pragma GCC diagnostic ignored "-Wcast-align" - - /* 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 9838fb2f50..f6aef0ef64 100644 +index df443f434d4..fb9dbf52528 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, +@@ -112,6 +112,38 @@ grub_efi_drop_alloc (grub_efi_physical_address_t address, } } @@ -186,7 +150,7 @@ index 9838fb2f50..f6aef0ef64 100644 + return 0; + + b = grub_efi_system_table->boot_services; -+ status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_MAX_ADDRESS, GRUB_EFI_LOADER_DATA, pages, &address); ++ status = b->allocate_pages (GRUB_EFI_ALLOCATE_MAX_ADDRESS, GRUB_EFI_LOADER_DATA, pages, &address); + + if (status != GRUB_EFI_SUCCESS) + return 0; @@ -196,7 +160,7 @@ index 9838fb2f50..f6aef0ef64 100644 + /* Uggh, the address 0 was allocated... This is too annoying, + so reallocate another one. */ + address = max; -+ status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_MAX_ADDRESS, GRUB_EFI_LOADER_DATA, pages, &address); ++ status = b->allocate_pages (GRUB_EFI_ALLOCATE_MAX_ADDRESS, GRUB_EFI_LOADER_DATA, pages, &address); + grub_efi_free_pages (0, pages); + if (status != GRUB_EFI_SUCCESS) + return 0; @@ -208,231 +172,27 @@ index 9838fb2f50..f6aef0ef64 100644 /* Allocate pages. Return the pointer to the first of allocated pages. */ 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 ef3e9f9444..a312c66868 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -29,6 +29,7 @@ +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index bfbd95aeef0..925394d1767 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -25,10 +25,12 @@ + #include + #include + #include ++#include #include #include #include -+#include #include ++#include + #include #include #include -@@ -41,6 +42,7 @@ static int loaded; +@@ -87,6 +89,51 @@ static grub_efi_load_file2_t initrd_lf2 = { + grub_efi_initrd_load_file2 + }; - static void *kernel_addr; - static grub_uint64_t kernel_size; -+static grub_uint32_t handover_offset; - - static char *linux_args; - static grub_uint32_t cmdline_size; -@@ -67,7 +69,8 @@ grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh) - static grub_err_t - finalize_params_linux (void) - { -- int node, retval; -+ grub_efi_loaded_image_t *loaded_image = NULL; -+ int node, retval, len; - - void *fdt; - -@@ -102,79 +105,70 @@ 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_err_t --grub_arch_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args) --{ -- grub_efi_memory_mapped_device_path_t *mempath; -- grub_efi_handle_t image_handle; -- grub_efi_boot_services_t *b; -- grub_efi_status_t status; -- grub_efi_loaded_image_t *loaded_image; -- int len; -- -- mempath = grub_malloc (2 * sizeof (grub_efi_memory_mapped_device_path_t)); -- if (!mempath) -- return grub_errno; -- -- mempath[0].header.type = GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE; -- mempath[0].header.subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE; -- mempath[0].header.length = grub_cpu_to_le16_compile_time (sizeof (*mempath)); -- mempath[0].memory_type = GRUB_EFI_LOADER_DATA; -- mempath[0].start_address = addr; -- mempath[0].end_address = addr + size; -- -- mempath[1].header.type = GRUB_EFI_END_DEVICE_PATH_TYPE; -- mempath[1].header.subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; -- mempath[1].header.length = sizeof (grub_efi_device_path_t); -- -- b = grub_efi_system_table->boot_services; -- status = b->load_image (0, grub_efi_image_handle, -- (grub_efi_device_path_t *) mempath, -- (void *) addr, size, &image_handle); -- if (status != GRUB_EFI_SUCCESS) -- return grub_error (GRUB_ERR_BAD_OS, "cannot load image"); -- -- 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)); -+ loaded_image->load_options = NULL; -+ loaded_image->load_options_size = 0; -+ } -+} -+ -+grub_err_t -+grub_arch_efi_linux_boot_image (grub_addr_t addr, char *args) -+{ -+ grub_err_t retval; -+ -+ retval = finalize_params_linux (); -+ if (retval != GRUB_ERR_NONE) -+ return grub_errno; -+ -+ grub_dprintf ("linux", "linux command line: '%s'\n", args); -+ -+ retval = grub_efi_linux_boot ((char *)addr, handover_offset, (void *)addr); -+ -+ /* Never reached... */ -+ free_params(); -+ return retval; - } - - static grub_err_t - grub_linux_boot (void) - { -- if (finalize_params_linux () != GRUB_ERR_NONE) -- return grub_errno; -- -- return (grub_arch_efi_linux_boot_image((grub_addr_t)kernel_addr, -- kernel_size, linux_args)); -+ return (grub_arch_efi_linux_boot_image((grub_addr_t)kernel_addr, linux_args)); - } - - static grub_err_t -@@ -288,6 +282,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - { - grub_file_t file = 0; - struct linux_arch_kernel_header lh; -+ struct grub_armxx_linux_pe_header *pe; - grub_err_t err; - - grub_dl_ref (my_mod); -@@ -333,6 +328,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); - -+ if (!grub_linuxefi_secure_validate (kernel_addr, kernel_size)) -+ { -+ grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), argv[0]); -+ goto fail; -+ } -+ -+ pe = (void *)((unsigned long)kernel_addr + lh.hdr_offset); -+ handover_offset = pe->opt.entry_addr; -+ - cmdline_size = grub_loader_cmdline_size (argc, argv) + sizeof (LINUX_IMAGE); - linux_args = grub_malloc (cmdline_size); - if (!linux_args) -diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c -index 22cc25eccd..d9b7a9ba40 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_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 0000000000..c24202a5dd ---- /dev/null -+++ b/grub-core/loader/efi/linux.c -@@ -0,0 +1,70 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2014 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 SHIM_LOCK_GUID \ + { 0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23} } + @@ -445,7 +205,7 @@ index 0000000000..c24202a5dd +grub_efi_boolean_t +grub_linuxefi_secure_validate (void *data, grub_uint32_t size) +{ -+ grub_efi_guid_t guid = SHIM_LOCK_GUID; ++ grub_guid_t guid = SHIM_LOCK_GUID; + grub_efi_shim_lock_t *shim_lock; + + shim_lock = grub_efi_locate_protocol(&guid, NULL); @@ -465,21 +225,25 @@ index 0000000000..c24202a5dd +typedef void (*handover_func) (void *, grub_efi_system_table_t *, void *); + +grub_err_t -+grub_efi_linux_boot (void *kernel_addr, grub_off_t offset, ++grub_efi_linux_boot (void *kernel_address, grub_off_t offset, + void *kernel_params) +{ + handover_func hf; + -+ hf = (handover_func)((char *)kernel_addr + offset); ++ hf = (handover_func)((char *)kernel_address + offset); + hf (grub_efi_image_handle, grub_efi_system_table, kernel_params); + + return GRUB_ERR_BUG; +} + +#pragma GCC diagnostic pop ++ + grub_err_t + grub_arch_efi_linux_load_image_header (grub_file_t file, + struct linux_arch_kernel_header * lh) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c new file mode 100644 -index 0000000000..bb2616a809 +index 00000000000..9bfb4ab9e3e --- /dev/null +++ b/grub-core/loader/i386/efi/linux.c @@ -0,0 +1,335 @@ @@ -537,7 +301,7 @@ index 0000000000..bb2616a809 + asm volatile ("cli"); + + return grub_efi_linux_boot ((char *)kernel_mem, handover_offset + offset, -+ params); ++ params); +} + +static grub_err_t @@ -547,17 +311,17 @@ index 0000000000..bb2616a809 + 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)); ++ 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)); ++ 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)); ++ BYTES_TO_PAGES(kernel_size)); + if (params) + grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)params, -+ BYTES_TO_PAGES(16384)); ++ BYTES_TO_PAGES(16384)); + return GRUB_ERR_NONE; +} + @@ -631,14 +395,14 @@ index 0000000000..bb2616a809 + + if (initrd_mem && grub_errno) + grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)initrd_mem, -+ BYTES_TO_PAGES(size)); ++ BYTES_TO_PAGES(size)); + + return grub_errno; +} + +static grub_err_t +grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), -+ int argc, char *argv[]) ++ int argc, char *argv[]) +{ + grub_file_t file = 0; + struct linux_i386_kernel_header lh; @@ -676,7 +440,7 @@ index 0000000000..bb2616a809 + if (! grub_linuxefi_secure_validate (kernel, filelen)) + { + grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), -+ argv[0]); ++ argv[0]); + goto fail; + } + @@ -718,7 +482,7 @@ index 0000000000..bb2616a809 + + grub_dprintf ("linux", "setting up cmdline\n"); + linux_cmdline = grub_efi_allocate_pages_max(0x3fffffff, -+ BYTES_TO_PAGES(lh.cmdline_size + 1)); ++ BYTES_TO_PAGES(lh.cmdline_size + 1)); + + if (!linux_cmdline) + { @@ -729,8 +493,8 @@ index 0000000000..bb2616a809 + 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), -+ GRUB_VERIFY_KERNEL_CMDLINE); ++ lh.cmdline_size - (sizeof (LINUX_IMAGE) - 1), ++ GRUB_VERIFY_KERNEL_CMDLINE); + + lh.cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline; + @@ -740,11 +504,11 @@ index 0000000000..bb2616a809 + len = grub_file_size(file) - start; + + kernel_mem = grub_efi_allocate_pages_max(lh.pref_address, -+ BYTES_TO_PAGES(lh.init_size)); ++ BYTES_TO_PAGES(lh.init_size)); + + if (!kernel_mem) + kernel_mem = grub_efi_allocate_pages_max(0x3fffffff, -+ BYTES_TO_PAGES(lh.init_size)); ++ BYTES_TO_PAGES(lh.init_size)); + + if (!kernel_mem) + { @@ -777,16 +541,16 @@ index 0000000000..bb2616a809 + + if (linux_cmdline && !loaded) + grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t) -+ linux_cmdline, -+ BYTES_TO_PAGES(lh.cmdline_size + 1)); ++ 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)); ++ BYTES_TO_PAGES(kernel_size)); + + if (params && !loaded) + grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)params, -+ BYTES_TO_PAGES(16384)); ++ BYTES_TO_PAGES(16384)); + + return grub_errno; +} @@ -819,10 +583,10 @@ index 0000000000..bb2616a809 + grub_unregister_command (cmd_initrdefi); +} diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c -index 2a29952016..8be4c3b3f4 100644 +index 600530a742b..8593d74737f 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c -@@ -474,14 +474,20 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), +@@ -483,14 +483,20 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), return grub_errno; } @@ -844,7 +608,7 @@ index 2a29952016..8be4c3b3f4 100644 grub_register_command ("initrd16", grub_cmd_initrd, 0, N_("Load initrd.")); my_mod = mod; -@@ -490,5 +496,7 @@ GRUB_MOD_INIT(linux16) +@@ -499,5 +505,7 @@ GRUB_MOD_INIT(linux16) GRUB_MOD_FINI(linux16) { grub_unregister_command (cmd_linux); @@ -852,71 +616,11 @@ index 2a29952016..8be4c3b3f4 100644 grub_unregister_command (cmd_initrd); + grub_unregister_command (cmd_initrd16); } -diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h -index bcd5a7eb18..b582f67f66 100644 ---- a/include/grub/arm/linux.h -+++ b/include/grub/arm/linux.h -@@ -20,6 +20,7 @@ - #ifndef GRUB_ARM_LINUX_HEADER - #define GRUB_ARM_LINUX_HEADER 1 - -+#include - #include "system.h" - - #define GRUB_LINUX_ARM_MAGIC_SIGNATURE 0x016f2818 -@@ -34,9 +35,17 @@ struct linux_arm_kernel_header { - grub_uint32_t hdr_offset; - }; - -+struct grub_arm_linux_pe_header -+{ -+ grub_uint32_t magic; -+ struct grub_pe32_coff_header coff; -+ struct grub_pe32_optional_header opt; -+}; -+ - #if defined(__arm__) - # define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM_MAGIC_SIGNATURE - # 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 7e22b4ab69..ea030312df 100644 ---- a/include/grub/arm64/linux.h -+++ b/include/grub/arm64/linux.h -@@ -19,6 +19,7 @@ - #ifndef GRUB_ARM64_LINUX_HEADER - #define GRUB_ARM64_LINUX_HEADER 1 - -+#include - #include - - #define GRUB_LINUX_ARM64_MAGIC_SIGNATURE 0x644d5241 /* 'ARM\x64' */ -@@ -38,9 +39,17 @@ struct linux_arm64_kernel_header - grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ - }; - -+struct grub_arm64_linux_pe_header -+{ -+ grub_uint32_t magic; -+ struct grub_pe32_coff_header coff; -+ struct grub_pe64_optional_header opt; -+}; -+ - #if defined(__aarch64__) - # define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM64_MAGIC_SIGNATURE - # 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 83d958f994..6295df85f3 100644 +index 3670eddc52b..83ddbe26e57 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, +@@ -75,6 +75,9 @@ 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); @@ -926,27 +630,9 @@ index 83d958f994..6295df85f3 100644 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); -@@ -88,6 +91,7 @@ EXPORT_FUNC (grub_efi_set_variable) (const char *var, - const grub_efi_guid_t *guid, - void *data, - grub_size_t datasize); -+grub_efi_boolean_t EXPORT_FUNC (grub_efi_secure_boot) (void); - int - EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1, - const grub_efi_device_path_t *dp2); -@@ -101,8 +105,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_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_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 0000000000..d9ede36773 +index 00000000000..d224daafa4f --- /dev/null +++ b/include/grub/efi/linux.h @@ -0,0 +1,31 @@ @@ -978,6 +664,6 @@ index 0000000000..d9ede36773 +EXPORT_FUNC(grub_linuxefi_secure_validate) (void *data, grub_uint32_t size); +grub_err_t +EXPORT_FUNC(grub_efi_linux_boot) (void *kernel_address, grub_off_t offset, -+ void *kernel_param); ++ void *kernel_param); + +#endif /* ! GRUB_EFI_LINUX_HEADER */ diff --git a/0214-commands-boot-Add-API-to-pass-context-to-loader.patch b/0214-commands-boot-Add-API-to-pass-context-to-loader.patch deleted file mode 100644 index 63a2d76..0000000 --- a/0214-commands-boot-Add-API-to-pass-context-to-loader.patch +++ /dev/null @@ -1,158 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Chris Coulson -Date: Fri, 29 Apr 2022 21:16:02 +0100 -Subject: [PATCH] commands/boot: Add API to pass context to loader - -Loaders rely on global variables for saving context which is consumed -in the boot hook and freed in the unload hook. In the case where a loader -command is executed twice, calling grub_loader_set a second time executes -the unload hook, but in some cases this runs when the loader's global -context has already been updated, resulting in the updated context being -freed and potential use-after-free bugs when the boot hook is subsequently -called. - -This adds a new API (grub_loader_set_ex) which allows a loader to specify -context that is passed to its boot and unload hooks. This is an alternative -to requiring that loaders call grub_loader_unset before mutating their -global context. - -Signed-off-by: Chris Coulson -(cherry picked from commit 4322a64dde7e8fedb58e50b79408667129d45dd3) ---- - grub-core/commands/boot.c | 66 +++++++++++++++++++++++++++++++++++++++++------ - include/grub/loader.h | 5 ++++ - 2 files changed, 63 insertions(+), 8 deletions(-) - -diff --git a/grub-core/commands/boot.c b/grub-core/commands/boot.c -index bbca81e947..53691a62d9 100644 ---- a/grub-core/commands/boot.c -+++ b/grub-core/commands/boot.c -@@ -27,10 +27,20 @@ - - GRUB_MOD_LICENSE ("GPLv3+"); - --static grub_err_t (*grub_loader_boot_func) (void); --static grub_err_t (*grub_loader_unload_func) (void); -+static grub_err_t (*grub_loader_boot_func) (void *); -+static grub_err_t (*grub_loader_unload_func) (void *); -+static void *grub_loader_context; - static int grub_loader_flags; - -+struct grub_simple_loader_hooks -+{ -+ grub_err_t (*boot) (void); -+ grub_err_t (*unload) (void); -+}; -+ -+/* Don't heap allocate this to avoid making grub_loader_set fallible. */ -+static struct grub_simple_loader_hooks simple_loader_hooks; -+ - struct grub_preboot - { - grub_err_t (*preboot_func) (int); -@@ -44,6 +54,29 @@ static int grub_loader_loaded; - static struct grub_preboot *preboots_head = 0, - *preboots_tail = 0; - -+static grub_err_t -+grub_simple_boot_hook (void *context) -+{ -+ struct grub_simple_loader_hooks *hooks; -+ -+ hooks = (struct grub_simple_loader_hooks *) context; -+ return hooks->boot (); -+} -+ -+static grub_err_t -+grub_simple_unload_hook (void *context) -+{ -+ struct grub_simple_loader_hooks *hooks; -+ grub_err_t ret; -+ -+ hooks = (struct grub_simple_loader_hooks *) context; -+ -+ ret = hooks->unload (); -+ grub_memset (hooks, 0, sizeof (*hooks)); -+ -+ return ret; -+} -+ - int - grub_loader_is_loaded (void) - { -@@ -110,28 +143,45 @@ grub_loader_unregister_preboot_hook (struct grub_preboot *hnd) - } - - void --grub_loader_set (grub_err_t (*boot) (void), -- grub_err_t (*unload) (void), -- int flags) -+grub_loader_set_ex (grub_err_t (*boot) (void *), -+ grub_err_t (*unload) (void *), -+ void *context, -+ int flags) - { - if (grub_loader_loaded && grub_loader_unload_func) -- grub_loader_unload_func (); -+ grub_loader_unload_func (grub_loader_context); - - grub_loader_boot_func = boot; - grub_loader_unload_func = unload; -+ grub_loader_context = context; - grub_loader_flags = flags; - - grub_loader_loaded = 1; - } - -+void -+grub_loader_set (grub_err_t (*boot) (void), -+ grub_err_t (*unload) (void), -+ int flags) -+{ -+ grub_loader_set_ex (grub_simple_boot_hook, -+ grub_simple_unload_hook, -+ &simple_loader_hooks, -+ flags); -+ -+ simple_loader_hooks.boot = boot; -+ simple_loader_hooks.unload = unload; -+} -+ - void - grub_loader_unset(void) - { - if (grub_loader_loaded && grub_loader_unload_func) -- grub_loader_unload_func (); -+ grub_loader_unload_func (grub_loader_context); - - grub_loader_boot_func = 0; - grub_loader_unload_func = 0; -+ grub_loader_context = 0; - - grub_loader_loaded = 0; - } -@@ -158,7 +208,7 @@ grub_loader_boot (void) - return err; - } - } -- err = (grub_loader_boot_func) (); -+ err = (grub_loader_boot_func) (grub_loader_context); - - for (cur = preboots_tail; cur; cur = cur->prev) - if (! err) -diff --git a/include/grub/loader.h b/include/grub/loader.h -index b208642821..1846fa6c5f 100644 ---- a/include/grub/loader.h -+++ b/include/grub/loader.h -@@ -40,6 +40,11 @@ void EXPORT_FUNC (grub_loader_set) (grub_err_t (*boot) (void), - grub_err_t (*unload) (void), - int flags); - -+void EXPORT_FUNC (grub_loader_set_ex) (grub_err_t (*boot) (void *), -+ grub_err_t (*unload) (void *), -+ void *context, -+ int flags); -+ - /* Unset current loader, if any. */ - void EXPORT_FUNC (grub_loader_unset) (void); - diff --git a/0214-fix-i386_pc-on-legacycfg-module.patch b/0214-fix-i386_pc-on-legacycfg-module.patch new file mode 100644 index 0000000..9461a9f --- /dev/null +++ b/0214-fix-i386_pc-on-legacycfg-module.patch @@ -0,0 +1,21 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Leo Sandoval +Date: Tue, 2 Apr 2024 12:59:10 -0600 +Subject: [PATCH] fix i386_pc on legacycfg module + +--- + grub-core/Makefile.core.def | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def +index 3f6e944d6a5..b045aac7c91 100644 +--- a/grub-core/Makefile.core.def ++++ b/grub-core/Makefile.core.def +@@ -2459,6 +2459,7 @@ module = { + common = commands/legacycfg.c; + common = lib/legacy_parse.c; + emu = lib/i386/pc/vesa_modes_table.c; ++ i386_pc = lib/i386/pc/vesa_modes_table.c; + i386_efi = lib/i386/pc/vesa_modes_table.c; + x86_64_efi = lib/i386/pc/vesa_modes_table.c; + xen = lib/i386/pc/vesa_modes_table.c; diff --git a/0007-Add-secureboot-support-on-efi-chainloader.patch b/0215-Add-secureboot-support-on-efi-chainloader.patch similarity index 88% rename from 0007-Add-secureboot-support-on-efi-chainloader.patch rename to 0215-Add-secureboot-support-on-efi-chainloader.patch index 34ead63..2e993cb 100644 --- a/0007-Add-secureboot-support-on-efi-chainloader.patch +++ b/0215-Add-secureboot-support-on-efi-chainloader.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Raymund Will -Date: Mon, 8 Jul 2019 11:55:18 +0200 +Date: Tue, 2 Apr 2024 16:39:53 -0600 Subject: [PATCH] Add secureboot support on efi chainloader Expand the chainloader to be able to verify the image by means of shim @@ -180,103 +180,77 @@ supported yet. This patch might need a new revision once that's the case. Signed-off-by: David Abdurachmanov --- - grub-core/kern/efi/efi.c | 14 +- - grub-core/loader/arm64/linux.c | 4 +- - grub-core/loader/efi/chainloader.c | 820 +++++++++++++++++++++++++++++++++---- + grub-core/loader/efi/chainloader.c | 849 +++++++++++++++++++++++++++++++++---- grub-core/loader/efi/linux.c | 25 +- grub-core/loader/i386/efi/linux.c | 17 +- include/grub/efi/linux.h | 2 +- - include/grub/efi/pe32.h | 52 ++- - 7 files changed, 844 insertions(+), 90 deletions(-) + include/grub/efi/pe32.h | 51 ++- + 5 files changed, 848 insertions(+), 96 deletions(-) -diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 35b8f67060..4a2259aa1c 100644 ---- a/grub-core/kern/efi/efi.c -+++ b/grub-core/kern/efi/efi.c -@@ -296,14 +296,20 @@ grub_efi_secure_boot (void) - grub_efi_boolean_t ret = 0; - - secure_boot = grub_efi_get_variable("SecureBoot", &efi_var_guid, &datasize); -- - if (datasize != 1 || !secure_boot) -- goto out; -+ { -+ grub_dprintf ("secureboot", "No SecureBoot variable\n"); -+ goto out; -+ } -+ grub_dprintf ("secureboot", "SecureBoot: %d\n", *secure_boot); - - setup_mode = grub_efi_get_variable("SetupMode", &efi_var_guid, &datasize); -- - if (datasize != 1 || !setup_mode) -- goto out; -+ { -+ grub_dprintf ("secureboot", "No SetupMode variable\n"); -+ goto out; -+ } -+ grub_dprintf ("secureboot", "SetupMode: %d\n", *setup_mode); - - if (*secure_boot && !*setup_mode) - ret = 1; -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index a312c66868..04994d5c67 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -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); - -@@ -328,7 +329,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - - grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); - -- if (!grub_linuxefi_secure_validate (kernel_addr, kernel_size)) -+ 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; diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 2bd80f4db3..e6a8d4ad0e 100644 +index 2036924504b..e4ac39c87b4 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c -@@ -32,6 +32,8 @@ +@@ -32,6 +32,9 @@ #include #include #include +#include ++#include +#include + #include #include #include - #include -@@ -46,9 +48,14 @@ static grub_dl_t my_mod; +@@ -45,13 +48,24 @@ GRUB_MOD_LICENSE ("GPLv3+"); - static grub_efi_physical_address_t address; - static grub_efi_uintn_t pages; + static grub_dl_t my_mod; + ++static grub_efi_physical_address_t address; ++static grub_efi_uintn_t pages; +static grub_ssize_t fsize; - static grub_efi_device_path_t *file_path; - static grub_efi_handle_t image_handle; - static grub_efi_char16_t *cmdline; ++static grub_efi_device_path_t *file_path; ++static grub_efi_handle_t image_handle; ++static grub_efi_char16_t *cmdline; +static grub_ssize_t cmdline_len; +static grub_efi_handle_t dev_handle; + -+static grub_efi_status_t (*entry_point) (grub_efi_handle_t image_handle, grub_efi_system_table_t *system_table); - ++static grub_efi_status_t (__grub_efi_api *entry_point) (grub_efi_handle_t image_handle, grub_efi_system_table_t *system_table); ++ static grub_err_t - grub_chainloader_unload (void) -@@ -63,6 +70,7 @@ grub_chainloader_unload (void) - grub_free (cmdline); - cmdline = 0; - file_path = 0; -+ dev_handle = 0; + grub_chainloader_unload (void *context) + { +- grub_efi_handle_t image_handle = (grub_efi_handle_t) context; + grub_efi_loaded_image_t *loaded_image; + grub_efi_boot_services_t *b; - grub_dl_unref (my_mod); - return GRUB_ERR_NONE; -@@ -213,20 +221,694 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) ++ image_handle = (grub_efi_handle_t) context; + loaded_image = grub_efi_get_loaded_image (image_handle); + if (loaded_image != NULL) + grub_free (loaded_image->load_options); +@@ -66,12 +80,12 @@ grub_chainloader_unload (void *context) + static grub_err_t + grub_chainloader_boot (void *context) + { +- grub_efi_handle_t image_handle = (grub_efi_handle_t) context; + grub_efi_boot_services_t *b; + grub_efi_status_t status; + grub_efi_uintn_t exit_data_size; + grub_efi_char16_t *exit_data = NULL; + ++ image_handle = (grub_efi_handle_t) context; + b = grub_efi_system_table->boot_services; + status = b->start_image (image_handle, &exit_data_size, &exit_data); + if (status != GRUB_EFI_SUCCESS) +@@ -136,7 +150,7 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) + char *dir_start; + char *dir_end; + grub_size_t size; +- grub_efi_device_path_t *d, *file_path; ++ grub_efi_device_path_t *d; + + dir_start = grub_strchr (filename, ')'); + if (! dir_start) +@@ -209,24 +223,701 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) return file_path; } @@ -327,7 +301,7 @@ index 2bd80f4db3..e6a8d4ad0e 100644 +read_header (void *data, grub_efi_uint32_t size, + pe_coff_loader_image_context_t *context) +{ -+ grub_efi_guid_t guid = SHIM_LOCK_GUID; ++ grub_guid_t guid = SHIM_LOCK_GUID; + grub_efi_shim_lock_t *shim_lock; + grub_efi_status_t status; + @@ -640,8 +614,8 @@ index 2bd80f4db3..e6a8d4ad0e 100644 + grub_dprintf ("chain", "image size is %08"PRIxGRUB_UINT64_T", datasize is %08x\n", + context.image_size, datasize); + -+ efi_status = efi_call_3 (b->allocate_pool, GRUB_EFI_LOADER_DATA, -+ buffer_size, &buffer); ++ efi_status = b->allocate_pool (GRUB_EFI_LOADER_DATA, ++ buffer_size, (void**)&buffer); + + if (efi_status != GRUB_EFI_SUCCESS) + { @@ -868,19 +842,19 @@ index 2bd80f4db3..e6a8d4ad0e 100644 + } + + grub_dprintf ("chain", "booting via entry point\n"); -+ efi_status = efi_call_2 (entry_point, grub_efi_image_handle, -+ grub_efi_system_table); ++ efi_status = entry_point (grub_efi_image_handle, ++ grub_efi_system_table); + + grub_dprintf ("chain", "entry_point returned %ld\n", efi_status); + grub_memcpy (li, &li_bak, sizeof (grub_efi_loaded_image_t)); -+ efi_status = efi_call_1 (b->free_pool, buffer); ++ efi_status = b->free_pool (buffer); + + return 1; + +error_exit: + grub_dprintf ("chain", "error_exit: grub_errno: %d\n", grub_errno); + if (buffer) -+ efi_call_1 (b->free_pool, buffer); ++ b->free_pool (buffer); + + return 0; +} @@ -891,7 +865,7 @@ index 2bd80f4db3..e6a8d4ad0e 100644 + grub_efi_boot_services_t *b; + + b = grub_efi_system_table->boot_services; -+ efi_call_2 (b->free_pages, address, pages); ++ b->free_pages (address, pages); + grub_free (file_path); + grub_free (cmdline); + cmdline = 0; @@ -911,8 +885,8 @@ index 2bd80f4db3..e6a8d4ad0e 100644 + + b = grub_efi_system_table->boot_services; + -+ status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, file_path, -+ boot_image, fsize, &image_handle); ++ status = b->load_image (0, grub_efi_image_handle, file_path, ++ boot_image, fsize, &image_handle); + if (status != GRUB_EFI_SUCCESS) + { + if (status == GRUB_EFI_OUT_OF_RESOURCES) @@ -965,20 +939,28 @@ index 2bd80f4db3..e6a8d4ad0e 100644 grub_efi_status_t status; grub_efi_boot_services_t *b; grub_device_t dev = 0; - grub_efi_device_path_t *dp = 0; +- grub_efi_device_path_t *dp = NULL, *file_path = NULL; - grub_efi_loaded_image_t *loaded_image; ++ grub_efi_device_path_t *dp = NULL; char *filename; void *boot_image = 0; - grub_efi_handle_t dev_handle = 0; +- grub_efi_physical_address_t address = 0; +- grub_efi_uintn_t pages = 0; +- grub_efi_char16_t *cmdline = NULL; +- grub_efi_handle_t image_handle = NULL; + int rc; ++ ++ file_path = NULL; ++ address = 0; ++ pages = 0; ++ cmdline = NULL; ++ image_handle = NULL; ++ dev_handle = 0; if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -@@ -238,15 +920,45 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - address = 0; - image_handle = 0; - file_path = 0; -+ dev_handle = 0; +@@ -236,12 +927,42 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), b = grub_efi_system_table->boot_services; @@ -1007,6 +989,7 @@ index 2bd80f4db3..e6a8d4ad0e 100644 + } + *(--p16) = 0; + } ++ + file = grub_file_open (filename, GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE); if (! file) @@ -1019,16 +1002,18 @@ index 2bd80f4db3..e6a8d4ad0e 100644 + dev = grub_device_open (devname); + if (devname) + grub_free (devname); - if (! dev) - goto fail; - -@@ -283,17 +995,14 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - if (! file_path) - goto fail; - -- grub_printf ("file path: "); -- grub_efi_print_device_path (file_path); + if (dev == NULL) + ; + else if (dev->disk) +@@ -272,19 +993,16 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + file_path = make_file_path (dp, filename); + if (file_path == NULL) + goto fail; - +- grub_printf ("file path: "); +- grub_efi_print_device_path (file_path); + } + - size = grub_file_size (file); - if (!size) + fsize = grub_file_size (file); @@ -1038,12 +1023,12 @@ index 2bd80f4db3..e6a8d4ad0e 100644 filename); goto fail; } -- pages = (((grub_efi_uintn_t) size + ((1 << 12) - 1)) >> 12); -+ pages = (((grub_efi_uintn_t) fsize + ((1 << 12) - 1)) >> 12); +- pages = (grub_efi_uintn_t) GRUB_EFI_BYTES_TO_PAGES (size); ++ pages = (grub_efi_uintn_t) GRUB_EFI_BYTES_TO_PAGES (fsize); - status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ANY_PAGES, + status = b->allocate_pages (GRUB_EFI_ALLOCATE_ANY_PAGES, GRUB_EFI_LOADER_CODE, -@@ -307,7 +1016,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -298,7 +1016,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), } boot_image = (void *) ((grub_addr_t) address); @@ -1052,7 +1037,7 @@ index 2bd80f4db3..e6a8d4ad0e 100644 { if (grub_errno == GRUB_ERR_NONE) grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), -@@ -317,7 +1026,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -308,7 +1026,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), } #if defined (__i386__) || defined (__x86_64__) @@ -1061,7 +1046,7 @@ index 2bd80f4db3..e6a8d4ad0e 100644 { struct grub_macho_fat_header *head = boot_image; if (head->magic -@@ -326,6 +1035,14 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -317,6 +1035,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); @@ -1076,7 +1061,7 @@ index 2bd80f4db3..e6a8d4ad0e 100644 for (i = 0; i < grub_cpu_to_le32 (head->nfat_arch); i++) { if (GRUB_MACHO_CPUTYPE_IS_HOST_CURRENT (archs[i].cputype)) -@@ -340,79 +1057,39 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -331,83 +1057,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) @@ -1094,9 +1079,9 @@ index 2bd80f4db3..e6a8d4ad0e 100644 } #endif -- status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, file_path, -- boot_image, size, -- &image_handle); +- status = b->load_image (0, grub_efi_image_handle, file_path, +- boot_image, size, +- &image_handle); - if (status != GRUB_EFI_SUCCESS) + rc = grub_linuxefi_secure_validate((void *)(unsigned long)address, fsize); + grub_dprintf ("chain", "linuxefi_secure_validate: %d\n", rc); @@ -1127,6 +1112,7 @@ index 2bd80f4db3..e6a8d4ad0e 100644 - } - loaded_image->device_handle = dev_handle; - +- /* Build load options with arguments from chainloader command line. */ - if (argc > 1) - { - int i, len; @@ -1142,7 +1128,7 @@ index 2bd80f4db3..e6a8d4ad0e 100644 + 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); ++ grub_loader_set_ex (grub_chainloader_boot, grub_chainloader_unload, image_handle, 0); - for (i = 1; i < argc; i++) - { @@ -1164,30 +1150,33 @@ index 2bd80f4db3..e6a8d4ad0e 100644 - grub_file_close (file); - grub_device_close (dev); - -- grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); +- /* We're finished with the source image buffer and file path now. */ +- b->free_pages (address, pages); +- grub_free (file_path); +- +- grub_loader_set_ex (grub_chainloader_boot, grub_chainloader_unload, image_handle, 0); - return 0; - - fail: -- +fail: + if (dev) grub_device_close (dev); - -@@ -424,6 +1101,9 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -421,6 +1103,9 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), if (address) - efi_call_2 (b->free_pages, address, pages); + grub_efi_free_pages (address, pages); + if (cmdline) + grub_free (cmdline); + - grub_dl_unref (my_mod); + if (image_handle != NULL) + b->unload_image (image_handle); - return grub_errno; diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index c24202a5dd..c8ecce6dfd 100644 +index 925394d1767..0a7f8208022 100644 --- a/grub-core/loader/efi/linux.c +++ b/grub-core/loader/efi/linux.c -@@ -33,21 +33,34 @@ struct grub_efi_shim_lock +@@ -98,21 +98,36 @@ struct grub_efi_shim_lock }; typedef struct grub_efi_shim_lock grub_efi_shim_lock_t; @@ -1195,12 +1184,12 @@ index c24202a5dd..c8ecce6dfd 100644 +int grub_linuxefi_secure_validate (void *data, grub_uint32_t size) { - grub_efi_guid_t guid = SHIM_LOCK_GUID; + grub_guid_t guid = SHIM_LOCK_GUID; grub_efi_shim_lock_t *shim_lock; + grub_efi_status_t status; shim_lock = grub_efi_locate_protocol(&guid, NULL); -- + + grub_dprintf ("secureboot", "shim_lock: %p\n", shim_lock); if (!shim_lock) - return 1; @@ -1219,17 +1208,18 @@ index c24202a5dd..c8ecce6dfd 100644 + grub_dprintf ("secureboot", "Kernel signature verification passed\n"); + return 1; + } - -- return 0; ++ + grub_dprintf ("secureboot", "Kernel signature verification failed (0x%lx)\n", + (unsigned long) status); + + return -1; + +- return 0; } #pragma GCC diagnostic push diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index bb2616a809..6b24cbb948 100644 +index 9bfb4ab9e3e..b59d125286d 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -117,6 +117,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), @@ -1255,7 +1245,7 @@ index bb2616a809..6b24cbb948 100644 { - grub_error (GRUB_ERR_FILE_READ_ERROR, N_("Can't read kernel %s"), argv[0]); + grub_error (GRUB_ERR_FILE_READ_ERROR, N_("Can't read kernel %s"), -+ argv[0]); ++ argv[0]); goto fail; } @@ -1264,7 +1254,7 @@ index bb2616a809..6b24cbb948 100644 + if (rc < 0) { grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), - argv[0]); + argv[0]); @@ -203,6 +208,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } @@ -1279,7 +1269,7 @@ index bb2616a809..6b24cbb948 100644 } + grub_dprintf ("linux", "linux_cmdline = %lx\n", -+ (unsigned long)linux_cmdline); ++ (unsigned long)linux_cmdline); + grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE)); grub_create_loader_cmdline (argc, argv, @@ -1289,7 +1279,7 @@ index bb2616a809..6b24cbb948 100644 params->type_of_loader = 0x21; + grub_dprintf("linux", "kernel_mem: %p handover_offset: %08x\n", -+ kernel_mem, handover_offset); ++ kernel_mem, handover_offset); fail: - @@ -1297,7 +1287,7 @@ index bb2616a809..6b24cbb948 100644 grub_file_close (file); diff --git a/include/grub/efi/linux.h b/include/grub/efi/linux.h -index d9ede36773..0033d9305a 100644 +index d224daafa4f..b2cfd8c1f44 100644 --- a/include/grub/efi/linux.h +++ b/include/grub/efi/linux.h @@ -22,7 +22,7 @@ @@ -1310,10 +1300,10 @@ index d9ede36773..0033d9305a 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 0ed8781f03..a43adf2746 100644 +index 9887e14b278..a39743396dc 100644 --- a/include/grub/efi/pe32.h +++ b/include/grub/efi/pe32.h -@@ -223,7 +223,11 @@ struct grub_pe64_optional_header +@@ -238,7 +238,11 @@ struct grub_pe64_optional_header struct grub_pe32_section_table { char name[8]; @@ -1326,7 +1316,7 @@ index 0ed8781f03..a43adf2746 100644 grub_uint32_t virtual_address; grub_uint32_t raw_data_size; grub_uint32_t raw_data_offset; -@@ -234,12 +238,18 @@ struct grub_pe32_section_table +@@ -249,12 +253,18 @@ struct grub_pe32_section_table grub_uint32_t characteristics; }; @@ -1349,7 +1339,7 @@ index 0ed8781f03..a43adf2746 100644 #define GRUB_PE32_SCN_ALIGN_1BYTES 0x00100000 #define GRUB_PE32_SCN_ALIGN_2BYTES 0x00200000 -@@ -248,10 +258,28 @@ struct grub_pe32_section_table +@@ -263,10 +273,26 @@ 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 @@ -1372,13 +1362,11 @@ index 0ed8781f03..a43adf2746 100644 +#define GRUB_PE32_SCN_MEM_EXECUTE 0x20000000 +#define GRUB_PE32_SCN_MEM_READ 0x40000000 +#define GRUB_PE32_SCN_MEM_WRITE 0x80000000 -+ -+ + #define GRUB_PE32_SIGNATURE_SIZE 4 - struct grub_pe32_header -@@ -274,6 +302,20 @@ struct grub_pe32_header + #if GRUB_TARGET_SIZEOF_VOID_P == 8 +@@ -292,6 +318,21 @@ struct grub_pe_image_header #endif }; @@ -1395,6 +1383,7 @@ index 0ed8781f03..a43adf2746 100644 + struct grub_pe32_coff_header coff_header; + struct grub_pe64_optional_header optional_header; +}; ++ + struct grub_pe32_fixup_block { diff --git a/0008-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch b/0216-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch similarity index 66% rename from 0008-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch rename to 0216-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch index 487d5c0..8313e06 100644 --- a/0008-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch +++ b/0216-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Tue, 6 Oct 2015 16:09:25 -0400 +Date: Tue, 13 Feb 2024 16:30:24 -0600 Subject: [PATCH] Make any of the loaders that link in efi mode honor secure boot. @@ -9,30 +9,27 @@ won't register commands if SB is enabled." Signed-off-by: Peter Jones --- - grub-core/commands/iorw.c | 7 +++++++ - grub-core/commands/memrw.c | 7 +++++++ - grub-core/kern/dl.c | 3 ++- - grub-core/kern/efi/efi.c | 34 ---------------------------------- - grub-core/loader/efi/appleloader.c | 7 +++++++ - grub-core/loader/efi/chainloader.c | 1 + - grub-core/loader/i386/bsd.c | 7 +++++++ - grub-core/loader/i386/linux.c | 7 +++++++ - grub-core/loader/i386/pc/linux.c | 7 +++++++ - grub-core/loader/multiboot.c | 7 +++++++ - grub-core/loader/xnu.c | 7 +++++++ - include/grub/efi/efi.h | 1 - - include/grub/ia64/linux.h | 0 - include/grub/mips/linux.h | 0 - include/grub/powerpc/linux.h | 0 - include/grub/sparc64/linux.h | 0 - 16 files changed, 59 insertions(+), 36 deletions(-) + grub-core/commands/iorw.c | 7 +++++++ + grub-core/commands/memrw.c | 7 +++++++ + grub-core/kern/dl.c | 4 ++-- + grub-core/loader/efi/appleloader.c | 7 +++++++ + grub-core/loader/i386/bsd.c | 7 +++++++ + grub-core/loader/i386/linux.c | 7 +++++++ + grub-core/loader/i386/pc/linux.c | 7 +++++++ + grub-core/loader/multiboot.c | 7 +++++++ + grub-core/loader/xnu.c | 7 +++++++ + include/grub/ia64/linux.h | 0 + include/grub/mips/linux.h | 0 + include/grub/powerpc/linux.h | 0 + include/grub/sparc64/linux.h | 0 + 13 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 include/grub/ia64/linux.h create mode 100644 include/grub/mips/linux.h create mode 100644 include/grub/powerpc/linux.h create mode 100644 include/grub/sparc64/linux.h diff --git a/grub-core/commands/iorw.c b/grub-core/commands/iorw.c -index 584baec8f9..7b2999b14b 100644 +index 584baec8f91..7b2999b14b5 100644 --- a/grub-core/commands/iorw.c +++ b/grub-core/commands/iorw.c @@ -24,6 +24,7 @@ @@ -64,7 +61,7 @@ index 584baec8f9..7b2999b14b 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 d401a6db0e..39cf3a06db 100644 +index d401a6db0ef..39cf3a06dbd 100644 --- a/grub-core/commands/memrw.c +++ b/grub-core/commands/memrw.c @@ -23,6 +23,7 @@ @@ -96,73 +93,27 @@ index d401a6db0e..39cf3a06db 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 b714937095..7afb9e6f72 100644 +index d48d4131ba7..2a9ae9fc894 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c -@@ -32,6 +32,7 @@ - #include - #include - #include -+#include - - /* Platforms where modules are in a readonly area of memory. */ - #if defined(GRUB_MACHINE_QEMU) -@@ -704,7 +705,7 @@ grub_dl_load_file (const char *filename) +@@ -871,13 +871,13 @@ grub_dl_load_file (const char *filename) grub_dl_t mod = 0; #ifdef GRUB_MACHINE_EFI -- if (grub_efi_secure_boot ()) +- if (grub_efi_get_secureboot ()) + if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) { #if 0 /* This is an error, but grub2-mkconfig still generates a pile of -diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c -index 4a2259aa1c..8cff7be028 100644 ---- a/grub-core/kern/efi/efi.c -+++ b/grub-core/kern/efi/efi.c -@@ -286,40 +286,6 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, - return grub_efi_get_variable_with_attributes (var, guid, datasize_out, data_out, NULL); - } - --grub_efi_boolean_t --grub_efi_secure_boot (void) --{ -- grub_efi_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID; -- grub_size_t datasize; -- char *secure_boot = NULL; -- char *setup_mode = NULL; -- grub_efi_boolean_t ret = 0; -- -- secure_boot = grub_efi_get_variable("SecureBoot", &efi_var_guid, &datasize); -- if (datasize != 1 || !secure_boot) -- { -- grub_dprintf ("secureboot", "No SecureBoot variable\n"); -- goto out; -- } -- grub_dprintf ("secureboot", "SecureBoot: %d\n", *secure_boot); -- -- setup_mode = grub_efi_get_variable("SetupMode", &efi_var_guid, &datasize); -- if (datasize != 1 || !setup_mode) -- { -- grub_dprintf ("secureboot", "No SetupMode variable\n"); -- goto out; -- } -- grub_dprintf ("secureboot", "SetupMode: %d\n", *setup_mode); -- -- if (*secure_boot && !*setup_mode) -- ret = 1; -- -- out: -- grub_free (secure_boot); -- grub_free (setup_mode); -- return ret; --} -- - #pragma GCC diagnostic ignored "-Wcast-align" - - /* Search the mods section from the PE32/PE32+ image. This code uses + * insmod commands, so emitting it would be mostly just obnoxious. */ + grub_error (GRUB_ERR_ACCESS_DENIED, +- "Secure Boot forbids loading module from %s", filename); ++ "Secure Boot forbids loading module from %s", filename); + #endif + return 0; + } diff --git a/grub-core/loader/efi/appleloader.c b/grub-core/loader/efi/appleloader.c -index 74888c463b..585f2b5738 100644 +index a0b61a240b7..35d53c5f85d 100644 --- a/grub-core/loader/efi/appleloader.c +++ b/grub-core/loader/efi/appleloader.c @@ -24,6 +24,7 @@ @@ -192,20 +143,8 @@ index 74888c463b..585f2b5738 100644 + grub_unregister_command (cmd); } -diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index e6a8d4ad0e..07c4937898 100644 ---- a/grub-core/loader/efi/chainloader.c -+++ b/grub-core/loader/efi/chainloader.c -@@ -34,6 +34,7 @@ - #include - #include - #include -+#include - #include - #include - #include diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c -index 5f3290ce17..54befc2662 100644 +index 1f9128f6f20..8075ac9b06a 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -40,6 +40,7 @@ @@ -237,7 +176,7 @@ index 5f3290ce17..54befc2662 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 dccf3bb300..4aeb0e4b9a 100644 +index 10f967f2563..5a257552234 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -37,6 +37,7 @@ @@ -248,7 +187,7 @@ index dccf3bb300..4aeb0e4b9a 100644 GRUB_MOD_LICENSE ("GPLv3+"); -@@ -1138,6 +1139,9 @@ static grub_command_t cmd_linux, cmd_initrd; +@@ -1164,6 +1165,9 @@ static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT(linux) { @@ -258,7 +197,7 @@ index dccf3bb300..4aeb0e4b9a 100644 cmd_linux = grub_register_command ("linux", grub_cmd_linux, 0, N_("Load Linux.")); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, -@@ -1147,6 +1151,9 @@ GRUB_MOD_INIT(linux) +@@ -1173,6 +1177,9 @@ GRUB_MOD_INIT(linux) GRUB_MOD_FINI(linux) { @@ -269,7 +208,7 @@ index dccf3bb300..4aeb0e4b9a 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 4b1750e360..e3fa1221e8 100644 +index 8593d74737f..54a76504a79 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -36,6 +36,7 @@ @@ -301,7 +240,7 @@ index 4b1750e360..e3fa1221e8 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 facb13f3d3..47e481f457 100644 +index 94be512c4d0..94c112a29d4 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -50,6 +50,7 @@ @@ -333,7 +272,7 @@ index facb13f3d3..47e481f457 100644 grub_unregister_command (cmd_module); } diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c -index 1c0cf6a430..baa54e652a 100644 +index 4cca55df92d..f76f511ac2d 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -35,6 +35,7 @@ @@ -364,27 +303,15 @@ index 1c0cf6a430..baa54e652a 100644 #ifndef GRUB_MACHINE_EMU grub_unregister_command (cmd_resume); #endif -diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 6295df85f3..585fa6662b 100644 ---- a/include/grub/efi/efi.h -+++ b/include/grub/efi/efi.h -@@ -91,7 +91,6 @@ EXPORT_FUNC (grub_efi_set_variable) (const char *var, - const grub_efi_guid_t *guid, - void *data, - grub_size_t datasize); --grub_efi_boolean_t EXPORT_FUNC (grub_efi_secure_boot) (void); - int - EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1, - const grub_efi_device_path_t *dp2); diff --git a/include/grub/ia64/linux.h b/include/grub/ia64/linux.h new file mode 100644 -index 0000000000..e69de29bb2 +index 00000000000..e69de29bb2d diff --git a/include/grub/mips/linux.h b/include/grub/mips/linux.h new file mode 100644 -index 0000000000..e69de29bb2 +index 00000000000..e69de29bb2d diff --git a/include/grub/powerpc/linux.h b/include/grub/powerpc/linux.h new file mode 100644 -index 0000000000..e69de29bb2 +index 00000000000..e69de29bb2d diff --git a/include/grub/sparc64/linux.h b/include/grub/sparc64/linux.h new file mode 100644 -index 0000000000..e69de29bb2 +index 00000000000..e69de29bb2d diff --git a/0030-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch b/0217-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch similarity index 93% rename from 0030-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch rename to 0217-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch index f4d83da..428737c 100644 --- a/0030-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch +++ b/0217-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch @@ -10,10 +10,10 @@ 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 301d1ac229..0f6505bf3b 100644 +index c2e107b41ab..4eadcba4b85 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in -@@ -253,6 +253,14 @@ version_test_gt () +@@ -299,6 +299,14 @@ version_test_gt () *.old:*.old) ;; *.old:*) version_test_gt_a="`echo "$version_test_gt_a" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=gt ;; *:*.old) version_test_gt_b="`echo "$version_test_gt_b" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=ge ;; diff --git a/0065-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch b/0218-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch similarity index 79% rename from 0065-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch rename to 0218-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch index 7658e9b..c0f1707 100644 --- a/0065-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch +++ b/0218-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch @@ -13,10 +13,10 @@ 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 a432a6be54..9a2fae6398 100644 +index 96ab7c96b52..98700423d79 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c -@@ -191,6 +191,24 @@ grub_real_dprintf (const char *file, const int line, const char *condition, +@@ -280,6 +280,24 @@ grub_real_dprintf (const char *file, const int line, const char *condition, } } @@ -42,13 +42,13 @@ index a432a6be54..9a2fae6398 100644 int diff --git a/include/grub/misc.h b/include/grub/misc.h -index fd18e6320b..3adc4036e3 100644 +index 3e9a00f0a9c..db517acd592 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h -@@ -345,6 +345,8 @@ void EXPORT_FUNC(grub_real_dprintf) (const char *file, - const int line, - const char *condition, +@@ -386,6 +386,8 @@ void EXPORT_FUNC(grub_real_dprintf) (const char *file, const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 4, 5))); + int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))); + int EXPORT_FUNC(grub_printf_) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))); +void EXPORT_FUNC(grub_qdprintf) (const char *condition, + const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 2, 3))); int EXPORT_FUNC(grub_vprintf) (const char *fmt, va_list args); diff --git a/0219-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch b/0219-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch new file mode 100644 index 0000000..c7d42e4 --- /dev/null +++ b/0219-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch @@ -0,0 +1,83 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 4 Apr 2024 11:57:54 -0600 +Subject: [PATCH] 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 +sections of grub-core/kernel.exec and any modules it loads. + +Specifically, it displays them in the gdb "add-symbol-file" syntax, with +the presumption that there's a variable $grubdir that reflects the path +to any such binaries. + +Signed-off-by: Peter Jones +--- + grub-core/kern/dl.c | 34 ++++++++++++++++++++++++++++++++++ + grub-core/kern/efi/init.c | 1 + + 2 files changed, 35 insertions(+) + +diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c +index 2a9ae9fc894..2eaef7150ed 100644 +--- a/grub-core/kern/dl.c ++++ b/grub-core/kern/dl.c +@@ -690,6 +690,38 @@ grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr) + return GRUB_ERR_NONE; + } + ++static void ++grub_dl_print_gdb_info (grub_dl_t mod, Elf_Ehdr *e) ++{ ++ void *text, *data = NULL; ++ long idx; ++ ++ idx = grub_dl_find_section_index (e, ".text"); ++ if (idx < 0) ++ return; ++ ++ text = grub_dl_get_section_addr (mod, idx); ++ if (!text) ++ return; ++ ++ idx = grub_dl_find_section_index (e, ".data"); ++ if (idx >= 0) ++ data = grub_dl_get_section_addr (mod, idx); ++ ++ if (data) ++ grub_qdprintf ("gdb", "add-symbol-file \\\n" ++ "/usr/lib/debug/usr/lib/grub/%s-%s/%s.debug " ++ "\\\n %p -s .data %p\n", ++ GRUB_TARGET_CPU, GRUB_PLATFORM, ++ mod->name, text, data); ++ else ++ grub_qdprintf ("gdb", "add-symbol-file \\\n" ++ "/usr/lib/debug/usr/lib/grub/%s-%s/%s.debug " ++ "\\\n%p\n", ++ GRUB_TARGET_CPU, GRUB_PLATFORM, ++ mod->name, text); ++} ++ + static grub_err_t + grub_dl_set_mem_attrs (grub_dl_t mod, void *ehdr) + { +@@ -833,6 +865,8 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size) + grub_dprintf ("modules", "module name: %s\n", mod->name); + grub_dprintf ("modules", "init function: %p\n", mod->init); + ++ grub_dl_print_gdb_info (mod, e); ++ + if (grub_dl_add (mod)) + { + grub_dl_unload (mod); +diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c +index dee3918fd35..d35d6974734 100644 +--- a/grub-core/kern/efi/init.c ++++ b/grub-core/kern/efi/init.c +@@ -157,6 +157,7 @@ grub_efi_init (void) + grub_efi_system_table->boot_services->set_watchdog_timer (0, 0, 0, NULL); + + grub_efi_env_init (); ++ grub_efi_print_gdb_info (); + grub_efidisk_init (); + + grub_efi_register_debug_commands (); diff --git a/0219-kern-efi-sb-Reject-non-kernel-files-in-the-shim_lock.patch b/0219-kern-efi-sb-Reject-non-kernel-files-in-the-shim_lock.patch deleted file mode 100644 index 715e6e1..0000000 --- a/0219-kern-efi-sb-Reject-non-kernel-files-in-the-shim_lock.patch +++ /dev/null @@ -1,101 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Julian Andres Klode -Date: Thu, 2 Dec 2021 15:03:53 +0100 -Subject: [PATCH] kern/efi/sb: Reject non-kernel files in the shim_lock - verifier - -We must not allow other verifiers to pass things like the GRUB modules. -Instead of maintaining a blocklist, maintain an allowlist of things -that we do not care about. - -This allowlist really should be made reusable, and shared by the -lockdown verifier, but this is the minimal patch addressing -security concerns where the TPM verifier was able to mark modules -as verified (or the OpenPGP verifier for that matter), when it -should not do so on shim-powered secure boot systems. - -Fixes: CVE-2022-28735 - -Signed-off-by: Julian Andres Klode -Reviewed-by: Daniel Kiper -(cherry picked from commit fa61ad69861c1cb3f68bf853d78fae7fd93986a0) ---- - grub-core/kern/efi/sb.c | 39 ++++++++++++++++++++++++++++++++++++--- - include/grub/verify.h | 1 + - 2 files changed, 37 insertions(+), 3 deletions(-) - -diff --git a/grub-core/kern/efi/sb.c b/grub-core/kern/efi/sb.c -index c52ec6226a..89c4bb3fd1 100644 ---- a/grub-core/kern/efi/sb.c -+++ b/grub-core/kern/efi/sb.c -@@ -119,10 +119,11 @@ shim_lock_verifier_init (grub_file_t io __attribute__ ((unused)), - void **context __attribute__ ((unused)), - enum grub_verify_flags *flags) - { -- *flags = GRUB_VERIFY_FLAGS_SKIP_VERIFICATION; -+ *flags = GRUB_VERIFY_FLAGS_NONE; - - switch (type & GRUB_FILE_TYPE_MASK) - { -+ /* Files we check. */ - case GRUB_FILE_TYPE_LINUX_KERNEL: - case GRUB_FILE_TYPE_MULTIBOOT_KERNEL: - case GRUB_FILE_TYPE_BSD_KERNEL: -@@ -130,11 +131,43 @@ shim_lock_verifier_init (grub_file_t io __attribute__ ((unused)), - case GRUB_FILE_TYPE_PLAN9_KERNEL: - case GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE: - *flags = GRUB_VERIFY_FLAGS_SINGLE_CHUNK; -+ return GRUB_ERR_NONE; - -- /* Fall through. */ -+ /* Files that do not affect secureboot state. */ -+ case GRUB_FILE_TYPE_NONE: -+ case GRUB_FILE_TYPE_LOOPBACK: -+ case GRUB_FILE_TYPE_LINUX_INITRD: -+ case GRUB_FILE_TYPE_OPENBSD_RAMDISK: -+ case GRUB_FILE_TYPE_XNU_RAMDISK: -+ case GRUB_FILE_TYPE_SIGNATURE: -+ case GRUB_FILE_TYPE_PUBLIC_KEY: -+ case GRUB_FILE_TYPE_PUBLIC_KEY_TRUST: -+ case GRUB_FILE_TYPE_PRINT_BLOCKLIST: -+ case GRUB_FILE_TYPE_TESTLOAD: -+ case GRUB_FILE_TYPE_GET_SIZE: -+ case GRUB_FILE_TYPE_FONT: -+ case GRUB_FILE_TYPE_ZFS_ENCRYPTION_KEY: -+ case GRUB_FILE_TYPE_CAT: -+ case GRUB_FILE_TYPE_HEXCAT: -+ case GRUB_FILE_TYPE_CMP: -+ case GRUB_FILE_TYPE_HASHLIST: -+ case GRUB_FILE_TYPE_TO_HASH: -+ case GRUB_FILE_TYPE_KEYBOARD_LAYOUT: -+ case GRUB_FILE_TYPE_PIXMAP: -+ case GRUB_FILE_TYPE_GRUB_MODULE_LIST: -+ case GRUB_FILE_TYPE_CONFIG: -+ case GRUB_FILE_TYPE_THEME: -+ case GRUB_FILE_TYPE_GETTEXT_CATALOG: -+ case GRUB_FILE_TYPE_FS_SEARCH: -+ case GRUB_FILE_TYPE_LOADENV: -+ case GRUB_FILE_TYPE_SAVEENV: -+ case GRUB_FILE_TYPE_VERIFY_SIGNATURE: -+ *flags = GRUB_VERIFY_FLAGS_SKIP_VERIFICATION; -+ return GRUB_ERR_NONE; - -+ /* Other files. */ - default: -- return GRUB_ERR_NONE; -+ return grub_error (GRUB_ERR_ACCESS_DENIED, N_("prohibited by secure boot policy")); - } - } - -diff --git a/include/grub/verify.h b/include/grub/verify.h -index cd129c398f..672ae16924 100644 ---- a/include/grub/verify.h -+++ b/include/grub/verify.h -@@ -24,6 +24,7 @@ - - enum grub_verify_flags - { -+ GRUB_VERIFY_FLAGS_NONE = 0, - GRUB_VERIFY_FLAGS_SKIP_VERIFICATION = 1, - GRUB_VERIFY_FLAGS_SINGLE_CHUNK = 2, - /* Defer verification to another authority. */ diff --git a/0009-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch b/0220-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch similarity index 84% rename from 0009-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch rename to 0220-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch index 452f43c..0284cc6 100644 --- a/0009-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch +++ b/0220-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch @@ -7,40 +7,40 @@ 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 ++++++++++++++++++++++++++------------ - include/grub/i386/linux.h | 7 ++- - 3 files changed, 89 insertions(+), 37 deletions(-) + grub-core/loader/efi/linux.c | 9 ++- + grub-core/loader/i386/efi/linux.c | 116 ++++++++++++++++++++++++++------------ + include/grub/i386/linux.h | 5 ++ + 3 files changed, 91 insertions(+), 39 deletions(-) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index c8ecce6dfd..0622dfa48d 100644 +index 0a7f8208022..742e8e9af35 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) +@@ -136,12 +136,17 @@ grub_linuxefi_secure_validate (void *data, grub_uint32_t size) typedef void (*handover_func) (void *, grub_efi_system_table_t *, void *); grub_err_t --grub_efi_linux_boot (void *kernel_addr, grub_off_t offset, -+grub_efi_linux_boot (void *kernel_addr, grub_off_t handover_offset, +-grub_efi_linux_boot (void *kernel_address, grub_off_t offset, ++grub_efi_linux_boot (void *kernel_address, grub_off_t handover_offset, void *kernel_params) { handover_func hf; + int offset = 0; -- hf = (handover_func)((char *)kernel_addr + offset); +- hf = (handover_func)((char *)kernel_address + offset); +#ifdef __x86_64__ + offset = 512; +#endif + -+ hf = (handover_func)((char *)kernel_addr + handover_offset + offset); ++ hf = (handover_func)((char *)kernel_address + handover_offset + offset); hf (grub_efi_image_handle, grub_efi_system_table, kernel_params); return GRUB_ERR_BUG; diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 6b24cbb948..3017d0f3e5 100644 +index b59d125286d..3c2e30f8751 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; +@@ -44,15 +44,11 @@ static char *linux_cmdline; static grub_err_t grub_linuxefi_boot (void) { @@ -52,11 +52,13 @@ index 6b24cbb948..3017d0f3e5 100644 asm volatile ("cli"); - return grub_efi_linux_boot ((char *)kernel_mem, handover_offset + offset, +- params); + return grub_efi_linux_boot ((char *)kernel_mem, + handover_offset, - params); ++ params); } + static grub_err_t @@ -153,14 +149,20 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), return grub_errno; } @@ -68,7 +70,7 @@ index 6b24cbb948..3017d0f3e5 100644 + static grub_err_t grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) + int argc, char *argv[]) { grub_file_t file = 0; - struct linux_i386_kernel_header lh; @@ -166,7 +168,7 @@ index 6b24cbb948..3017d0f3e5 100644 + grub_dprintf ("linux", "setting up cmdline\n"); linux_cmdline = grub_efi_allocate_pages_max(0x3fffffff, -- BYTES_TO_PAGES(lh.cmdline_size + 1)); +- BYTES_TO_PAGES(lh.cmdline_size + 1)); - + BYTES_TO_PAGES(lh->cmdline_size + 1)); if (!linux_cmdline) @@ -176,9 +178,10 @@ index 6b24cbb948..3017d0f3e5 100644 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->cmdline_size - (sizeof (LINUX_IMAGE) - 1), - GRUB_VERIFY_KERNEL_CMDLINE); ++ GRUB_VERIFY_KERNEL_CMDLINE); - lh.cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline; + grub_dprintf ("linux", "cmdline:%s\n", linux_cmdline); @@ -194,13 +197,13 @@ index 6b24cbb948..3017d0f3e5 100644 + start = (lh->setup_sects + 1) * 512; - kernel_mem = grub_efi_allocate_pages_max(lh.pref_address, -- BYTES_TO_PAGES(lh.init_size)); +- BYTES_TO_PAGES(lh.init_size)); + 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(0x3fffffff, -- BYTES_TO_PAGES(lh.init_size)); +- BYTES_TO_PAGES(lh.init_size)); + BYTES_TO_PAGES(lh->init_size)); if (!kernel_mem) @@ -229,7 +232,7 @@ index 6b24cbb948..3017d0f3e5 100644 + params->ext_loader_type = 0; + params->ext_loader_ver = 2; grub_dprintf("linux", "kernel_mem: %p handover_offset: %08x\n", - kernel_mem, handover_offset); + kernel_mem, handover_offset); @@ -301,10 +343,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), loaded = 0; @@ -238,27 +241,26 @@ index 6b24cbb948..3017d0f3e5 100644 - if (linux_cmdline && !loaded) + 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)); +- linux_cmdline, +- BYTES_TO_PAGES(lh.cmdline_size + 1)); ++ 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, diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h -index eddf9251d9..25ef52c04e 100644 +index d4b55086953..4ccd9d7d9f2 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h -@@ -138,7 +138,12 @@ struct linux_i386_kernel_header +@@ -148,6 +148,11 @@ struct linux_i386_kernel_header grub_uint32_t kernel_alignment; grub_uint8_t relocatable; grub_uint8_t min_alignment; -- grub_uint8_t pad[2]; +#define LINUX_XLF_KERNEL_64 (1<<0) +#define LINUX_XLF_CAN_BE_LOADED_ABOVE_4G (1<<1) +#define LINUX_XLF_EFI_HANDOVER_32 (1<<2) +#define LINUX_XLF_EFI_HANDOVER_64 (1<<3) +#define LINUX_XLF_EFI_KEXEC (1<<4) -+ grub_uint16_t xloadflags; + grub_uint16_t xloadflags; grub_uint32_t cmdline_size; grub_uint32_t hardware_subarch; - grub_uint64_t hardware_subarch_data; diff --git a/0220-kern-file-Do-not-leak-device_name-on-error-in-grub_f.patch b/0220-kern-file-Do-not-leak-device_name-on-error-in-grub_f.patch deleted file mode 100644 index 59f9471..0000000 --- a/0220-kern-file-Do-not-leak-device_name-on-error-in-grub_f.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Fri, 25 Jun 2021 02:19:05 +1000 -Subject: [PATCH] kern/file: Do not leak device_name on error in - grub_file_open() - -If we have an error in grub_file_open() before we free device_name, we -will leak it. - -Free device_name in the error path and null out the pointer in the good -path once we free it there. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 1499a5068839fa37cb77ecef4b5bdacbd1ed12ea) ---- - grub-core/kern/file.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c -index ec10e54fc0..db938e099d 100644 ---- a/grub-core/kern/file.c -+++ b/grub-core/kern/file.c -@@ -84,6 +84,7 @@ grub_file_open (const char *name, enum grub_file_type type) - - device = grub_device_open (device_name); - grub_free (device_name); -+ device_name = NULL; - if (! device) - goto fail; - -@@ -138,6 +139,7 @@ grub_file_open (const char *name, enum grub_file_type type) - return file; - - fail: -+ grub_free (device_name); - if (device) - grub_device_close (device); - diff --git a/0098-Try-to-pick-better-locations-for-kernel-and-initrd.patch b/0221-Try-to-pick-better-locations-for-kernel-and-initrd.patch similarity index 94% rename from 0098-Try-to-pick-better-locations-for-kernel-and-initrd.patch rename to 0221-Try-to-pick-better-locations-for-kernel-and-initrd.patch index 4f42ea5..2927f4b 100644 --- a/0098-Try-to-pick-better-locations-for-kernel-and-initrd.patch +++ b/0221-Try-to-pick-better-locations-for-kernel-and-initrd.patch @@ -38,10 +38,10 @@ Signed-off-by: Robbie Harwood 8 files changed, 29 insertions(+), 12 deletions(-) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index 85ad4b4494..e84961d078 100644 +index fb9dbf52528..8f75205a732 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, +@@ -121,7 +121,7 @@ grub_efi_allocate_pages_max (grub_efi_physical_address_t max, grub_efi_boot_services_t *b; grub_efi_physical_address_t address = max; @@ -50,7 +50,7 @@ index 85ad4b4494..e84961d078 100644 return 0; b = grub_efi_system_table->boot_services; -@@ -480,7 +480,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, +@@ -477,7 +477,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, { if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY #if 1 @@ -59,7 +59,7 @@ index 85ad4b4494..e84961d078 100644 #endif && desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000 && desc->num_pages != 0) -@@ -498,9 +498,9 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, +@@ -495,9 +495,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 @@ -72,7 +72,7 @@ index 85ad4b4494..e84961d078 100644 #endif diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 3017d0f3e5..33e981e76e 100644 +index 3c2e30f8751..9e5dca9458a 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -27,6 +27,7 @@ @@ -138,7 +138,7 @@ index 3017d0f3e5..33e981e76e 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 2c64918e3f..a4c2ec8350 100644 +index 2c64918e3f7..a4c2ec83502 100644 --- a/include/grub/arm/efi/memory.h +++ b/include/grub/arm/efi/memory.h @@ -2,5 +2,6 @@ @@ -149,7 +149,7 @@ index 2c64918e3f..a4c2ec8350 100644 #endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/arm64/efi/memory.h b/include/grub/arm64/efi/memory.h -index c6cb324171..acb61dca44 100644 +index c6cb3241714..acb61dca44b 100644 --- a/include/grub/arm64/efi/memory.h +++ b/include/grub/arm64/efi/memory.h @@ -2,5 +2,6 @@ @@ -160,7 +160,7 @@ index c6cb324171..acb61dca44 100644 #endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/i386/efi/memory.h b/include/grub/i386/efi/memory.h -index 2c64918e3f..a4c2ec8350 100644 +index 2c64918e3f7..a4c2ec83502 100644 --- a/include/grub/i386/efi/memory.h +++ b/include/grub/i386/efi/memory.h @@ -2,5 +2,6 @@ @@ -171,7 +171,7 @@ index 2c64918e3f..a4c2ec8350 100644 #endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/ia64/efi/memory.h b/include/grub/ia64/efi/memory.h -index 2c64918e3f..a4c2ec8350 100644 +index 2c64918e3f7..a4c2ec83502 100644 --- a/include/grub/ia64/efi/memory.h +++ b/include/grub/ia64/efi/memory.h @@ -2,5 +2,6 @@ @@ -182,7 +182,7 @@ index 2c64918e3f..a4c2ec8350 100644 #endif /* ! GRUB_MEMORY_CPU_HEADER */ diff --git a/include/grub/riscv64/efi/memory.h b/include/grub/riscv64/efi/memory.h -index c6cb324171..acb61dca44 100644 +index c6cb3241714..acb61dca44b 100644 --- a/include/grub/riscv64/efi/memory.h +++ b/include/grub/riscv64/efi/memory.h @@ -2,5 +2,6 @@ @@ -193,7 +193,7 @@ index c6cb324171..acb61dca44 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 46e9145a30..e81cfb3221 100644 +index 46e9145a308..e81cfb32213 100644 --- a/include/grub/x86_64/efi/memory.h +++ b/include/grub/x86_64/efi/memory.h @@ -2,9 +2,11 @@ diff --git a/0221-video-readers-png-Abort-sooner-if-a-read-operation-f.patch b/0221-video-readers-png-Abort-sooner-if-a-read-operation-f.patch deleted file mode 100644 index 385d3ed..0000000 --- a/0221-video-readers-png-Abort-sooner-if-a-read-operation-f.patch +++ /dev/null @@ -1,198 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Tue, 6 Jul 2021 14:02:55 +1000 -Subject: [PATCH] video/readers/png: Abort sooner if a read operation fails - -Fuzzing revealed some inputs that were taking a long time, potentially -forever, because they did not bail quickly upon encountering an I/O error. - -Try to catch I/O errors sooner and bail out. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 882be97d1df6449b9fd4d593f0cb70005fde3494) ---- - grub-core/video/readers/png.c | 55 ++++++++++++++++++++++++++++++++++++------- - 1 file changed, 47 insertions(+), 8 deletions(-) - -diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c -index 0157ff7420..e2a6b1cf3c 100644 ---- a/grub-core/video/readers/png.c -+++ b/grub-core/video/readers/png.c -@@ -142,6 +142,7 @@ static grub_uint8_t - grub_png_get_byte (struct grub_png_data *data) - { - grub_uint8_t r; -+ grub_ssize_t bytes_read = 0; - - if ((data->inside_idat) && (data->idat_remain == 0)) - { -@@ -175,7 +176,14 @@ grub_png_get_byte (struct grub_png_data *data) - } - - r = 0; -- grub_file_read (data->file, &r, 1); -+ bytes_read = grub_file_read (data->file, &r, 1); -+ -+ if (bytes_read != 1) -+ { -+ grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "png: unexpected end of data"); -+ return 0; -+ } - - if (data->inside_idat) - data->idat_remain--; -@@ -231,15 +239,16 @@ grub_png_decode_image_palette (struct grub_png_data *data, - if (len == 0) - return GRUB_ERR_NONE; - -- for (i = 0; 3 * i < len && i < 256; i++) -+ grub_errno = GRUB_ERR_NONE; -+ for (i = 0; 3 * i < len && i < 256 && grub_errno == GRUB_ERR_NONE; i++) - for (j = 0; j < 3; j++) - data->palette[i][j] = grub_png_get_byte (data); -- for (i *= 3; i < len; i++) -+ for (i *= 3; i < len && grub_errno == GRUB_ERR_NONE; i++) - grub_png_get_byte (data); - - grub_png_get_dword (data); - -- return GRUB_ERR_NONE; -+ return grub_errno; - } - - static grub_err_t -@@ -256,9 +265,13 @@ grub_png_decode_image_header (struct grub_png_data *data) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, "png: invalid image size"); - - color_bits = grub_png_get_byte (data); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - data->is_16bit = (color_bits == 16); - - color_type = grub_png_get_byte (data); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - - /* According to PNG spec, no other types are valid. */ - if ((color_type & ~(PNG_COLOR_MASK_ALPHA | PNG_COLOR_MASK_COLOR)) -@@ -340,14 +353,20 @@ grub_png_decode_image_header (struct grub_png_data *data) - if (grub_png_get_byte (data) != PNG_COMPRESSION_BASE) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, - "png: compression method not supported"); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - - if (grub_png_get_byte (data) != PNG_FILTER_TYPE_BASE) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, - "png: filter method not supported"); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - - if (grub_png_get_byte (data) != PNG_INTERLACE_NONE) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, - "png: interlace method not supported"); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - - /* Skip crc checksum. */ - grub_png_get_dword (data); -@@ -449,7 +468,7 @@ grub_png_get_huff_code (struct grub_png_data *data, struct huff_table *ht) - int code, i; - - code = 0; -- for (i = 0; i < ht->max_length; i++) -+ for (i = 0; i < ht->max_length && grub_errno == GRUB_ERR_NONE; i++) - { - code = (code << 1) + grub_png_get_bits (data, 1); - if (code < ht->maxval[i]) -@@ -504,8 +523,14 @@ grub_png_init_dynamic_block (struct grub_png_data *data) - grub_uint8_t lens[DEFLATE_HCLEN_MAX]; - - nl = DEFLATE_HLIT_BASE + grub_png_get_bits (data, 5); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - nd = DEFLATE_HDIST_BASE + grub_png_get_bits (data, 5); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - nb = DEFLATE_HCLEN_BASE + grub_png_get_bits (data, 4); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - - if ((nl > DEFLATE_HLIT_MAX) || (nd > DEFLATE_HDIST_MAX) || - (nb > DEFLATE_HCLEN_MAX)) -@@ -533,7 +558,7 @@ grub_png_init_dynamic_block (struct grub_png_data *data) - data->dist_offset); - - prev = 0; -- for (i = 0; i < nl + nd; i++) -+ for (i = 0; i < nl + nd && grub_errno == GRUB_ERR_NONE; i++) - { - int n, code; - struct huff_table *ht; -@@ -721,17 +746,21 @@ grub_png_read_dynamic_block (struct grub_png_data *data) - len = cplens[n]; - if (cplext[n]) - len += grub_png_get_bits (data, cplext[n]); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - - n = grub_png_get_huff_code (data, &data->dist_table); - dist = cpdist[n]; - if (cpdext[n]) - dist += grub_png_get_bits (data, cpdext[n]); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - - pos = data->wp - dist; - if (pos < 0) - pos += WSIZE; - -- while (len > 0) -+ while (len > 0 && grub_errno == GRUB_ERR_NONE) - { - data->slide[data->wp] = data->slide[pos]; - grub_png_output_byte (data, data->slide[data->wp]); -@@ -759,7 +788,11 @@ grub_png_decode_image_data (struct grub_png_data *data) - int final; - - cmf = grub_png_get_byte (data); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - flg = grub_png_get_byte (data); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - - if ((cmf & 0xF) != Z_DEFLATED) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, -@@ -774,7 +807,11 @@ grub_png_decode_image_data (struct grub_png_data *data) - int block_type; - - final = grub_png_get_bits (data, 1); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - block_type = grub_png_get_bits (data, 2); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - - switch (block_type) - { -@@ -790,7 +827,7 @@ grub_png_decode_image_data (struct grub_png_data *data) - grub_png_get_byte (data); - grub_png_get_byte (data); - -- for (i = 0; i < len; i++) -+ for (i = 0; i < len && grub_errno == GRUB_ERR_NONE; i++) - grub_png_output_byte (data, grub_png_get_byte (data)); - - break; -@@ -1045,6 +1082,8 @@ grub_png_decode_png (struct grub_png_data *data) - - len = grub_png_get_dword (data); - type = grub_png_get_dword (data); -+ if (grub_errno != GRUB_ERR_NONE) -+ break; - data->next_offset = data->file->offset + len + 4; - - switch (type) diff --git a/0222-video-readers-png-Refuse-to-handle-multiple-image-he.patch b/0222-video-readers-png-Refuse-to-handle-multiple-image-he.patch deleted file mode 100644 index 9168fe5..0000000 --- a/0222-video-readers-png-Refuse-to-handle-multiple-image-he.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Tue, 6 Jul 2021 14:13:40 +1000 -Subject: [PATCH] video/readers/png: Refuse to handle multiple image headers - -This causes the bitmap to be leaked. Do not permit multiple image headers. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 8ce433557adeadbc46429aabb9f850b02ad2bdfb) ---- - grub-core/video/readers/png.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c -index e2a6b1cf3c..8955b8ecfd 100644 ---- a/grub-core/video/readers/png.c -+++ b/grub-core/video/readers/png.c -@@ -258,6 +258,9 @@ grub_png_decode_image_header (struct grub_png_data *data) - int color_bits; - enum grub_video_blit_format blt; - -+ if (data->image_width || data->image_height) -+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "png: two image headers found"); -+ - data->image_width = grub_png_get_dword (data); - data->image_height = grub_png_get_dword (data); - diff --git a/0101-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch b/0222-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch similarity index 97% rename from 0101-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch rename to 0222-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch index 5a9c6f2..83c02c9 100644 --- a/0101-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch +++ b/0222-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch @@ -12,7 +12,7 @@ Signed-off-by: Peter Jones 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 33e981e76e..2f0336809e 100644 +index 9e5dca9458a..3a940bec7f6 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; @@ -98,4 +98,4 @@ index 33e981e76e..2f0336809e 100644 - static grub_err_t grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) + int argc, char *argv[]) diff --git a/0223-video-readers-png-Drop-greyscale-support-to-fix-heap.patch b/0223-video-readers-png-Drop-greyscale-support-to-fix-heap.patch deleted file mode 100644 index 4529cb8..0000000 --- a/0223-video-readers-png-Drop-greyscale-support-to-fix-heap.patch +++ /dev/null @@ -1,170 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Tue, 6 Jul 2021 18:51:35 +1000 -Subject: [PATCH] video/readers/png: Drop greyscale support to fix heap - out-of-bounds write - -A 16-bit greyscale PNG without alpha is processed in the following loop: - - for (i = 0; i < (data->image_width * data->image_height); - i++, d1 += 4, d2 += 2) - { - d1[R3] = d2[1]; - d1[G3] = d2[1]; - d1[B3] = d2[1]; - } - -The increment of d1 is wrong. d1 is incremented by 4 bytes per iteration, -but there are only 3 bytes allocated for storage. This means that image -data will overwrite somewhat-attacker-controlled parts of memory - 3 bytes -out of every 4 following the end of the image. - -This has existed since greyscale support was added in 2013 in commit -3ccf16dff98f (grub-core/video/readers/png.c: Support grayscale). - -Saving starfield.png as a 16-bit greyscale image without alpha in the gimp -and attempting to load it causes grub-emu to crash - I don't think this code -has ever worked. - -Delete all PNG greyscale support. - -Fixes: CVE-2021-3695 - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 0e1d163382669bd734439d8864ee969616d971d9) -[rharwood: context conflict] -Signed-off-by: Robbie Harwood ---- - grub-core/video/readers/png.c | 85 +++---------------------------------------- - 1 file changed, 6 insertions(+), 79 deletions(-) - -diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c -index 8955b8ecfd..a3161e25b6 100644 ---- a/grub-core/video/readers/png.c -+++ b/grub-core/video/readers/png.c -@@ -100,7 +100,7 @@ struct grub_png_data - - unsigned image_width, image_height; - int bpp, is_16bit; -- int raw_bytes, is_gray, is_alpha, is_palette; -+ int raw_bytes, is_alpha, is_palette; - int row_bytes, color_bits; - grub_uint8_t *image_data; - -@@ -296,13 +296,13 @@ grub_png_decode_image_header (struct grub_png_data *data) - data->bpp = 3; - else - { -- data->is_gray = 1; -- data->bpp = 1; -+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "png: color type not supported"); - } - - if ((color_bits != 8) && (color_bits != 16) - && (color_bits != 4 -- || !(data->is_gray || data->is_palette))) -+ || !data->is_palette)) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, - "png: bit depth must be 8 or 16"); - -@@ -331,7 +331,7 @@ grub_png_decode_image_header (struct grub_png_data *data) - } - - #ifndef GRUB_CPU_WORDS_BIGENDIAN -- if (data->is_16bit || data->is_gray || data->is_palette) -+ if (data->is_16bit || data->is_palette) - #endif - { - data->image_data = grub_calloc (data->image_height, data->row_bytes); -@@ -899,27 +899,8 @@ grub_png_convert_image (struct grub_png_data *data) - int shift; - int mask = (1 << data->color_bits) - 1; - unsigned j; -- if (data->is_gray) -- { -- /* Generic formula is -- (0xff * i) / ((1U << data->color_bits) - 1) -- but for allowed bit depth of 1, 2 and for it's -- equivalent to -- (0xff / ((1U << data->color_bits) - 1)) * i -- Precompute the multipliers to avoid division. -- */ - -- const grub_uint8_t multipliers[5] = { 0xff, 0xff, 0x55, 0x24, 0x11 }; -- for (i = 0; i < (1U << data->color_bits); i++) -- { -- grub_uint8_t col = multipliers[data->color_bits] * i; -- palette[i][0] = col; -- palette[i][1] = col; -- palette[i][2] = col; -- } -- } -- else -- grub_memcpy (palette, data->palette, 3 << data->color_bits); -+ grub_memcpy (palette, data->palette, 3 << data->color_bits); - d1c = d1; - d2c = d2; - for (j = 0; j < data->image_height; j++, d1c += data->image_width * 3, -@@ -956,60 +937,6 @@ grub_png_convert_image (struct grub_png_data *data) - } - return; - } -- -- if (data->is_gray) -- { -- switch (data->bpp) -- { -- case 4: -- /* 16-bit gray with alpha. */ -- for (i = 0; i < (data->image_width * data->image_height); -- i++, d1 += 4, d2 += 4) -- { -- d1[R4] = d2[3]; -- d1[G4] = d2[3]; -- d1[B4] = d2[3]; -- d1[A4] = d2[1]; -- } -- break; -- case 2: -- if (data->is_16bit) -- /* 16-bit gray without alpha. */ -- { -- for (i = 0; i < (data->image_width * data->image_height); -- i++, d1 += 4, d2 += 2) -- { -- d1[R3] = d2[1]; -- d1[G3] = d2[1]; -- d1[B3] = d2[1]; -- } -- } -- else -- /* 8-bit gray with alpha. */ -- { -- for (i = 0; i < (data->image_width * data->image_height); -- i++, d1 += 4, d2 += 2) -- { -- d1[R4] = d2[1]; -- d1[G4] = d2[1]; -- d1[B4] = d2[1]; -- d1[A4] = d2[0]; -- } -- } -- break; -- /* 8-bit gray without alpha. */ -- case 1: -- for (i = 0; i < (data->image_width * data->image_height); -- i++, d1 += 3, d2++) -- { -- d1[R3] = d2[0]; -- d1[G3] = d2[0]; -- d1[B3] = d2[0]; -- } -- break; -- } -- return; -- } - - { - /* Only copy the upper 8 bit. */ diff --git a/0102-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch b/0223-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch similarity index 98% rename from 0102-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch rename to 0223-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch index 9b10d68..e4c80fe 100644 --- a/0102-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch +++ b/0223-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch @@ -11,7 +11,7 @@ Signed-off-by: Peter Jones 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 2f0336809e..5f48fa5561 100644 +index 3a940bec7f6..8d0b9436011 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)), @@ -121,7 +121,7 @@ index 2f0336809e..5f48fa5561 100644 params->ext_loader_type = 0; params->ext_loader_ver = 2; - grub_dprintf("linux", "kernel_mem: %p handover_offset: %08x\n", -- kernel_mem, handover_offset); +- 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); diff --git a/0224-video-readers-png-Avoid-heap-OOB-R-W-inserting-huff-.patch b/0224-video-readers-png-Avoid-heap-OOB-R-W-inserting-huff-.patch deleted file mode 100644 index 51dddfe..0000000 --- a/0224-video-readers-png-Avoid-heap-OOB-R-W-inserting-huff-.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Tue, 6 Jul 2021 23:25:07 +1000 -Subject: [PATCH] video/readers/png: Avoid heap OOB R/W inserting huff table - items - -In fuzzing we observed crashes where a code would attempt to be inserted -into a huffman table before the start, leading to a set of heap OOB reads -and writes as table entries with negative indices were shifted around and -the new code written in. - -Catch the case where we would underflow the array and bail. - -Fixes: CVE-2021-3696 - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 1ae9a91d42cb40da8a6f11fac65541858e340afa) ---- - grub-core/video/readers/png.c | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c -index a3161e25b6..d7ed5aa6cf 100644 ---- a/grub-core/video/readers/png.c -+++ b/grub-core/video/readers/png.c -@@ -438,6 +438,13 @@ grub_png_insert_huff_item (struct huff_table *ht, int code, int len) - for (i = len; i < ht->max_length; i++) - n += ht->maxval[i]; - -+ if (n > ht->num_values) -+ { -+ grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "png: out of range inserting huffman table item"); -+ return; -+ } -+ - for (i = 0; i < n; i++) - ht->values[ht->num_values - i] = ht->values[ht->num_values - i - 1]; - diff --git a/0103-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch b/0224-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch similarity index 90% rename from 0103-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch rename to 0224-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch index 700c98b..afd82c3 100644 --- a/0103-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch +++ b/0224-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch @@ -7,11 +7,11 @@ 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(-) + grub-core/loader/i386/efi/linux.c | 166 +++++++++++++++++++++----------------- + 1 file changed, 93 insertions(+), 73 deletions(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 5f48fa5561..3e4f7ef39f 100644 +index 8d0b9436011..039b40e321d 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; @@ -86,17 +86,17 @@ index 5f48fa5561..3e4f7ef39f 100644 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)); +- 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)); +- 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)); +- BYTES_TO_PAGES(kernel_size)); - if (params) - grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)params, -- BYTES_TO_PAGES(16384)); +- BYTES_TO_PAGES(16384)); + + kernel_free(initrd_mem, params->ramdisk_size); + kernel_free(linux_cmdline, params->cmdline_size + 1); @@ -127,7 +127,7 @@ index 5f48fa5561..3e4f7ef39f 100644 params->ramdisk_size = size; - params->ramdisk_image = (grub_uint32_t)(grub_addr_t) initrd_mem; -+ params->ramdisk_image = initrd_mem; ++ params->ramdisk_image = (grub_uint64_t) initrd_mem; ptr = initrd_mem; @@ -185,21 +185,20 @@ index 5f48fa5561..3e4f7ef39f 100644 - } - - grub_dprintf ("linux", "linux_cmdline = %lx\n", -- (unsigned long)linux_cmdline); +- (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)), +@@ -343,27 +371,23 @@ 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; ++ ++ lh->cmd_line_ptr = (grub_uint64_t) linux_cmdline; handover_offset = lh->handover_offset; - grub_dprintf("linux", "handover_offset: %08x\n", handover_offset); @@ -230,7 +229,7 @@ index 5f48fa5561..3e4f7ef39f 100644 grub_dprintf("linux", "kernel_mem = %p\n", kernel_mem); grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0); -@@ -398,18 +423,14 @@ fail: +@@ -398,18 +422,14 @@ fail: loaded = 0; } @@ -245,11 +244,11 @@ index 5f48fa5561..3e4f7ef39f 100644 - if (kernel_mem && !loaded) - grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)kernel_mem, -- BYTES_TO_PAGES(kernel_size)); +- BYTES_TO_PAGES(kernel_size)); - - if (params && !loaded) - grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)params, -- BYTES_TO_PAGES(16384)); +- BYTES_TO_PAGES(16384)); + kernel_free (kernel_mem, kernel_size); + kernel_free (params, sizeof(*params)); + } diff --git a/0225-video-readers-png-Sanity-check-some-huffman-codes.patch b/0225-video-readers-png-Sanity-check-some-huffman-codes.patch deleted file mode 100644 index c9cef25..0000000 --- a/0225-video-readers-png-Sanity-check-some-huffman-codes.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Tue, 6 Jul 2021 19:19:11 +1000 -Subject: [PATCH] video/readers/png: Sanity check some huffman codes - -ASAN picked up two OOB global reads: we weren't checking if some code -values fit within the cplens or cpdext arrays. Check and throw an error -if not. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit c3a8ab0cbd24153ec7b1f84a96ddfdd72ef8d117) ---- - grub-core/video/readers/png.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c -index d7ed5aa6cf..7f2ba7849b 100644 ---- a/grub-core/video/readers/png.c -+++ b/grub-core/video/readers/png.c -@@ -753,6 +753,9 @@ grub_png_read_dynamic_block (struct grub_png_data *data) - int len, dist, pos; - - n -= 257; -+ if (((unsigned int) n) >= ARRAY_SIZE (cplens)) -+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "png: invalid huff code"); - len = cplens[n]; - if (cplext[n]) - len += grub_png_get_bits (data, cplext[n]); -@@ -760,6 +763,9 @@ grub_png_read_dynamic_block (struct grub_png_data *data) - return grub_errno; - - n = grub_png_get_huff_code (data, &data->dist_table); -+ if (((unsigned int) n) >= ARRAY_SIZE (cpdist)) -+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "png: invalid huff code"); - dist = cpdist[n]; - if (cpdext[n]) - dist += grub_png_get_bits (data, cpdext[n]); diff --git a/0104-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch b/0225-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch similarity index 92% rename from 0104-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch rename to 0225-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch index 6ac11a1..a3b68e6 100644 --- a/0104-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch +++ b/0225-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch @@ -11,10 +11,10 @@ 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(-) + 2 files changed, 66 insertions(+), 7 deletions(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 3e4f7ef39f..6bc18d5aef 100644 +index 039b40e321d..015bb01d4c4 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -52,13 +52,22 @@ struct allocation_choice { @@ -68,7 +68,7 @@ index 3e4f7ef39f..6bc18d5aef 100644 grub_dprintf ("linux", "initrd_mem = %p\n", initrd_mem); - params->ramdisk_size = size; -- params->ramdisk_image = initrd_mem; +- params->ramdisk_image = (grub_uint64_t) initrd_mem; + params->ramdisk_size = LOW_U32(size); + params->ramdisk_image = LOW_U32(initrd_mem); +#if defined(__x86_64__) @@ -97,12 +97,12 @@ index 3e4f7ef39f..6bc18d5aef 100644 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)), +@@ -372,20 +405,41 @@ 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; + +- lh->cmd_line_ptr = (grub_uint64_t) linux_cmdline; ++ grub_dprintf ("linux", "setting lh->cmd_line_ptr to 0x%08x\n", + LOW_U32(linux_cmdline)); + lh->cmd_line_ptr = LOW_U32(linux_cmdline); +#if defined(__x86_64__) @@ -140,7 +140,7 @@ index 3e4f7ef39f..6bc18d5aef 100644 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)), +@@ -394,8 +448,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), loaded = 1; @@ -153,10 +153,10 @@ index 3e4f7ef39f..6bc18d5aef 100644 grub_memcpy (kernel_mem, (char *)kernel + start, filelen - start); diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h -index 25ef52c04e..fac22476cc 100644 +index 4ccd9d7d9f2..461097781fd 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h -@@ -236,7 +236,11 @@ struct linux_kernel_params +@@ -246,7 +246,11 @@ struct linux_kernel_params grub_uint32_t ofw_cif_handler; /* b8 */ grub_uint32_t ofw_idt; /* bc */ diff --git a/0126-efi-Set-image-base-address-before-jumping-to-the-PE-.patch b/0226-efi-Set-image-base-address-before-jumping-to-the-PE-.patch similarity index 78% rename from 0126-efi-Set-image-base-address-before-jumping-to-the-PE-.patch rename to 0226-efi-Set-image-base-address-before-jumping-to-the-PE-.patch index 6aa5013..f6176ba 100644 --- a/0126-efi-Set-image-base-address-before-jumping-to-the-PE-.patch +++ b/0226-efi-Set-image-base-address-before-jumping-to-the-PE-.patch @@ -29,18 +29,18 @@ Signed-off-by: Javier Martinez Canillas 1 file changed, 14 insertions(+) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index 0622dfa48d..e8b9ecb17f 100644 +index 742e8e9af35..32766bf7b19 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, +@@ -139,6 +139,7 @@ grub_err_t + grub_efi_linux_boot (void *kernel_address, 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,19 @@ grub_efi_linux_boot (void *kernel_addr, grub_off_t handover_offset, +@@ -146,6 +147,19 @@ grub_efi_linux_boot (void *kernel_address, grub_off_t handover_offset, offset = 512; #endif @@ -51,12 +51,12 @@ index 0622dfa48d..e8b9ecb17f 100644 + */ + loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); + if (loaded_image) -+ loaded_image->image_base = kernel_addr; ++ loaded_image->image_base = kernel_address; + 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); ++ grub_dprintf ("linux", "kernel_address: %p handover_offset: %p params: %p\n", ++ kernel_address, (void *)(grub_efi_uintn_t)handover_offset, kernel_params); + hf = (handover_func)((char *)kernel_address + handover_offset + offset); hf (grub_efi_image_handle, grub_efi_system_table, kernel_params); diff --git a/0226-video-readers-jpeg-Abort-sooner-if-a-read-operation-.patch b/0226-video-readers-jpeg-Abort-sooner-if-a-read-operation-.patch deleted file mode 100644 index 5491816..0000000 --- a/0226-video-readers-jpeg-Abort-sooner-if-a-read-operation-.patch +++ /dev/null @@ -1,255 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Mon, 28 Jun 2021 14:16:14 +1000 -Subject: [PATCH] video/readers/jpeg: Abort sooner if a read operation fails - -Fuzzing revealed some inputs that were taking a long time, potentially -forever, because they did not bail quickly upon encountering an I/O error. - -Try to catch I/O errors sooner and bail out. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit ab2e5d2e4bff488bbb557ed435a61ae102ef9f0c) ---- - grub-core/video/readers/jpeg.c | 86 ++++++++++++++++++++++++++++++++++-------- - 1 file changed, 70 insertions(+), 16 deletions(-) - -diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c -index e31602f766..10225abd53 100644 ---- a/grub-core/video/readers/jpeg.c -+++ b/grub-core/video/readers/jpeg.c -@@ -109,9 +109,17 @@ static grub_uint8_t - grub_jpeg_get_byte (struct grub_jpeg_data *data) - { - grub_uint8_t r; -+ grub_ssize_t bytes_read; - - r = 0; -- grub_file_read (data->file, &r, 1); -+ bytes_read = grub_file_read (data->file, &r, 1); -+ -+ if (bytes_read != 1) -+ { -+ grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "jpeg: unexpected end of data"); -+ return 0; -+ } - - return r; - } -@@ -120,9 +128,17 @@ static grub_uint16_t - grub_jpeg_get_word (struct grub_jpeg_data *data) - { - grub_uint16_t r; -+ grub_ssize_t bytes_read; - - r = 0; -- grub_file_read (data->file, &r, sizeof (grub_uint16_t)); -+ bytes_read = grub_file_read (data->file, &r, sizeof (grub_uint16_t)); -+ -+ if (bytes_read != sizeof (grub_uint16_t)) -+ { -+ grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "jpeg: unexpected end of data"); -+ return 0; -+ } - - return grub_be_to_cpu16 (r); - } -@@ -135,6 +151,11 @@ grub_jpeg_get_bit (struct grub_jpeg_data *data) - if (data->bit_mask == 0) - { - data->bit_save = grub_jpeg_get_byte (data); -+ if (grub_errno != GRUB_ERR_NONE) { -+ grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "jpeg: file read error"); -+ return 0; -+ } - if (data->bit_save == JPEG_ESC_CHAR) - { - if (grub_jpeg_get_byte (data) != 0) -@@ -143,6 +164,11 @@ grub_jpeg_get_bit (struct grub_jpeg_data *data) - "jpeg: invalid 0xFF in data stream"); - return 0; - } -+ if (grub_errno != GRUB_ERR_NONE) -+ { -+ grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: file read error"); -+ return 0; -+ } - } - data->bit_mask = 0x80; - } -@@ -161,7 +187,7 @@ grub_jpeg_get_number (struct grub_jpeg_data *data, int num) - return 0; - - msb = value = grub_jpeg_get_bit (data); -- for (i = 1; i < num; i++) -+ for (i = 1; i < num && grub_errno == GRUB_ERR_NONE; i++) - value = (value << 1) + (grub_jpeg_get_bit (data) != 0); - if (!msb) - value += 1 - (1 << num); -@@ -202,6 +228,8 @@ grub_jpeg_decode_huff_table (struct grub_jpeg_data *data) - while (data->file->offset + sizeof (count) + 1 <= next_marker) - { - id = grub_jpeg_get_byte (data); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - ac = (id >> 4) & 1; - id &= 0xF; - if (id > 1) -@@ -252,6 +280,8 @@ grub_jpeg_decode_quan_table (struct grub_jpeg_data *data) - - next_marker = data->file->offset; - next_marker += grub_jpeg_get_word (data); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - - if (next_marker > data->file->size) - { -@@ -263,6 +293,8 @@ grub_jpeg_decode_quan_table (struct grub_jpeg_data *data) - <= next_marker) - { - id = grub_jpeg_get_byte (data); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - if (id >= 0x10) /* Upper 4-bit is precision. */ - return grub_error (GRUB_ERR_BAD_FILE_TYPE, - "jpeg: only 8-bit precision is supported"); -@@ -294,6 +326,9 @@ grub_jpeg_decode_sof (struct grub_jpeg_data *data) - next_marker = data->file->offset; - next_marker += grub_jpeg_get_word (data); - -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; -+ - if (grub_jpeg_get_byte (data) != 8) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, - "jpeg: only 8-bit precision is supported"); -@@ -319,6 +354,8 @@ grub_jpeg_decode_sof (struct grub_jpeg_data *data) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid index"); - - ss = grub_jpeg_get_byte (data); /* Sampling factor. */ -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - if (!id) - { - grub_uint8_t vs, hs; -@@ -498,7 +535,7 @@ grub_jpeg_idct_transform (jpeg_data_unit_t du) - } - } - --static void -+static grub_err_t - grub_jpeg_decode_du (struct grub_jpeg_data *data, int id, jpeg_data_unit_t du) - { - int h1, h2, qt; -@@ -513,6 +550,9 @@ grub_jpeg_decode_du (struct grub_jpeg_data *data, int id, jpeg_data_unit_t du) - data->dc_value[id] += - grub_jpeg_get_number (data, grub_jpeg_get_huff_code (data, h1)); - -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; -+ - du[0] = data->dc_value[id] * (int) data->quan_table[qt][0]; - pos = 1; - while (pos < ARRAY_SIZE (data->quan_table[qt])) -@@ -527,11 +567,13 @@ grub_jpeg_decode_du (struct grub_jpeg_data *data, int id, jpeg_data_unit_t du) - num >>= 4; - pos += num; - -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; -+ - if (pos >= ARRAY_SIZE (jpeg_zigzag_order)) - { -- grub_error (GRUB_ERR_BAD_FILE_TYPE, -- "jpeg: invalid position in zigzag order!?"); -- return; -+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "jpeg: invalid position in zigzag order!?"); - } - - du[jpeg_zigzag_order[pos]] = val * (int) data->quan_table[qt][pos]; -@@ -539,6 +581,7 @@ grub_jpeg_decode_du (struct grub_jpeg_data *data, int id, jpeg_data_unit_t du) - } - - grub_jpeg_idct_transform (du); -+ return GRUB_ERR_NONE; - } - - static void -@@ -597,7 +640,8 @@ grub_jpeg_decode_sos (struct grub_jpeg_data *data) - data_offset += grub_jpeg_get_word (data); - - cc = grub_jpeg_get_byte (data); -- -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - if (cc != 3 && cc != 1) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, - "jpeg: component count must be 1 or 3"); -@@ -610,7 +654,8 @@ grub_jpeg_decode_sos (struct grub_jpeg_data *data) - id = grub_jpeg_get_byte (data) - 1; - if ((id < 0) || (id >= 3)) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid index"); -- -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - ht = grub_jpeg_get_byte (data); - data->comp_index[id][1] = (ht >> 4); - data->comp_index[id][2] = (ht & 0xF) + 2; -@@ -618,11 +663,14 @@ grub_jpeg_decode_sos (struct grub_jpeg_data *data) - if ((data->comp_index[id][1] < 0) || (data->comp_index[id][1] > 3) || - (data->comp_index[id][2] < 0) || (data->comp_index[id][2] > 3)) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid hufftable index"); -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - } - - grub_jpeg_get_byte (data); /* Skip 3 unused bytes. */ - grub_jpeg_get_word (data); -- -+ if (grub_errno != GRUB_ERR_NONE) -+ return grub_errno; - if (data->file->offset != data_offset) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: extra byte in sos"); - -@@ -640,6 +688,7 @@ grub_jpeg_decode_data (struct grub_jpeg_data *data) - { - unsigned c1, vb, hb, nr1, nc1; - int rst = data->dri; -+ grub_err_t err = GRUB_ERR_NONE; - - vb = 8 << data->log_vs; - hb = 8 << data->log_hs; -@@ -660,17 +709,22 @@ grub_jpeg_decode_data (struct grub_jpeg_data *data) - - for (r2 = 0; r2 < (1U << data->log_vs); r2++) - for (c2 = 0; c2 < (1U << data->log_hs); c2++) -- grub_jpeg_decode_du (data, 0, data->ydu[r2 * 2 + c2]); -+ { -+ err = grub_jpeg_decode_du (data, 0, data->ydu[r2 * 2 + c2]); -+ if (err != GRUB_ERR_NONE) -+ return err; -+ } - - if (data->color_components >= 3) - { -- grub_jpeg_decode_du (data, 1, data->cbdu); -- grub_jpeg_decode_du (data, 2, data->crdu); -+ err = grub_jpeg_decode_du (data, 1, data->cbdu); -+ if (err != GRUB_ERR_NONE) -+ return err; -+ err = grub_jpeg_decode_du (data, 2, data->crdu); -+ if (err != GRUB_ERR_NONE) -+ return err; - } - -- if (grub_errno) -- return grub_errno; -- - nr2 = (data->r1 == nr1 - 1) ? (data->image_height - data->r1 * vb) : vb; - nc2 = (c1 == nc1 - 1) ? (data->image_width - c1 * hb) : hb; - diff --git a/0227-video-readers-jpeg-Do-not-reallocate-a-given-huff-ta.patch b/0227-video-readers-jpeg-Do-not-reallocate-a-given-huff-ta.patch deleted file mode 100644 index 199ec32..0000000 --- a/0227-video-readers-jpeg-Do-not-reallocate-a-given-huff-ta.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Mon, 28 Jun 2021 14:16:58 +1000 -Subject: [PATCH] video/readers/jpeg: Do not reallocate a given huff table - -Fix a memory leak where an invalid file could cause us to reallocate -memory for a huffman table we had already allocated memory for. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit bc06e12b4de55cc6f926af9f064170c82b1403e9) ---- - grub-core/video/readers/jpeg.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c -index 10225abd53..caa211f06d 100644 ---- a/grub-core/video/readers/jpeg.c -+++ b/grub-core/video/readers/jpeg.c -@@ -245,6 +245,9 @@ grub_jpeg_decode_huff_table (struct grub_jpeg_data *data) - n += count[i]; - - id += ac * 2; -+ if (data->huff_value[id] != NULL) -+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "jpeg: attempt to reallocate huffman table"); - data->huff_value[id] = grub_malloc (n); - if (grub_errno) - return grub_errno; diff --git a/0128-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch b/0227-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch similarity index 97% rename from 0128-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch rename to 0227-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch index 7c41e87..35c0f32 100644 --- a/0128-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch +++ b/0227-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch @@ -26,7 +26,7 @@ Signed-off-by: Javier Martinez Canillas 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 6bc18d5aef..15d40d6e35 100644 +index 015bb01d4c4..adfb2739ae4 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) diff --git a/0134-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch b/0228-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch similarity index 97% rename from 0134-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch rename to 0228-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch index 8e63d1d..7b507d9 100644 --- a/0134-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch +++ b/0228-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch @@ -13,7 +13,7 @@ Signed-off-by: Colin Watson 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 15d40d6e35..f992ceeef2 100644 +index adfb2739ae4..325aa594db1 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -28,6 +28,8 @@ diff --git a/0228-video-readers-jpeg-Refuse-to-handle-multiple-start-o.patch b/0228-video-readers-jpeg-Refuse-to-handle-multiple-start-o.patch deleted file mode 100644 index 179238b..0000000 --- a/0228-video-readers-jpeg-Refuse-to-handle-multiple-start-o.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Mon, 28 Jun 2021 14:25:17 +1000 -Subject: [PATCH] video/readers/jpeg: Refuse to handle multiple start of - streams - -An invalid file could contain multiple start of stream blocks, which -would cause us to reallocate and leak our bitmap. Refuse to handle -multiple start of streams. - -Additionally, fix a grub_error() call formatting. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit f3a854def3e281b7ad4bbea730cd3046de1da52f) ---- - grub-core/video/readers/jpeg.c | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c -index caa211f06d..1df1171d78 100644 ---- a/grub-core/video/readers/jpeg.c -+++ b/grub-core/video/readers/jpeg.c -@@ -677,6 +677,9 @@ grub_jpeg_decode_sos (struct grub_jpeg_data *data) - if (data->file->offset != data_offset) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: extra byte in sos"); - -+ if (*data->bitmap) -+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: too many start of scan blocks"); -+ - if (grub_video_bitmap_create (data->bitmap, data->image_width, - data->image_height, - GRUB_VIDEO_BLIT_FORMAT_RGB_888)) -@@ -699,8 +702,8 @@ grub_jpeg_decode_data (struct grub_jpeg_data *data) - nc1 = (data->image_width + hb - 1) >> (3 + data->log_hs); - - if (data->bitmap_ptr == NULL) -- return grub_error(GRUB_ERR_BAD_FILE_TYPE, -- "jpeg: attempted to decode data before start of stream"); -+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "jpeg: attempted to decode data before start of stream"); - - for (; data->r1 < nr1 && (!data->dri || rst); - data->r1++, data->bitmap_ptr += (vb * data->image_width - hb * nc1) * 3) diff --git a/0135-linuxefi-fail-kernel-validation-without-shim-protoco.patch b/0229-linuxefi-fail-kernel-validation-without-shim-protoco.patch similarity index 69% rename from 0135-linuxefi-fail-kernel-validation-without-shim-protoco.patch rename to 0229-linuxefi-fail-kernel-validation-without-shim-protoco.patch index 828fe16..0bf7b19 100644 --- a/0135-linuxefi-fail-kernel-validation-without-shim-protoco.patch +++ b/0229-linuxefi-fail-kernel-validation-without-shim-protoco.patch @@ -16,61 +16,28 @@ CVE-2020-15705 Reported-by: Mathieu Trudel-Lapierre Signed-off-by: Dimitri John Ledkov --- - grub-core/loader/arm64/linux.c | 13 +++++++++---- grub-core/loader/efi/chainloader.c | 1 + grub-core/loader/efi/linux.c | 1 + grub-core/loader/i386/efi/linux.c | 17 +++++++++++------ - 4 files changed, 22 insertions(+), 10 deletions(-) + 3 files changed, 13 insertions(+), 6 deletions(-) -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index 70a0075ec5..47f8cf0d84 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -34,6 +34,7 @@ - #include - #include - #include -+#include - - GRUB_MOD_LICENSE ("GPLv3+"); - -@@ -363,11 +364,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_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) - { -- 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/chainloader.c b/grub-core/loader/efi/chainloader.c -index ac8dfd40c6..d41e8ea14a 100644 +index e4ac39c87b4..0ec682e2988 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c -@@ -1084,6 +1084,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -1088,6 +1088,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), return 0; } + // -1 fall-through to fail fail: - if (dev) + diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index e8b9ecb17f..9260731c10 100644 +index 32766bf7b19..ecb6d593cef 100644 --- a/grub-core/loader/efi/linux.c +++ b/grub-core/loader/efi/linux.c -@@ -33,6 +33,7 @@ struct grub_efi_shim_lock +@@ -98,6 +98,7 @@ struct grub_efi_shim_lock }; typedef struct grub_efi_shim_lock grub_efi_shim_lock_t; @@ -79,7 +46,7 @@ index e8b9ecb17f..9260731c10 100644 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 f992ceeef2..3cf0f9b330 100644 +index 325aa594db1..97484bbe24d 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -30,6 +30,7 @@ @@ -108,7 +75,7 @@ index f992ceeef2..3cf0f9b330 100644 + if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) { - grub_error (GRUB_ERR_INVALID_COMMAND, N_("%s has invalid signature"), -- argv[0]); +- argv[0]); - goto fail; + rc = grub_linuxefi_secure_validate (kernel, filelen); + if (rc <= 0) diff --git a/0229-video-readers-jpeg-Block-int-underflow-wild-pointer-.patch b/0229-video-readers-jpeg-Block-int-underflow-wild-pointer-.patch deleted file mode 100644 index 99eeb62..0000000 --- a/0229-video-readers-jpeg-Block-int-underflow-wild-pointer-.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Wed, 7 Jul 2021 15:38:19 +1000 -Subject: [PATCH] video/readers/jpeg: Block int underflow -> wild pointer write - -Certain 1 px wide images caused a wild pointer write in -grub_jpeg_ycrcb_to_rgb(). This was caused because in grub_jpeg_decode_data(), -we have the following loop: - -for (; data->r1 < nr1 && (!data->dri || rst); - data->r1++, data->bitmap_ptr += (vb * data->image_width - hb * nc1) * 3) - -We did not check if vb * width >= hb * nc1. - -On a 64-bit platform, if that turns out to be negative, it will underflow, -be interpreted as unsigned 64-bit, then be added to the 64-bit pointer, so -we see data->bitmap_ptr jump, e.g.: - -0x6180_0000_0480 to -0x6181_0000_0498 - ^ - ~--- carry has occurred and this pointer is now far away from - any object. - -On a 32-bit platform, it will decrement the pointer, creating a pointer -that won't crash but will overwrite random data. - -Catch the underflow and error out. - -Fixes: CVE-2021-3697 - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 41aeb2004db9924fecd9f2dd64bc2a5a5594a4b5) ---- - grub-core/video/readers/jpeg.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c -index 1df1171d78..2da04094b3 100644 ---- a/grub-core/video/readers/jpeg.c -+++ b/grub-core/video/readers/jpeg.c -@@ -705,6 +705,10 @@ grub_jpeg_decode_data (struct grub_jpeg_data *data) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, - "jpeg: attempted to decode data before start of stream"); - -+ if (vb * data->image_width <= hb * nc1) -+ return grub_error (GRUB_ERR_BAD_FILE_TYPE, -+ "jpeg: cannot decode image with these dimensions"); -+ - for (; data->r1 < nr1 && (!data->dri || rst); - data->r1++, data->bitmap_ptr += (vb * data->image_width - hb * nc1) * 3) - for (c1 = 0; c1 < nc1 && (!data->dri || rst); diff --git a/0177-Allow-chainloading-EFI-apps-from-loop-mounts.patch b/0230-Allow-chainloading-EFI-apps-from-loop-mounts.patch similarity index 81% rename from 0177-Allow-chainloading-EFI-apps-from-loop-mounts.patch rename to 0230-Allow-chainloading-EFI-apps-from-loop-mounts.patch index c3101e1..c5e4457 100644 --- a/0177-Allow-chainloading-EFI-apps-from-loop-mounts.patch +++ b/0230-Allow-chainloading-EFI-apps-from-loop-mounts.patch @@ -7,13 +7,13 @@ Signed-off-by: Dimitri John Ledkov Signed-off-by: Robbie Harwood --- grub-core/disk/loopback.c | 9 +-------- - grub-core/loader/efi/chainloader.c | 23 +++++++++++++++++++++++ + grub-core/loader/efi/chainloader.c | 24 ++++++++++++++++++++++++ include/grub/loopback.h | 30 ++++++++++++++++++++++++++++++ - 3 files changed, 54 insertions(+), 8 deletions(-) + 3 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 include/grub/loopback.h diff --git a/grub-core/disk/loopback.c b/grub-core/disk/loopback.c -index 41bebd14fe..99f47924ec 100644 +index 4635dcfdeec..11a5e0cbd02 100644 --- a/grub-core/disk/loopback.c +++ b/grub-core/disk/loopback.c @@ -21,20 +21,13 @@ @@ -39,7 +39,7 @@ index 41bebd14fe..99f47924ec 100644 static unsigned long last_id = 0; diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index d41e8ea14a..3af6b12292 100644 +index 0ec682e2988..efbe2bd38aa 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -24,6 +24,7 @@ @@ -50,20 +50,21 @@ index d41e8ea14a..3af6b12292 100644 #include #include #include -@@ -901,6 +902,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -907,6 +908,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), grub_efi_status_t status; grub_efi_boot_services_t *b; grub_device_t dev = 0; + grub_device_t orig_dev = 0; - grub_efi_device_path_t *dp = 0; + grub_efi_device_path_t *dp = NULL; char *filename; void *boot_image = 0; -@@ -958,6 +960,15 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - if (! dev) - goto fail; - +@@ -963,6 +965,16 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + dev = grub_device_open (devname); + if (devname) + grub_free (devname); ++ + /* if device is loopback, use underlying dev */ -+ if (dev->disk->dev->id == GRUB_DISK_DEVICE_LOOPBACK_ID) ++ if (dev && dev->disk->dev->id == GRUB_DISK_DEVICE_LOOPBACK_ID) + { + struct grub_loopback *d; + orig_dev = dev; @@ -71,10 +72,10 @@ index d41e8ea14a..3af6b12292 100644 + dev = d->file->device; + } + - if (dev->disk) - dev_handle = grub_efidisk_get_device_handle (dev->disk); - else if (dev->net && dev->net->server) -@@ -1065,6 +1076,12 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + if (dev == NULL) + ; + else if (dev->disk) +@@ -1069,6 +1081,12 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), } #endif @@ -87,10 +88,10 @@ index d41e8ea14a..3af6b12292 100644 rc = grub_linuxefi_secure_validate((void *)(unsigned long)address, fsize); grub_dprintf ("chain", "linuxefi_secure_validate: %d\n", rc); if (rc > 0) -@@ -1087,6 +1104,12 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - // -1 fall-through to fail +@@ -1092,6 +1110,12 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), fail: + + if (orig_dev) + { + dev = orig_dev; @@ -102,7 +103,7 @@ index d41e8ea14a..3af6b12292 100644 diff --git a/include/grub/loopback.h b/include/grub/loopback.h new file mode 100644 -index 0000000000..3b9a9e32e8 +index 00000000000..3b9a9e32e80 --- /dev/null +++ b/include/grub/loopback.h @@ -0,0 +1,30 @@ diff --git a/0230-normal-charset-Fix-array-out-of-bounds-formatting-un.patch b/0230-normal-charset-Fix-array-out-of-bounds-formatting-un.patch deleted file mode 100644 index 6e64ed8..0000000 --- a/0230-normal-charset-Fix-array-out-of-bounds-formatting-un.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Tue, 13 Jul 2021 13:24:38 +1000 -Subject: [PATCH] normal/charset: Fix array out-of-bounds formatting unicode - for display - -In some cases attempting to display arbitrary binary strings leads -to ASAN splats reading the widthspec array out of bounds. - -Check the index. If it would be out of bounds, return a width of 1. -I don't know if that's strictly correct, but we're not really expecting -great display of arbitrary binary data, and it's certainly not worse than -an OOB read. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit fdf32abc7a3928852422c0f291d8cd1dd6b34a8d) ---- - grub-core/normal/charset.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c -index 4dfcc31078..7a5a7c153c 100644 ---- a/grub-core/normal/charset.c -+++ b/grub-core/normal/charset.c -@@ -395,6 +395,8 @@ grub_unicode_estimate_width (const struct grub_unicode_glyph *c) - { - if (grub_unicode_get_comb_type (c->base)) - return 0; -+ if (((unsigned long) (c->base >> 3)) >= ARRAY_SIZE (widthspec)) -+ return 1; - if (widthspec[c->base >> 3] & (1 << (c->base & 7))) - return 2; - else diff --git a/0206-grub-core-loader-i386-efi-linux.c-do-not-validate-ke.patch b/0231-grub-core-loader-i386-efi-linux.c-do-not-validate-ke.patch similarity index 98% rename from 0206-grub-core-loader-i386-efi-linux.c-do-not-validate-ke.patch rename to 0231-grub-core-loader-i386-efi-linux.c-do-not-validate-ke.patch index 4fe8adf..084be2f 100644 --- a/0206-grub-core-loader-i386-efi-linux.c-do-not-validate-ke.patch +++ b/0231-grub-core-loader-i386-efi-linux.c-do-not-validate-ke.patch @@ -34,7 +34,7 @@ Signed-off-by: Dimitri John Ledkov 1 file changed, 13 deletions(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 3cf0f9b330..941df6400b 100644 +index 97484bbe24d..1dd787081f2 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -30,7 +30,6 @@ diff --git a/0231-net-netbuff-Block-overly-large-netbuff-allocs.patch b/0231-net-netbuff-Block-overly-large-netbuff-allocs.patch deleted file mode 100644 index 2e10d49..0000000 --- a/0231-net-netbuff-Block-overly-large-netbuff-allocs.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Tue, 8 Mar 2022 23:47:46 +1100 -Subject: [PATCH] net/netbuff: Block overly large netbuff allocs - -A netbuff shouldn't be too huge. It's bounded by MTU and TCP segment -reassembly. - -This helps avoid some bugs (and provides a spot to instrument to catch -them at their source). - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit ee9591103004cd13b4efadda671536090ca7fd57) ---- - grub-core/net/netbuff.c | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -diff --git a/grub-core/net/netbuff.c b/grub-core/net/netbuff.c -index dbeeefe478..d5e9e9a0d7 100644 ---- a/grub-core/net/netbuff.c -+++ b/grub-core/net/netbuff.c -@@ -79,10 +79,23 @@ grub_netbuff_alloc (grub_size_t len) - - COMPILE_TIME_ASSERT (NETBUFF_ALIGN % sizeof (grub_properly_aligned_t) == 0); - -+ /* -+ * The largest size of a TCP packet is 64 KiB, and everything else -+ * should be a lot smaller - most MTUs are 1500 or less. Cap data -+ * size at 64 KiB + a buffer. -+ */ -+ if (len > 0xffffUL + 0x1000UL) -+ { -+ grub_error (GRUB_ERR_BUG, -+ "attempted to allocate a packet that is too big"); -+ return NULL; -+ } -+ - if (len < NETBUFFMINLEN) - len = NETBUFFMINLEN; - - len = ALIGN_UP (len, NETBUFF_ALIGN); -+ - #ifdef GRUB_MACHINE_EMU - data = grub_malloc (len + sizeof (*nb)); - #else diff --git a/0208-grub-core-loader-efi-chainloader.c-do-not-validate-c.patch b/0232-grub-core-loader-efi-chainloader.c-do-not-validate-c.patch similarity index 86% rename from 0208-grub-core-loader-efi-chainloader.c-do-not-validate-c.patch rename to 0232-grub-core-loader-efi-chainloader.c-do-not-validate-c.patch index 4c56d60..1ec4787 100644 --- a/0208-grub-core-loader-efi-chainloader.c-do-not-validate-c.patch +++ b/0232-grub-core-loader-efi-chainloader.c-do-not-validate-c.patch @@ -39,18 +39,18 @@ Signed-off-by: Dimitri John Ledkov 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 3af6b12292..644cd2e56f 100644 +index efbe2bd38aa..3a3b55c1d61 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c -@@ -906,7 +906,6 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - grub_efi_device_path_t *dp = 0; +@@ -912,7 +912,6 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + grub_efi_device_path_t *dp = NULL; char *filename; void *boot_image = 0; - int rc; - if (argc == 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -@@ -1082,9 +1081,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + file_path = NULL; + address = 0; +@@ -1087,9 +1086,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), orig_dev = 0; } @@ -61,7 +61,7 @@ index 3af6b12292..644cd2e56f 100644 { grub_file_close (file); grub_device_close (dev); -@@ -1092,7 +1089,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -1097,7 +1094,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), grub_secureboot_chainloader_unload, 0); return 0; } @@ -70,11 +70,11 @@ index 3af6b12292..644cd2e56f 100644 { grub_load_and_start_image(boot_image); grub_file_close (file); -@@ -1101,7 +1098,6 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -1106,7 +1103,6 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), return 0; } - // -1 fall-through to fail fail: - if (orig_dev) + diff --git a/0232-net-ip-Do-IP-fragment-maths-safely.patch b/0232-net-ip-Do-IP-fragment-maths-safely.patch deleted file mode 100644 index 118448d..0000000 --- a/0232-net-ip-Do-IP-fragment-maths-safely.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Mon, 20 Dec 2021 19:41:21 +1100 -Subject: [PATCH] net/ip: Do IP fragment maths safely - -This avoids an underflow and subsequent unpleasantness. - -Fixes: CVE-2022-28733 - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit eb74e5743ca7e18a5e75c392fe0b21d1549a1936) ---- - grub-core/net/ip.c | 10 +++++++++- - 1 file changed, 9 insertions(+), 1 deletion(-) - -diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c -index ce6bdc75c6..cf74f1f794 100644 ---- a/grub-core/net/ip.c -+++ b/grub-core/net/ip.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - #include - - struct iphdr { -@@ -551,7 +552,14 @@ grub_net_recv_ip4_packets (struct grub_net_buff *nb, - { - rsm->total_len = (8 * (grub_be_to_cpu16 (iph->frags) & OFFSET_MASK) - + (nb->tail - nb->data)); -- rsm->total_len -= ((iph->verhdrlen & 0xf) * sizeof (grub_uint32_t)); -+ -+ if (grub_sub (rsm->total_len, (iph->verhdrlen & 0xf) * sizeof (grub_uint32_t), -+ &rsm->total_len)) -+ { -+ grub_dprintf ("net", "IP reassembly size underflow\n"); -+ return GRUB_ERR_NONE; -+ } -+ - rsm->asm_netbuff = grub_netbuff_alloc (rsm->total_len); - if (!rsm->asm_netbuff) - { diff --git a/0209-grub-core-loader-efi-linux.c-drop-now-unused-grub_li.patch b/0233-grub-core-loader-efi-linux.c-drop-now-unused-grub_li.patch similarity index 83% rename from 0209-grub-core-loader-efi-linux.c-drop-now-unused-grub_li.patch rename to 0233-grub-core-loader-efi-linux.c-drop-now-unused-grub_li.patch index c683fcb..a9f7888 100644 --- a/0209-grub-core-loader-efi-linux.c-drop-now-unused-grub_li.patch +++ b/0233-grub-core-loader-efi-linux.c-drop-now-unused-grub_li.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dimitri John Ledkov -Date: Fri, 4 Mar 2022 11:36:09 +0100 +From: Leo Sandoval +Date: Mon, 8 Apr 2024 10:59:25 -0600 Subject: [PATCH] grub-core/loader/efi/linux.c: drop now unused grub_linuxefi_secure_validate @@ -13,17 +13,17 @@ shim-lock-verifier is an optional module. Signed-off-by: Dimitri John Ledkov --- - grub-core/loader/efi/linux.c | 40 ---------------------------------------- + grub-core/loader/efi/linux.c | 42 ------------------------------------------ include/grub/efi/linux.h | 2 -- - 2 files changed, 42 deletions(-) + 2 files changed, 44 deletions(-) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index 9260731c10..9265cf4200 100644 +index ecb6d593cef..f5ab0128991 100644 --- a/grub-core/loader/efi/linux.c +++ b/grub-core/loader/efi/linux.c -@@ -24,46 +24,6 @@ - #include - #include +@@ -89,48 +89,6 @@ static grub_efi_load_file2_t initrd_lf2 = { + grub_efi_initrd_load_file2 + }; -#define SHIM_LOCK_GUID \ - { 0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23} } @@ -38,11 +38,12 @@ index 9260731c10..9265cf4200 100644 -int -grub_linuxefi_secure_validate (void *data, grub_uint32_t size) -{ -- grub_efi_guid_t guid = SHIM_LOCK_GUID; +- grub_guid_t guid = SHIM_LOCK_GUID; - grub_efi_shim_lock_t *shim_lock; - grub_efi_status_t status; - - shim_lock = grub_efi_locate_protocol(&guid, NULL); +- - grub_dprintf ("secureboot", "shim_lock: %p\n", shim_lock); - if (!shim_lock) - { @@ -63,13 +64,14 @@ index 9260731c10..9265cf4200 100644 - (unsigned long) status); - - return -1; +- -} - #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-align" diff --git a/include/grub/efi/linux.h b/include/grub/efi/linux.h -index 0033d9305a..887b02fd9f 100644 +index b2cfd8c1f44..c806a7757f3 100644 --- a/include/grub/efi/linux.h +++ b/include/grub/efi/linux.h @@ -22,8 +22,6 @@ @@ -80,4 +82,4 @@ index 0033d9305a..887b02fd9f 100644 -EXPORT_FUNC(grub_linuxefi_secure_validate) (void *data, grub_uint32_t size); grub_err_t EXPORT_FUNC(grub_efi_linux_boot) (void *kernel_address, grub_off_t offset, - void *kernel_param); + void *kernel_param); diff --git a/0233-net-dns-Fix-double-free-addresses-on-corrupt-DNS-res.patch b/0233-net-dns-Fix-double-free-addresses-on-corrupt-DNS-res.patch deleted file mode 100644 index 19701b6..0000000 --- a/0233-net-dns-Fix-double-free-addresses-on-corrupt-DNS-res.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Thu, 16 Sep 2021 01:29:54 +1000 -Subject: [PATCH] net/dns: Fix double-free addresses on corrupt DNS response - -grub_net_dns_lookup() takes as inputs a pointer to an array of addresses -("addresses") for the given name, and pointer to a number of addresses -("naddresses"). grub_net_dns_lookup() is responsible for allocating -"addresses", and the caller is responsible for freeing it if -"naddresses" > 0. - -The DNS recv_hook will sometimes set and free the addresses array, -for example if the packet is too short: - - if (ptr + 10 >= nb->tail) - { - if (!*data->naddresses) - grub_free (*data->addresses); - grub_netbuff_free (nb); - return GRUB_ERR_NONE; - } - -Later on the nslookup command code unconditionally frees the "addresses" -array. Normally this is fine: the array is either populated with valid -data or is NULL. But in these sorts of error cases it is neither NULL -nor valid and we get a double-free. - -Only free "addresses" if "naddresses" > 0. - -It looks like the other use of grub_net_dns_lookup() is not affected. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit eb2e69fcf51307757e43f55ee8c9354d1ee42dd1) ---- - grub-core/net/dns.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c -index 906ec7d678..135faac035 100644 ---- a/grub-core/net/dns.c -+++ b/grub-core/net/dns.c -@@ -667,9 +667,11 @@ grub_cmd_nslookup (struct grub_command *cmd __attribute__ ((unused)), - grub_net_addr_to_str (&addresses[i], buf); - grub_printf ("%s\n", buf); - } -- grub_free (addresses); - if (naddresses) -- return GRUB_ERR_NONE; -+ { -+ grub_free (addresses); -+ return GRUB_ERR_NONE; -+ } - return grub_error (GRUB_ERR_NET_NO_DOMAIN, N_("no DNS record found")); - } - diff --git a/0212-loader-efi-chainloader-grub_load_and_start_image-doe.patch b/0234-loader-efi-chainloader-grub_load_and_start_image-doe.patch similarity index 87% rename from 0212-loader-efi-chainloader-grub_load_and_start_image-doe.patch rename to 0234-loader-efi-chainloader-grub_load_and_start_image-doe.patch index f61ed28..75cb622 100644 --- a/0212-loader-efi-chainloader-grub_load_and_start_image-doe.patch +++ b/0234-loader-efi-chainloader-grub_load_and_start_image-doe.patch @@ -21,10 +21,10 @@ Signed-off-by: Chris Coulson 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 644cd2e56f..d3bf02ed8a 100644 +index 3a3b55c1d61..9c6a5f92600 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c -@@ -841,7 +841,7 @@ grub_secureboot_chainloader_unload (void) +@@ -847,7 +847,7 @@ grub_secureboot_chainloader_unload (void) } static grub_err_t @@ -33,7 +33,7 @@ index 644cd2e56f..d3bf02ed8a 100644 { grub_efi_boot_services_t *b; grub_efi_status_t status; -@@ -883,13 +883,23 @@ grub_load_and_start_image(void *boot_image) +@@ -889,13 +889,23 @@ grub_load_and_start_image(void *boot_image) static grub_err_t grub_secureboot_chainloader_boot (void) { @@ -58,7 +58,7 @@ index 644cd2e56f..d3bf02ed8a 100644 grub_loader_unset (); return grub_errno; } -@@ -1091,7 +1101,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -1096,7 +1106,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), } else { @@ -66,4 +66,4 @@ index 644cd2e56f..d3bf02ed8a 100644 + grub_load_image(boot_image); grub_file_close (file); grub_device_close (dev); - grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); + grub_loader_set_ex (grub_chainloader_boot, grub_chainloader_unload, image_handle, 0); diff --git a/0234-net-dns-Don-t-read-past-the-end-of-the-string-we-re-.patch b/0234-net-dns-Don-t-read-past-the-end-of-the-string-we-re-.patch deleted file mode 100644 index ab0d471..0000000 --- a/0234-net-dns-Don-t-read-past-the-end-of-the-string-we-re-.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Mon, 20 Dec 2021 21:55:43 +1100 -Subject: [PATCH] net/dns: Don't read past the end of the string we're checking - against - -I don't really understand what's going on here but fuzzing found -a bug where we read past the end of check_with. That's a C string, -so use grub_strlen() to make sure we don't overread it. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 6a97b3f4b1d5173aa516edc6dedbc63de7306d21) ---- - grub-core/net/dns.c | 19 ++++++++++++++++--- - 1 file changed, 16 insertions(+), 3 deletions(-) - -diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c -index 135faac035..17961a9f18 100644 ---- a/grub-core/net/dns.c -+++ b/grub-core/net/dns.c -@@ -146,11 +146,18 @@ check_name_real (const grub_uint8_t *name_at, const grub_uint8_t *head, - int *length, char *set) - { - const char *readable_ptr = check_with; -+ int readable_len; - const grub_uint8_t *ptr; - char *optr = set; - int bytes_processed = 0; - if (length) - *length = 0; -+ -+ if (readable_ptr != NULL) -+ readable_len = grub_strlen (readable_ptr); -+ else -+ readable_len = 0; -+ - for (ptr = name_at; ptr < tail && bytes_processed < tail - head + 2; ) - { - /* End marker. */ -@@ -172,13 +179,16 @@ check_name_real (const grub_uint8_t *name_at, const grub_uint8_t *head, - ptr = head + (((ptr[0] & 0x3f) << 8) | ptr[1]); - continue; - } -- if (readable_ptr && grub_memcmp (ptr + 1, readable_ptr, *ptr) != 0) -+ if (readable_ptr != NULL && (*ptr > readable_len || grub_memcmp (ptr + 1, readable_ptr, *ptr) != 0)) - return 0; - if (grub_memchr (ptr + 1, 0, *ptr) - || grub_memchr (ptr + 1, '.', *ptr)) - return 0; - if (readable_ptr) -- readable_ptr += *ptr; -+ { -+ readable_ptr += *ptr; -+ readable_len -= *ptr; -+ } - if (readable_ptr && *readable_ptr != '.' && *readable_ptr != 0) - return 0; - bytes_processed += *ptr + 1; -@@ -192,7 +202,10 @@ check_name_real (const grub_uint8_t *name_at, const grub_uint8_t *head, - if (optr) - *optr++ = '.'; - if (readable_ptr && *readable_ptr) -- readable_ptr++; -+ { -+ readable_ptr++; -+ readable_len--; -+ } - ptr += *ptr + 1; - } - return 0; diff --git a/0213-loader-efi-chainloader-simplify-the-loader-state.patch b/0235-loader-efi-chainloader-simplify-the-loader-state.patch similarity index 76% rename from 0213-loader-efi-chainloader-simplify-the-loader-state.patch rename to 0235-loader-efi-chainloader-simplify-the-loader-state.patch index 205124e..d9962f0 100644 --- a/0213-loader-efi-chainloader-simplify-the-loader-state.patch +++ b/0235-loader-efi-chainloader-simplify-the-loader-state.patch @@ -18,14 +18,14 @@ Signed-off-by: Chris Coulson [rharwood: fix unitialized handle and double-frees of file/dev] Signed-off-by: Robbie Harwood --- - grub-core/loader/efi/chainloader.c | 160 +++++++++++++++++++++++-------------- - 1 file changed, 102 insertions(+), 58 deletions(-) + grub-core/loader/efi/chainloader.c | 161 ++++++++++++++++++++++++------------- + 1 file changed, 103 insertions(+), 58 deletions(-) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index d3bf02ed8a..3342492ff1 100644 +index 9c6a5f92600..cbe028cd8af 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c -@@ -48,38 +48,21 @@ GRUB_MOD_LICENSE ("GPLv3+"); +@@ -49,46 +49,30 @@ GRUB_MOD_LICENSE ("GPLv3+"); static grub_dl_t my_mod; @@ -38,7 +38,7 @@ index d3bf02ed8a..3342492ff1 100644 -static grub_ssize_t cmdline_len; -static grub_efi_handle_t dev_handle; --static grub_efi_status_t (*entry_point) (grub_efi_handle_t image_handle, grub_efi_system_table_t *system_table); +-static grub_efi_status_t (__grub_efi_api *entry_point) (grub_efi_handle_t image_handle, grub_efi_system_table_t *system_table); +struct grub_secureboot_chainloader_context { + grub_efi_physical_address_t address; + grub_efi_uintn_t pages; @@ -51,40 +51,41 @@ index d3bf02ed8a..3342492ff1 100644 +static struct grub_secureboot_chainloader_context *sb_context; static grub_err_t --grub_chainloader_unload (void) +-grub_chainloader_unload (void *context) -{ +- grub_efi_loaded_image_t *loaded_image; - grub_efi_boot_services_t *b; - -- b = grub_efi_system_table->boot_services; -- efi_call_1 (b->unload_image, image_handle); -- grub_efi_free_pages (address, pages); +- image_handle = (grub_efi_handle_t) context; +- loaded_image = grub_efi_get_loaded_image (image_handle); +- if (loaded_image != NULL) +- grub_free (loaded_image->load_options); - -- grub_free (file_path); -- grub_free (cmdline); -- cmdline = 0; -- file_path = 0; -- dev_handle = 0; +- b = grub_efi_system_table->boot_services; +- b->unload_image (image_handle); - - grub_dl_unref (my_mod); - return GRUB_ERR_NONE; -} - -static grub_err_t --grub_chainloader_boot (void) +-grub_chainloader_boot (void *context) +grub_start_image (grub_efi_handle_t handle) { grub_efi_boot_services_t *b; grub_efi_status_t status; -@@ -87,7 +70,7 @@ grub_chainloader_boot (void) + grub_efi_uintn_t exit_data_size; grub_efi_char16_t *exit_data = NULL; +- image_handle = (grub_efi_handle_t) context; b = grub_efi_system_table->boot_services; -- status = efi_call_3 (b->start_image, image_handle, &exit_data_size, &exit_data); -+ status = efi_call_3 (b->start_image, handle, &exit_data_size, &exit_data); +- status = b->start_image (image_handle, &exit_data_size, &exit_data); ++ ++ status = b->start_image (handle, &exit_data_size, &exit_data); if (status != GRUB_EFI_SUCCESS) { if (exit_data) -@@ -111,11 +94,37 @@ grub_chainloader_boot (void) +@@ -112,11 +96,37 @@ grub_chainloader_boot (void *context) if (exit_data) grub_efi_free_pool (exit_data); @@ -104,7 +105,7 @@ index d3bf02ed8a..3342492ff1 100644 + grub_free (loaded_image->load_options); + + b = grub_efi_system_table->boot_services; -+ efi_call_1 (b->unload_image, image_handle); ++ b->unload_image (image_handle); + + grub_dl_unref (my_mod); + return GRUB_ERR_NONE; @@ -124,7 +125,7 @@ index d3bf02ed8a..3342492ff1 100644 static grub_err_t copy_file_path (grub_efi_file_path_device_path_t *fp, const char *str, grub_efi_uint16_t len) -@@ -150,7 +159,7 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) +@@ -151,7 +161,7 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) char *dir_start; char *dir_end; grub_size_t size; @@ -133,29 +134,32 @@ index d3bf02ed8a..3342492ff1 100644 dir_start = grub_strchr (filename, ')'); if (! dir_start) -@@ -526,10 +535,12 @@ grub_efi_get_media_file_path (grub_efi_device_path_t *dp) +@@ -527,12 +537,14 @@ 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) +handle_image (struct grub_secureboot_chainloader_context *load_context) { + grub_efi_boot_services_t *b; grub_efi_loaded_image_t *li, li_bak; grub_efi_status_t efi_status; +- char *buffer = NULL; + void *data = (void *)(unsigned long)load_context->address; + grub_efi_uint32_t datasize = load_context->fsize; - void *buffer = NULL; ++ void *buffer = NULL; char *buffer_aligned = NULL; grub_efi_uint32_t i; -@@ -540,6 +551,7 @@ handle_image (void *data, grub_efi_uint32_t datasize) + struct grub_pe32_section_table *section; +@@ -542,6 +554,7 @@ handle_image (void *data, grub_efi_uint32_t datasize) grub_uint32_t buffer_size; int found_entry_point = 0; int rc; + grub_efi_status_t (*entry_point) (grub_efi_handle_t image_handle, grub_efi_system_table_t *system_table); - rc = read_header (data, datasize, &context); - if (rc < 0) -@@ -797,10 +809,10 @@ handle_image (void *data, grub_efi_uint32_t datasize) + b = grub_efi_system_table->boot_services; + +@@ -801,10 +814,10 @@ handle_image (void *data, grub_efi_uint32_t datasize) grub_memcpy (&li_bak, li, sizeof (grub_efi_loaded_image_t)); li->image_base = buffer_aligned; li->image_size = context.image_size; @@ -170,21 +174,23 @@ index d3bf02ed8a..3342492ff1 100644 if (!li->file_path) { grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching file path found"); -@@ -829,19 +841,22 @@ error_exit: +@@ -832,22 +845,22 @@ error_exit: static grub_err_t grub_secureboot_chainloader_unload (void) { -- grub_efi_free_pages (address, pages); +- grub_efi_boot_services_t *b; ++ grub_efi_free_pages (sb_context->address, sb_context->pages); ++ grub_free (sb_context->file_path); ++ grub_free (sb_context->cmdline); ++ grub_free (sb_context); + +- b = grub_efi_system_table->boot_services; +- b->free_pages (address, pages); - grub_free (file_path); - grub_free (cmdline); - cmdline = 0; - file_path = 0; - dev_handle = 0; -+ grub_efi_free_pages (sb_context->address, sb_context->pages); -+ grub_free (sb_context->file_path); -+ grub_free (sb_context->cmdline); -+ grub_free (sb_context); -+ + sb_context = 0; grub_dl_unref (my_mod); @@ -200,16 +206,16 @@ index d3bf02ed8a..3342492ff1 100644 { grub_efi_boot_services_t *b; grub_efi_status_t status; -@@ -850,7 +865,7 @@ grub_load_image(void *boot_image) +@@ -856,7 +869,7 @@ grub_load_image(void *boot_image) b = grub_efi_system_table->boot_services; - status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, file_path, -- boot_image, fsize, &image_handle); -+ boot_image, image_size, image_handle_out); + status = b->load_image (0, grub_efi_image_handle, file_path, +- boot_image, fsize, &image_handle); ++ boot_image, image_size, image_handle_out); if (status != GRUB_EFI_SUCCESS) { if (status == GRUB_EFI_OUT_OF_RESOURCES) -@@ -863,7 +878,7 @@ grub_load_image(void *boot_image) +@@ -869,7 +882,7 @@ grub_load_image(void *boot_image) /* 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. */ @@ -218,7 +224,7 @@ index d3bf02ed8a..3342492ff1 100644 if (! loaded_image) { grub_error (GRUB_ERR_BAD_OS, "no loaded image available"); -@@ -885,20 +900,25 @@ grub_secureboot_chainloader_boot (void) +@@ -891,20 +904,25 @@ grub_secureboot_chainloader_boot (void) { grub_efi_boot_services_t *b; int rc; @@ -244,15 +250,15 @@ index d3bf02ed8a..3342492ff1 100644 b = grub_efi_system_table->boot_services; - efi_call_1 (b->unload_image, image_handle); -+ efi_call_1 (b->unload_image, handle); ++ b->unload_image (handle); grub_loader_unset (); return grub_errno; -@@ -913,9 +933,15 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -919,9 +937,15 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), grub_efi_boot_services_t *b; grub_device_t dev = 0; grub_device_t orig_dev = 0; -- grub_efi_device_path_t *dp = 0; +- grub_efi_device_path_t *dp = NULL; + grub_efi_device_path_t *dp = 0, *file_path = 0; char *filename; void *boot_image = 0; @@ -263,22 +269,9 @@ index d3bf02ed8a..3342492ff1 100644 + grub_ssize_t cmdline_len = 0; + grub_efi_handle_t dev_handle = 0; - if (argc == 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -@@ -923,12 +949,6 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - - grub_dl_ref (my_mod); - -- /* Initialize some global variables. */ -- address = 0; -- image_handle = 0; -- file_path = 0; -- dev_handle = 0; -- - b = grub_efi_system_table->boot_services; - - if (argc > 1) -@@ -1093,17 +1113,35 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + file_path = NULL; + address = 0; +@@ -1098,18 +1122,36 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) { @@ -307,24 +300,27 @@ index d3bf02ed8a..3342492ff1 100644 + cmdline_len, &image_handle); grub_file_close (file); grub_device_close (dev); +- grub_loader_set_ex (grub_chainloader_boot, grub_chainloader_unload, image_handle, 0); + + /* We're finished with the source image buffer and file path now */ -+ efi_call_2 (b->free_pages, address, pages); ++ b->free_pages (address, pages); + grub_free (file_path); + - grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); ++ grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); return 0; -@@ -1130,6 +1168,12 @@ fail: + } +@@ -1137,8 +1179,11 @@ fail: if (cmdline) grub_free (cmdline); +- if (image_handle != NULL) +- b->unload_image (image_handle); + if (image_handle != 0) + { -+ efi_call_1 (b->unload_image, image_handle); ++ b->unload_image (image_handle); + image_handle = 0; + } -+ + grub_dl_unref (my_mod); - return grub_errno; diff --git a/0235-net-tftp-Prevent-a-UAF-and-double-free-from-a-failed.patch b/0235-net-tftp-Prevent-a-UAF-and-double-free-from-a-failed.patch deleted file mode 100644 index 3ff7b6b..0000000 --- a/0235-net-tftp-Prevent-a-UAF-and-double-free-from-a-failed.patch +++ /dev/null @@ -1,112 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Mon, 20 Sep 2021 01:12:24 +1000 -Subject: [PATCH] net/tftp: Prevent a UAF and double-free from a failed seek - -A malicious tftp server can cause UAFs and a double free. - -An attempt to read from a network file is handled by grub_net_fs_read(). If -the read is at an offset other than the current offset, grub_net_seek_real() -is invoked. - -In grub_net_seek_real(), if a backwards seek cannot be satisfied from the -currently received packets, and the underlying transport does not provide -a seek method, then grub_net_seek_real() will close and reopen the network -protocol layer. - -For tftp, the ->close() call goes to tftp_close() and frees the tftp_data_t -file->data. The file->data pointer is not nulled out after the free. - -If the ->open() call fails, the file->data will not be reallocated and will -continue point to a freed memory block. This could happen from a server -refusing to send the requisite ack to the new tftp request, for example. - -The seek and the read will then fail, but the grub_file continues to exist: -the failed seek does not necessarily cause the entire file to be thrown -away (e.g. where the file is checked to see if it is gzipped/lzio/xz/etc., -a read failure is interpreted as a decompressor passing on the file, not as -an invalidation of the entire grub_file_t structure). - -This means subsequent attempts to read or seek the file will use the old -file->data after free. Eventually, the file will be close()d again and -file->data will be freed again. - -Mark a net_fs file that doesn't reopen as broken. Do not permit read() or -close() on a broken file (seek is not exposed directly to the file API - -it is only called as part of read, so this blocks seeks as well). - -As an additional defence, null out the ->data pointer if tftp_open() fails. -That would have lead to a simple null pointer dereference rather than -a mess of UAFs. - -This may affect other protocols, I haven't checked. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit dada1dda695439bb55b2848dddc2d89843552f81) ---- - grub-core/net/net.c | 11 +++++++++-- - grub-core/net/tftp.c | 1 + - include/grub/net.h | 1 + - 3 files changed, 11 insertions(+), 2 deletions(-) - -diff --git a/grub-core/net/net.c b/grub-core/net/net.c -index 55aed92722..1001c611d1 100644 ---- a/grub-core/net/net.c -+++ b/grub-core/net/net.c -@@ -1625,7 +1625,8 @@ grub_net_fs_close (grub_file_t file) - grub_netbuff_free (file->device->net->packs.first->nb); - grub_net_remove_packet (file->device->net->packs.first); - } -- file->device->net->protocol->close (file); -+ if (!file->device->net->broken) -+ file->device->net->protocol->close (file); - grub_free (file->device->net->name); - return GRUB_ERR_NONE; - } -@@ -1847,7 +1848,10 @@ grub_net_seek_real (struct grub_file *file, grub_off_t offset) - file->device->net->stall = 0; - err = file->device->net->protocol->open (file, file->device->net->name); - if (err) -- return err; -+ { -+ file->device->net->broken = 1; -+ return err; -+ } - grub_net_fs_read_real (file, NULL, offset); - return grub_errno; - } -@@ -1856,6 +1860,9 @@ grub_net_seek_real (struct grub_file *file, grub_off_t offset) - static grub_ssize_t - grub_net_fs_read (grub_file_t file, char *buf, grub_size_t len) - { -+ if (file->device->net->broken) -+ return -1; -+ - if (file->offset != file->device->net->offset) - { - grub_err_t err; -diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c -index d54b13f09f..788ad1dc44 100644 ---- a/grub-core/net/tftp.c -+++ b/grub-core/net/tftp.c -@@ -408,6 +408,7 @@ tftp_open (struct grub_file *file, const char *filename) - { - grub_net_udp_close (data->sock); - grub_free (data); -+ file->data = NULL; - return grub_errno; - } - -diff --git a/include/grub/net.h b/include/grub/net.h -index 42af7de250..9e4898cc6b 100644 ---- a/include/grub/net.h -+++ b/include/grub/net.h -@@ -280,6 +280,7 @@ typedef struct grub_net - grub_fs_t fs; - int eof; - int stall; -+ int broken; - } *grub_net_t; - - extern grub_net_t (*EXPORT_VAR (grub_net_open)) (const char *name); diff --git a/0215-loader-efi-chainloader-Use-grub_loader_set_ex.patch b/0236-loader-efi-chainloader-Use-grub_loader_set_ex.patch similarity index 79% rename from 0215-loader-efi-chainloader-Use-grub_loader_set_ex.patch rename to 0236-loader-efi-chainloader-Use-grub_loader_set_ex.patch index fc15b84..ce98152 100644 --- a/0215-loader-efi-chainloader-Use-grub_loader_set_ex.patch +++ b/0236-loader-efi-chainloader-Use-grub_loader_set_ex.patch @@ -12,14 +12,14 @@ Signed-off-by: Chris Coulson [rharwood: context sludge from other change] Signed-off-by: Robbie Harwood --- - grub-core/loader/efi/chainloader.c | 38 ++++++++++++++++++++++---------------- - 1 file changed, 22 insertions(+), 16 deletions(-) + grub-core/loader/efi/chainloader.c | 39 +++++++++++++++++++++----------------- + 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index 3342492ff1..fb874f1855 100644 +index cbe028cd8af..b40acdeda80 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c -@@ -48,8 +48,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); +@@ -49,8 +49,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); static grub_dl_t my_mod; @@ -28,7 +28,7 @@ index 3342492ff1..fb874f1855 100644 struct grub_secureboot_chainloader_context { grub_efi_physical_address_t address; grub_efi_uintn_t pages; -@@ -59,7 +57,6 @@ struct grub_secureboot_chainloader_context { +@@ -60,7 +58,6 @@ struct grub_secureboot_chainloader_context { grub_ssize_t cmdline_len; grub_efi_handle_t dev_handle; }; @@ -36,7 +36,7 @@ index 3342492ff1..fb874f1855 100644 static grub_err_t grub_start_image (grub_efi_handle_t handle) -@@ -98,11 +95,14 @@ grub_start_image (grub_efi_handle_t handle) +@@ -100,11 +97,14 @@ grub_start_image (grub_efi_handle_t handle) } static grub_err_t @@ -52,7 +52,7 @@ index 3342492ff1..fb874f1855 100644 loaded_image = grub_efi_get_loaded_image (image_handle); if (loaded_image != NULL) grub_free (loaded_image->load_options); -@@ -115,10 +115,12 @@ grub_chainloader_unload (void) +@@ -117,10 +117,12 @@ grub_chainloader_unload (void) } static grub_err_t @@ -66,7 +66,7 @@ index 3342492ff1..fb874f1855 100644 err = grub_start_image (image_handle); grub_loader_unset (); -@@ -839,15 +841,17 @@ error_exit: +@@ -843,15 +845,17 @@ error_exit: } static grub_err_t @@ -87,7 +87,7 @@ index 3342492ff1..fb874f1855 100644 grub_dl_unref (my_mod); return GRUB_ERR_NONE; } -@@ -896,12 +900,15 @@ grub_load_image(grub_efi_device_path_t *file_path, void *boot_image, +@@ -900,12 +904,15 @@ grub_load_image(grub_efi_device_path_t *file_path, void *boot_image, } static grub_err_t @@ -104,16 +104,16 @@ index 3342492ff1..fb874f1855 100644 rc = handle_image (sb_context); if (rc == 0) { -@@ -942,6 +949,8 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -946,6 +953,8 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), grub_efi_char16_t *cmdline = 0; grub_ssize_t cmdline_len = 0; grub_efi_handle_t dev_handle = 0; + grub_efi_handle_t image_handle = 0; + struct grub_secureboot_chainloader_context *sb_context = 0; - if (argc == 0) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -@@ -1127,8 +1136,8 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + file_path = NULL; + address = 0; +@@ -1136,8 +1145,8 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), grub_file_close (file); grub_device_close (dev); @@ -124,8 +124,8 @@ index 3342492ff1..fb874f1855 100644 return 0; } else -@@ -1142,7 +1151,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), - efi_call_2 (b->free_pages, address, pages); +@@ -1151,7 +1160,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), + b->free_pages (address, pages); grub_free (file_path); - grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); @@ -133,15 +133,16 @@ index 3342492ff1..fb874f1855 100644 return 0; } -@@ -1169,10 +1178,7 @@ fail: +@@ -1179,11 +1188,7 @@ fail: + if (cmdline) grub_free (cmdline); - if (image_handle != 0) +- if (image_handle != 0) - { -- efi_call_1 (b->unload_image, image_handle); +- b->unload_image (image_handle); - image_handle = 0; - } -+ efi_call_1 (b->unload_image, image_handle); ++ b->unload_image (image_handle); grub_dl_unref (my_mod); diff --git a/0236-net-tftp-Avoid-a-trivial-UAF.patch b/0236-net-tftp-Avoid-a-trivial-UAF.patch deleted file mode 100644 index 4ec3b56..0000000 --- a/0236-net-tftp-Avoid-a-trivial-UAF.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Tue, 18 Jan 2022 14:29:20 +1100 -Subject: [PATCH] net/tftp: Avoid a trivial UAF - -Under tftp errors, we print a tftp error message from the tftp header. -However, the tftph pointer is a pointer inside nb, the netbuff. Previously, -we were freeing the nb and then dereferencing it. Don't do that, use it -and then free it later. - -This isn't really _bad_ per se, especially as we're single-threaded, but -it trips up fuzzers. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 956f4329cec23e4375182030ca9b2be631a61ba5) ---- - 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 788ad1dc44..a95766dcbd 100644 ---- a/grub-core/net/tftp.c -+++ b/grub-core/net/tftp.c -@@ -251,9 +251,9 @@ tftp_receive (grub_net_udp_socket_t sock __attribute__ ((unused)), - return GRUB_ERR_NONE; - case TFTP_ERROR: - data->have_oack = 1; -- grub_netbuff_free (nb); - grub_error (GRUB_ERR_IO, "%s", tftph->u.err.errmsg); - grub_error_save (&data->save_err); -+ grub_netbuff_free (nb); - return GRUB_ERR_NONE; - default: - grub_netbuff_free (nb); diff --git a/0216-loader-i386-efi-linux-Avoid-a-use-after-free-in-the-.patch b/0237-loader-i386-efi-linux-Avoid-a-use-after-free-in-the-.patch similarity index 93% rename from 0216-loader-i386-efi-linux-Avoid-a-use-after-free-in-the-.patch rename to 0237-loader-i386-efi-linux-Avoid-a-use-after-free-in-the-.patch index b79c78c..4d080a0 100644 --- a/0216-loader-i386-efi-linux-Avoid-a-use-after-free-in-the-.patch +++ b/0237-loader-i386-efi-linux-Avoid-a-use-after-free-in-the-.patch @@ -17,10 +17,10 @@ Signed-off-by: Chris Coulson 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 941df6400b..27bc2aa161 100644 +index 1dd787081f2..8f7eddaa962 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c -@@ -465,9 +465,6 @@ fail: +@@ -466,9 +466,6 @@ fail: if (file) grub_file_close (file); @@ -30,7 +30,7 @@ index 941df6400b..27bc2aa161 100644 if (grub_errno != GRUB_ERR_NONE) { grub_dl_unref (my_mod); -@@ -483,6 +480,8 @@ fail: +@@ -484,6 +481,8 @@ fail: kernel_free (params, sizeof(*params)); } diff --git a/0237-net-http-Do-not-tear-down-socket-if-it-s-already-bee.patch b/0237-net-http-Do-not-tear-down-socket-if-it-s-already-bee.patch deleted file mode 100644 index 186f0c3..0000000 --- a/0237-net-http-Do-not-tear-down-socket-if-it-s-already-bee.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Tue, 1 Mar 2022 23:14:15 +1100 -Subject: [PATCH] net/http: Do not tear down socket if it's already been torn - down - -It's possible for data->sock to get torn down in tcp error handling. -If we unconditionally tear it down again we will end up doing writes -to an offset of the NULL pointer when we go to tear it down again. - -Detect if it has been torn down and don't do it again. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit ec233d3ecf995293304de443579aab5c46c49e85) ---- - grub-core/net/http.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index 7f878b5615..19cb8768e3 100644 ---- a/grub-core/net/http.c -+++ b/grub-core/net/http.c -@@ -427,7 +427,7 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) - return err; - } - -- for (i = 0; !data->headers_recv && i < 100; i++) -+ for (i = 0; data->sock && !data->headers_recv && i < 100; i++) - { - grub_net_tcp_retransmit (); - grub_net_poll_cards (300, &data->headers_recv); -@@ -435,7 +435,8 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial) - - if (!data->headers_recv) - { -- grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT); -+ if (data->sock) -+ grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT); - if (data->err) - { - char *str = data->errmsg; diff --git a/0217-loader-i386-efi-linux-Use-grub_loader_set_ex.patch b/0238-loader-i386-efi-linux-Use-grub_loader_set_ex.patch similarity index 94% rename from 0217-loader-i386-efi-linux-Use-grub_loader_set_ex.patch rename to 0238-loader-i386-efi-linux-Use-grub_loader_set_ex.patch index 1a129db..428c498 100644 --- a/0217-loader-i386-efi-linux-Use-grub_loader_set_ex.patch +++ b/0238-loader-i386-efi-linux-Use-grub_loader_set_ex.patch @@ -18,11 +18,11 @@ Signed-off-by: Chris Coulson [rharwood/pjones: set kernel_size in context] Signed-off-by: Robbie Harwood --- - grub-core/loader/i386/efi/linux.c | 146 +++++++++++++++++++++++--------------- - 1 file changed, 87 insertions(+), 59 deletions(-) + grub-core/loader/i386/efi/linux.c | 149 ++++++++++++++++++++++---------------- + 1 file changed, 88 insertions(+), 61 deletions(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 27bc2aa161..e3c2d6fe0b 100644 +index 8f7eddaa962..3aaa2e9f175 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -34,13 +34,19 @@ @@ -154,17 +154,19 @@ index 27bc2aa161..e3c2d6fe0b 100644 for (i = 0; i < nfiles; i++) { -@@ -261,8 +277,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), +@@ -261,9 +277,9 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_file_close (files[i]); grub_free (files); - if (initrd_mem && grub_errno) - grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)initrd_mem, +- BYTES_TO_PAGES(size)); + if (context->initrd_mem && grub_errno) + grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)context->initrd_mem, - BYTES_TO_PAGES(size)); ++ BYTES_TO_PAGES(size)); return grub_errno; + } @@ -277,6 +293,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_ssize_t start, filelen; void *kernel = NULL; @@ -178,7 +180,7 @@ index 27bc2aa161..e3c2d6fe0b 100644 grub_dl_ref (my_mod); -@@ -390,27 +412,27 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -390,28 +412,27 @@ 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"); @@ -199,6 +201,7 @@ index 27bc2aa161..e3c2d6fe0b 100644 GRUB_VERIFY_KERNEL_CMDLINE); - grub_dprintf ("linux", "cmdline:%s\n", linux_cmdline); +- + grub_dprintf ("linux", "cmdline:%s\n", cmdline); grub_dprintf ("linux", "setting lh->cmd_line_ptr to 0x%08x\n", - LOW_U32(linux_cmdline)); @@ -217,7 +220,7 @@ index 27bc2aa161..e3c2d6fe0b 100644 } #endif -@@ -435,16 +457,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -436,16 +457,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), } max_addresses[1].addr = GRUB_EFI_MAX_ALLOCATION_ADDRESS; max_addresses[2].addr = GRUB_EFI_MAX_ALLOCATION_ADDRESS; @@ -236,7 +239,7 @@ index 27bc2aa161..e3c2d6fe0b 100644 grub_dprintf ("linux", "setting lh->code32_start to 0x%08x\n", LOW_U32(kernel_mem)); lh->code32_start = LOW_U32(kernel_mem); -@@ -461,33 +480,42 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -462,33 +480,42 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), "setting lh->ext_loader_{type,ver} = {0x%02x,0x%02x}\n", params->ext_loader_type, params->ext_loader_ver); diff --git a/0238-net-http-Fix-OOB-write-for-split-http-headers.patch b/0238-net-http-Fix-OOB-write-for-split-http-headers.patch deleted file mode 100644 index f22960b..0000000 --- a/0238-net-http-Fix-OOB-write-for-split-http-headers.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Tue, 8 Mar 2022 18:17:03 +1100 -Subject: [PATCH] net/http: Fix OOB write for split http headers - -GRUB has special code for handling an http header that is split -across two packets. - -The code tracks the end of line by looking for a "\n" byte. The -code for split headers has always advanced the pointer just past the -end of the line, whereas the code that handles unsplit headers does -not advance the pointer. This extra advance causes the length to be -one greater, which breaks an assumption in parse_line(), leading to -it writing a NUL byte one byte past the end of the buffer where we -reconstruct the line from the two packets. - -It's conceivable that an attacker controlled set of packets could -cause this to zero out the first byte of the "next" pointer of the -grub_mm_region structure following the current_line buffer. - -Do not advance the pointer in the split header case. - -Fixes: CVE-2022-28734 - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit e9fb459638811c12b0989dbf64e3e124974ef617) ---- - grub-core/net/http.c | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) - -diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index 19cb8768e3..58546739a2 100644 ---- a/grub-core/net/http.c -+++ b/grub-core/net/http.c -@@ -193,9 +193,7 @@ http_receive (grub_net_tcp_socket_t sock __attribute__ ((unused)), - int have_line = 1; - char *t; - ptr = grub_memchr (nb->data, '\n', nb->tail - nb->data); -- if (ptr) -- ptr++; -- else -+ if (ptr == NULL) - { - have_line = 0; - ptr = (char *) nb->tail; diff --git a/0218-loader-i386-efi-linux-Fix-a-memory-leak-in-the-initr.patch b/0239-loader-i386-efi-linux-Fix-a-memory-leak-in-the-initr.patch similarity index 98% rename from 0218-loader-i386-efi-linux-Fix-a-memory-leak-in-the-initr.patch rename to 0239-loader-i386-efi-linux-Fix-a-memory-leak-in-the-initr.patch index 51953fd..e3b44f1 100644 --- a/0218-loader-i386-efi-linux-Fix-a-memory-leak-in-the-initr.patch +++ b/0239-loader-i386-efi-linux-Fix-a-memory-leak-in-the-initr.patch @@ -14,7 +14,7 @@ Signed-off-by: Chris Coulson 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index e3c2d6fe0b..9e5c11ac69 100644 +index 3aaa2e9f175..71c7ed6a76e 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -209,6 +209,7 @@ grub_cmd_initrd (grub_command_t cmd, int argc, char *argv[]) diff --git a/0239-net-http-Error-out-on-headers-with-LF-without-CR.patch b/0239-net-http-Error-out-on-headers-with-LF-without-CR.patch deleted file mode 100644 index b73c169..0000000 --- a/0239-net-http-Error-out-on-headers-with-LF-without-CR.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Tue, 8 Mar 2022 19:04:40 +1100 -Subject: [PATCH] net/http: Error out on headers with LF without CR - -In a similar vein to the previous patch, parse_line() would write -a NUL byte past the end of the buffer if there was an HTTP header -with a LF rather than a CRLF. - -RFC-2616 says: - - Many HTTP/1.1 header field values consist of words separated by LWS - or special characters. These special characters MUST be in a quoted - string to be used within a parameter value (as defined in section 3.6). - -We don't support quoted sections or continuation lines, etc. - -If we see an LF that's not part of a CRLF, bail out. - -Fixes: CVE-2022-28734 - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit d232ad41ac4979a9de4d746e5fdff9caf0e303de) ---- - grub-core/net/http.c | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/grub-core/net/http.c b/grub-core/net/http.c -index 58546739a2..57d2721719 100644 ---- a/grub-core/net/http.c -+++ b/grub-core/net/http.c -@@ -69,7 +69,15 @@ parse_line (grub_file_t file, http_data_t data, char *ptr, grub_size_t len) - char *end = ptr + len; - while (end > ptr && *(end - 1) == '\r') - end--; -+ -+ /* LF without CR. */ -+ if (end == ptr + len) -+ { -+ data->errmsg = grub_strdup (_("invalid HTTP header - LF without CR")); -+ return GRUB_ERR_NONE; -+ } - *end = 0; -+ - /* Trailing CRLF. */ - if (data->in_chunk_len == 1) - { diff --git a/0253-EFI-allocate-kernel-in-EFI_RUNTIME_SERVICES_CODE-ins.patch b/0240-EFI-allocate-kernel-in-EFI_RUNTIME_SERVICES_CODE-ins.patch similarity index 98% rename from 0253-EFI-allocate-kernel-in-EFI_RUNTIME_SERVICES_CODE-ins.patch rename to 0240-EFI-allocate-kernel-in-EFI_RUNTIME_SERVICES_CODE-ins.patch index c6688cd..ed35915 100644 --- a/0253-EFI-allocate-kernel-in-EFI_RUNTIME_SERVICES_CODE-ins.patch +++ b/0240-EFI-allocate-kernel-in-EFI_RUNTIME_SERVICES_CODE-ins.patch @@ -19,7 +19,7 @@ Signed-off-by: Robbie Harwood 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 9e5c11ac69..92b2fb5091 100644 +index 71c7ed6a76e..3ec9bb09c52 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -86,7 +86,9 @@ kernel_free(void *addr, grub_efi_uintn_t size) diff --git a/0240-fs-f2fs-Do-not-read-past-the-end-of-nat-journal-entr.patch b/0240-fs-f2fs-Do-not-read-past-the-end-of-nat-journal-entr.patch deleted file mode 100644 index 79df1c2..0000000 --- a/0240-fs-f2fs-Do-not-read-past-the-end-of-nat-journal-entr.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Sudhakar Kuppusamy -Date: Wed, 6 Apr 2022 18:03:37 +0530 -Subject: [PATCH] fs/f2fs: Do not read past the end of nat journal entries - -A corrupt f2fs file system could specify a nat journal entry count -that is beyond the maximum NAT_JOURNAL_ENTRIES. - -Check if the specified nat journal entry count before accessing the -array, and throw an error if it is too large. - -Signed-off-by: Sudhakar Kuppusamy -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit a3988cb3f0a108dd67ac127a79a4c8479d23334e) ---- - grub-core/fs/f2fs.c | 21 ++++++++++++++------- - 1 file changed, 14 insertions(+), 7 deletions(-) - -diff --git a/grub-core/fs/f2fs.c b/grub-core/fs/f2fs.c -index 8a9992ca9e..63702214b0 100644 ---- a/grub-core/fs/f2fs.c -+++ b/grub-core/fs/f2fs.c -@@ -632,23 +632,27 @@ get_nat_journal (struct grub_f2fs_data *data) - return err; - } - --static grub_uint32_t --get_blkaddr_from_nat_journal (struct grub_f2fs_data *data, grub_uint32_t nid) -+static grub_err_t -+get_blkaddr_from_nat_journal (struct grub_f2fs_data *data, grub_uint32_t nid, -+ grub_uint32_t *blkaddr) - { - grub_uint16_t n = grub_le_to_cpu16 (data->nat_j.n_nats); -- grub_uint32_t blkaddr = 0; - grub_uint16_t i; - -+ if (n >= NAT_JOURNAL_ENTRIES) -+ return grub_error (GRUB_ERR_BAD_FS, -+ "invalid number of nat journal entries"); -+ - 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); -+ *blkaddr = grub_le_to_cpu32 (data->nat_j.entries[i].ne.block_addr); - break; - } - } - -- return blkaddr; -+ return GRUB_ERR_NONE; - } - - static grub_uint32_t -@@ -656,10 +660,13 @@ 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_uint32_t blkaddr = 0; - grub_err_t err; - -- blkaddr = get_blkaddr_from_nat_journal (data, nid); -+ err = get_blkaddr_from_nat_journal (data, nid, &blkaddr); -+ if (err != GRUB_ERR_NONE) -+ return 0; -+ - if (blkaddr) - return blkaddr; - diff --git a/0263-efi-use-enumerated-array-positions-for-our-allocatio.patch b/0241-efi-use-enumerated-array-positions-for-our-allocatio.patch similarity index 95% rename from 0263-efi-use-enumerated-array-positions-for-our-allocatio.patch rename to 0241-efi-use-enumerated-array-positions-for-our-allocatio.patch index 206e3a6..24f9131 100644 --- a/0263-efi-use-enumerated-array-positions-for-our-allocatio.patch +++ b/0241-efi-use-enumerated-array-positions-for-our-allocatio.patch @@ -18,7 +18,7 @@ Signed-off-by: Peter Jones 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 91ae274299..8daa070132 100644 +index 3ec9bb09c52..ef5875b7697 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -60,17 +60,26 @@ struct allocation_choice { @@ -54,7 +54,7 @@ index 91ae274299..8daa070132 100644 }; static struct allocation_choice saved_addresses[4]; -@@ -405,7 +414,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -388,7 +397,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (lh->xloadflags & LINUX_XLF_CAN_BE_LOADED_ABOVE_4G) { grub_dprintf ("linux", "Loading kernel above 4GB is supported; enabling.\n"); @@ -63,7 +63,7 @@ index 91ae274299..8daa070132 100644 } else { -@@ -478,11 +487,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -461,11 +470,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), 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) { diff --git a/0241-fs-f2fs-Do-not-read-past-the-end-of-nat-bitmap.patch b/0241-fs-f2fs-Do-not-read-past-the-end-of-nat-bitmap.patch deleted file mode 100644 index 855e882..0000000 --- a/0241-fs-f2fs-Do-not-read-past-the-end-of-nat-bitmap.patch +++ /dev/null @@ -1,132 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Sudhakar Kuppusamy -Date: Wed, 6 Apr 2022 18:49:09 +0530 -Subject: [PATCH] fs/f2fs: Do not read past the end of nat bitmap - -A corrupt f2fs filesystem could have a block offset or a bitmap -offset that would cause us to read beyond the bounds of the nat -bitmap. - -Introduce the nat_bitmap_size member in grub_f2fs_data which holds -the size of nat bitmap. - -Set the size when loading the nat bitmap in nat_bitmap_ptr(), and -catch when an invalid offset would create a pointer past the end of -the allocated space. - -Check against the bitmap size in grub_f2fs_test_bit() test bit to avoid -reading past the end of the nat bitmap. - -Signed-off-by: Sudhakar Kuppusamy -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 62d63d5e38c67a6e349148bf7cb87c560e935a7e) ---- - grub-core/fs/f2fs.c | 33 +++++++++++++++++++++++++++------ - 1 file changed, 27 insertions(+), 6 deletions(-) - -diff --git a/grub-core/fs/f2fs.c b/grub-core/fs/f2fs.c -index 63702214b0..8898b235e0 100644 ---- a/grub-core/fs/f2fs.c -+++ b/grub-core/fs/f2fs.c -@@ -122,6 +122,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #define F2FS_INLINE_DOTS 0x10 /* File having implicit dot dentries. */ - - #define MAX_VOLUME_NAME 512 -+#define MAX_NAT_BITMAP_SIZE 3900 - - enum FILE_TYPE - { -@@ -183,7 +184,7 @@ struct grub_f2fs_checkpoint - 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_uint8_t sit_nat_version_bitmap[MAX_NAT_BITMAP_SIZE]; - grub_uint32_t checksum; - } GRUB_PACKED; - -@@ -302,6 +303,7 @@ struct grub_f2fs_data - - struct grub_f2fs_nat_journal nat_j; - char *nat_bitmap; -+ grub_uint32_t nat_bitmap_size; - - grub_disk_t disk; - struct grub_f2fs_node *inode; -@@ -377,15 +379,20 @@ sum_blk_addr (struct grub_f2fs_data *data, int base, int type) - } - - static void * --nat_bitmap_ptr (struct grub_f2fs_data *data) -+nat_bitmap_ptr (struct grub_f2fs_data *data, grub_uint32_t *nat_bitmap_size) - { - struct grub_f2fs_checkpoint *ckpt = &data->ckpt; - grub_uint32_t offset; -+ *nat_bitmap_size = MAX_NAT_BITMAP_SIZE; - - 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); -+ if (offset >= MAX_NAT_BITMAP_SIZE) -+ return NULL; -+ -+ *nat_bitmap_size = *nat_bitmap_size - offset; - - return ckpt->sit_nat_version_bitmap + offset; - } -@@ -438,11 +445,15 @@ grub_f2fs_crc_valid (grub_uint32_t blk_crc, void *buf, const grub_uint32_t len) - } - - static int --grub_f2fs_test_bit (grub_uint32_t nr, const char *p) -+grub_f2fs_test_bit (grub_uint32_t nr, const char *p, grub_uint32_t len) - { - int mask; -+ grub_uint32_t shifted_nr = (nr >> 3); - -- p += (nr >> 3); -+ if (shifted_nr >= len) -+ return -1; -+ -+ p += shifted_nr; - mask = 1 << (7 - (nr & 0x07)); - - return mask & *p; -@@ -662,6 +673,7 @@ get_node_blkaddr (struct grub_f2fs_data *data, grub_uint32_t nid) - grub_uint32_t seg_off, block_off, entry_off, block_addr; - grub_uint32_t blkaddr = 0; - grub_err_t err; -+ int result_bit; - - err = get_blkaddr_from_nat_journal (data, nid, &blkaddr); - if (err != GRUB_ERR_NONE) -@@ -682,8 +694,15 @@ get_node_blkaddr (struct grub_f2fs_data *data, grub_uint32_t nid) - ((seg_off * data->blocks_per_seg) << 1) + - (block_off & (data->blocks_per_seg - 1)); - -- if (grub_f2fs_test_bit (block_off, data->nat_bitmap)) -+ result_bit = grub_f2fs_test_bit (block_off, data->nat_bitmap, -+ data->nat_bitmap_size); -+ if (result_bit > 0) - block_addr += data->blocks_per_seg; -+ else if (result_bit == -1) -+ { -+ grub_free (nat_block); -+ return 0; -+ } - - err = grub_f2fs_block_read (data, block_addr, nat_block); - if (err) -@@ -833,7 +852,9 @@ grub_f2fs_mount (grub_disk_t disk) - if (err) - goto fail; - -- data->nat_bitmap = nat_bitmap_ptr (data); -+ data->nat_bitmap = nat_bitmap_ptr (data, &data->nat_bitmap_size); -+ if (data->nat_bitmap == NULL) -+ goto fail; - - err = get_nat_journal (data); - if (err) diff --git a/0264-efi-split-allocation-policy-for-kernel-vs-initrd-mem.patch b/0242-efi-split-allocation-policy-for-kernel-vs-initrd-mem.patch similarity index 94% rename from 0264-efi-split-allocation-policy-for-kernel-vs-initrd-mem.patch rename to 0242-efi-split-allocation-policy-for-kernel-vs-initrd-mem.patch index d25cf30..20f3c66 100644 --- a/0264-efi-split-allocation-policy-for-kernel-vs-initrd-mem.patch +++ b/0242-efi-split-allocation-policy-for-kernel-vs-initrd-mem.patch @@ -18,7 +18,7 @@ Signed-off-by: Peter Jones 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 8daa070132..e6b8998e5e 100644 +index ef5875b7697..1d7ced3d1f8 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -55,7 +55,14 @@ struct grub_linuxefi_context { @@ -85,7 +85,7 @@ index 8daa070132..e6b8998e5e 100644 /* * 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 -@@ -261,7 +276,8 @@ grub_cmd_initrd (grub_command_t cmd, int argc, char *argv[]) +@@ -253,7 +268,8 @@ grub_cmd_initrd (grub_command_t cmd, int argc, char *argv[]) } } @@ -95,7 +95,7 @@ index 8daa070132..e6b8998e5e 100644 N_("can't allocate initrd")); if (initrd_mem == NULL) goto fail; -@@ -422,7 +438,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -405,7 +421,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), } #endif @@ -105,7 +105,7 @@ index 8daa070132..e6b8998e5e 100644 "cannot allocate kernel parameters"); if (!params) goto fail; -@@ -445,7 +462,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -428,7 +445,7 @@ 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"); @@ -114,7 +114,7 @@ index 8daa070132..e6b8998e5e 100644 GRUB_EFI_RUNTIME_SERVICES_DATA, N_("can't allocate cmdline")); if (!cmdline) -@@ -493,7 +510,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -476,7 +493,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), max_addresses[KERNEL_4G_LIMIT].addr = GRUB_EFI_MAX_ALLOCATION_ADDRESS; max_addresses[KERNEL_NO_LIMIT].addr = GRUB_EFI_MAX_ALLOCATION_ADDRESS; kernel_size = lh->init_size; diff --git a/0242-fs-f2fs-Do-not-copy-file-names-that-are-too-long.patch b/0242-fs-f2fs-Do-not-copy-file-names-that-are-too-long.patch deleted file mode 100644 index 0553d60..0000000 --- a/0242-fs-f2fs-Do-not-copy-file-names-that-are-too-long.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Sudhakar Kuppusamy -Date: Wed, 6 Apr 2022 18:17:43 +0530 -Subject: [PATCH] fs/f2fs: Do not copy file names that are too long - -A corrupt f2fs file system might specify a name length which is greater -than the maximum name length supported by the GRUB f2fs driver. - -We will allocate enough memory to store the overly long name, but there -are only F2FS_NAME_LEN bytes in the source, so we would read past the end -of the source. - -While checking directory entries, do not copy a file name with an invalid -length. - -Signed-off-by: Sudhakar Kuppusamy -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 9a891f638509e031d322c94e3cbcf38d36f3993a) ---- - grub-core/fs/f2fs.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/grub-core/fs/f2fs.c b/grub-core/fs/f2fs.c -index 8898b235e0..df6beb544c 100644 ---- a/grub-core/fs/f2fs.c -+++ b/grub-core/fs/f2fs.c -@@ -1003,6 +1003,10 @@ grub_f2fs_check_dentries (struct grub_f2fs_dir_iter_ctx *ctx) - - ftype = ctx->dentry[i].file_type; - name_len = grub_le_to_cpu16 (ctx->dentry[i].name_len); -+ -+ if (name_len >= F2FS_NAME_LEN) -+ return 0; -+ - filename = grub_malloc (name_len + 1); - if (!filename) - return 0; diff --git a/0265-efi-allocate-the-initrd-within-the-bounds-expressed-.patch b/0243-efi-allocate-the-initrd-within-the-bounds-expressed-.patch similarity index 90% rename from 0265-efi-allocate-the-initrd-within-the-bounds-expressed-.patch rename to 0243-efi-allocate-the-initrd-within-the-bounds-expressed-.patch index 47e31e2..922088b 100644 --- a/0265-efi-allocate-the-initrd-within-the-bounds-expressed-.patch +++ b/0243-efi-allocate-the-initrd-within-the-bounds-expressed-.patch @@ -20,10 +20,10 @@ Signed-off-by: Peter Jones 1 file changed, 6 insertions(+) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index e6b8998e5e..d003b474ee 100644 +index 1d7ced3d1f8..a798da334ab 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c -@@ -190,6 +190,8 @@ grub_linuxefi_unload (void *data) +@@ -182,6 +182,8 @@ grub_linuxefi_unload (void *data) cmd_initrdefi->data = 0; grub_free (context); @@ -32,7 +32,7 @@ index e6b8998e5e..d003b474ee 100644 return GRUB_ERR_NONE; } -@@ -426,11 +428,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -409,11 +411,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), } #endif @@ -46,7 +46,7 @@ index e6b8998e5e..d003b474ee 100644 } else { -@@ -560,6 +564,8 @@ fail: +@@ -542,6 +546,8 @@ fail: grub_dl_unref (my_mod); diff --git a/0243-fs-btrfs-Fix-several-fuzz-issues-with-invalid-dir-it.patch b/0243-fs-btrfs-Fix-several-fuzz-issues-with-invalid-dir-it.patch deleted file mode 100644 index 7ff5821..0000000 --- a/0243-fs-btrfs-Fix-several-fuzz-issues-with-invalid-dir-it.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Darren Kenny -Date: Tue, 29 Mar 2022 10:49:56 +0000 -Subject: [PATCH] fs/btrfs: Fix several fuzz issues with invalid dir item - sizing - -According to the btrfs code in Linux, the structure of a directory item -leaf should be of the form: - - |struct btrfs_dir_item|name|data| - -in GRUB the name len and data len are in the grub_btrfs_dir_item -structure's n and m fields respectively. - -The combined size of the structure, name and data should be less than -the allocated memory, a difference to the Linux kernel's struct -btrfs_dir_item is that the grub_btrfs_dir_item has an extra field for -where the name is stored, so we adjust for that too. - -Signed-off-by: Darren Kenny -Reviewed-by: Daniel Kiper -(cherry picked from commit 6d3f06c0b6a8992b9b1bb0e62af93ac5ff2781f0) -[rharwood: we've an extra variable here] -Signed-off-by: Robbie Harwood ---- - grub-core/fs/btrfs.c | 26 ++++++++++++++++++++++++++ - 1 file changed, 26 insertions(+) - -diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 07c0ff874b..2fcfb738fe 100644 ---- a/grub-core/fs/btrfs.c -+++ b/grub-core/fs/btrfs.c -@@ -2254,6 +2254,7 @@ grub_btrfs_dir (grub_device_t device, const char *path, - grub_uint64_t tree; - grub_uint8_t type; - char *new_path = NULL; -+ grub_size_t est_size = 0; - - if (!data) - return grub_errno; -@@ -2320,6 +2321,18 @@ grub_btrfs_dir (grub_device_t device, const char *path, - break; - } - -+ if (direl == NULL || -+ grub_add (grub_le_to_cpu16 (direl->n), -+ grub_le_to_cpu16 (direl->m), &est_size) || -+ grub_add (est_size, sizeof (*direl), &est_size) || -+ grub_sub (est_size, sizeof (direl->name), &est_size) || -+ est_size > allocated) -+ { -+ grub_errno = GRUB_ERR_OUT_OF_RANGE; -+ r = -grub_errno; -+ goto out; -+ } -+ - for (cdirel = direl; - (grub_uint8_t *) cdirel - (grub_uint8_t *) direl - < (grub_ssize_t) elemsize; -@@ -2330,6 +2343,19 @@ grub_btrfs_dir (grub_device_t device, const char *path, - char c; - struct grub_btrfs_inode inode; - struct grub_dirhook_info info; -+ -+ if (cdirel == NULL || -+ grub_add (grub_le_to_cpu16 (cdirel->n), -+ grub_le_to_cpu16 (cdirel->m), &est_size) || -+ grub_add (est_size, sizeof (*cdirel), &est_size) || -+ grub_sub (est_size, sizeof (cdirel->name), &est_size) || -+ est_size > allocated) -+ { -+ grub_errno = GRUB_ERR_OUT_OF_RANGE; -+ r = -grub_errno; -+ goto out; -+ } -+ - err = grub_btrfs_read_inode (data, &inode, cdirel->key.object_id, - tree); - grub_memset (&info, 0, sizeof (info)); diff --git a/0266-efi-use-EFI_LOADER_-CODE-DATA-for-kernel-and-initrd-.patch b/0244-efi-use-EFI_LOADER_-CODE-DATA-for-kernel-and-initrd-.patch similarity index 87% rename from 0266-efi-use-EFI_LOADER_-CODE-DATA-for-kernel-and-initrd-.patch rename to 0244-efi-use-EFI_LOADER_-CODE-DATA-for-kernel-and-initrd-.patch index 8451dbf..914ad43 100644 --- a/0266-efi-use-EFI_LOADER_-CODE-DATA-for-kernel-and-initrd-.patch +++ b/0244-efi-use-EFI_LOADER_-CODE-DATA-for-kernel-and-initrd-.patch @@ -20,10 +20,10 @@ Signed-off-by: Peter Jones 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index d003b474ee..ac5ef50bdb 100644 +index a798da334ab..03d27c81fd3 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c -@@ -279,7 +279,7 @@ grub_cmd_initrd (grub_command_t cmd, int argc, char *argv[]) +@@ -271,7 +271,7 @@ grub_cmd_initrd (grub_command_t cmd, int argc, char *argv[]) } grub_dprintf ("linux", "Trying to allocate initrd mem\n"); @@ -32,7 +32,7 @@ index d003b474ee..ac5ef50bdb 100644 N_("can't allocate initrd")); if (initrd_mem == NULL) goto fail; -@@ -443,7 +443,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -426,7 +426,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), #endif params = kernel_alloc (KERNEL_MEM, sizeof(*params), @@ -41,7 +41,7 @@ index d003b474ee..ac5ef50bdb 100644 "cannot allocate kernel parameters"); if (!params) goto fail; -@@ -467,7 +467,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -450,7 +450,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_dprintf ("linux", "setting up cmdline\n"); cmdline = kernel_alloc (KERNEL_MEM, lh->cmdline_size + 1, @@ -50,7 +50,7 @@ index d003b474ee..ac5ef50bdb 100644 N_("can't allocate cmdline")); if (!cmdline) goto fail; -@@ -516,7 +516,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -499,7 +499,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), kernel_size = lh->init_size; grub_dprintf ("linux", "Trying to allocate kernel mem\n"); kernel_mem = kernel_alloc (KERNEL_MEM, kernel_size, diff --git a/0244-fs-btrfs-Fix-more-ASAN-and-SEGV-issues-found-with-fu.patch b/0244-fs-btrfs-Fix-more-ASAN-and-SEGV-issues-found-with-fu.patch deleted file mode 100644 index d638c11..0000000 --- a/0244-fs-btrfs-Fix-more-ASAN-and-SEGV-issues-found-with-fu.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Darren Kenny -Date: Tue, 29 Mar 2022 15:52:46 +0000 -Subject: [PATCH] fs/btrfs: Fix more ASAN and SEGV issues found with fuzzing - -The fuzzer is generating btrfs file systems that have chunks with -invalid combinations of stripes and substripes for the given RAID -configurations. - -After examining the Linux kernel fs/btrfs/tree-checker.c code, it -appears that sub-stripes should only be applied to RAID10, and in that -case there should only ever be 2 of them. - -Similarly, RAID single should only have 1 stripe, and RAID1/1C3/1C4 -should have 2. 3 or 4 stripes respectively, which is what redundancy -corresponds. - -Some of the chunks ended up with a size of 0, which grub_malloc() still -returned memory for and in turn generated ASAN errors later when -accessed. - -While it would be possible to specifically limit the number of stripes, -a more correct test was on the combination of the chunk item, and the -number of stripes by the size of the chunk stripe structure in -comparison to the size of the chunk itself. - -Signed-off-by: Darren Kenny -Reviewed-by: Daniel Kiper -(cherry picked from commit 3849647b4b98a4419366708fc4b7f339c6f55ec7) ---- - grub-core/fs/btrfs.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 55 insertions(+) - -diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 2fcfb738fe..0e9b450413 100644 ---- a/grub-core/fs/btrfs.c -+++ b/grub-core/fs/btrfs.c -@@ -941,6 +941,12 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, - return grub_error (GRUB_ERR_BAD_FS, - "couldn't find the chunk descriptor"); - -+ if (!chsize) -+ { -+ grub_dprintf ("btrfs", "zero-size chunk\n"); -+ return grub_error (GRUB_ERR_BAD_FS, -+ "got an invalid zero-size chunk"); -+ } - chunk = grub_malloc (chsize); - if (!chunk) - return grub_errno; -@@ -999,6 +1005,16 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, - stripe_length = grub_divmod64 (grub_le_to_cpu64 (chunk->size), - nstripes, - NULL); -+ -+ /* For single, there should be exactly 1 stripe. */ -+ if (grub_le_to_cpu16 (chunk->nstripes) != 1) -+ { -+ grub_dprintf ("btrfs", "invalid RAID_SINGLE: nstripes != 1 (%u)\n", -+ grub_le_to_cpu16 (chunk->nstripes)); -+ return grub_error (GRUB_ERR_BAD_FS, -+ "invalid RAID_SINGLE: nstripes != 1 (%u)", -+ grub_le_to_cpu16 (chunk->nstripes)); -+ } - if (stripe_length == 0) - stripe_length = 512; - stripen = grub_divmod64 (off, stripe_length, &stripe_offset); -@@ -1018,6 +1034,19 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, - stripen = 0; - stripe_offset = off; - csize = grub_le_to_cpu64 (chunk->size) - off; -+ -+ /* -+ * Redundancy, and substripes only apply to RAID10, and there -+ * should be exactly 2 sub-stripes. -+ */ -+ if (grub_le_to_cpu16 (chunk->nstripes) != redundancy) -+ { -+ grub_dprintf ("btrfs", "invalid RAID1: nstripes != %u (%u)\n", -+ redundancy, grub_le_to_cpu16 (chunk->nstripes)); -+ return grub_error (GRUB_ERR_BAD_FS, -+ "invalid RAID1: nstripes != %u (%u)", -+ redundancy, grub_le_to_cpu16 (chunk->nstripes)); -+ } - break; - } - case GRUB_BTRFS_CHUNK_TYPE_RAID0: -@@ -1054,6 +1083,20 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, - stripe_offset = low + chunk_stripe_length - * high; - csize = chunk_stripe_length - low; -+ -+ /* -+ * Substripes only apply to RAID10, and there -+ * should be exactly 2 sub-stripes. -+ */ -+ if (grub_le_to_cpu16 (chunk->nsubstripes) != 2) -+ { -+ grub_dprintf ("btrfs", "invalid RAID10: nsubstripes != 2 (%u)", -+ grub_le_to_cpu16 (chunk->nsubstripes)); -+ return grub_error (GRUB_ERR_BAD_FS, -+ "invalid RAID10: nsubstripes != 2 (%u)", -+ grub_le_to_cpu16 (chunk->nsubstripes)); -+ } -+ - break; - } - case GRUB_BTRFS_CHUNK_TYPE_RAID5: -@@ -1153,6 +1196,8 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, - - for (j = 0; j < 2; j++) - { -+ grub_size_t est_chunk_alloc = 0; -+ - grub_dprintf ("btrfs", "chunk 0x%" PRIxGRUB_UINT64_T - "+0x%" PRIxGRUB_UINT64_T - " (%d stripes (%d substripes) of %" -@@ -1165,6 +1210,16 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, - grub_dprintf ("btrfs", "reading laddr 0x%" PRIxGRUB_UINT64_T "\n", - addr); - -+ if (grub_mul (sizeof (struct grub_btrfs_chunk_stripe), -+ grub_le_to_cpu16 (chunk->nstripes), &est_chunk_alloc) || -+ grub_add (est_chunk_alloc, -+ sizeof (struct grub_btrfs_chunk_item), &est_chunk_alloc) || -+ est_chunk_alloc > chunk->size) -+ { -+ err = GRUB_ERR_BAD_FS; -+ break; -+ } -+ - if (is_raid56) - { - err = btrfs_read_from_chunk (data, chunk, stripen, diff --git a/0245-fs-btrfs-Fix-more-fuzz-issues-related-to-chunks.patch b/0245-fs-btrfs-Fix-more-fuzz-issues-related-to-chunks.patch deleted file mode 100644 index 2e5145f..0000000 --- a/0245-fs-btrfs-Fix-more-fuzz-issues-related-to-chunks.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Darren Kenny -Date: Thu, 7 Apr 2022 15:18:12 +0000 -Subject: [PATCH] fs/btrfs: Fix more fuzz issues related to chunks - -The corpus we generating issues in grub_btrfs_read_logical() when -attempting to iterate over nstripes entries in the boot mapping. - -In most cases the reason for the failure was that the number of strips -exceeded the possible space statically allocated in superblock bootmapping -space. Each stripe entry in the bootmapping block consists of -a grub_btrfs_key followed by a grub_btrfs_chunk_stripe. - -Another issue that came up was that while calculating the chunk size, -in an earlier piece of code in that function, depending on the data -provided in the btrfs file system, it would end up calculating a size -that was too small to contain even 1 grub_btrfs_chunk_item, which is -obviously invalid too. - -Signed-off-by: Darren Kenny -Reviewed-by: Daniel Kiper -(cherry picked from commit e00cd76cbadcc897a9cc4087cb2fcb5dbe15e596) ---- - grub-core/fs/btrfs.c | 24 ++++++++++++++++++++++++ - 1 file changed, 24 insertions(+) - -diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c -index 0e9b450413..47325f6ad7 100644 ---- a/grub-core/fs/btrfs.c -+++ b/grub-core/fs/btrfs.c -@@ -947,6 +947,17 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, - return grub_error (GRUB_ERR_BAD_FS, - "got an invalid zero-size chunk"); - } -+ -+ /* -+ * The space being allocated for a chunk should at least be able to -+ * contain one chunk item. -+ */ -+ if (chsize < sizeof (struct grub_btrfs_chunk_item)) -+ { -+ grub_dprintf ("btrfs", "chunk-size too small\n"); -+ return grub_error (GRUB_ERR_BAD_FS, -+ "got an invalid chunk size"); -+ } - chunk = grub_malloc (chsize); - if (!chunk) - return grub_errno; -@@ -1194,6 +1205,13 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, - if (csize > (grub_uint64_t) size) - csize = size; - -+ /* -+ * The space for a chunk stripe is limited to the space provide in the super-block's -+ * bootstrap mapping with an initial btrfs key at the start of each chunk. -+ */ -+ grub_size_t avail_stripes = sizeof (data->sblock.bootstrap_mapping) / -+ (sizeof (struct grub_btrfs_key) + sizeof (struct grub_btrfs_chunk_stripe)); -+ - for (j = 0; j < 2; j++) - { - grub_size_t est_chunk_alloc = 0; -@@ -1220,6 +1238,12 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, - break; - } - -+ if (grub_le_to_cpu16 (chunk->nstripes) > avail_stripes) -+ { -+ err = GRUB_ERR_BAD_FS; -+ break; -+ } -+ - if (is_raid56) - { - err = btrfs_read_from_chunk (data, chunk, stripen, diff --git a/0275-x86-efi-Fix-an-incorrect-array-size-in-kernel-alloca.patch b/0245-x86-efi-Fix-an-incorrect-array-size-in-kernel-alloca.patch similarity index 97% rename from 0275-x86-efi-Fix-an-incorrect-array-size-in-kernel-alloca.patch rename to 0245-x86-efi-Fix-an-incorrect-array-size-in-kernel-alloca.patch index 0079750..e19f154 100644 --- a/0275-x86-efi-Fix-an-incorrect-array-size-in-kernel-alloca.patch +++ b/0245-x86-efi-Fix-an-incorrect-array-size-in-kernel-alloca.patch @@ -22,7 +22,7 @@ Signed-off-by: Peter Jones 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 ac5ef50bdb..9854b0defa 100644 +index 03d27c81fd3..f97b123a51e 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -92,7 +92,7 @@ static struct allocation_choice max_addresses[] = diff --git a/0339-grub-install-on-EFI-if-forced.patch b/0246-grub-install-on-EFI-if-forced.patch similarity index 73% rename from 0339-grub-install-on-EFI-if-forced.patch rename to 0246-grub-install-on-EFI-if-forced.patch index ad231ac..e569cf1 100644 --- a/0339-grub-install-on-EFI-if-forced.patch +++ b/0246-grub-install-on-EFI-if-forced.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Marta Lewandowska -Date: Fri, 13 Oct 2023 09:13:41 +0200 +Date: Tue, 6 Feb 2024 17:42:47 -0600 Subject: [PATCH] grub-install on EFI if forced UEFI Secure Boot requires signed grub binaries to work, so grub- @@ -12,14 +12,14 @@ fixes bz#1917213 / bz#2240994 Signed-off-by: Marta Lewandowska --- - util/grub-install.c | 42 ++++++++++++++++++++++++++---------------- - 1 file changed, 26 insertions(+), 16 deletions(-) + util/grub-install.c | 38 +++++++++++++++++++------------------- + 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/util/grub-install.c b/util/grub-install.c -index 5babc7af5518..162162bec6e2 100644 +index 828e8722ba5..314b6143b8e 100644 --- a/util/grub-install.c +++ b/util/grub-install.c -@@ -899,22 +899,6 @@ main (int argc, char *argv[]) +@@ -915,25 +915,6 @@ main (int argc, char *argv[]) platform = grub_install_get_target (grub_install_source_directory); @@ -29,6 +29,9 @@ index 5babc7af5518..162162bec6e2 100644 - case GRUB_INSTALL_PLATFORM_ARM64_EFI: - case GRUB_INSTALL_PLATFORM_I386_EFI: - case GRUB_INSTALL_PLATFORM_IA64_EFI: +- case GRUB_INSTALL_PLATFORM_LOONGARCH64_EFI: +- case GRUB_INSTALL_PLATFORM_RISCV32_EFI: +- case GRUB_INSTALL_PLATFORM_RISCV64_EFI: - case GRUB_INSTALL_PLATFORM_X86_64_EFI: - is_efi = 1; - grub_util_error (_("this utility cannot be used for EFI platforms" @@ -42,19 +45,18 @@ index 5babc7af5518..162162bec6e2 100644 { char *platname = grub_install_get_platform_name (platform); fprintf (stderr, _("Installing for %s platform.\n"), platname); -@@ -1027,6 +1011,32 @@ main (int argc, char *argv[]) - grub_hostfs_init (); - grub_host_init (); +@@ -1050,6 +1031,22 @@ main (int argc, char *argv[]) -+ switch (platform) -+ { -+ case GRUB_INSTALL_PLATFORM_I386_EFI: -+ case GRUB_INSTALL_PLATFORM_X86_64_EFI: + switch (platform) + { + case GRUB_INSTALL_PLATFORM_ARM_EFI: + case GRUB_INSTALL_PLATFORM_ARM64_EFI: ++ case GRUB_INSTALL_PLATFORM_I386_EFI: ++ case GRUB_INSTALL_PLATFORM_IA64_EFI: ++ case GRUB_INSTALL_PLATFORM_LOONGARCH64_EFI: + case GRUB_INSTALL_PLATFORM_RISCV32_EFI: + case GRUB_INSTALL_PLATFORM_RISCV64_EFI: -+ case GRUB_INSTALL_PLATFORM_IA64_EFI: ++ case GRUB_INSTALL_PLATFORM_X86_64_EFI: + is_efi = 1; + if (!force) + grub_util_error (_("This utility should not be used for EFI platforms" @@ -63,15 +65,16 @@ index 5babc7af5518..162162bec6e2 100644 + " option.\nMake sure Secure Boot is disabled before" + " proceeding")); + break; -+ default: -+ is_efi = 0; -+ break; -+ + case GRUB_INSTALL_PLATFORM_I386_IEEE1275: + case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275: + #ifdef __linux__ +@@ -1058,6 +1055,9 @@ main (int argc, char *argv[]) + try_open ("/dev/nvram"); + #endif + break; + /* pacify warning. */ + case GRUB_INSTALL_PLATFORM_MAX: + break; -+ } -+ - /* Find the EFI System Partition. */ - if (is_efi) - { + default: + break; + } diff --git a/0340-Remove-Install-section-from-aux-systemd-units.patch b/0247-Remove-Install-section-from-aux-systemd-units.patch similarity index 93% rename from 0340-Remove-Install-section-from-aux-systemd-units.patch rename to 0247-Remove-Install-section-from-aux-systemd-units.patch index 1a62cdd..500b9f5 100644 --- a/0340-Remove-Install-section-from-aux-systemd-units.patch +++ b/0247-Remove-Install-section-from-aux-systemd-units.patch @@ -10,7 +10,7 @@ See https://bugzilla.redhat.com/show_bug.cgi?id=2247635#c7 2 files changed, 6 deletions(-) diff --git a/docs/grub-boot-indeterminate.service b/docs/grub-boot-indeterminate.service -index 5bcb474a3d31..6c8dcb186b63 100644 +index 5bcb474a3d3..6c8dcb186b6 100644 --- a/docs/grub-boot-indeterminate.service +++ b/docs/grub-boot-indeterminate.service @@ -9,6 +9,3 @@ Before=system-update-pre.target @@ -21,7 +21,7 @@ index 5bcb474a3d31..6c8dcb186b63 100644 -[Install] -WantedBy=system-update.target diff --git a/util/systemd/grub-systemd-integration.service.in b/util/systemd/grub-systemd-integration.service.in -index 22ca1ca4885e..c81fb594ce17 100644 +index 22ca1ca4885..c81fb594ce1 100644 --- a/util/systemd/grub-systemd-integration.service.in +++ b/util/systemd/grub-systemd-integration.service.in @@ -6,6 +6,3 @@ ConditionPathExists=/run/systemd/reboot-to-boot-loader-menu diff --git a/0346-chainloader-remove-device-path-debug-message.patch b/0248-chainloader-remove-device-path-debug-message.patch similarity index 89% rename from 0346-chainloader-remove-device-path-debug-message.patch rename to 0248-chainloader-remove-device-path-debug-message.patch index ef7720f..306aad3 100644 --- a/0346-chainloader-remove-device-path-debug-message.patch +++ b/0248-chainloader-remove-device-path-debug-message.patch @@ -12,10 +12,10 @@ Signed-off-by: raravind 1 file changed, 1 deletion(-) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index dd31ac9bb..b1c86dab2 100644 +index b40acdeda80..badff5e50b5 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c -@@ -210,7 +210,6 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename) +@@ -212,7 +212,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)); @@ -23,6 +23,3 @@ index dd31ac9bb..b1c86dab2 100644 if (copy_file_path ((grub_efi_file_path_device_path_t *) d, dir_start, dir_end - dir_start) != GRUB_ERR_NONE) { --- -2.43.0 - diff --git a/0356-grub-set-bootflag-Conservative-partial-fix-for-CVE-2.patch b/0249-grub-set-bootflag-Conservative-partial-fix-for-CVE-2.patch similarity index 99% rename from 0356-grub-set-bootflag-Conservative-partial-fix-for-CVE-2.patch rename to 0249-grub-set-bootflag-Conservative-partial-fix-for-CVE-2.patch index d20f909..995181f 100644 --- a/0356-grub-set-bootflag-Conservative-partial-fix-for-CVE-2.patch +++ b/0249-grub-set-bootflag-Conservative-partial-fix-for-CVE-2.patch @@ -70,7 +70,7 @@ Signed-off-by: Solar Designer 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c -index 3b4c25ca2ac6..5bbbef804391 100644 +index 3b4c25ca2ac..5bbbef80439 100644 --- a/util/grub-set-bootflag.c +++ b/util/grub-set-bootflag.c @@ -33,6 +33,8 @@ diff --git a/0357-grub-set-bootflag-More-complete-fix-for-CVE-2024-104.patch b/0250-grub-set-bootflag-More-complete-fix-for-CVE-2024-104.patch similarity index 99% rename from 0357-grub-set-bootflag-More-complete-fix-for-CVE-2024-104.patch rename to 0250-grub-set-bootflag-More-complete-fix-for-CVE-2024-104.patch index b47b311..615b04d 100644 --- a/0357-grub-set-bootflag-More-complete-fix-for-CVE-2024-104.patch +++ b/0250-grub-set-bootflag-More-complete-fix-for-CVE-2024-104.patch @@ -29,7 +29,7 @@ Signed-off-by: Solar Designer 1 file changed, 79 insertions(+), 16 deletions(-) diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c -index 5bbbef804391..514c4f9091ac 100644 +index 5bbbef80439..514c4f9091a 100644 --- a/util/grub-set-bootflag.c +++ b/util/grub-set-bootflag.c @@ -33,6 +33,7 @@ diff --git a/0358-grub-set-bootflag-Exit-calmly-when-not-running-as-ro.patch b/0251-grub-set-bootflag-Exit-calmly-when-not-running-as-ro.patch similarity index 96% rename from 0358-grub-set-bootflag-Exit-calmly-when-not-running-as-ro.patch rename to 0251-grub-set-bootflag-Exit-calmly-when-not-running-as-ro.patch index dba46d4..5b41025 100644 --- a/0358-grub-set-bootflag-Exit-calmly-when-not-running-as-ro.patch +++ b/0251-grub-set-bootflag-Exit-calmly-when-not-running-as-ro.patch @@ -13,7 +13,7 @@ Signed-off-by: Solar Designer 1 file changed, 11 insertions(+) diff --git a/util/grub-set-bootflag.c b/util/grub-set-bootflag.c -index 514c4f9091ac..31a868aeca8a 100644 +index 514c4f9091a..31a868aeca8 100644 --- a/util/grub-set-bootflag.c +++ b/util/grub-set-bootflag.c @@ -98,6 +98,17 @@ int main(int argc, char *argv[]) diff --git a/0252-Makefile.core.def-fix-linux-module.patch b/0252-Makefile.core.def-fix-linux-module.patch new file mode 100644 index 0000000..83d8d8e --- /dev/null +++ b/0252-Makefile.core.def-fix-linux-module.patch @@ -0,0 +1,61 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Leo Sandoval +Date: Mon, 15 Apr 2024 09:24:47 -0600 +Subject: [PATCH] Makefile.core.def: fix linux module + +Set EFI source file targets specifically for i386 and x86_64 archs, +otherwise we observe build failures at aarch64 + +../../grub-core/tests/videotest_checksum.c > videotest_checksum.marker.new || (rm -f videotest_checksum.marker; exit 1) +../../grub-core/loader/efi/linux.c:28:10: fatal error: grub/cpu/linux.h: No such file or directory + 28 | #include + | ^~~~~~~~~~~~~~~~~~ +compilation terminated. +. +. +. +../../grub-core/loader/i386/linux.c:30:10: fatal error: grub/cpu/linux.h: No such file or directory + 30 | #include + | ^~~~~~~~~~~~~~~~~~ +compilation terminated. + +Signed-off-by: Leo Sandoval +--- + grub-core/Makefile.core.def | 7 ++++--- + grub-core/loader/efi/linux.c | 1 - + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def +index b045aac7c91..6ff4835340d 100644 +--- a/grub-core/Makefile.core.def ++++ b/grub-core/Makefile.core.def +@@ -1902,13 +1902,14 @@ module = { + riscv32 = loader/efi/linux.c; + riscv64 = loader/efi/linux.c; + i386_efi = loader/i386/efi/linux.c; ++ i386_efi = loader/efi/linux.c; ++ i386_efi = loader/i386/linux.c; + x86_64_efi = loader/i386/efi/linux.c; ++ x86_64_efi = loader/efi/linux.c; ++ x86_64_efi = loader/i386/linux.c; + emu = loader/emu/linux.c; +- fdt = lib/fdt.c; + common = loader/linux.c; + common = lib/cmdline.c; +- efi = loader/efi/linux.c; +- efi = loader/i386/linux.c; + }; + + module = { +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index f5ab0128991..44587df3858 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -25,7 +25,6 @@ + #include + #include + #include +-#include + #include + #include + #include diff --git a/0253-Add-support-for-Linux-EFI-stub-loading-on-arm-archit.patch b/0253-Add-support-for-Linux-EFI-stub-loading-on-arm-archit.patch new file mode 100644 index 0000000..d9ff0b6 --- /dev/null +++ b/0253-Add-support-for-Linux-EFI-stub-loading-on-arm-archit.patch @@ -0,0 +1,270 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Matthew Garrett +Date: Mon, 15 Apr 2024 11:19:31 -0600 +Subject: [PATCH] Add support for Linux EFI stub loading on arm architectures + +--- + grub-core/loader/arm64/xen_boot.c | 1 - + grub-core/loader/efi/linux.c | 116 ++++++++++++++++++-------------------- + include/grub/efi/efi.h | 28 ++++++++- + 3 files changed, 80 insertions(+), 65 deletions(-) + +diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c +index 26e1472c9d2..9838a0f878b 100644 +--- a/grub-core/loader/arm64/xen_boot.c ++++ b/grub-core/loader/arm64/xen_boot.c +@@ -252,7 +252,6 @@ xen_boot (void) + return err; + + 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 +index 44587df3858..8742e303d85 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -42,6 +43,7 @@ static int loaded; + + static void *kernel_addr; + static grub_uint64_t kernel_size; ++static grub_uint32_t handover_offset; + + static char *linux_args; + static grub_uint32_t cmdline_size; +@@ -94,7 +96,7 @@ static grub_efi_load_file2_t initrd_lf2 = { + typedef void (*handover_func) (void *, grub_efi_system_table_t *, void *); + + grub_err_t +-grub_efi_linux_boot (void *kernel_address, grub_off_t handover_offset, ++grub_efi_linux_boot (void *kernel_address, grub_off_t ho_offset, + void *kernel_params) + { + grub_efi_loaded_image_t *loaded_image = NULL; +@@ -117,8 +119,8 @@ grub_efi_linux_boot (void *kernel_address, grub_off_t handover_offset, + grub_dprintf ("linux", "Loaded Image base address could not be set\n"); + + grub_dprintf ("linux", "kernel_address: %p handover_offset: %p params: %p\n", +- kernel_address, (void *)(grub_efi_uintn_t)handover_offset, kernel_params); +- hf = (handover_func)((char *)kernel_address + handover_offset + offset); ++ kernel_address, (void *)(grub_efi_uintn_t)ho_offset, kernel_params); ++ hf = (handover_func)((char *)kernel_address + ho_offset + offset); + hf (grub_efi_image_handle, grub_efi_system_table, kernel_params); + + return GRUB_ERR_BUG; +@@ -178,7 +180,8 @@ grub_arch_efi_linux_load_image_header (grub_file_t file, + static grub_err_t + finalize_params_linux (void) + { +- int node, retval; ++ grub_efi_loaded_image_t *loaded_image = NULL; ++ int node, retval, len; + + void *fdt; + +@@ -213,79 +216,65 @@ 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"); +-} +-#endif +- +-grub_err_t +-grub_arch_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args) +-{ +- grub_efi_memory_mapped_device_path_t *mempath; +- grub_efi_handle_t image_handle; +- grub_efi_boot_services_t *b; +- grub_efi_status_t status; +- grub_efi_loaded_image_t *loaded_image; +- int len; +- +- mempath = grub_malloc (2 * sizeof (grub_efi_memory_mapped_device_path_t)); +- if (!mempath) +- return grub_errno; +- +- mempath[0].header.type = GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE; +- mempath[0].header.subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE; +- mempath[0].header.length = grub_cpu_to_le16_compile_time (sizeof (*mempath)); +- mempath[0].memory_type = GRUB_EFI_LOADER_DATA; +- mempath[0].start_address = addr; +- mempath[0].end_address = addr + size; +- +- mempath[1].header.type = GRUB_EFI_END_DEVICE_PATH_TYPE; +- mempath[1].header.subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; +- mempath[1].header.length = sizeof (grub_efi_device_path_t); +- +- b = grub_efi_system_table->boot_services; +- status = b->load_image (0, grub_efi_image_handle, +- (grub_efi_device_path_t *) mempath, +- (void *) addr, size, &image_handle); +- if (status != GRUB_EFI_SUCCESS) +- return grub_error (GRUB_ERR_BAD_OS, "cannot load image"); +- +- 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 == NULL) + { + grub_error (GRUB_ERR_BAD_FIRMWARE, "missing loaded_image proto"); +- goto unload; ++ 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 */ +- grub_error (GRUB_ERR_BAD_OS, "start_image() returned 0x%" PRIxGRUB_EFI_UINTN_T, status); +- grub_efi_free_pages ((grub_addr_t) loaded_image->load_options, +- GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); +-unload: +- b->unload_image (image_handle); ++failure: ++ grub_fdt_unload(); ++ return grub_error(GRUB_ERR_BAD_OS, "failed to install/update FDT"); ++} ++#endif ++ ++static void ++free_params (void) ++{ ++ grub_efi_loaded_image_t *loaded_image = NULL; + +- return grub_errno; ++ loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); ++ if (loaded_image) ++ { ++ if (loaded_image->load_options) ++ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_efi_uintn_t)loaded_image->load_options, ++ GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); ++ loaded_image->load_options = NULL; ++ loaded_image->load_options_size = 0; ++ } + } + ++grub_err_t ++grub_arch_efi_linux_boot_image (grub_addr_t addr, char *args) ++{ ++ grub_err_t retval; ++ ++ grub_dprintf ("linux", "linux command line: '%s'\n", args); ++ ++ retval = grub_efi_linux_boot ((char *)addr, handover_offset, (void *)addr); ++ ++ /* Never reached... */ ++ free_params(); ++ return retval; ++ } ++ + static grub_err_t + grub_linux_boot (void) + { +@@ -294,8 +283,7 @@ grub_linux_boot (void) + return grub_errno; + #endif + +- return grub_arch_efi_linux_boot_image ((grub_addr_t) kernel_addr, +- kernel_size, linux_args); ++ return grub_arch_efi_linux_boot_image ((grub_addr_t) kernel_addr, linux_args); + } + + static grub_err_t +@@ -572,6 +560,12 @@ fallback: + + grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); + ++#if !defined(__i386__) && !defined(__x86_64__) ++ struct grub_armxx_linux_pe_header *pe; ++ pe = (void *)((unsigned long)kernel_addr + lh.hdr_offset); ++ handover_offset = pe->opt.entry_addr; ++#endif ++ + cmdline_size = grub_loader_cmdline_size (argc, argv) + sizeof (LINUX_IMAGE); + linux_args = grub_malloc (cmdline_size); + if (!linux_args) +diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h +index 83ddbe26e57..bff833468ee 100644 +--- a/include/grub/efi/efi.h ++++ b/include/grub/efi/efi.h +@@ -20,6 +20,7 @@ + #ifndef GRUB_EFI_EFI_HEADER + #define GRUB_EFI_EFI_HEADER 1 + ++#include + #include + #include + #include +@@ -36,7 +37,29 @@ struct linux_arch_kernel_header { + struct grub_pe_image_header pe_image_header; + }; + +-#define GRUB_EFI_GRUB_VARIABLE_GUID \ ++struct grub_arm_linux_pe_header ++{ ++ grub_uint32_t magic; ++ struct grub_pe32_coff_header coff; ++ struct grub_pe32_optional_header opt; ++}; ++ ++struct grub_arm64_linux_pe_header ++{ ++ grub_uint32_t magic; ++ struct grub_pe32_coff_header coff; ++ struct grub_pe64_optional_header opt; ++}; ++ ++#if defined(__arm__) ++# define grub_armxx_linux_pe_header grub_arm_linux_pe_header ++#endif ++ ++#if defined(__aarch64__) ++# define grub_armxx_linux_pe_header grub_arm64_linux_pe_header ++#endif ++ ++#define GRUB_EFI_GRUB_VARIABLE_GUID \ + { 0x91376aff, 0xcba6, 0x42be, \ + { 0x94, 0x9d, 0x06, 0xfd, 0xe8, 0x11, 0x28, 0xe8 } \ + } +@@ -173,8 +196,7 @@ grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); + #include + grub_err_t grub_arch_efi_linux_load_image_header(grub_file_t file, + 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_arch_efi_linux_boot_image(grub_addr_t addr, char *args); + + grub_addr_t grub_efi_section_addr (const char *section); + diff --git a/0097-arm-arm64-loader-Better-memory-allocation-and-error-.patch b/0254-arm-arm64-loader-Better-memory-allocation-and-error-.patch similarity index 80% rename from 0097-arm-arm64-loader-Better-memory-allocation-and-error-.patch rename to 0254-arm-arm64-loader-Better-memory-allocation-and-error-.patch index 57d937c..b6c1dc9 100644 --- a/0097-arm-arm64-loader-Better-memory-allocation-and-error-.patch +++ b/0254-arm-arm64-loader-Better-memory-allocation-and-error-.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Thu, 11 Jul 2019 14:38:57 +0200 +Date: Mon, 15 Apr 2024 12:58:13 -0600 Subject: [PATCH] arm/arm64 loader: Better memory allocation and error messages. @@ -66,28 +66,31 @@ per-platform constraints on its given address are maintained. Signed-off-by: Peter Jones --- - grub-core/kern/efi/mm.c | 33 +++++++++++++++----- - grub-core/loader/arm64/linux.c | 68 +++++++++++++++++++++++++++++++----------- - 2 files changed, 76 insertions(+), 25 deletions(-) + grub-core/kern/efi/mm.c | 35 ++++++++++++++++++------ + grub-core/loader/efi/linux.c | 65 +++++++++++++++++++++++++++++++++----------- + 2 files changed, 75 insertions(+), 25 deletions(-) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index f6aef0ef64..85ad4b4494 100644 +index 8f75205a732..560b859b6f4 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, +@@ -153,8 +153,9 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, { grub_efi_status_t status; grub_efi_boot_services_t *b; + grub_efi_physical_address_t ret = address; - /* Limit the memory access to less than 4GB for 32-bit platforms. */ +- /* Limit the memory access to less than 4GB for 32-bit platforms. */ ++/* Limit the memory access to less than 4GB for 32-bit platforms. */ if (address > GRUB_EFI_MAX_USABLE_ADDRESS) -@@ -170,19 +171,22 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, + { + char inv_addr[17], max_addr[17]; /* log16(2^64) = 16, plus NUL. */ +@@ -169,19 +170,22 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, } b = grub_efi_system_table->boot_services; -- status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &address); -+ status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &ret); +- status = b->allocate_pages (alloctype, memtype, pages, &address); ++ status = b->allocate_pages (alloctype, memtype, pages, &ret); if (status != GRUB_EFI_SUCCESS) { + grub_dprintf ("efi", @@ -103,13 +106,13 @@ index f6aef0ef64..85ad4b4494 100644 /* 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, alloctype, memtype, pages, &address); +- status = b->allocate_pages (alloctype, memtype, pages, &address); + ret = address; -+ status = efi_call_4 (b->allocate_pages, alloctype, memtype, pages, &ret); ++ status = b->allocate_pages (alloctype, memtype, pages, &ret); grub_efi_free_pages (0, pages); if (status != GRUB_EFI_SUCCESS) { -@@ -191,9 +195,9 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, +@@ -190,9 +194,9 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, } } @@ -121,7 +124,7 @@ index f6aef0ef64..85ad4b4494 100644 } void * -@@ -713,8 +717,21 @@ grub_efi_get_ram_base(grub_addr_t *base_addr) +@@ -711,8 +715,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)) @@ -145,11 +148,11 @@ index f6aef0ef64..85ad4b4494 100644 grub_free(memory_map); -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index 04994d5c67..70a0075ec5 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -71,20 +71,25 @@ finalize_params_linux (void) +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index 8742e303d85..ddb27834131 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -182,7 +182,7 @@ finalize_params_linux (void) { grub_efi_loaded_image_t *loaded_image = NULL; int node, retval, len; @@ -157,29 +160,32 @@ index 04994d5c67..70a0075ec5 100644 + grub_err_t err = GRUB_ERR_NONE; void *fdt; - fdt = grub_fdt_load (GRUB_EFI_LINUX_FDT_EXTRA_SPACE); -- - if (!fdt) -- goto failure; -+ { -+ err = grub_error(GRUB_ERR_BAD_OS, "failed to load FDT"); -+ goto failure; -+ } - - node = grub_fdt_find_subnode (fdt, 0, "chosen"); - if (node < 0) - node = grub_fdt_add_subnode (fdt, 0, "chosen"); - - if (node < 1) -- goto failure; -+ { -+ err = grub_error(grub_errno, "failed to load chosen fdt node."); -+ goto failure; -+ } - /* Set initrd info */ - if (initrd_start && initrd_end > initrd_start) -@@ -95,15 +100,26 @@ finalize_params_linux (void) +@@ -191,14 +191,21 @@ finalize_params_linux (void) + fdt = grub_fdt_load (GRUB_EFI_LINUX_FDT_EXTRA_SPACE); + + if (!fdt) +- goto failure; ++ { ++ err = grub_error(GRUB_ERR_BAD_OS, "failed to load FDT"); ++ goto failure; ++ } ++ + + node = grub_fdt_find_subnode (fdt, 0, "chosen"); + if (node < 0) + node = grub_fdt_add_subnode (fdt, 0, "chosen"); + + if (node < 1) +- goto failure; ++ { ++ err = grub_error(grub_errno, "failed to load chosen fdt node."); ++ goto failure; ++ } + + grub_dprintf ("linux", "Initrd @ %p-%p\n", + (void *) initrd_start, (void *) initrd_end); +@@ -206,15 +213,26 @@ finalize_params_linux (void) retval = grub_fdt_set_prop64 (fdt, node, "linux,initrd-start", initrd_start); if (retval) @@ -210,18 +216,16 @@ index 04994d5c67..70a0075ec5 100644 grub_dprintf ("linux", "Installed/updated FDT configuration table @ %p\n", fdt); -@@ -111,14 +127,20 @@ finalize_params_linux (void) - /* Convert command line to UCS-2 */ +@@ -223,7 +241,7 @@ finalize_params_linux (void) loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); - if (!loaded_image) -- goto failure; -+ { + if (loaded_image == NULL) + { +- grub_error (GRUB_ERR_BAD_FIRMWARE, "missing loaded_image proto"); + err = grub_error(grub_errno, "Failed to install fdt"); -+ goto failure; -+ } - + goto failure; + } loaded_image->load_options_size = len = - (grub_strlen (linux_args) + 1) * sizeof (grub_efi_char16_t); +@@ -231,7 +249,10 @@ finalize_params_linux (void) loaded_image->load_options = grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); if (!loaded_image->load_options) @@ -233,16 +237,16 @@ index 04994d5c67..70a0075ec5 100644 loaded_image->load_options_size = 2 * grub_utf8_to_utf16 (loaded_image->load_options, len, -@@ -128,7 +150,7 @@ finalize_params_linux (void) +@@ -241,7 +262,7 @@ finalize_params_linux (void) failure: grub_fdt_unload(); - return grub_error(GRUB_ERR_BAD_OS, "failed to install/update FDT"); + return err; } + #endif - static void -@@ -212,16 +234,28 @@ grub_linux_unload (void) +@@ -344,16 +365,28 @@ grub_linux_unload (void) static void * allocate_initrd_mem (int initrd_pages) { @@ -275,5 +279,5 @@ index 04994d5c67..70a0075ec5 100644 + grub_dprintf ("linux", "got 0x%016llx\n", (unsigned long long)ret); + return ret; } + #endif - static grub_err_t diff --git a/0185-arm64-Fix-EFI-loader-kernel-image-allocation.patch b/0255-arm64-Fix-EFI-loader-kernel-image-allocation.patch similarity index 67% rename from 0185-arm64-Fix-EFI-loader-kernel-image-allocation.patch rename to 0255-arm64-Fix-EFI-loader-kernel-image-allocation.patch index cc5458c..61f6d44 100644 --- a/0185-arm64-Fix-EFI-loader-kernel-image-allocation.patch +++ b/0255-arm64-Fix-EFI-loader-kernel-image-allocation.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt -Date: Mon, 2 Aug 2021 23:10:01 +1000 +Date: Tue, 16 Apr 2024 12:22:54 -0600 Subject: [PATCH] arm64: Fix EFI loader kernel image allocation We are currently allocating just enough memory for the file size, @@ -18,15 +18,14 @@ Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Peter Jones Signed-off-by: Robbie Harwood --- - grub-core/loader/arm64/linux.c | 100 +++++++++++++++++++++++++++-------------- - include/grub/arm/linux.h | 1 + - include/grub/arm64/linux.h | 1 + - 3 files changed, 68 insertions(+), 34 deletions(-) + grub-core/loader/efi/linux.c | 93 +++++++++++++++++++++++++++++++------------- + include/grub/efi/efi.h | 3 +- + 2 files changed, 68 insertions(+), 28 deletions(-) -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index 47f8cf0d84..f18d90bd74 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index ddb27834131..cb9de5565de 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c @@ -41,6 +41,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); static grub_dl_t my_mod; static int loaded; @@ -36,7 +35,7 @@ index 47f8cf0d84..f18d90bd74 100644 static void *kernel_addr; static grub_uint64_t kernel_size; static grub_uint32_t handover_offset; -@@ -204,9 +206,8 @@ grub_linux_unload (void) +@@ -319,9 +321,8 @@ grub_linux_unload (void) GRUB_EFI_BYTES_TO_PAGES (initrd_end - initrd_start)); initrd_start = initrd_end = 0; grub_free (linux_args); @@ -45,13 +44,14 @@ index 47f8cf0d84..f18d90bd74 100644 - GRUB_EFI_BYTES_TO_PAGES (kernel_size)); + if (kernel_alloc_addr) + grub_efi_free_pages ((grub_addr_t) kernel_alloc_addr, kernel_alloc_pages); + #if !defined(__i386__) && !defined(__x86_64__) grub_fdt_unload (); - return GRUB_ERR_NONE; - } -@@ -311,14 +312,35 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), + #endif +@@ -512,12 +513,37 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), return grub_errno; } ++#if !defined(__i386__) && !defined(__x86_64__) +static grub_err_t +parse_pe_header (void *kernel, grub_uint64_t *total_size, + grub_uint32_t *entry_offset, @@ -71,106 +71,96 @@ index 47f8cf0d84..f18d90bd74 100644 + + return GRUB_ERR_NONE; +} ++#endif + static grub_err_t grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { grub_file_t file = 0; -- struct linux_arch_kernel_header lh; -- struct grub_armxx_linux_pe_header *pe; - grub_err_t err; + struct linux_arch_kernel_header lh; + grub_off_t filelen; + grub_uint32_t align; + void *kernel = NULL; - int rc; + grub_err_t err; grub_dl_ref (my_mod); -@@ -333,40 +355,24 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -548,8 +574,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (!file) goto fail; - kernel_size = grub_file_size (file); - -- if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh)) -- return grub_errno; -- -- if (grub_arch_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_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) + if (grub_arch_efi_linux_load_image_header (file, &lh) != GRUB_ERR_NONE) + #if !defined(__i386__) && !defined(__x86_64__) + goto fail; +@@ -570,33 +594,46 @@ fallback: + } + #endif + + filelen = grub_file_size (file); + kernel = grub_malloc(filelen); + if (!kernel) - { -- grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); ++ { + grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate kernel load buffer")); - goto fail; - } - -- grub_file_seek (file, 0); -- if (grub_file_read (file, kernel_addr, kernel_size) -- < (grub_int64_t) kernel_size) ++ goto fail; ++ } ++ + if (grub_file_read (file, kernel, filelen) < (grub_ssize_t)filelen) - { -- if (!grub_errno) -- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]); ++ { + grub_error (GRUB_ERR_FILE_READ_ERROR, N_("Can't read kernel %s"), + argv[0]); - goto fail; - } - -- grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); -- - if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED) - { -- rc = grub_linuxefi_secure_validate (kernel_addr, kernel_size); -+ rc = grub_linuxefi_secure_validate (kernel, filelen); - if (rc <= 0) - { - grub_error (GRUB_ERR_INVALID_COMMAND, -@@ -375,8 +381,32 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - } - } - -- pe = (void *)((unsigned long)kernel_addr + lh.hdr_offset); -- handover_offset = pe->opt.entry_addr; -+ if (grub_arch_efi_linux_check_image (kernel) != GRUB_ERR_NONE) -+ goto fail; ++ goto fail; ++ } ++ ++#if !defined(__i386__) && !defined(__x86_64__) + if (parse_pe_header (kernel, &kernel_size, &handover_offset, &align) != GRUB_ERR_NONE) + goto fail; + grub_dprintf ("linux", "kernel mem size : %lld\n", (long long) kernel_size); + grub_dprintf ("linux", "kernel entry offset : %d\n", handover_offset); + grub_dprintf ("linux", "kernel alignment : 0x%x\n", align); + -+ grub_loader_unset(); -+ + grub_loader_unset(); + +- grub_dprintf ("linux", "kernel file size: %lld\n", (long long) 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) + kernel_alloc_pages = GRUB_EFI_BYTES_TO_PAGES (kernel_size + align - 1); + kernel_alloc_addr = grub_efi_allocate_any_pages (kernel_alloc_pages); + grub_dprintf ("linux", "kernel numpages: %d\n", kernel_alloc_pages); + if (!kernel_alloc_addr) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); -+ goto fail; -+ } + { + grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); + goto fail; + } +- +- grub_file_seek (file, 0); +- if (grub_file_read (file, kernel_addr, kernel_size) +- < (grub_int64_t) kernel_size) +- { +- if (!grub_errno) +- grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]); +- goto fail; +- } + kernel_addr = (void *)ALIGN_UP((grub_uint64_t)kernel_alloc_addr, align); -+ -+ grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); + + grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); +- +-#if !defined(__i386__) && !defined(__x86_64__) +- struct grub_armxx_linux_pe_header *pe; +- pe = (void *)((unsigned long)kernel_addr + lh.hdr_offset); +- handover_offset = pe->opt.entry_addr; + grub_memcpy (kernel_addr, kernel, grub_min(filelen, kernel_size)); + if (kernel_size > filelen) + grub_memset ((char *)kernel_addr + filelen, 0, kernel_size - filelen); + grub_free(kernel); + kernel = NULL; + #endif cmdline_size = grub_loader_cmdline_size (argc, argv) + sizeof (LINUX_IMAGE); - linux_args = grub_malloc (cmdline_size); -@@ -400,6 +430,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -621,6 +658,9 @@ fallback: } fail: @@ -180,7 +170,7 @@ index 47f8cf0d84..f18d90bd74 100644 if (file) grub_file_close (file); -@@ -412,9 +445,8 @@ fail: +@@ -633,9 +673,8 @@ fail: if (linux_args && !loaded) grub_free (linux_args); @@ -192,27 +182,28 @@ index 47f8cf0d84..f18d90bd74 100644 return grub_errno; } -diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h -index b582f67f66..966a5074f5 100644 ---- a/include/grub/arm/linux.h -+++ b/include/grub/arm/linux.h -@@ -44,6 +44,7 @@ struct grub_arm_linux_pe_header +diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h +index bff833468ee..c40684821e1 100644 +--- a/include/grub/efi/efi.h ++++ b/include/grub/efi/efi.h +@@ -20,7 +20,6 @@ + #ifndef GRUB_EFI_EFI_HEADER + #define GRUB_EFI_EFI_HEADER 1 + +-#include + #include + #include + #include +@@ -52,10 +51,12 @@ struct grub_arm64_linux_pe_header + }; #if defined(__arm__) - # define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM_MAGIC_SIGNATURE +# define GRUB_PE32_PEXX_MAGIC GRUB_PE32_PE32_MAGIC - # define linux_arch_kernel_header linux_arm_kernel_header # define grub_armxx_linux_pe_header grub_arm_linux_pe_header #endif -diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h -index ea030312df..422bf2bf24 100644 ---- a/include/grub/arm64/linux.h -+++ b/include/grub/arm64/linux.h -@@ -48,6 +48,7 @@ struct grub_arm64_linux_pe_header #if defined(__aarch64__) - # define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM64_MAGIC_SIGNATURE +# define GRUB_PE32_PEXX_MAGIC GRUB_PE32_PE64_MAGIC - # define linux_arch_kernel_header linux_arm64_kernel_header # define grub_armxx_linux_pe_header grub_arm64_linux_pe_header #endif + diff --git a/0252-pe-add-the-DOS-header-struct-and-fix-some-bad-naming.patch b/0256-pe-add-the-DOS-header-struct-and-fix-some-bad-naming.patch similarity index 68% rename from 0252-pe-add-the-DOS-header-struct-and-fix-some-bad-naming.patch rename to 0256-pe-add-the-DOS-header-struct-and-fix-some-bad-naming.patch index ef51214..222a13c 100644 --- a/0252-pe-add-the-DOS-header-struct-and-fix-some-bad-naming.patch +++ b/0256-pe-add-the-DOS-header-struct-and-fix-some-bad-naming.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Fri, 25 Mar 2022 15:40:12 -0400 +Date: Tue, 16 Apr 2024 12:51:50 -0600 Subject: [PATCH] pe: add the DOS header struct and fix some bad naming. In order to properly validate a loaded kernel's support for being loaded @@ -16,17 +16,17 @@ define, and adds defines for the actual PE magic. Signed-off-by: Peter Jones --- - grub-core/loader/arm64/linux.c | 2 +- - include/grub/efi/pe32.h | 28 ++++++++++++++++++++++++++-- + grub-core/loader/efi/linux.c | 2 +- + include/grub/efi/pe32.h | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index d2af47c2c0..cc67f43906 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -58,7 +58,7 @@ grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh) - if (lh->magic != GRUB_LINUX_ARMXX_MAGIC_SIGNATURE) - return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index cb9de5565de..ecaa8c18c4d 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -138,7 +138,7 @@ grub_arch_efi_linux_load_image_header (grub_file_t file, + if (grub_file_read (file, lh, sizeof (*lh)) < (grub_ssize_t) sizeof (*lh)) + return grub_error(GRUB_ERR_FILE_READ_ERROR, "failed to read Linux image header"); - if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC) + if ((lh->code0 & 0xffff) != GRUB_DOS_MAGIC) @@ -34,7 +34,7 @@ index d2af47c2c0..cc67f43906 100644 N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled")); diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h -index a43adf2746..2a5e1ee003 100644 +index a39743396dc..13fdd0e7d98 100644 --- a/include/grub/efi/pe32.h +++ b/include/grub/efi/pe32.h @@ -46,7 +46,30 @@ @@ -67,15 +67,15 @@ index a43adf2746..2a5e1ee003 100644 + grub_uint32_t lfanew; +}; - /* According to the spec, the minimal alignment is 512 bytes... - But some examples (such as EFI drivers in the Intel -@@ -280,7 +303,8 @@ struct grub_pe32_section_table - - + struct grub_msdos_image_header + { +@@ -293,7 +316,8 @@ struct grub_pe32_section_table + #define GRUB_PE32_SCN_MEM_READ 0x40000000 + #define GRUB_PE32_SCN_MEM_WRITE 0x80000000 -#define GRUB_PE32_SIGNATURE_SIZE 4 +#define GRUB_PE32_SIGNATURE_SIZE 4 +#define GRUB_PE32_SIGNATURE "PE\0\0" - struct grub_pe32_header - { + #if GRUB_TARGET_SIZEOF_VOID_P == 8 + #define GRUB_PE32_NATIVE_MAGIC GRUB_PE32_PE64_MAGIC diff --git a/0273-Correct-BSS-zeroing-on-aarch64.patch b/0257-Correct-BSS-zeroing-on-aarch64.patch similarity index 76% rename from 0273-Correct-BSS-zeroing-on-aarch64.patch rename to 0257-Correct-BSS-zeroing-on-aarch64.patch index 4f9a2b7..232393f 100644 --- a/0273-Correct-BSS-zeroing-on-aarch64.patch +++ b/0257-Correct-BSS-zeroing-on-aarch64.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jeremy Linton -Date: Tue, 6 Sep 2022 15:33:03 -0500 +Date: Tue, 16 Apr 2024 13:26:55 -0600 Subject: [PATCH] Correct BSS zeroing on aarch64 The aarch64 loader doesn't use efi bootservices, and @@ -17,19 +17,19 @@ Resolves: rhbz#2125069 Signed-off-by: Jeremy Linton --- - grub-core/loader/arm64/linux.c | 27 ++++++++++++++++++++++----- + grub-core/loader/efi/linux.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index 489d0c7173..419f2201df 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -316,10 +316,12 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index ecaa8c18c4d..55c5c8600d4 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -517,10 +517,12 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), static grub_err_t parse_pe_header (void *kernel, grub_uint64_t *total_size, grub_uint32_t *entry_offset, - grub_uint32_t *alignment) -+ grub_uint32_t *alignment,grub_uint32_t *code_size) ++ grub_uint32_t *alignment, grub_uint32_t *code_size) { struct linux_arch_kernel_header *lh = kernel; struct grub_armxx_linux_pe_header *pe; @@ -38,7 +38,7 @@ index 489d0c7173..419f2201df 100644 pe = (void *)((unsigned long)kernel + lh->hdr_offset); -@@ -329,6 +331,19 @@ parse_pe_header (void *kernel, grub_uint64_t *total_size, +@@ -530,6 +532,19 @@ parse_pe_header (void *kernel, grub_uint64_t *total_size, *total_size = pe->opt.image_size; *entry_offset = pe->opt.entry_addr; *alignment = pe->opt.section_alignment; @@ -58,18 +58,18 @@ index 489d0c7173..419f2201df 100644 return GRUB_ERR_NONE; } -@@ -341,6 +356,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - grub_err_t err; +@@ -543,6 +558,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + struct linux_arch_kernel_header lh; grub_off_t filelen; grub_uint32_t align; + grub_uint32_t code_size; void *kernel = NULL; - int nx_supported = 1; + grub_err_t err; -@@ -373,11 +389,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -610,11 +626,12 @@ fallback: + } - if (grub_arch_efi_linux_check_image (kernel) != GRUB_ERR_NONE) - goto fail; + #if !defined(__i386__) && !defined(__x86_64__) - if (parse_pe_header (kernel, &kernel_size, &handover_offset, &align) != GRUB_ERR_NONE) + if (parse_pe_header (kernel, &kernel_size, &handover_offset, &align, &code_size) != GRUB_ERR_NONE) goto fail; @@ -78,9 +78,9 @@ index 489d0c7173..419f2201df 100644 grub_dprintf ("linux", "kernel alignment : 0x%x\n", align); + grub_dprintf ("linux", "kernel size : 0x%x\n", code_size); - err = grub_efi_check_nx_image_support((grub_addr_t)kernel, filelen, &nx_supported); - if (err != GRUB_ERR_NONE) -@@ -396,9 +413,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + grub_loader_unset(); + +@@ -629,9 +646,9 @@ fallback: kernel_addr = (void *)ALIGN_UP((grub_uint64_t)kernel_alloc_addr, align); grub_dprintf ("linux", "kernel @ %p\n", kernel_addr); @@ -92,4 +92,4 @@ index 489d0c7173..419f2201df 100644 + grub_memset ((char *)kernel_addr + code_size, 0, kernel_size - code_size); grub_free(kernel); kernel = NULL; - + #endif diff --git a/0336-arm64-Use-proper-memory-type-for-kernel-allocation.patch b/0258-arm64-Use-proper-memory-type-for-kernel-allocation.patch similarity index 77% rename from 0336-arm64-Use-proper-memory-type-for-kernel-allocation.patch rename to 0258-arm64-Use-proper-memory-type-for-kernel-allocation.patch index e77fcbf..453ee57 100644 --- a/0336-arm64-Use-proper-memory-type-for-kernel-allocation.patch +++ b/0258-arm64-Use-proper-memory-type-for-kernel-allocation.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Maximilian Luz -Date: Tue, 28 Jun 2022 23:06:46 +0200 +Date: Tue, 16 Apr 2024 14:21:49 -0600 Subject: [PATCH] arm64: Use proper memory type for kernel allocation Currently, the kernel pages are allocated with type EFI_LOADER_DATA. @@ -13,24 +13,24 @@ memory that is actually executable. Signed-off-by: Maximilian Luz --- - grub-core/loader/arm64/linux.c | 7 ++++++- + grub-core/loader/efi/linux.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index 419f2201df8b..a3a193c255e9 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -26,7 +26,9 @@ +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index 55c5c8600d4..d9ded7c4f12 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -25,7 +25,9 @@ + #include #include #include - #include +#include #include +#include #include #include #include -@@ -403,7 +405,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -636,7 +638,10 @@ fallback: grub_loader_unset(); kernel_alloc_pages = GRUB_EFI_BYTES_TO_PAGES (kernel_size + align - 1); diff --git a/0259-grub-probe-document-the-behavior-of-multiple-v.patch b/0259-grub-probe-document-the-behavior-of-multiple-v.patch deleted file mode 100644 index 4e9d7cc..0000000 --- a/0259-grub-probe-document-the-behavior-of-multiple-v.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robbie Harwood -Date: Fri, 15 Jul 2022 15:49:25 -0400 -Subject: [PATCH] grub-probe: document the behavior of multiple -v - -Signed-off-by: Robbie Harwood -(cherry picked from commit 51a55233eed08f7f12276afd6b3724b807a0b680) ---- - util/grub-probe.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/util/grub-probe.c b/util/grub-probe.c -index c6fac732b4..ba867319a7 100644 ---- a/util/grub-probe.c -+++ b/util/grub-probe.c -@@ -732,7 +732,8 @@ static struct argp_option options[] = { - {"device-map", 'm', N_("FILE"), 0, - N_("use FILE as the device map [default=%s]"), 0}, - {"target", 't', N_("TARGET"), 0, 0, 0}, -- {"verbose", 'v', 0, 0, N_("print verbose messages."), 0}, -+ {"verbose", 'v', 0, 0, -+ N_("print verbose messages (pass twice to enable debug printing)."), 0}, - {0, '0', 0, 0, N_("separate items in output using ASCII NUL characters"), 0}, - { 0, 0, 0, 0, 0, 0 } - }; diff --git a/0347-normal-Remove-grub_env_set-prefix-in-grub_try_normal.patch b/0259-normal-Remove-grub_env_set-prefix-in-grub_try_normal.patch similarity index 96% rename from 0347-normal-Remove-grub_env_set-prefix-in-grub_try_normal.patch rename to 0259-normal-Remove-grub_env_set-prefix-in-grub_try_normal.patch index 900c59a..af24bcc 100644 --- a/0347-normal-Remove-grub_env_set-prefix-in-grub_try_normal.patch +++ b/0259-normal-Remove-grub_env_set-prefix-in-grub_try_normal.patch @@ -14,7 +14,7 @@ Signed-off-by: Nicolas Frayer 1 file changed, 1 deletion(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c -index d59145f861d5..bac7b8a0e1d8 100644 +index 803b9656d36..26872ce9477 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -372,7 +372,6 @@ grub_try_normal_prefix (const char *prefix) diff --git a/0260-fs-xfs-Handle-non-continuous-data-blocks-in-director.patch b/0260-fs-xfs-Handle-non-continuous-data-blocks-in-director.patch new file mode 100644 index 0000000..2198ce3 --- /dev/null +++ b/0260-fs-xfs-Handle-non-continuous-data-blocks-in-director.patch @@ -0,0 +1,54 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jon DeVree +Date: Sun, 11 Feb 2024 10:34:58 -0500 +Subject: [PATCH] fs/xfs: Handle non-continuous data blocks in directory + extents + +The directory extent list does not have to be a continuous list of data +blocks. When GRUB tries to read a non-existant member of the list, +grub_xfs_read_file() will return a block of zero'ed memory. Checking for +a zero'ed magic number is sufficient to skip this non-existant data block. + +Prior to commit 07318ee7e (fs/xfs: Fix XFS directory extent parsing) +this was handled as a subtle side effect of reading the (non-existant) +tail data structure. Since the block was zero'ed the computation of the +number of directory entries in the block would return 0 as well. + +Fixes: 07318ee7e (fs/xfs: Fix XFS directory extent parsing) +Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2254370 + +Signed-off-by: Jon DeVree +Reviewed-By: Vladimir Serbinenko +Reviewed-by: Daniel Kiper +--- + grub-core/fs/xfs.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c +index bc2224dbb46..8e02ab4a301 100644 +--- a/grub-core/fs/xfs.c ++++ b/grub-core/fs/xfs.c +@@ -902,6 +902,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, + grub_xfs_first_de(dir->data, dirblock); + int entries = -1; + char *end = dirblock + dirblk_size; ++ grub_uint32_t magic; + + numread = grub_xfs_read_file (dir, 0, 0, + blk << dirblk_log2, +@@ -912,6 +913,15 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, + return 0; + } + ++ /* ++ * If this data block isn't actually part of the extent list then ++ * grub_xfs_read_file() returns a block of zeros. So, if the magic ++ * number field is all zeros then this block should be skipped. ++ */ ++ magic = *(grub_uint32_t *)(void *) dirblock; ++ if (!magic) ++ continue; ++ + /* + * Leaf and tail information are only in the data block if the number + * of extents is 1. diff --git a/0349-Ignore-warnings-for-incompatible-types.patch b/0261-Ignore-warnings-for-incompatible-types.patch similarity index 90% rename from 0349-Ignore-warnings-for-incompatible-types.patch rename to 0261-Ignore-warnings-for-incompatible-types.patch index 73e9910..ad7dacb 100644 --- a/0349-Ignore-warnings-for-incompatible-types.patch +++ b/0261-Ignore-warnings-for-incompatible-types.patch @@ -12,10 +12,10 @@ Signed-off-by: Nicolas Frayer 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac -index 79f45ef1e14c..b66e07c67851 100644 +index d223fe3ef6e..4788f3d6adc 100644 --- a/configure.ac +++ b/configure.ac -@@ -2009,8 +2009,8 @@ if test x"$enable_wextra" != xno ; then +@@ -2166,8 +2166,8 @@ if test x"$enable_wextra" != xno ; then HOST_CFLAGS="$HOST_CFLAGS -Wextra" fi diff --git a/0261-fs-fat-don-t-error-when-mtime-is-0.patch b/0261-fs-fat-don-t-error-when-mtime-is-0.patch deleted file mode 100644 index f014f6c..0000000 --- a/0261-fs-fat-don-t-error-when-mtime-is-0.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robbie Harwood -Date: Fri, 15 Jul 2022 15:42:41 -0400 -Subject: [PATCH] fs/fat: don't error when mtime is 0 -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -In the wild, we occasionally see valid ESPs where some file modification times -are 0. For instance: - - ├── [Dec 31 1979] EFI - │ ├── [Dec 31 1979] BOOT - │ │ ├── [Dec 31 1979] BOOTX64.EFI - │ │ └── [Dec 31 1979] fbx64.efi - │ └── [Jun 27 02:41] fedora - │ ├── [Dec 31 1979] BOOTX64.CSV - │ ├── [Dec 31 1979] fonts - │ ├── [Mar 14 03:35] fw - │ │ ├── [Mar 14 03:35] fwupd-359c1169-abd6-4a0d-8bce-e4d4713335c1.cap - │ │ ├── [Mar 14 03:34] fwupd-9d255c4b-2d88-4861-860d-7ee52ade9463.cap - │ │ └── [Mar 14 03:34] fwupd-b36438d8-9128-49d2-b280-487be02d948b.cap - │ ├── [Dec 31 1979] fwupdx64.efi - │ ├── [May 10 10:47] grub.cfg - │ ├── [Jun 3 12:38] grub.cfg.new.new - │ ├── [May 10 10:41] grub.cfg.old - │ ├── [Jun 27 02:41] grubenv - │ ├── [Dec 31 1979] grubx64.efi - │ ├── [Dec 31 1979] mmx64.efi - │ ├── [Dec 31 1979] shim.efi - │ ├── [Dec 31 1979] shimx64.efi - │ └── [Dec 31 1979] shimx64-fedora.efi - └── [Dec 31 1979] FSCK0000.REC - - 5 directories, 17 files - -This causes grub-probe failure, which in turn causes grub-mkconfig -failure. They are valid filesystems that appear intact, and the Linux -FAT stack is able to mount and manipulate them without complaint. - -The check for mtime of 0 has been present since -20def1a3c3952982395cd7c3ea7e78638527962b ("fat: support file -modification times"). - -Signed-off-by: Robbie Harwood -(cherry picked from commit 0615c4887352e32d7bb7198e9ad0d695f9dc2c31) ---- - grub-core/fs/fat.c | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c -index dd82e4ee35..ff6200c5be 100644 ---- a/grub-core/fs/fat.c -+++ b/grub-core/fs/fat.c -@@ -1027,9 +1027,6 @@ grub_fat_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook, - grub_le_to_cpu16 (ctxt.dir.w_date), - &info.mtime); - #endif -- if (info.mtimeset == 0) -- grub_error (GRUB_ERR_OUT_OF_RANGE, -- "invalid modification timestamp for %s", path); - - if (hook (ctxt.filename, &info, hook_data)) - break; diff --git a/0365-cmd-search-Rework-of-CVE-2023-4001-fix.patch b/0262-cmd-search-Rework-of-CVE-2023-4001-fix.patch similarity index 92% rename from 0365-cmd-search-Rework-of-CVE-2023-4001-fix.patch rename to 0262-cmd-search-Rework-of-CVE-2023-4001-fix.patch index 5e794a9..c63fc3e 100644 --- a/0365-cmd-search-Rework-of-CVE-2023-4001-fix.patch +++ b/0262-cmd-search-Rework-of-CVE-2023-4001-fix.patch @@ -16,11 +16,11 @@ containing the actual grub cfg stub) Signed-off-by: Nicolas Frayer --- - grub-core/commands/search.c | 136 +++++++++++++++++++++++++++++++++++++++++--- - 1 file changed, 127 insertions(+), 9 deletions(-) + grub-core/commands/search.c | 134 +++++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 126 insertions(+), 8 deletions(-) diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c -index 819231751c38..1e61a5cf940f 100644 +index db8692ffbfb..9dd937e6df4 100644 --- a/grub-core/commands/search.c +++ b/grub-core/commands/search.c @@ -30,6 +30,8 @@ @@ -133,11 +133,10 @@ index 819231751c38..1e61a5cf940f 100644 /* Helper for FUNC_NAME. */ static int iterate_device (const char *name, void *data) -@@ -104,15 +200,37 @@ iterate_device (const char *name, void *data) - grub_str_sep (root_dev, root_disk, ',', rem_1); +@@ -106,14 +202,36 @@ iterate_device (const char *name, void *data) grub_str_sep (name, name_disk, ',', rem_2); if (root_disk != NULL && *root_disk != '\0' && -- name_disk != NULL && *name_disk != '\0') + name_disk != NULL && *name_disk != '\0') - if (grub_strcmp(root_disk, name_disk) != 0) - { - grub_free (root_disk); @@ -146,7 +145,6 @@ index 819231751c38..1e61a5cf940f 100644 - grub_free (rem_2); - return 0; - } -+ name_disk != NULL && *name_disk != '\0') + { + grub_device_t dev, dev_part; + diff --git a/0263-loader-efi-linux.c-read-the-kernel-image-before-head.patch b/0263-loader-efi-linux.c-read-the-kernel-image-before-head.patch new file mode 100644 index 0000000..e8dc223 --- /dev/null +++ b/0263-loader-efi-linux.c-read-the-kernel-image-before-head.patch @@ -0,0 +1,69 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Leo Sandoval +Date: Wed, 29 May 2024 17:35:35 -0600 +Subject: [PATCH] loader/efi/linux.c: read the kernel image before header + +Signed-off-by: Leo Sandoval +--- + grub-core/loader/efi/linux.c | 34 ++++++++++++++++++++-------------- + 1 file changed, 20 insertions(+), 14 deletions(-) + +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index d9ded7c4f12..3ada50ed969 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -559,6 +559,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + grub_file_t file = 0; + struct linux_arch_kernel_header lh; + grub_off_t filelen; ++ grub_off_t filereadlen; + grub_uint32_t align; + grub_uint32_t code_size; + void *kernel = NULL; +@@ -592,6 +593,25 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + if (!file) + goto fail; + ++ filelen = grub_file_size (file); ++ kernel = grub_malloc(filelen); ++ if (!kernel) ++ { ++ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate kernel load buffer")); ++ goto fail; ++ } ++ ++ filereadlen = grub_file_read (file, kernel, filelen); ++ grub_dprintf ("linux", "filelen : %lld\n", (long long) filelen); ++ grub_dprintf ("linux", "filereadlen : %lld\n", (long long) filereadlen); ++ ++ if (filereadlen < filelen) ++ { ++ grub_error (GRUB_ERR_FILE_READ_ERROR, N_("Can't read kernel %s"), ++ argv[0]); ++ goto fail; ++ } ++ + if (grub_arch_efi_linux_load_image_header (file, &lh) != GRUB_ERR_NONE) + #if !defined(__i386__) && !defined(__x86_64__) + goto fail; +@@ -612,20 +632,6 @@ fallback: + } + #endif + +- filelen = grub_file_size (file); +- kernel = grub_malloc(filelen); +- if (!kernel) +- { +- grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate kernel load buffer")); +- goto fail; +- } +- +- if (grub_file_read (file, kernel, filelen) < (grub_ssize_t)filelen) +- { +- grub_error (GRUB_ERR_FILE_READ_ERROR, N_("Can't read kernel %s"), +- argv[0]); +- goto fail; +- } + + #if !defined(__i386__) && !defined(__x86_64__) + if (parse_pe_header (kernel, &kernel_size, &handover_offset, &align, &code_size) != GRUB_ERR_NONE) diff --git a/0257-nx-set-attrs-in-our-kernel-loaders.patch b/0264-nx-set-attrs-in-our-kernel-loaders.patch similarity index 77% rename from 0257-nx-set-attrs-in-our-kernel-loaders.patch rename to 0264-nx-set-attrs-in-our-kernel-loaders.patch index 514df1f..6b0aa1d 100644 --- a/0257-nx-set-attrs-in-our-kernel-loaders.patch +++ b/0264-nx-set-attrs-in-our-kernel-loaders.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Jones -Date: Tue, 22 Mar 2022 10:57:07 -0400 +Date: Wed, 3 Jul 2024 17:54:41 -0600 Subject: [PATCH] nx: set attrs in our kernel loaders For NX, our kernel loaders need to set write and execute page @@ -12,23 +12,22 @@ Signed-off-by: Peter Jones [rharwood: fix stack_attrs undefined, fix aarch64 callsites] Signed-off-by: Robbie Harwood --- - grub-core/kern/efi/mm.c | 77 +++++++++++++++++ - grub-core/loader/arm64/linux.c | 16 +++- - grub-core/loader/arm64/xen_boot.c | 4 +- + grub-core/kern/efi/mm.c | 79 ++++++++++++++++ + grub-core/loader/arm64/xen_boot.c | 5 +- grub-core/loader/efi/chainloader.c | 11 +++ - grub-core/loader/efi/linux.c | 164 ++++++++++++++++++++++++++++++++++++- - grub-core/loader/i386/efi/linux.c | 26 +++++- - grub-core/loader/i386/linux.c | 5 ++ + grub-core/loader/efi/linux.c | 188 ++++++++++++++++++++++++++++++++++--- + grub-core/loader/i386/efi/linux.c | 26 ++++- + grub-core/loader/i386/linux.c | 5 + include/grub/efi/efi.h | 6 +- include/grub/efi/linux.h | 16 +++- include/grub/efi/pe32.h | 2 + - 10 files changed, 312 insertions(+), 15 deletions(-) + 9 files changed, 319 insertions(+), 19 deletions(-) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index 2c33758ed7..e460b072e6 100644 +index 560b859b6f4..464fe1c3c01 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c -@@ -610,6 +610,81 @@ print_memory_map (grub_efi_memory_descriptor_t *memory_map, +@@ -603,6 +603,83 @@ print_memory_map (grub_efi_memory_descriptor_t *memory_map, } #endif @@ -107,11 +106,13 @@ index 2c33758ed7..e460b072e6 100644 + } +} + - void - grub_efi_mm_init (void) ++ ++ + static grub_err_t + grub_efi_mm_add_regions (grub_size_t required_bytes, unsigned int flags) { -@@ -623,6 +698,8 @@ grub_efi_mm_init (void) - grub_efi_uint64_t required_pages; +@@ -615,6 +692,8 @@ grub_efi_mm_add_regions (grub_size_t required_bytes, unsigned int flags) + grub_err_t err; int mm_status; + grub_nx_init (); @@ -119,66 +120,11 @@ index 2c33758ed7..e460b072e6 100644 /* Prepare a memory region to store two memory maps. */ memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); if (! memory_map) -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index cc67f43906..de85583487 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -172,7 +172,8 @@ free_params (void) - } - - grub_err_t --grub_arch_efi_linux_boot_image (grub_addr_t addr, char *args) -+grub_arch_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args, -+ int nx_supported) - { - grub_err_t retval; - -@@ -182,7 +183,8 @@ grub_arch_efi_linux_boot_image (grub_addr_t addr, char *args) - - grub_dprintf ("linux", "linux command line: '%s'\n", args); - -- retval = grub_efi_linux_boot ((char *)addr, handover_offset, (void *)addr); -+ retval = grub_efi_linux_boot (addr, size, handover_offset, -+ (void *)addr, nx_supported); - - /* Never reached... */ - free_params(); -@@ -192,7 +194,10 @@ grub_arch_efi_linux_boot_image (grub_addr_t addr, char *args) - static grub_err_t - grub_linux_boot (void) - { -- return (grub_arch_efi_linux_boot_image((grub_addr_t)kernel_addr, linux_args)); -+ return grub_arch_efi_linux_boot_image((grub_addr_t)kernel_addr, -+ (grub_size_t)kernel_size, -+ linux_args, -+ 0); - } - - static grub_err_t -@@ -340,6 +345,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - grub_off_t filelen; - grub_uint32_t align; - void *kernel = NULL; -+ int nx_supported = 1; - - grub_dl_ref (my_mod); - -@@ -376,6 +382,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), - grub_dprintf ("linux", "kernel entry offset : %d\n", handover_offset); - grub_dprintf ("linux", "kernel alignment : 0x%x\n", align); - -+ err = grub_efi_check_nx_image_support((grub_addr_t)kernel, filelen, &nx_supported); -+ if (err != GRUB_ERR_NONE) -+ goto fail; -+ - grub_loader_unset(); - - kernel_alloc_pages = GRUB_EFI_BYTES_TO_PAGES (kernel_size + align - 1); diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c -index d9b7a9ba40..6e7e920416 100644 +index 9838a0f878b..5d7c8603db9 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c -@@ -266,7 +266,9 @@ xen_boot (void) +@@ -252,7 +252,10 @@ xen_boot (void) return err; return grub_arch_efi_linux_boot_image (xen_hypervisor->start, @@ -186,14 +132,15 @@ index d9b7a9ba40..6e7e920416 100644 + xen_hypervisor->size, + xen_hypervisor->cmdline, + 0); ++ } static void diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c -index fb874f1855..dd31ac9bb3 100644 +index badff5e50b5..5cd6f6a5993 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c -@@ -1070,6 +1070,17 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), +@@ -1078,6 +1078,17 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), goto fail; } @@ -212,18 +159,18 @@ index fb874f1855..dd31ac9bb3 100644 if (fsize >= (grub_ssize_t) sizeof (struct grub_macho_fat_header)) { diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index 9265cf4200..277f352e0c 100644 +index 3ada50ed969..fe48001442a 100644 --- a/grub-core/loader/efi/linux.c +++ b/grub-core/loader/efi/linux.c -@@ -26,16 +26,127 @@ +@@ -96,16 +96,127 @@ static grub_efi_load_file2_t initrd_lf2 = { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-align" +#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" + +grub_err_t -+grub_efi_check_nx_image_support (grub_addr_t kernel_addr, -+ grub_size_t kernel_size, ++grub_efi_check_nx_image_support (grub_addr_t k_add, ++ grub_size_t k_size, + int *nx_supported) +{ + struct grub_dos_header *doshdr; @@ -235,19 +182,19 @@ index 9265cf4200..277f352e0c 100644 + int image_is_compatible = 0; + int is_64_bit; + -+ if (kernel_size < sz) ++ if (k_size < sz) + return grub_error (GRUB_ERR_BAD_OS, N_("kernel is too small")); + -+ doshdr = (void *)kernel_addr; ++ doshdr = (void *)k_add; + + if ((doshdr->magic & 0xffff) != GRUB_DOS_MAGIC) + return grub_error (GRUB_ERR_BAD_OS, N_("kernel DOS magic is invalid")); + + sz = doshdr->lfanew + sizeof (*pe32); -+ if (kernel_size < sz) ++ if (k_size < sz) + return grub_error (GRUB_ERR_BAD_OS, N_("kernel is too small")); + -+ pe32 = (struct grub_pe32_header_32 *)(kernel_addr + doshdr->lfanew); ++ pe32 = (struct grub_pe32_header_32 *)(k_add + doshdr->lfanew); + pe64 = (struct grub_pe32_header_64 *)pe32; + + if (grub_memcmp (pe32->signature, GRUB_PE32_SIGNATURE, @@ -275,7 +222,7 @@ index 9265cf4200..277f352e0c 100644 + if (is_64_bit) + { + sz = doshdr->lfanew + sizeof (*pe64); -+ if (kernel_size < sz) ++ if (k_size < sz) + return grub_error (GRUB_ERR_BAD_OS, N_("kernel is too small")); + + if (pe64->optional_header.dll_characteristics & GRUB_PE32_NX_COMPAT) @@ -295,7 +242,7 @@ index 9265cf4200..277f352e0c 100644 +grub_efi_check_nx_required (int *nx_required) +{ + grub_efi_status_t status; -+ grub_efi_guid_t guid = GRUB_EFI_SHIM_LOCK_GUID; ++ grub_guid_t guid = GRUB_EFI_SHIM_LOCK_GUID; + grub_size_t mok_policy_sz = 0; + char *mok_policy = NULL; + grub_uint32_t mok_policy_attrs = 0; @@ -325,10 +272,10 @@ index 9265cf4200..277f352e0c 100644 typedef void (*handover_func) (void *, grub_efi_system_table_t *, void *); grub_err_t --grub_efi_linux_boot (void *kernel_addr, grub_off_t handover_offset, +-grub_efi_linux_boot (void *kernel_address, grub_off_t ho_offset, - void *kernel_params) -+grub_efi_linux_boot (grub_addr_t kernel_addr, grub_size_t kernel_size, -+ grub_off_t handover_offset, void *kernel_params, ++grub_efi_linux_boot (grub_addr_t k_address, grub_size_t k_size, ++ grub_off_t h_offset, void *k_params, + int nx_supported) { grub_efi_loaded_image_t *loaded_image = NULL; @@ -345,18 +292,20 @@ index 9265cf4200..277f352e0c 100644 #ifdef __x86_64__ offset = 512; -@@ -48,12 +159,57 @@ grub_efi_linux_boot (void *kernel_addr, grub_off_t handover_offset, +@@ -118,14 +229,59 @@ grub_efi_linux_boot (void *kernel_address, grub_off_t ho_offset, */ loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); if (loaded_image) -- loaded_image->image_base = kernel_addr; -+ loaded_image->image_base = (void *)kernel_addr; +- loaded_image->image_base = kernel_address; ++ loaded_image->image_base = (void *)k_address; 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); -+ (void *)kernel_addr, (void *)handover_offset, kernel_params); + grub_dprintf ("linux", "kernel_address: %p handover_offset: %p params: %p\n", +- kernel_address, (void *)(grub_efi_uintn_t)ho_offset, kernel_params); +- hf = (handover_func)((char *)kernel_address + ho_offset + offset); +- hf (grub_efi_image_handle, grub_efi_system_table, kernel_params); ++ (void *)k_address, (void *)h_offset, k_params); + + + if (nx_required && !nx_supported) @@ -371,14 +320,14 @@ index 9265cf4200..277f352e0c 100644 + } + + grub_dprintf ("nx", "Setting attributes for 0x%"PRIxGRUB_ADDR"-0x%"PRIxGRUB_ADDR" to r%cx\n", -+ kernel_addr, kernel_addr + kernel_size - 1, ++ k_address, k_address + k_size - 1, + (kernel_set_attrs & GRUB_MEM_ATTR_W) ? 'w' : '-'); -+ grub_update_mem_attrs (kernel_addr, kernel_size, ++ grub_update_mem_attrs (k_address, k_size, + kernel_set_attrs, kernel_clear_attrs); + -+ grub_get_mem_attrs (kernel_addr, 4096, &attrs); ++ grub_get_mem_attrs (k_address, 4096, &attrs); + grub_dprintf ("nx", "permissions for 0x%"PRIxGRUB_ADDR" are %s%s%s\n", -+ (grub_addr_t)kernel_addr, ++ (grub_addr_t)k_address, + (attrs & GRUB_MEM_ATTR_R) ? "r" : "-", + (attrs & GRUB_MEM_ATTR_W) ? "w" : "-", + (attrs & GRUB_MEM_ATTR_X) ? "x" : "-"); @@ -402,11 +351,75 @@ index 9265cf4200..277f352e0c 100644 + asm volatile ("cli"); +#endif + - hf = (handover_func)((char *)kernel_addr + handover_offset + offset); - hf (grub_efi_image_handle, grub_efi_system_table, kernel_params); ++ hf = (handover_func)((char *)k_address + h_offset + offset); ++ hf (grub_efi_image_handle, grub_efi_system_table, k_params); + return GRUB_ERR_BUG; + } +@@ -287,13 +443,15 @@ free_params (void) + } + + grub_err_t +-grub_arch_efi_linux_boot_image (grub_addr_t addr, char *args) ++grub_arch_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args, ++ int nx_supported) + { + grub_err_t retval; + + grub_dprintf ("linux", "linux command line: '%s'\n", args); + +- retval = grub_efi_linux_boot ((char *)addr, handover_offset, (void *)addr); ++ retval = grub_efi_linux_boot (addr, size, handover_offset, ++ (void *)addr, nx_supported); + + /* Never reached... */ + free_params(); +@@ -308,7 +466,10 @@ grub_linux_boot (void) + return grub_errno; + #endif + +- return grub_arch_efi_linux_boot_image ((grub_addr_t) kernel_addr, linux_args); ++ return grub_arch_efi_linux_boot_image((grub_addr_t)kernel_addr, ++ (grub_size_t)kernel_size, ++ linux_args, ++ 0); + } + + static grub_err_t +@@ -560,10 +721,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + struct linux_arch_kernel_header lh; + grub_off_t filelen; + grub_off_t filereadlen; +- grub_uint32_t align; +- grub_uint32_t code_size; + void *kernel = NULL; + grub_err_t err; ++ int nx_supported = 1; + + grub_dl_ref (my_mod); + +@@ -634,6 +794,8 @@ fallback: + + + #if !defined(__i386__) && !defined(__x86_64__) ++ grub_uint32_t align; ++ grub_uint32_t code_size; + if (parse_pe_header (kernel, &kernel_size, &handover_offset, &align, &code_size) != GRUB_ERR_NONE) + goto fail; + grub_dprintf ("linux", "kernel mem size : %lld\n", (long long) kernel_size); +@@ -641,6 +803,10 @@ fallback: + grub_dprintf ("linux", "kernel alignment : 0x%x\n", align); + grub_dprintf ("linux", "kernel size : 0x%x\n", code_size); + ++ err = grub_efi_check_nx_image_support((grub_addr_t)kernel, filelen, &nx_supported); ++ if (err != GRUB_ERR_NONE) ++ goto fail; ++ + grub_loader_unset(); + + kernel_alloc_pages = GRUB_EFI_BYTES_TO_PAGES (kernel_size + align - 1); diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c -index 92b2fb5091..91ae274299 100644 +index f97b123a51e..abbf6b24f50 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -44,7 +44,7 @@ struct grub_linuxefi_context { @@ -418,7 +431,7 @@ index 92b2fb5091..91ae274299 100644 void *initrd_mem; }; -@@ -110,13 +110,19 @@ kernel_alloc(grub_efi_uintn_t size, +@@ -134,13 +134,19 @@ kernel_alloc(kernel_alloc_purpose_t purpose, pages = BYTES_TO_PAGES(size); grub_dprintf ("linux", "Trying to allocate %lu pages from %p\n", (unsigned long)pages, (void *)(unsigned long)max); @@ -439,7 +452,7 @@ index 92b2fb5091..91ae274299 100644 } while (grub_error_pop ()) -@@ -137,9 +143,11 @@ grub_linuxefi_boot (void *data) +@@ -161,9 +167,11 @@ grub_linuxefi_boot (void *data) asm volatile ("cli"); @@ -453,7 +466,7 @@ index 92b2fb5091..91ae274299 100644 } static grub_err_t -@@ -304,7 +312,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -331,7 +339,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_uint32_t handover_offset; struct linux_kernel_params *params = 0; char *cmdline = 0; @@ -463,7 +476,7 @@ index 92b2fb5091..91ae274299 100644 grub_dl_ref (my_mod); -@@ -334,6 +344,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -361,6 +371,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } @@ -477,7 +490,7 @@ index 92b2fb5091..91ae274299 100644 lh = (struct linux_i386_kernel_header *)kernel; grub_dprintf ("linux", "original lh is at %p\n", kernel); -@@ -498,6 +515,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -530,6 +547,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), context->handover_offset = handover_offset; context->params = params; context->cmdline = cmdline; @@ -486,10 +499,10 @@ index 92b2fb5091..91ae274299 100644 grub_loader_set_ex (grub_linuxefi_boot, grub_linuxefi_unload, context, 0); diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c -index 4aeb0e4b9a..3c1ff64763 100644 +index 5a257552234..90121e9bc5a 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c -@@ -805,6 +805,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), +@@ -817,6 +817,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), kernel_offset += len; } @@ -502,29 +515,31 @@ index 4aeb0e4b9a..3c1ff64763 100644 linux_params.kernel_alignment = (1 << align); linux_params.ps_mouse = linux_params.padding11 = 0; diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h -index 34825c4adc..449e55269f 100644 +index c40684821e1..2c0e7f24bda 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h -@@ -140,12 +140,16 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, - char **device, - char **path); +@@ -190,6 +190,9 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd, + void * + EXPORT_FUNC (grub_efi_find_configuration_table) (const grub_guid_t *target_guid); +extern grub_addr_t EXPORT_VAR(grub_stack_addr); +extern grub_size_t EXPORT_VAR(grub_stack_size); + - #if defined(__arm__) || defined(__aarch64__) || defined(__riscv) + #if defined(__arm__) || defined(__aarch64__) || defined(__riscv) || defined(__loongarch__) 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_arch_efi_linux_check_image(struct linux_arch_kernel_header *lh); +@@ -197,7 +200,8 @@ grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *); + #include + grub_err_t grub_arch_efi_linux_load_image_header(grub_file_t file, + struct linux_arch_kernel_header *lh); -grub_err_t grub_arch_efi_linux_boot_image(grub_addr_t addr, char *args); +grub_err_t grub_arch_efi_linux_boot_image(grub_addr_t addr, grub_size_t size, + char *args, int nx_enabled); - #endif grub_addr_t grub_efi_section_addr (const char *section); + diff --git a/include/grub/efi/linux.h b/include/grub/efi/linux.h -index 887b02fd9f..b82f71006a 100644 +index c806a7757f3..5b4e626c37c 100644 --- a/include/grub/efi/linux.h +++ b/include/grub/efi/linux.h @@ -22,8 +22,20 @@ @@ -535,26 +550,26 @@ index 887b02fd9f..b82f71006a 100644 + grub_err_t -EXPORT_FUNC(grub_efi_linux_boot) (void *kernel_address, grub_off_t offset, -- void *kernel_param); +- void *kernel_param); +EXPORT_FUNC(grub_efi_linux_boot) (grub_addr_t kernel_address, -+ grub_size_t kernel_size, -+ grub_off_t handover_offset, -+ void *kernel_param, int nx_enabled); ++ grub_size_t kernel_size, ++ grub_off_t handover_offset, ++ void *kernel_param, int nx_enabled); + +grub_err_t +EXPORT_FUNC(grub_efi_check_nx_image_support) (grub_addr_t kernel_addr, -+ grub_size_t kernel_size, -+ int *nx_supported); ++ grub_size_t kernel_size, ++ int *nx_supported); + +grub_err_t +EXPORT_FUNC(grub_efi_check_nx_required) (int *nx_required); #endif /* ! GRUB_EFI_LINUX_HEADER */ diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h -index 2a5e1ee003..a5e623eb04 100644 +index 13fdd0e7d98..a4d62373cc9 100644 --- a/include/grub/efi/pe32.h +++ b/include/grub/efi/pe32.h -@@ -181,6 +181,8 @@ struct grub_pe32_optional_header +@@ -194,6 +194,8 @@ struct grub_pe32_optional_header struct grub_pe32_data_directory reserved_entry; }; diff --git a/0265-efi-Provide-wrappers-for-load_image-start_image.patch b/0265-efi-Provide-wrappers-for-load_image-start_image.patch new file mode 100644 index 0000000..1ee0f32 --- /dev/null +++ b/0265-efi-Provide-wrappers-for-load_image-start_image.patch @@ -0,0 +1,183 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Julian Andres Klode +Date: Tue, 9 Jul 2024 16:46:05 -0600 +Subject: [PATCH] efi: Provide wrappers for load_image, start_image, + +These can be used to register a different implementation later, +for example, when shim provides a protocol with those functions. + +Signed-off-by: Mate Kukri +--- + grub-core/kern/efi/efi.c | 57 ++++++++++++++++++++++++++++++++++++++ + grub-core/loader/efi/chainloader.c | 13 ++++----- + include/grub/efi/efi.h | 37 +++++++++++++++++++++++++ + 3 files changed, 100 insertions(+), 7 deletions(-) + +diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c +index cdfc11565c7..b5b8a329622 100644 +--- a/grub-core/kern/efi/efi.c ++++ b/grub-core/kern/efi/efi.c +@@ -1131,6 +1131,63 @@ grub_efi_find_configuration_table (const grub_guid_t *target_guid) + return 0; + } + ++static const grub_efi_loader_t *override_loader = NULL; ++ ++grub_err_t ++grub_efi_register_loader (const grub_efi_loader_t *loader) ++{ ++ if (override_loader != NULL) ++ return grub_error (GRUB_ERR_BUG, "trying to register different loader"); ++ override_loader = loader; ++ return GRUB_ERR_NONE; ++} ++ ++grub_err_t ++grub_efi_unregister_loader (const grub_efi_loader_t *loader) ++{ ++ if (loader != override_loader) ++ return grub_error (GRUB_ERR_BUG, "trying to unregister different loader"); ++ ++ override_loader = NULL; ++ return GRUB_ERR_NONE; ++} ++ ++grub_efi_status_t ++grub_efi_load_image (grub_efi_boolean_t boot_policy, ++ grub_efi_handle_t parent_image_handle, ++ grub_efi_device_path_t *file_path, void *source_buffer, ++ grub_efi_uintn_t source_size, ++ grub_efi_handle_t *image_handle) ++{ ++ if (override_loader != NULL) ++ return override_loader->load_image (boot_policy, parent_image_handle, ++ file_path, source_buffer, source_size, ++ image_handle); ++ return grub_efi_system_table->boot_services->load_image ( ++ boot_policy, parent_image_handle, file_path, source_buffer, source_size, ++ image_handle); ++} ++ ++grub_efi_status_t ++grub_efi_start_image (grub_efi_handle_t image_handle, ++ grub_efi_uintn_t *exit_data_size, ++ grub_efi_char16_t **exit_data) ++{ ++ if (override_loader != NULL) ++ return override_loader->start_image (image_handle, exit_data_size, ++ exit_data); ++ return grub_efi_system_table->boot_services->start_image ( ++ image_handle, exit_data_size, exit_data); ++} ++ ++grub_efi_status_t ++grub_efi_unload_image (grub_efi_handle_t image_handle) ++{ ++ if (override_loader != NULL) ++ return override_loader->unload_image (image_handle); ++ return grub_efi_system_table->boot_services->unload_image (image_handle); ++} ++ + grub_err_t + grub_efi_status_to_err (grub_efi_status_t status) + { +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index 5cd6f6a5993..9b1cc3fd41d 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -69,7 +69,7 @@ grub_start_image (grub_efi_handle_t handle) + + b = grub_efi_system_table->boot_services; + +- status = b->start_image (handle, &exit_data_size, &exit_data); ++ status = grub_efi_start_image (handle, &exit_data_size, &exit_data); + if (status != GRUB_EFI_SUCCESS) + { + if (exit_data) +@@ -101,7 +101,6 @@ grub_chainloader_unload (void *context) + { + grub_efi_handle_t image_handle; + grub_efi_loaded_image_t *loaded_image; +- grub_efi_boot_services_t *b; + + image_handle = (grub_efi_handle_t) context; + +@@ -109,8 +108,7 @@ grub_chainloader_unload (void *context) + if (loaded_image != NULL) + grub_free (loaded_image->load_options); + +- b = grub_efi_system_table->boot_services; +- b->unload_image (image_handle); ++ grub_efi_unload_image (image_handle); + + grub_dl_unref (my_mod); + return GRUB_ERR_NONE; +@@ -871,8 +869,8 @@ grub_load_image(grub_efi_device_path_t *file_path, void *boot_image, + + b = grub_efi_system_table->boot_services; + +- status = b->load_image (0, grub_efi_image_handle, file_path, +- boot_image, image_size, image_handle_out); ++ status = grub_efi_load_image (0, grub_efi_image_handle, file_path, ++ boot_image, image_size, image_handle_out); + if (status != GRUB_EFI_SUCCESS) + { + if (status == GRUB_EFI_OUT_OF_RESOURCES) +@@ -1198,7 +1196,8 @@ fail: + if (cmdline) + grub_free (cmdline); + +- b->unload_image (image_handle); ++ if (image_handle != NULL) ++ grub_efi_unload_image (image_handle); + + grub_dl_unref (my_mod); + +diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h +index 2c0e7f24bda..7eed1bd791d 100644 +--- a/include/grub/efi/efi.h ++++ b/include/grub/efi/efi.h +@@ -202,6 +202,43 @@ grub_err_t grub_arch_efi_linux_load_image_header(grub_file_t file, + 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, int nx_enabled); ++grub_efi_status_t ++EXPORT_FUNC (grub_efi_load_image) (grub_efi_boolean_t boot_policy, ++ grub_efi_handle_t parent_image_handle, ++ grub_efi_device_path_t *file_path, ++ void *source_buffer, grub_efi_uintn_t source_size, ++ grub_efi_handle_t *image_handle); ++ ++grub_efi_status_t ++EXPORT_FUNC (grub_efi_start_image) (grub_efi_handle_t image_handle, ++ grub_efi_uintn_t *exit_data_size, ++ grub_efi_char16_t **exit_data); ++ ++grub_efi_status_t ++EXPORT_FUNC (grub_efi_unload_image) (grub_efi_handle_t image_handle); ++ ++typedef struct grub_efi_loader ++{ ++ grub_efi_status_t (__grub_efi_api *load_image) (grub_efi_boolean_t boot_policy, ++ grub_efi_handle_t parent_image_handle, ++ grub_efi_device_path_t *file_path, ++ void *source_buffer, ++ grub_efi_uintn_t source_size, ++ grub_efi_handle_t *image_handle); ++ ++ grub_efi_status_t (__grub_efi_api *start_image) (grub_efi_handle_t image_handle, ++ grub_efi_uintn_t *exit_data_size, ++ grub_efi_char16_t **exit_data); ++ ++ grub_efi_status_t (__grub_efi_api *unload_image) (grub_efi_handle_t image_handle); ++} grub_efi_loader_t; ++ ++grub_err_t ++EXPORT_FUNC (grub_efi_register_loader) (const grub_efi_loader_t *loader); ++ ++grub_err_t ++EXPORT_FUNC (grub_efi_unregister_loader) (const grub_efi_loader_t *loader); ++ + + grub_addr_t grub_efi_section_addr (const char *section); + diff --git a/0266-efi-Disallow-fallback-to-legacy-Linux-loader-when-sh.patch b/0266-efi-Disallow-fallback-to-legacy-Linux-loader-when-sh.patch new file mode 100644 index 0000000..719d920 --- /dev/null +++ b/0266-efi-Disallow-fallback-to-legacy-Linux-loader-when-sh.patch @@ -0,0 +1,66 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Mate Kukri +Date: Wed, 10 Jul 2024 12:07:17 -0600 +Subject: [PATCH] efi: Disallow fallback to legacy Linux loader when shim says + NX is required. + +Signed-off-by: Mate Kukri +--- + grub-core/loader/efi/linux.c | 13 ++++++++----- + include/grub/efi/api.h | 2 ++ + 2 files changed, 10 insertions(+), 5 deletions(-) + +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index fe48001442a..0d1804b602d 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -724,6 +724,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + void *kernel = NULL; + grub_err_t err; + int nx_supported = 1; ++ int nx_required = 0; + + grub_dl_ref (my_mod); + +@@ -772,21 +773,23 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + goto fail; + } + ++#if !defined(__i386__) && !defined(__x86_64__) + if (grub_arch_efi_linux_load_image_header (file, &lh) != GRUB_ERR_NONE) +-#if !defined(__i386__) && !defined(__x86_64__) + goto fail; + #else +- goto fallback; +- +- if (!initrd_use_loadfile2) ++ if (grub_arch_efi_linux_load_image_header (file, &lh) != GRUB_ERR_NONE || ++ !initrd_use_loadfile2) + { ++ /* We cannot use the legacy loader when NX is required */ ++ if (grub_efi_check_nx_required(&nx_required)) ++ goto fail; ++ + /* + * This is a EFI stub image but it is too old to implement the LoadFile2 + * based initrd loading scheme, and Linux/x86 does not support the DT + * based method either. So fall back to the x86-specific loader that + * enters Linux in EFI mode but without going through its EFI stub. + */ +-fallback: + grub_file_close (file); + return grub_cmd_linux_x86_legacy (cmd, argc, argv); + } +diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h +index 76c88fbdcb0..2376182d735 100644 +--- a/include/grub/efi/api.h ++++ b/include/grub/efi/api.h +@@ -2006,6 +2006,8 @@ struct grub_efi_block_io + }; + typedef struct grub_efi_block_io grub_efi_block_io_t; + ++#define GRUB_MOK_POLICY_NX_REQUIRED 0x1 ++ + struct grub_efi_shim_lock_protocol + { + /* diff --git a/0267-Set-non-executable-stack-sections-on-EFI-assembly-fi.patch b/0267-Set-non-executable-stack-sections-on-EFI-assembly-fi.patch new file mode 100644 index 0000000..85ccb0e --- /dev/null +++ b/0267-Set-non-executable-stack-sections-on-EFI-assembly-fi.patch @@ -0,0 +1,47 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Leo Sandoval +Date: Mon, 5 Aug 2024 13:19:28 -0600 +Subject: [PATCH] Set non-executable stack sections on EFI assembly files + +For those manual assembly files created where no '.note.GNU-stack' +section is explicitly added, linker defaults it as executable and this +is the reason that RHEL CI rpminspect & annocheck tests are +failing. The proposed change sets the corresponding GNU-stack +sections otherwise CI detects the following security vulnerability + + $ annocheck annocheck --ignore-unknown --verbose --profile=el9 *.rpm 2>&1 | grep FAIL | grep stack + (standard input):(standard input):Hardened: ./usr/lib/grub/x86_64-efi/kernel.exec: FAIL: gnu-stack test because .note.GNU-stack section has execute permission + (standard input):(standard input):Hardened: ./usr/lib/grub/x86_64-efi/kernel.img: FAIL: gnu-stack test because .note.GNU-stack section has execute permission + +Signed-off-by: Leo Sandoval +--- + grub-core/kern/i386/efi/startup.S | 5 +++++ + grub-core/kern/x86_64/efi/startup.S | 5 +++++ + 2 files changed, 10 insertions(+) + +diff --git a/grub-core/kern/i386/efi/startup.S b/grub-core/kern/i386/efi/startup.S +index fc5ea3dac86..36d1b1a6897 100644 +--- a/grub-core/kern/i386/efi/startup.S ++++ b/grub-core/kern/i386/efi/startup.S +@@ -34,3 +34,8 @@ _start: + movl %eax, EXT_C(grub_efi_system_table) + call EXT_C(grub_main) + ret ++ ++/* An executable stack is not required for these functions. */ ++#if defined (__linux__) && defined (__ELF__) ++.section .note.GNU-stack,"",%progbits ++#endif +diff --git a/grub-core/kern/x86_64/efi/startup.S b/grub-core/kern/x86_64/efi/startup.S +index 9357e5c5dda..f5c6bc3d8eb 100644 +--- a/grub-core/kern/x86_64/efi/startup.S ++++ b/grub-core/kern/x86_64/efi/startup.S +@@ -33,3 +33,8 @@ _start: + andq $~0xf, %rsp + call EXT_C(grub_main) + /* Doesn't return. */ ++ ++/* An executable stack is not required for these functions. */ ++#if defined (__linux__) && defined (__ELF__) ++.section .note.GNU-stack,"",%progbits ++#endif diff --git a/0366-grub-mkconfig.in-turn-off-executable-owner-bit.patch b/0268-grub-mkconfig.in-turn-off-executable-owner-bit.patch similarity index 76% rename from 0366-grub-mkconfig.in-turn-off-executable-owner-bit.patch rename to 0268-grub-mkconfig.in-turn-off-executable-owner-bit.patch index fc3c0f9..9a40b96 100644 --- a/0366-grub-mkconfig.in-turn-off-executable-owner-bit.patch +++ b/0268-grub-mkconfig.in-turn-off-executable-owner-bit.patch @@ -1,29 +1,27 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Leo Sandoval -Date: Mon, 1 Jul 2024 12:52:13 -0600 +Date: Mon, 6 May 2024 15:35:41 -0600 Subject: [PATCH] grub-mkconfig.in: turn off executable owner bit Stricker permissions are required on the grub.cfg file, resulting in at most 0600 owner's file permissions. This resolves conflicting requirement permissions on grub2-pc package's grub2.cfg file. -Resolves: RHEL-45870 - Signed-off-by: Leo Sandoval --- util/grub-mkconfig.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 3f131eea2b12..8c2bb8259de1 100644 +index bec52e052fc..461df7f09af 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in -@@ -328,7 +328,7 @@ and /etc/grub.d/* files or please file a bug report with - exit 1 +@@ -316,7 +316,7 @@ and /etc/grub.d/* files or please file a bug report with else # none of the children aborted with error, install the new grub.cfg -- oldumask=$(umask); umask 077 -+ oldumask=$(umask); umask 177 + oldumask=$(umask) +- umask 077 ++ umask 177 cat ${grub_cfg}.new > ${grub_cfg} umask $oldumask rm -f ${grub_cfg}.new diff --git a/0269-kern-ieee1275-init-Add-IEEE-1275-Radix-support-for-K.patch b/0269-kern-ieee1275-init-Add-IEEE-1275-Radix-support-for-K.patch new file mode 100644 index 0000000..4847c54 --- /dev/null +++ b/0269-kern-ieee1275-init-Add-IEEE-1275-Radix-support-for-K.patch @@ -0,0 +1,119 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Avnish Chouhan +Date: Thu, 23 May 2024 18:43:14 +0530 +Subject: [PATCH] kern/ieee1275/init: Add IEEE 1275 Radix support for KVM on + Power + +This patch adds support for Radix, Xive and Radix_gtse in Options +vector5 which is required for KVM LPARs. KVM LPARs ONLY support +Radix and not the Hash. Not enabling Radix on any PowerVM KVM LPARs +will result in boot failure. + +Signed-off-by: Avnish Chouhan +Reviewed-by: Daniel Kiper +--- + grub-core/kern/ieee1275/init.c | 63 +++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 62 insertions(+), 1 deletion(-) + +diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c +index 13e8a5b4bb8..6c5f4fb77af 100644 +--- a/grub-core/kern/ieee1275/init.c ++++ b/grub-core/kern/ieee1275/init.c +@@ -113,6 +113,16 @@ grub_addr_t grub_ieee1275_original_stack; + #define DRC_INFO 0x40 + #define BYTE22 (DY_MEM_V2 | DRC_INFO) + ++/* For ibm,arch-vec-5-platform-support. */ ++#define XIVE_INDEX 0x17 ++#define MMU_INDEX 0x18 ++#define RADIX_GTSE_INDEX 0x1a ++#define RADIX_ENABLED 0x40 ++#define XIVE_ENABLED 0x40 ++#define HASH_ENABLED 0x00 ++#define MAX_SUPPORTED 0xC0 ++#define RADIX_GTSE_ENABLED 0x40 ++ + void + grub_exit (int rc __attribute__((unused))) + { +@@ -739,6 +749,10 @@ struct option_vector5 + grub_uint32_t platform_facilities; + grub_uint8_t sub_processors; + grub_uint8_t byte22; ++ grub_uint8_t xive; ++ grub_uint8_t mmu; ++ grub_uint8_t hpt_ext; ++ grub_uint8_t radix_gtse; + } GRUB_PACKED; + + struct pvr_entry +@@ -777,6 +791,13 @@ grub_ieee1275_ibm_cas (void) + { + int rc; + grub_ieee1275_ihandle_t root; ++ grub_uint8_t ibm_arch_platform_support[8]; ++ grub_ssize_t actual; ++ grub_uint8_t xive_support = 0; ++ grub_uint8_t mmu_support = 0; ++ grub_uint8_t radix_gtse_support = 0; ++ int i = 0; ++ int prop_len = 8; + struct cas_args + { + struct grub_ieee1275_common_hdr common; +@@ -785,6 +806,46 @@ grub_ieee1275_ibm_cas (void) + grub_ieee1275_cell_t cas_addr; + grub_ieee1275_cell_t result; + } args; ++ ++ grub_ieee1275_get_integer_property (grub_ieee1275_chosen, ++ "ibm,arch-vec-5-platform-support", ++ (grub_uint32_t *) ibm_arch_platform_support, ++ sizeof (ibm_arch_platform_support), ++ &actual); ++ ++ for (i = 0; i < prop_len; i++) ++ { ++ switch (ibm_arch_platform_support[i]) ++ { ++ case XIVE_INDEX: ++ if (ibm_arch_platform_support[i + 1] & MAX_SUPPORTED) ++ xive_support = XIVE_ENABLED; ++ else ++ xive_support = 0; ++ break; ++ ++ case MMU_INDEX: ++ if (ibm_arch_platform_support[i + 1] & MAX_SUPPORTED) ++ mmu_support = RADIX_ENABLED; ++ else ++ mmu_support = HASH_ENABLED; ++ break; ++ ++ case RADIX_GTSE_INDEX: ++ if (mmu_support == RADIX_ENABLED) ++ radix_gtse_support = ibm_arch_platform_support[i + 1] & RADIX_GTSE_ENABLED; ++ else ++ radix_gtse_support = 0; ++ break; ++ ++ default: ++ /* Ignoring the other indexes of ibm,arch-vec-5-platform-support. */ ++ break; ++ } ++ /* Skipping the property value. */ ++ i++; ++ } ++ + struct cas_vector vector = + { + .pvr_list = { { 0x00000000, 0xffffffff } }, /* any processor */ +@@ -801,7 +862,7 @@ grub_ieee1275_ibm_cas (void) + .vec4 = 0x0001, /* set required minimum capacity % to the lowest value */ + .vec5_size = 1 + sizeof (struct option_vector5) - 2, + .vec5 = { +- 0, BYTE2, 0, CMO, ASSOCIATIVITY, BIN_OPTS, 0, 0, MAX_CPU, 0, 0, PLATFORM_FACILITIES, SUB_PROCESSORS, BYTE22 ++ 0, BYTE2, 0, CMO, ASSOCIATIVITY, BIN_OPTS, 0, 0, MAX_CPU, 0, 0, PLATFORM_FACILITIES, SUB_PROCESSORS, BYTE22, xive_support, mmu_support, 0, radix_gtse_support + } + }; + diff --git a/0351-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch b/0270-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch similarity index 95% rename from 0351-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch rename to 0270-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch index fc76a5e..a3f8c80 100644 --- a/0351-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch +++ b/0270-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch @@ -14,10 +14,10 @@ Signed-off-by: Nicolas Frayer 1 file changed, 14 insertions(+) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 34f7c13fc521..34d0120d0ba2 100644 +index 461df7f09af..b560aae6c5f 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in -@@ -114,6 +114,20 @@ do +@@ -109,6 +109,20 @@ do esac done diff --git a/0352-grub2-mkconfig-Simplify-os_name-detection.patch b/0271-grub2-mkconfig-Simplify-os_name-detection.patch similarity index 86% rename from 0352-grub2-mkconfig-Simplify-os_name-detection.patch rename to 0271-grub2-mkconfig-Simplify-os_name-detection.patch index 3d2f9a6..72e7e32 100644 --- a/0352-grub2-mkconfig-Simplify-os_name-detection.patch +++ b/0271-grub2-mkconfig-Simplify-os_name-detection.patch @@ -1,4 +1,4 @@ -From ac5b2bc87a6c361fd504898a368f0867ef3e2679 Mon Sep 17 00:00:00 2001 +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Andrew Lukoshko Date: Wed, 31 Jul 2024 16:06:10 +0000 Subject: [PATCH] grub2-mkconfig: Simplify os_name detection @@ -8,10 +8,10 @@ Subject: [PATCH] grub2-mkconfig: Simplify os_name detection 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 7a0738b..ebf5150 100644 +index b560aae6c5f..6f48c5dab5f 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in -@@ -114,12 +114,7 @@ do +@@ -109,12 +109,7 @@ do esac done @@ -25,6 +25,3 @@ index 7a0738b..ebf5150 100644 if test "x${grub_cfg}" = "x/boot/efi/EFI/$os_name/grub.cfg" &&\ mountpoint -q /boot/efi; then gettext_printf "Running \`grub2-mkconfig -o %s' will overwrite the GRUB wrapper.\n" "$grub_cfg" 1>&2 --- -2.43.5 - diff --git a/0353-grub-mkconfig-Remove-check-for-mount-point-for-grub-.patch b/0272-grub-mkconfig-Remove-check-for-mount-point-for-grub-.patch similarity index 95% rename from 0353-grub-mkconfig-Remove-check-for-mount-point-for-grub-.patch rename to 0272-grub-mkconfig-Remove-check-for-mount-point-for-grub-.patch index e503cef..35ee9e2 100644 --- a/0353-grub-mkconfig-Remove-check-for-mount-point-for-grub-.patch +++ b/0272-grub-mkconfig-Remove-check-for-mount-point-for-grub-.patch @@ -14,10 +14,10 @@ Signed-off-by: Nicolas Frayer 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index a4972039b751..3f131eea2b12 100644 +index 6f48c5dab5f..1cfb5873ff2 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in -@@ -115,8 +115,7 @@ do +@@ -110,8 +110,7 @@ do done os_name=$(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/' -e 's/\"//g') diff --git a/0272-loader-arm64-linux-Remove-magic-number-header-field-.patch b/0272-loader-arm64-linux-Remove-magic-number-header-field-.patch deleted file mode 100644 index faaa071..0000000 --- a/0272-loader-arm64-linux-Remove-magic-number-header-field-.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Ard Biesheuvel -Date: Thu, 11 Aug 2022 16:51:57 +0200 -Subject: [PATCH] loader/arm64/linux: Remove magic number header field check - -The "ARM\x64" magic number in the file header identifies an image as one -that implements the bare metal boot protocol, allowing the loader to -simply move the file to a suitably aligned address in memory, with -sufficient headroom for the trailing .bss segment (the required memory -size is described in the header as well). - -Note of this matters for GRUB, as it only supports EFI boot. EFI does -not care about this magic number, and nor should GRUB: this prevents us -from booting other PE linux images, such as the generic EFI zboot -decompressor, which is a pure PE/COFF image, and does not implement the -bare metal boot protocol. - -So drop the magic number check. - -Signed-off-by: Ard Biesheuvel -Reviewed-by: Daniel Kiper -Resolves: rhbz#2125069 -Signed-off-by: Jeremy Linton -(cherry-picked from commit 69edb31205602c29293a8c6e67363bba2a4a1e66) -Signed-off-by: Robbie Harwood ---- - grub-core/loader/arm64/linux.c | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c -index de85583487..489d0c7173 100644 ---- a/grub-core/loader/arm64/linux.c -+++ b/grub-core/loader/arm64/linux.c -@@ -55,9 +55,6 @@ static grub_addr_t initrd_end; - grub_err_t - grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh) - { -- if (lh->magic != GRUB_LINUX_ARMXX_MAGIC_SIGNATURE) -- return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); -- - if ((lh->code0 & 0xffff) != GRUB_DOS_MAGIC) - return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled")); diff --git a/0273-efi-api.h-include-missing-__grub_efi_api-macros-on-E.patch b/0273-efi-api.h-include-missing-__grub_efi_api-macros-on-E.patch new file mode 100644 index 0000000..f71764d --- /dev/null +++ b/0273-efi-api.h-include-missing-__grub_efi_api-macros-on-E.patch @@ -0,0 +1,495 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peter Jones +Date: Thu, 29 Aug 2024 12:11:11 -0600 +Subject: [PATCH] efi/api.h: include missing __grub_efi_api macros on EFI + functions + +Signed-off-by: Peter Jones +Signed-off-by: Leo Sandoval +--- + grub-core/loader/efi/chainloader.c | 2 +- + include/grub/efi/api.h | 34 +++++++++++++------------- + include/grub/efi/dhcp.h | 42 ++++++++++++++++---------------- + include/grub/efi/edid.h | 2 +- + include/grub/efi/http.h | 12 ++++----- + include/grub/efi/pci.h | 50 +++++++++++++++++++------------------- + 6 files changed, 71 insertions(+), 71 deletions(-) + +diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c +index 9b1cc3fd41d..7652f5a9291 100644 +--- a/grub-core/loader/efi/chainloader.c ++++ b/grub-core/loader/efi/chainloader.c +@@ -553,7 +553,7 @@ handle_image (struct grub_secureboot_chainloader_context *load_context) + grub_uint32_t buffer_size; + int found_entry_point = 0; + int rc; +- grub_efi_status_t (*entry_point) (grub_efi_handle_t image_handle, grub_efi_system_table_t *system_table); ++ grub_efi_status_t (__grub_efi_api *entry_point) (grub_efi_handle_t image_handle, grub_efi_system_table_t *system_table); + + b = grub_efi_system_table->boot_services; + +diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h +index 2376182d735..5047ecf28c5 100644 +--- a/include/grub/efi/api.h ++++ b/include/grub/efi/api.h +@@ -1094,11 +1094,11 @@ typedef struct grub_efi_bios_device_path grub_efi_bios_device_path_t; + struct grub_efi_service_binding; + + typedef grub_efi_status_t +-(*grub_efi_service_binding_create_child) (struct grub_efi_service_binding *this, ++(__grub_efi_api *grub_efi_service_binding_create_child) (struct grub_efi_service_binding *this, + grub_efi_handle_t *child_handle); + + typedef grub_efi_status_t +-(*grub_efi_service_binding_destroy_child) (struct grub_efi_service_binding *this, ++(__grub_efi_api *grub_efi_service_binding_destroy_child) (struct grub_efi_service_binding *this, + grub_efi_handle_t *child_handle); + + typedef struct grub_efi_service_binding +@@ -1754,12 +1754,12 @@ typedef struct grub_efi_pxe_mode + typedef struct grub_efi_pxe + { + grub_uint64_t rev; +- grub_efi_status_t (*start) (struct grub_efi_pxe *this, grub_efi_boolean_t use_ipv6); ++ grub_efi_status_t (__grub_efi_api *start) (struct grub_efi_pxe *this, grub_efi_boolean_t use_ipv6); + void (*stop) (void); +- grub_efi_status_t (*dhcp) (struct grub_efi_pxe *this, ++ grub_efi_status_t (__grub_efi_api *dhcp) (struct grub_efi_pxe *this, + grub_efi_boolean_t sort_offers); + void (*discover) (void); +- grub_efi_status_t (*mtftp) (struct grub_efi_pxe *this, ++ grub_efi_status_t (__grub_efi_api *mtftp) (struct grub_efi_pxe *this, + grub_efi_pxe_base_code_tftp_opcode_t operation, + void *buffer_ptr, + grub_efi_boolean_t overwrite, +@@ -1775,7 +1775,7 @@ typedef struct grub_efi_pxe + void (*setipfilter) (void); + void (*arp) (void); + void (*setparams) (void); +- grub_efi_status_t (*set_station_ip) (struct grub_efi_pxe *this, ++ grub_efi_status_t (__grub_efi_api *set_station_ip) (struct grub_efi_pxe *this, + grub_efi_pxe_ip_address_t *new_station_ip, + grub_efi_pxe_ip_address_t *new_subnet_mask); + void (*setpackets) (void); +@@ -2054,21 +2054,21 @@ typedef enum grub_efi_ip4_config2_data_type grub_efi_ip4_config2_data_type_t; + + struct grub_efi_ip4_config2_protocol + { +- grub_efi_status_t (*set_data) (struct grub_efi_ip4_config2_protocol *this, ++ grub_efi_status_t (__grub_efi_api *set_data) (struct grub_efi_ip4_config2_protocol *this, + grub_efi_ip4_config2_data_type_t data_type, + grub_efi_uintn_t data_size, + void *data); + +- grub_efi_status_t (*get_data) (struct grub_efi_ip4_config2_protocol *this, ++ grub_efi_status_t (__grub_efi_api *get_data) (struct grub_efi_ip4_config2_protocol *this, + grub_efi_ip4_config2_data_type_t data_type, + grub_efi_uintn_t *data_size, + void *data); + +- grub_efi_status_t (*register_data_notify) (struct grub_efi_ip4_config2_protocol *this, ++ grub_efi_status_t (__grub_efi_api *register_data_notify) (struct grub_efi_ip4_config2_protocol *this, + grub_efi_ip4_config2_data_type_t data_type, + grub_efi_event_t event); + +- grub_efi_status_t (*unregister_datanotify) (struct grub_efi_ip4_config2_protocol *this, ++ grub_efi_status_t (__grub_efi_api *unregister_datanotify) (struct grub_efi_ip4_config2_protocol *this, + grub_efi_ip4_config2_data_type_t data_type, + grub_efi_event_t event); + }; +@@ -2126,21 +2126,21 @@ typedef enum grub_efi_ip6_config_data_type grub_efi_ip6_config_data_type_t; + + struct grub_efi_ip6_config_protocol + { +- grub_efi_status_t (*set_data) (struct grub_efi_ip6_config_protocol *this, ++ grub_efi_status_t (__grub_efi_api *set_data) (struct grub_efi_ip6_config_protocol *this, + grub_efi_ip6_config_data_type_t data_type, + grub_efi_uintn_t data_size, + void *data); + +- grub_efi_status_t (*get_data) (struct grub_efi_ip6_config_protocol *this, ++ grub_efi_status_t (__grub_efi_api *get_data) (struct grub_efi_ip6_config_protocol *this, + grub_efi_ip6_config_data_type_t data_type, + grub_efi_uintn_t *data_size, + void *data); + +- grub_efi_status_t (*register_data_notify) (struct grub_efi_ip6_config_protocol *this, ++ grub_efi_status_t (__grub_efi_api *register_data_notify) (struct grub_efi_ip6_config_protocol *this, + grub_efi_ip6_config_data_type_t data_type, + grub_efi_event_t event); + +- grub_efi_status_t (*unregister_datanotify) (struct grub_efi_ip6_config_protocol *this, ++ grub_efi_status_t (__grub_efi_api *unregister_datanotify) (struct grub_efi_ip6_config_protocol *this, + grub_efi_ip6_config_data_type_t data_type, + grub_efi_event_t event); + }; +@@ -2191,17 +2191,17 @@ typedef struct grub_efi_ip6_config_manual_address grub_efi_ip6_config_manual_add + + struct grub_efi_memory_attribute_protocol + { +- grub_efi_status_t (*get_memory_attributes) ( ++ grub_efi_status_t (__grub_efi_api *get_memory_attributes) ( + struct grub_efi_memory_attribute_protocol *this, + grub_efi_physical_address_t base_address, + grub_efi_uint64_t length, + grub_efi_uint64_t *attributes); +- grub_efi_status_t (*set_memory_attributes) ( ++ grub_efi_status_t (__grub_efi_api *set_memory_attributes) ( + struct grub_efi_memory_attribute_protocol *this, + grub_efi_physical_address_t base_address, + grub_efi_uint64_t length, + grub_efi_uint64_t attributes); +- grub_efi_status_t (*clear_memory_attributes) ( ++ grub_efi_status_t (__grub_efi_api *clear_memory_attributes) ( + struct grub_efi_memory_attribute_protocol *this, + grub_efi_physical_address_t base_address, + grub_efi_uint64_t length, +diff --git a/include/grub/efi/dhcp.h b/include/grub/efi/dhcp.h +index fdb88eb810e..d996716e409 100644 +--- a/include/grub/efi/dhcp.h ++++ b/include/grub/efi/dhcp.h +@@ -123,7 +123,7 @@ struct grub_efi_dhcp4_config_data { + grub_efi_uint32_t request_try_count; + grub_efi_uint32_t *request_timeout; + grub_efi_ipv4_address_t client_address; +- grub_efi_status_t (*dhcp4_callback) ( ++ grub_efi_status_t (__grub_efi_api *dhcp4_callback) ( + grub_efi_dhcp4_protocol_t *this, + void *context, + grub_efi_dhcp4_state_t current_state, +@@ -153,27 +153,27 @@ struct grub_efi_dhcp4_mode_data { + typedef struct grub_efi_dhcp4_mode_data grub_efi_dhcp4_mode_data_t; + + struct grub_efi_dhcp4_protocol { +- grub_efi_status_t (*get_mode_data) (grub_efi_dhcp4_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *get_mode_data) (grub_efi_dhcp4_protocol_t *this, + grub_efi_dhcp4_mode_data_t *dhcp4_mode_data); +- grub_efi_status_t (*configure) (grub_efi_dhcp4_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *configure) (grub_efi_dhcp4_protocol_t *this, + grub_efi_dhcp4_config_data_t *dhcp4_cfg_data); +- grub_efi_status_t (*start) (grub_efi_dhcp4_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *start) (grub_efi_dhcp4_protocol_t *this, + grub_efi_event_t completion_event); +- grub_efi_status_t (*renew_rebind) (grub_efi_dhcp4_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *renew_rebind) (grub_efi_dhcp4_protocol_t *this, + grub_efi_boolean_t rebind_request, + grub_efi_event_t completion_event); +- grub_efi_status_t (*release) (grub_efi_dhcp4_protocol_t *this); +- grub_efi_status_t (*stop) (grub_efi_dhcp4_protocol_t *this); +- grub_efi_status_t (*build) (grub_efi_dhcp4_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *release) (grub_efi_dhcp4_protocol_t *this); ++ grub_efi_status_t (__grub_efi_api *stop) (grub_efi_dhcp4_protocol_t *this); ++ grub_efi_status_t (__grub_efi_api *build) (grub_efi_dhcp4_protocol_t *this, + grub_efi_dhcp4_packet_t *seed_packet, + grub_efi_uint32_t delete_count, + grub_efi_uint8_t *delete_list, + grub_efi_uint32_t append_count, + grub_efi_dhcp4_packet_option_t *append_list[], + grub_efi_dhcp4_packet_t **new_packet); +- grub_efi_status_t (*transmit_receive) (grub_efi_dhcp4_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *transmit_receive) (grub_efi_dhcp4_protocol_t *this, + grub_efi_dhcp4_transmit_receive_token_t *token); +- grub_efi_status_t (*parse) (grub_efi_dhcp4_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *parse) (grub_efi_dhcp4_protocol_t *this, + grub_efi_dhcp4_packet_t *packet, + grub_efi_uint32_t *option_count, + grub_efi_dhcp4_packet_option_t *packet_option_list[]); +@@ -289,7 +289,7 @@ struct grub_efi_dhcp6_mode_data { + typedef struct grub_efi_dhcp6_mode_data grub_efi_dhcp6_mode_data_t; + + struct grub_efi_dhcp6_config_data { +- grub_efi_status_t (*dhcp6_callback) (grub_efi_dhcp6_protocol_t this, ++ grub_efi_status_t (__grub_efi_api *dhcp6_callback) (grub_efi_dhcp6_protocol_t this, + void *context, + grub_efi_dhcp6_state_t current_state, + grub_efi_dhcp6_event_t dhcp6_event, +@@ -308,33 +308,33 @@ struct grub_efi_dhcp6_config_data { + typedef struct grub_efi_dhcp6_config_data grub_efi_dhcp6_config_data_t; + + struct grub_efi_dhcp6_protocol { +- grub_efi_status_t (*get_mode_data) (grub_efi_dhcp6_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *get_mode_data) (grub_efi_dhcp6_protocol_t *this, + grub_efi_dhcp6_mode_data_t *dhcp6_mode_data, + grub_efi_dhcp6_config_data_t *dhcp6_config_data); +- grub_efi_status_t (*configure) (grub_efi_dhcp6_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *configure) (grub_efi_dhcp6_protocol_t *this, + grub_efi_dhcp6_config_data_t *dhcp6_cfg_data); +- grub_efi_status_t (*start) (grub_efi_dhcp6_protocol_t *this); +- grub_efi_status_t (*info_request) (grub_efi_dhcp6_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *start) (grub_efi_dhcp6_protocol_t *this); ++ grub_efi_status_t (__grub_efi_api *info_request) (grub_efi_dhcp6_protocol_t *this, + grub_efi_boolean_t send_client_id, + grub_efi_dhcp6_packet_option_t *option_request, + grub_efi_uint32_t option_count, + grub_efi_dhcp6_packet_option_t *option_list[], + grub_efi_dhcp6_retransmission_t *retransmission, + grub_efi_event_t timeout_event, +- grub_efi_status_t (*reply_callback) (grub_efi_dhcp6_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *reply_callback) (grub_efi_dhcp6_protocol_t *this, + void *context, + grub_efi_dhcp6_packet_t *packet), + void *callback_context); +- grub_efi_status_t (*renew_rebind) (grub_efi_dhcp6_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *renew_rebind) (grub_efi_dhcp6_protocol_t *this, + grub_efi_boolean_t rebind_request); +- grub_efi_status_t (*decline) (grub_efi_dhcp6_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *decline) (grub_efi_dhcp6_protocol_t *this, + grub_efi_uint32_t address_count, + grub_efi_ipv6_address_t *addresses); +- grub_efi_status_t (*release) (grub_efi_dhcp6_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *release) (grub_efi_dhcp6_protocol_t *this, + grub_efi_uint32_t address_count, + grub_efi_ipv6_address_t *addresses); +- grub_efi_status_t (*stop) (grub_efi_dhcp6_protocol_t *this); +- grub_efi_status_t (*parse) (grub_efi_dhcp6_protocol_t *this, ++ grub_efi_status_t (__grub_efi_api *stop) (grub_efi_dhcp6_protocol_t *this); ++ grub_efi_status_t (__grub_efi_api *parse) (grub_efi_dhcp6_protocol_t *this, + grub_efi_dhcp6_packet_t *packet, + grub_efi_uint32_t *option_count, + grub_efi_dhcp6_packet_option_t *packet_option_list[]); +diff --git a/include/grub/efi/edid.h b/include/grub/efi/edid.h +index 43c0c4372f7..ac1b8e2fdac 100644 +--- a/include/grub/efi/edid.h ++++ b/include/grub/efi/edid.h +@@ -33,7 +33,7 @@ + struct grub_efi_edid_override; + + typedef grub_efi_status_t +-(*grub_efi_edid_override_get_edid) (struct grub_efi_edid_override *this, ++(__grub_efi_api *grub_efi_edid_override_get_edid) (struct grub_efi_edid_override *this, + grub_efi_handle_t *childhandle, + grub_efi_uint32_t *attributes, + grub_efi_uintn_t *edidsize, +diff --git a/include/grub/efi/http.h b/include/grub/efi/http.h +index ad164ba1913..242d001b624 100644 +--- a/include/grub/efi/http.h ++++ b/include/grub/efi/http.h +@@ -188,27 +188,27 @@ typedef struct { + + struct grub_efi_http { + grub_efi_status_t +- (*get_mode_data) (struct grub_efi_http *this, ++ (__grub_efi_api *get_mode_data) (struct grub_efi_http *this, + grub_efi_http_config_data_t *http_config_data); + + grub_efi_status_t +- (*configure) (struct grub_efi_http *this, ++ (__grub_efi_api *configure) (struct grub_efi_http *this, + grub_efi_http_config_data_t *http_config_data); + + grub_efi_status_t +- (*request) (struct grub_efi_http *this, ++ (__grub_efi_api *request) (struct grub_efi_http *this, + grub_efi_http_token_t *token); + + grub_efi_status_t +- (*cancel) (struct grub_efi_http *this, ++ (__grub_efi_api *cancel) (struct grub_efi_http *this, + grub_efi_http_token_t *token); + + grub_efi_status_t +- (*response) (struct grub_efi_http *this, ++ (__grub_efi_api *response) (struct grub_efi_http *this, + grub_efi_http_token_t *token); + + grub_efi_status_t +- (*poll) (struct grub_efi_http *this); ++ (__grub_efi_api *poll) (struct grub_efi_http *this); + }; + typedef struct grub_efi_http grub_efi_http_t; + +diff --git a/include/grub/efi/pci.h b/include/grub/efi/pci.h +index b17245549f5..a90f6104228 100644 +--- a/include/grub/efi/pci.h ++++ b/include/grub/efi/pci.h +@@ -48,7 +48,7 @@ typedef enum + struct grub_efi_pci_io; + + typedef grub_efi_status_t +-(*grub_efi_pci_io_mem_t) (struct grub_efi_pci_io *this, ++(__grub_efi_api *grub_efi_pci_io_mem_t) (struct grub_efi_pci_io *this, + grub_efi_pci_io_width_t width, + grub_efi_uint8_t bar_index, + grub_efi_uint64_t offset, +@@ -56,7 +56,7 @@ typedef grub_efi_status_t + void *buffer); + + typedef grub_efi_status_t +-(*grub_efi_pci_io_config_t) (struct grub_efi_pci_io *this, ++(__grub_efi_api *grub_efi_pci_io_config_t) (struct grub_efi_pci_io *this, + grub_efi_pci_io_width_t width, + grub_efi_uint32_t offset, + grub_efi_uintn_t count, +@@ -113,7 +113,7 @@ typedef enum + grub_efi_pci_io_attribute_operation_t; + + typedef grub_efi_status_t +-(*grub_efi_pci_io_poll_io_mem_t) (struct grub_efi_pci_io *this, ++(__grub_efi_api *grub_efi_pci_io_poll_io_mem_t) (struct grub_efi_pci_io *this, + grub_efi_pci_io_width_t width, + grub_efi_uint8_t bar_ndex, + grub_efi_uint64_t offset, +@@ -123,7 +123,7 @@ typedef grub_efi_status_t + grub_efi_uint64_t *result); + + typedef grub_efi_status_t +-(*grub_efi_pci_io_copy_mem_t) (struct grub_efi_pci_io *this, ++(__grub_efi_api *grub_efi_pci_io_copy_mem_t) (struct grub_efi_pci_io *this, + grub_efi_pci_io_width_t width, + grub_efi_uint8_t dest_bar_index, + grub_efi_uint64_t dest_offset, +@@ -132,7 +132,7 @@ typedef grub_efi_status_t + grub_efi_uintn_t count); + + typedef grub_efi_status_t +-(*grub_efi_pci_io_map_t) (struct grub_efi_pci_io *this, ++(__grub_efi_api *grub_efi_pci_io_map_t) (struct grub_efi_pci_io *this, + grub_efi_pci_io_operation_t operation, + void *host_address, + grub_efi_uintn_t *number_of_bytes, +@@ -140,11 +140,11 @@ typedef grub_efi_status_t + void **mapping); + + typedef grub_efi_status_t +-(*grub_efi_pci_io_unmap_t) (struct grub_efi_pci_io *this, ++(__grub_efi_api *grub_efi_pci_io_unmap_t) (struct grub_efi_pci_io *this, + void *mapping); + + typedef grub_efi_status_t +-(*grub_efi_pci_io_allocate_buffer_t) (struct grub_efi_pci_io *this, ++(__grub_efi_api *grub_efi_pci_io_allocate_buffer_t) (struct grub_efi_pci_io *this, + grub_efi_allocate_type_t type, + grub_efi_memory_type_t memory_type, + grub_efi_uintn_t pages, +@@ -152,7 +152,7 @@ typedef grub_efi_status_t + grub_efi_uint64_t attributes); + + typedef grub_efi_status_t +-(*grub_efi_pci_io_free_buffer_t) (struct grub_efi_pci_io *this, ++(__grub_efi_api *grub_efi_pci_io_free_buffer_t) (struct grub_efi_pci_io *this, + grub_efi_allocate_type_t type, + grub_efi_memory_type_t memory_type, + grub_efi_uintn_t pages, +@@ -160,29 +160,29 @@ typedef grub_efi_status_t + grub_efi_uint64_t attributes); + + typedef grub_efi_status_t +-(*grub_efi_pci_io_flush_t) (struct grub_efi_pci_io *this); ++(__grub_efi_api *grub_efi_pci_io_flush_t) (struct grub_efi_pci_io *this); + + typedef grub_efi_status_t +-(*grub_efi_pci_io_get_location_t) (struct grub_efi_pci_io *this, ++(__grub_efi_api *grub_efi_pci_io_get_location_t) (struct grub_efi_pci_io *this, + grub_efi_uintn_t *segment_number, + grub_efi_uintn_t *bus_number, + grub_efi_uintn_t *device_number, + grub_efi_uintn_t *function_number); + + typedef grub_efi_status_t +-(*grub_efi_pci_io_attributes_t) (struct grub_efi_pci_io *this, ++(__grub_efi_api *grub_efi_pci_io_attributes_t) (struct grub_efi_pci_io *this, + grub_efi_pci_io_attribute_operation_t operation, + grub_efi_uint64_t attributes, + grub_efi_uint64_t *result); + + typedef grub_efi_status_t +-(*grub_efi_pci_io_get_bar_attributes_t) (struct grub_efi_pci_io *this, ++(__grub_efi_api *grub_efi_pci_io_get_bar_attributes_t) (struct grub_efi_pci_io *this, + grub_efi_uint8_t bar_index, + grub_efi_uint64_t *supports, + void **resources); + + typedef grub_efi_status_t +-(*grub_efi_pci_io_set_bar_attributes_t) (struct grub_efi_pci_io *this, ++(__grub_efi_api *grub_efi_pci_io_set_bar_attributes_t) (struct grub_efi_pci_io *this, + grub_efi_uint64_t attributes, + grub_efi_uint8_t bar_index, + grub_efi_uint64_t *offset, +@@ -212,12 +212,12 @@ struct grub_efi_pci_root_io; + + typedef struct + { +- grub_efi_status_t(*read) (struct grub_efi_pci_root_io *this, ++ grub_efi_status_t(__grub_efi_api *read) (struct grub_efi_pci_root_io *this, + grub_efi_pci_io_width_t width, + grub_efi_uint64_t address, + grub_efi_uintn_t count, + void *buffer); +- grub_efi_status_t(*write) (struct grub_efi_pci_root_io *this, ++ grub_efi_status_t(__grub_efi_api *write) (struct grub_efi_pci_root_io *this, + grub_efi_pci_io_width_t width, + grub_efi_uint64_t address, + grub_efi_uintn_t count, +@@ -237,7 +237,7 @@ typedef enum + grub_efi_pci_root_io_operation_t; + + typedef grub_efi_status_t +-(*grub_efi_pci_root_io_poll_io_mem_t) (struct grub_efi_pci_root_io *this, ++(__grub_efi_api *grub_efi_pci_root_io_poll_io_mem_t) (struct grub_efi_pci_root_io *this, + grub_efi_pci_io_width_t width, + grub_efi_uint64_t address, + grub_efi_uint64_t mask, +@@ -246,7 +246,7 @@ typedef grub_efi_status_t + grub_efi_uint64_t *result); + + typedef grub_efi_status_t +-(*grub_efi_pci_root_io_copy_mem_t) (struct grub_efi_pci_root_io *this, ++(__grub_efi_api *grub_efi_pci_root_io_copy_mem_t) (struct grub_efi_pci_root_io *this, + grub_efi_pci_io_width_t width, + grub_efi_uint64_t dest_offset, + grub_efi_uint64_t src_offset, +@@ -254,7 +254,7 @@ typedef grub_efi_status_t + + + typedef grub_efi_status_t +-(*grub_efi_pci_root_io_map_t) (struct grub_efi_pci_root_io *this, ++(__grub_efi_api *grub_efi_pci_root_io_map_t) (struct grub_efi_pci_root_io *this, + grub_efi_pci_root_io_operation_t operation, + void *host_address, + grub_efi_uintn_t *number_of_bytes, +@@ -262,11 +262,11 @@ typedef grub_efi_status_t + void **mapping); + + typedef grub_efi_status_t +-(*grub_efi_pci_root_io_unmap_t) (struct grub_efi_pci_root_io *this, ++(__grub_efi_api *grub_efi_pci_root_io_unmap_t) (struct grub_efi_pci_root_io *this, + void *mapping); + + typedef grub_efi_status_t +-(*grub_efi_pci_root_io_allocate_buffer_t) (struct grub_efi_pci_root_io *this, ++(__grub_efi_api *grub_efi_pci_root_io_allocate_buffer_t) (struct grub_efi_pci_root_io *this, + grub_efi_allocate_type_t type, + grub_efi_memory_type_t memory_type, + grub_efi_uintn_t pages, +@@ -274,26 +274,26 @@ typedef grub_efi_status_t + grub_efi_uint64_t attributes); + + typedef grub_efi_status_t +-(*grub_efi_pci_root_io_free_buffer_t) (struct grub_efi_pci_root_io *this, ++(__grub_efi_api *grub_efi_pci_root_io_free_buffer_t) (struct grub_efi_pci_root_io *this, + grub_efi_uintn_t pages, + void **host_address); + + typedef grub_efi_status_t +-(*grub_efi_pci_root_io_flush_t) (struct grub_efi_pci_root_io *this); ++(__grub_efi_api *grub_efi_pci_root_io_flush_t) (struct grub_efi_pci_root_io *this); + + typedef grub_efi_status_t +-(*grub_efi_pci_root_io_get_attributes_t) (struct grub_efi_pci_root_io *this, ++(__grub_efi_api *grub_efi_pci_root_io_get_attributes_t) (struct grub_efi_pci_root_io *this, + grub_efi_uint64_t *supports, + void **resources); + + typedef grub_efi_status_t +-(*grub_efi_pci_root_io_set_attributes_t) (struct grub_efi_pci_root_io *this, ++(__grub_efi_api *grub_efi_pci_root_io_set_attributes_t) (struct grub_efi_pci_root_io *this, + grub_efi_uint64_t attributes, + grub_efi_uint64_t *offset, + grub_efi_uint64_t *length); + + typedef grub_efi_status_t +-(*grub_efi_pci_root_io_configuration_t) (struct grub_efi_pci_root_io *this, ++(__grub_efi_api *grub_efi_pci_root_io_configuration_t) (struct grub_efi_pci_root_io *this, + void **resources); + + struct grub_efi_pci_root_io { diff --git a/0274-grub-core-net-arp.c-fix-variable-name.patch b/0274-grub-core-net-arp.c-fix-variable-name.patch new file mode 100644 index 0000000..f1f26ba --- /dev/null +++ b/0274-grub-core-net-arp.c-fix-variable-name.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Leo Sandoval +Date: Wed, 28 Aug 2024 13:37:42 -0600 +Subject: [PATCH] grub-core/net/arp.c: fix variable name + +Signed-off-by: Leo Sandoval +--- + grub-core/net/arp.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c +index 8bf0a06e193..7adeb7447b4 100644 +--- a/grub-core/net/arp.c ++++ b/grub-core/net/arp.c +@@ -159,7 +159,7 @@ grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card, + sender_addr.option = 0; + target_addr.option = 0; + +- grub_memcpy(&target_addr.ipv4, tmp_ptr, pln); ++ grub_memcpy(&sender_addr.ipv4, tmp_ptr, pln); + tmp_ptr += pln; + + grub_net_link_layer_add_address (card, &sender_addr, &sender_mac_addr, 1); diff --git a/0275-load-EFI-commands-inside-test-expressions.patch b/0275-load-EFI-commands-inside-test-expressions.patch new file mode 100644 index 0000000..ce74316 --- /dev/null +++ b/0275-load-EFI-commands-inside-test-expressions.patch @@ -0,0 +1,44 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Leo Sandoval +Date: Wed, 4 Sep 2024 13:25:23 -0600 +Subject: [PATCH] load EFI commands inside test expressions + +These two commands may fail interrumping the normal boot process, +so placing these inside test expressions is a safer approach. + +Resolves: #2305291 +Suggested-by: Kan-Ru Chen: +Signed-off-by: Leo Sandoval +--- + util/grub.d/25_bli.in | 4 +++- + util/grub.d/30_uefi-firmware.in | 3 +-- + 2 files changed, 4 insertions(+), 3 deletions(-) + +diff --git a/util/grub.d/25_bli.in b/util/grub.d/25_bli.in +index 26e27a01975..00a8d7159c0 100644 +--- a/util/grub.d/25_bli.in ++++ b/util/grub.d/25_bli.in +@@ -19,6 +19,8 @@ set -e + + cat << EOF + if [ "\$grub_platform" = "efi" ]; then +- insmod bli ++ if [ ! insmod bli ]; then ++ echo "bli module not available" ++ fi + fi + EOF +diff --git a/util/grub.d/30_uefi-firmware.in b/util/grub.d/30_uefi-firmware.in +index 1c2365ddbd3..1ef31e08f6b 100644 +--- a/util/grub.d/30_uefi-firmware.in ++++ b/util/grub.d/30_uefi-firmware.in +@@ -32,8 +32,7 @@ gettext_printf "Adding boot menu entry for UEFI Firmware Settings ...\n" >&2 + + cat << EOF + if [ "\$grub_platform" = "efi" ]; then +- fwsetup --is-supported +- if [ "\$?" = 0 ]; then ++ if [ fwsetup --is-supported ]; then + menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' { + fwsetup + } diff --git a/0276-commands-efi-tpm-Refine-the-status-of-log-event.patch b/0276-commands-efi-tpm-Refine-the-status-of-log-event.patch deleted file mode 100644 index 896e49b..0000000 --- a/0276-commands-efi-tpm-Refine-the-status-of-log-event.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Lu Ken -Date: Wed, 13 Jul 2022 10:06:10 +0800 -Subject: [PATCH] commands/efi/tpm: Refine the status of log event - -1. Use macro GRUB_ERR_NONE instead of hard code 0. -2. Keep lowercase of the first char for the status string of log event. - -Signed-off-by: Lu Ken -Reviewed-by: Daniel Kiper -(cherry picked from commit 922898573e37135f5dedc16f3e15a1d1d4c53f8a) ---- - grub-core/commands/efi/tpm.c | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c -index a97d85368a..7acf510499 100644 ---- a/grub-core/commands/efi/tpm.c -+++ b/grub-core/commands/efi/tpm.c -@@ -135,17 +135,17 @@ grub_efi_log_event_status (grub_efi_status_t status) - switch (status) - { - case GRUB_EFI_SUCCESS: -- return 0; -+ return GRUB_ERR_NONE; - case GRUB_EFI_DEVICE_ERROR: -- return grub_error (GRUB_ERR_IO, N_("Command failed")); -+ return grub_error (GRUB_ERR_IO, N_("command failed")); - case GRUB_EFI_INVALID_PARAMETER: -- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("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")); -+ 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")); -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("unknown TPM error")); - } - } - diff --git a/0276-efi-loader-Check-if-NX-is-required-in-grub_efi_linux.patch b/0276-efi-loader-Check-if-NX-is-required-in-grub_efi_linux.patch new file mode 100644 index 0000000..88d6765 --- /dev/null +++ b/0276-efi-loader-Check-if-NX-is-required-in-grub_efi_linux.patch @@ -0,0 +1,25 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nicolas Frayer +Date: Wed, 25 Sep 2024 17:23:33 +0200 +Subject: [PATCH] efi/loader: Check if NX is required in grub_efi_linux_boot() + +Call grub_efi_check_nx_required() passing it nx_required to +assign the correct value + +Signed-off-by: Nicolas Frayer +--- + grub-core/loader/efi/linux.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c +index 0d1804b602d..5889e3f36f8 100644 +--- a/grub-core/loader/efi/linux.c ++++ b/grub-core/loader/efi/linux.c +@@ -236,6 +236,7 @@ grub_efi_linux_boot (grub_addr_t k_address, grub_size_t k_size, + grub_dprintf ("linux", "kernel_address: %p handover_offset: %p params: %p\n", + (void *)k_address, (void *)h_offset, k_params); + ++ grub_efi_check_nx_required(&nx_required); + + if (nx_required && !nx_supported) + return grub_error (GRUB_ERR_BAD_OS, N_("kernel does not support NX loading required by policy")); diff --git a/0277-Stop-grub.efi-from-always-printing-dynamic_load_symb.patch b/0277-Stop-grub.efi-from-always-printing-dynamic_load_symb.patch new file mode 100644 index 0000000..44e7790 --- /dev/null +++ b/0277-Stop-grub.efi-from-always-printing-dynamic_load_symb.patch @@ -0,0 +1,80 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Thu, 3 Oct 2024 12:26:07 +0200 +Subject: [PATCH] Stop grub.efi from always printing "dynamic_load_symbols + %p\n" during boot + +Commit 972aa68d2bf5 ("Make a "gdb" dprintf that tells us load addresses.") +added some debug prints to help with running gdb against grub. + +Besides adding a new grub_dl_print_gdb_info () function which uses +`grub_qdprintf ("gdb", ...);` it also adds a new grub_efi_print_gdb_info () +call to grub_efi_init (). + +grub_efi_print_gdb_info () is intended for the gdbinfo command and uses +a non debug grub_printf () call leading to grub now always printing this +message during boot breaking flicker-free boot. + +Add a new "debug" parameter to grub_efi_print_gdb_info () and use +`grub_qdprintf ("gdb", ...);` when this is set to silence the printing +done from grub_efi_init () when debugging is not enabled. + +Fixes: 972aa68d2bf5 ("Make a "gdb" dprintf that tells us load addresses.") +Signed-off-by: Hans de Goede +--- + grub-core/kern/efi/debug.c | 2 +- + grub-core/kern/efi/init.c | 2 +- + include/grub/efi/debug.h | 7 +++++-- + 3 files changed, 7 insertions(+), 4 deletions(-) + +diff --git a/grub-core/kern/efi/debug.c b/grub-core/kern/efi/debug.c +index 5d2ab1a36ff..5ac194fc8f4 100644 +--- a/grub-core/kern/efi/debug.c ++++ b/grub-core/kern/efi/debug.c +@@ -26,7 +26,7 @@ grub_cmd_gdbinfo (struct grub_command *cmd __attribute__ ((unused)), + int argc __attribute__ ((unused)), + char **args __attribute__ ((unused))) + { +- grub_efi_print_gdb_info (); ++ grub_efi_print_gdb_info (false); + return 0; + } + +diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c +index d35d6974734..ce8a7fe7122 100644 +--- a/grub-core/kern/efi/init.c ++++ b/grub-core/kern/efi/init.c +@@ -157,7 +157,7 @@ grub_efi_init (void) + grub_efi_system_table->boot_services->set_watchdog_timer (0, 0, 0, NULL); + + grub_efi_env_init (); +- grub_efi_print_gdb_info (); ++ grub_efi_print_gdb_info (true); + grub_efidisk_init (); + + grub_efi_register_debug_commands (); +diff --git a/include/grub/efi/debug.h b/include/grub/efi/debug.h +index c2d2a03b06f..961e591afa3 100644 +--- a/include/grub/efi/debug.h ++++ b/include/grub/efi/debug.h +@@ -27,7 +27,7 @@ + void grub_efi_register_debug_commands (void); + + static inline void +-grub_efi_print_gdb_info (void) ++grub_efi_print_gdb_info (bool debug) + { + grub_addr_t text; + +@@ -35,7 +35,10 @@ grub_efi_print_gdb_info (void) + if (!text) + return; + +- grub_printf ("dynamic_load_symbols %p\n", (void *)text); ++ if (debug) ++ grub_qdprintf ("gdb", "dynamic_load_symbols %p\n", (void *)text); ++ else ++ grub_printf ("dynamic_load_symbols %p\n", (void *)text); + } + + #endif /* ! GRUB_EFI_DEBUG_HEADER */ diff --git a/0277-commands-efi-tpm-Use-grub_strcpy-instead-of-grub_mem.patch b/0277-commands-efi-tpm-Use-grub_strcpy-instead-of-grub_mem.patch deleted file mode 100644 index e04dcbc..0000000 --- a/0277-commands-efi-tpm-Use-grub_strcpy-instead-of-grub_mem.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Lu Ken -Date: Wed, 13 Jul 2022 10:06:11 +0800 -Subject: [PATCH] commands/efi/tpm: Use grub_strcpy() instead of grub_memcpy() - -The event description is a string, so using grub_strcpy() is cleaner than -using grub_memcpy(). - -Signed-off-by: Lu Ken -Reviewed-by: Daniel Kiper -(cherry picked from commit ef8679b645a63eb9eb191bb9539d7d25a9d6ff3b) ---- - grub-core/commands/efi/tpm.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c -index 7acf510499..bb59599721 100644 ---- a/grub-core/commands/efi/tpm.c -+++ b/grub-core/commands/efi/tpm.c -@@ -175,7 +175,7 @@ grub_tpm1_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf, - event->PCRIndex = pcr; - event->EventType = EV_IPL; - event->EventSize = grub_strlen (description) + 1; -- grub_memcpy (event->Event, description, event->EventSize); -+ grub_strcpy ((char *) event->Event, description); - - algorithm = TCG_ALG_SHA; - status = efi_call_7 (tpm->log_extend_event, tpm, (grub_addr_t) buf, (grub_uint64_t) size, -@@ -212,7 +212,7 @@ grub_tpm2_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf, - 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); -+ grub_strcpy ((char *) event->Event, description); - - status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (grub_addr_t) buf, - (grub_uint64_t) size, event); diff --git a/0278-efi-tpm-Add-EFI_CC_MEASUREMENT_PROTOCOL-support.patch b/0278-efi-tpm-Add-EFI_CC_MEASUREMENT_PROTOCOL-support.patch deleted file mode 100644 index 610c81a..0000000 --- a/0278-efi-tpm-Add-EFI_CC_MEASUREMENT_PROTOCOL-support.patch +++ /dev/null @@ -1,258 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Lu Ken -Date: Wed, 13 Jul 2022 10:06:12 +0800 -Subject: [PATCH] efi/tpm: Add EFI_CC_MEASUREMENT_PROTOCOL support - -The EFI_CC_MEASUREMENT_PROTOCOL abstracts the measurement for virtual firmware -in confidential computing environment. It is similar to the EFI_TCG2_PROTOCOL. -It was proposed by Intel and ARM and approved by UEFI organization. - -It is defined in Intel GHCI specification: https://cdrdv2.intel.com/v1/dl/getContent/726790 . -The EDKII header file is available at https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Protocol/CcMeasurement.h . - -Signed-off-by: Lu Ken -Reviewed-by: Daniel Kiper -(cherry picked from commit 4c76565b6cb885b7e144dc27f3612066844e2d19) ---- - grub-core/commands/efi/tpm.c | 48 ++++++++++++++ - include/grub/efi/cc.h | 151 +++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 199 insertions(+) - create mode 100644 include/grub/efi/cc.h - -diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c -index bb59599721..ae09c1bf8b 100644 ---- a/grub-core/commands/efi/tpm.c -+++ b/grub-core/commands/efi/tpm.c -@@ -22,6 +22,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -31,6 +32,7 @@ typedef TCG_PCR_EVENT grub_tpm_event_t; - - static grub_efi_guid_t tpm_guid = EFI_TPM_GUID; - static grub_efi_guid_t tpm2_guid = EFI_TPM2_GUID; -+static grub_efi_guid_t cc_measurement_guid = GRUB_EFI_CC_MEASUREMENT_PROTOCOL_GUID; - - static grub_efi_handle_t *grub_tpm_handle; - static grub_uint8_t grub_tpm_version; -@@ -221,6 +223,50 @@ grub_tpm2_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf, - return grub_efi_log_event_status (status); - } - -+static void -+grub_cc_log_event (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, -+ const char *description) -+{ -+ grub_efi_cc_event_t *event; -+ grub_efi_status_t status; -+ grub_efi_cc_protocol_t *cc; -+ grub_efi_cc_mr_index_t mr; -+ -+ cc = grub_efi_locate_protocol (&cc_measurement_guid, NULL); -+ if (cc == NULL) -+ return; -+ -+ status = efi_call_3 (cc->map_pcr_to_mr_index, cc, pcr, &mr); -+ if (status != GRUB_EFI_SUCCESS) -+ { -+ grub_efi_log_event_status (status); -+ return; -+ } -+ -+ event = grub_zalloc (sizeof (grub_efi_cc_event_t) + -+ grub_strlen (description) + 1); -+ if (event == NULL) -+ { -+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate CC event buffer")); -+ return; -+ } -+ -+ event->Header.HeaderSize = sizeof (grub_efi_cc_event_header_t); -+ event->Header.HeaderVersion = GRUB_EFI_CC_EVENT_HEADER_VERSION; -+ event->Header.MrIndex = mr; -+ event->Header.EventType = EV_IPL; -+ event->Size = sizeof (*event) + grub_strlen (description) + 1; -+ grub_strcpy ((char *) event->Event, description); -+ -+ status = efi_call_5 (cc->hash_log_extend_event, cc, 0, -+ (grub_efi_physical_address_t)(grub_addr_t) buf, -+ (grub_efi_uint64_t) size, event); -+ grub_free (event); -+ -+ if (status != GRUB_EFI_SUCCESS) -+ grub_efi_log_event_status (status); -+} -+ - grub_err_t - grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, - const char *description) -@@ -228,6 +274,8 @@ grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, - grub_efi_handle_t tpm_handle; - grub_efi_uint8_t protocol_version; - -+ grub_cc_log_event(buf, size, pcr, description); -+ - if (!grub_tpm_handle_find (&tpm_handle, &protocol_version)) - return 0; - -diff --git a/include/grub/efi/cc.h b/include/grub/efi/cc.h -new file mode 100644 -index 0000000000..8960306890 ---- /dev/null -+++ b/include/grub/efi/cc.h -@@ -0,0 +1,151 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2022 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_CC_H -+#define GRUB_EFI_CC_H 1 -+ -+#include -+#include -+#include -+ -+#define GRUB_EFI_CC_MEASUREMENT_PROTOCOL_GUID \ -+ { 0x96751a3d, 0x72f4, 0x41a6, \ -+ { 0xa7, 0x94, 0xed, 0x5d, 0x0e, 0x67, 0xae, 0x6b } \ -+ }; -+ -+struct grub_efi_cc_version -+{ -+ grub_efi_uint8_t Major; -+ grub_efi_uint8_t Minor; -+}; -+typedef struct grub_efi_cc_version grub_efi_cc_version_t; -+ -+/* EFI_CC Type/SubType definition. */ -+#define GRUB_EFI_CC_TYPE_NONE 0 -+#define GRUB_EFI_CC_TYPE_SEV 1 -+#define GRUB_EFI_CC_TYPE_TDX 2 -+ -+struct grub_efi_cc_type -+{ -+ grub_efi_uint8_t Type; -+ grub_efi_uint8_t SubType; -+}; -+typedef struct grub_efi_cc_type grub_efi_cc_type_t; -+ -+typedef grub_efi_uint32_t grub_efi_cc_event_log_bitmap_t; -+typedef grub_efi_uint32_t grub_efi_cc_event_log_format_t; -+typedef grub_efi_uint32_t grub_efi_cc_event_algorithm_bitmap_t; -+typedef grub_efi_uint32_t grub_efi_cc_mr_index_t; -+ -+/* Intel TDX measure register index. */ -+#define GRUB_TDX_MR_INDEX_MRTD 0 -+#define GRUB_TDX_MR_INDEX_RTMR0 1 -+#define GRUB_TDX_MR_INDEX_RTMR1 2 -+#define GRUB_TDX_MR_INDEX_RTMR2 3 -+#define GRUB_TDX_MR_INDEX_RTMR3 4 -+ -+#define GRUB_EFI_CC_EVENT_LOG_FORMAT_TCG_2 0x00000002 -+#define GRUB_EFI_CC_BOOT_HASH_ALG_SHA384 0x00000004 -+#define GRUB_EFI_CC_EVENT_HEADER_VERSION 1 -+ -+struct grub_efi_cc_event_header -+{ -+ /* Size of the event header itself (sizeof(EFI_TD_EVENT_HEADER)). */ -+ grub_efi_uint32_t HeaderSize; -+ -+ /* -+ * Header version. For this version of this specification, -+ * the value shall be 1. -+ */ -+ grub_efi_uint16_t HeaderVersion; -+ -+ /* Index of the MR that shall be extended. */ -+ grub_efi_cc_mr_index_t MrIndex; -+ -+ /* Type of the event that shall be extended (and optionally logged). */ -+ grub_efi_uint32_t EventType; -+} GRUB_PACKED; -+typedef struct grub_efi_cc_event_header grub_efi_cc_event_header_t; -+ -+struct grub_efi_cc_event -+{ -+ /* Total size of the event including the Size component, the header and the Event data. */ -+ grub_efi_uint32_t Size; -+ grub_efi_cc_event_header_t Header; -+ grub_efi_uint8_t Event[0]; -+} GRUB_PACKED; -+typedef struct grub_efi_cc_event grub_efi_cc_event_t; -+ -+struct grub_efi_cc_boot_service_capability -+{ -+ /* Allocated size of the structure. */ -+ grub_efi_uint8_t Size; -+ -+ /* -+ * Version of the grub_efi_cc_boot_service_capability_t structure itself. -+ * For this version of the protocol, the Major version shall be set to 1 -+ * and the Minor version shall be set to 1. -+ */ -+ grub_efi_cc_version_t StructureVersion; -+ -+ /* -+ * Version of the EFI TD protocol. -+ * For this version of the protocol, the Major version shall be set to 1 -+ * and the Minor version shall be set to 1. -+ */ -+ grub_efi_cc_version_t ProtocolVersion; -+ -+ /* Supported hash algorithms. */ -+ grub_efi_cc_event_algorithm_bitmap_t HashAlgorithmBitmap; -+ -+ /* Bitmap of supported event log formats. */ -+ grub_efi_cc_event_log_bitmap_t SupportedEventLogs; -+ -+ /* Indicates the CC type. */ -+ grub_efi_cc_type_t CcType; -+}; -+typedef struct grub_efi_cc_boot_service_capability grub_efi_cc_boot_service_capability_t; -+ -+struct grub_efi_cc_protocol -+{ -+ grub_efi_status_t -+ (*get_capability) (struct grub_efi_cc_protocol *this, -+ grub_efi_cc_boot_service_capability_t *ProtocolCapability); -+ -+ grub_efi_status_t -+ (*get_event_log) (struct grub_efi_cc_protocol *this, -+ grub_efi_cc_event_log_format_t 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_cc_protocol *this, -+ grub_efi_uint64_t Flags, -+ grub_efi_physical_address_t DataToHash, -+ grub_efi_uint64_t DataToHashLen, -+ grub_efi_cc_event_t *EfiCcEvent); -+ -+ grub_efi_status_t -+ (*map_pcr_to_mr_index) (struct grub_efi_cc_protocol *this, -+ grub_efi_uint32_t PcrIndex, -+ grub_efi_cc_mr_index_t *MrIndex); -+}; -+typedef struct grub_efi_cc_protocol grub_efi_cc_protocol_t; -+ -+#endif diff --git a/0274-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch b/0278-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch similarity index 78% rename from 0274-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch rename to 0278-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch index eff155d..f837dff 100644 --- a/0274-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch +++ b/0278-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch @@ -16,7 +16,7 @@ Signed-off-by: dann frazier 1 file changed, 4 insertions(+) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c -index 277f352e0c..e413bdcc23 100644 +index 5889e3f36f8..21a6298b087 100644 --- a/grub-core/loader/efi/linux.c +++ b/grub-core/loader/efi/linux.c @@ -16,6 +16,7 @@ @@ -24,16 +24,16 @@ index 277f352e0c..e413bdcc23 100644 */ +#include + #include + #include #include - #include - #include -@@ -210,6 +211,9 @@ grub_efi_linux_boot (grub_addr_t kernel_addr, grub_size_t kernel_size, +@@ -281,6 +282,9 @@ grub_efi_linux_boot (grub_addr_t k_address, grub_size_t k_size, asm volatile ("cli"); #endif + /* Invalidate the instruction cache */ + grub_arch_sync_caches((void *)kernel_addr, kernel_size); + - hf = (handover_func)((char *)kernel_addr + handover_offset + offset); - hf (grub_efi_image_handle, grub_efi_system_table, kernel_params); + hf = (handover_func)((char *)k_address + h_offset + offset); + hf (grub_efi_image_handle, grub_efi_system_table, k_params); diff --git a/0279-font-Reject-glyphs-exceeds-font-max_glyph_width-or-f.patch b/0279-font-Reject-glyphs-exceeds-font-max_glyph_width-or-f.patch deleted file mode 100644 index e0dd347..0000000 --- a/0279-font-Reject-glyphs-exceeds-font-max_glyph_width-or-f.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Wed, 3 Aug 2022 19:45:33 +0800 -Subject: [PATCH] font: Reject glyphs exceeds font->max_glyph_width or - font->max_glyph_height - -Check glyph's width and height against limits specified in font's -metadata. Reject the glyph (and font) if such limits are exceeded. - -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit 5760fcfd466cc757540ea0d591bad6a08caeaa16) ---- - grub-core/font/font.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/grub-core/font/font.c b/grub-core/font/font.c -index d09bb38d89..2f09a4a55b 100644 ---- a/grub-core/font/font.c -+++ b/grub-core/font/font.c -@@ -760,7 +760,9 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code) - || read_be_uint16 (font->file, &height) != 0 - || read_be_int16 (font->file, &xoff) != 0 - || read_be_int16 (font->file, &yoff) != 0 -- || read_be_int16 (font->file, &dwidth) != 0) -+ || read_be_int16 (font->file, &dwidth) != 0 -+ || width > font->max_char_width -+ || height > font->max_char_height) - { - remove_font (font); - return 0; diff --git a/0354-grub-mkconfig-dont-overwrite-BLS-cmdline-if-BLSCFG.patch b/0279-grub-mkconfig-dont-overwrite-BLS-cmdline-if-BLSCFG.patch similarity index 93% rename from 0354-grub-mkconfig-dont-overwrite-BLS-cmdline-if-BLSCFG.patch rename to 0279-grub-mkconfig-dont-overwrite-BLS-cmdline-if-BLSCFG.patch index 080374f..226b845 100644 --- a/0354-grub-mkconfig-dont-overwrite-BLS-cmdline-if-BLSCFG.patch +++ b/0279-grub-mkconfig-dont-overwrite-BLS-cmdline-if-BLSCFG.patch @@ -17,7 +17,7 @@ Signed-off-by: mkl 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in -index 520a672cd2c8..34f7c13fc521 100644 +index 1cfb5873ff2..b043a19c12e 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -51,6 +51,7 @@ export TEXTDOMAIN=@PACKAGE@ @@ -46,7 +46,7 @@ index 520a672cd2c8..34f7c13fc521 100644 -*) gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2 usage -@@ -167,6 +172,10 @@ fi +@@ -175,6 +180,10 @@ fi eval "$("${grub_get_kernel_settings}")" || true @@ -58,10 +58,10 @@ index 520a672cd2c8..34f7c13fc521 100644 if [ -z "${GRUB_DISABLE_LINUX_UUID}" ]; then GRUB_DISABLE_LINUX_UUID="true" diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 4795a63b4ce6..72b75effe448 100644 +index 11c19304f8b..c258aa3cd81 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in -@@ -265,7 +265,7 @@ if [ -z "\${kernelopts}" ]; then +@@ -267,7 +267,7 @@ if [ -z "\${kernelopts}" ]; then fi EOF diff --git a/0280-font-Fix-size-overflow-in-grub_font_get_glyph_intern.patch b/0280-font-Fix-size-overflow-in-grub_font_get_glyph_intern.patch deleted file mode 100644 index b5f10f6..0000000 --- a/0280-font-Fix-size-overflow-in-grub_font_get_glyph_intern.patch +++ /dev/null @@ -1,110 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Fri, 5 Aug 2022 00:51:20 +0800 -Subject: [PATCH] font: Fix size overflow in grub_font_get_glyph_internal() - -The length of memory allocation and file read may overflow. This patch -fixes the problem by using safemath macros. - -There is a lot of code repetition like "(x * y + 7) / 8". It is unsafe -if overflow happens. This patch introduces grub_video_bitmap_calc_1bpp_bufsz(). -It is safe replacement for such code. It has safemath-like prototype. - -This patch also introduces grub_cast(value, pointer), it casts value to -typeof(*pointer) then store the value to *pointer. It returns true when -overflow occurs or false if there is no overflow. The semantics of arguments -and return value are designed to be consistent with other safemath macros. - -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit 941d10ad6f1dcbd12fb613002249e29ba035f985) ---- - grub-core/font/font.c | 17 +++++++++++++---- - include/grub/bitmap.h | 18 ++++++++++++++++++ - include/grub/safemath.h | 2 ++ - 3 files changed, 33 insertions(+), 4 deletions(-) - -diff --git a/grub-core/font/font.c b/grub-core/font/font.c -index 2f09a4a55b..6a3fbebbd8 100644 ---- a/grub-core/font/font.c -+++ b/grub-core/font/font.c -@@ -739,7 +739,8 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code) - grub_int16_t xoff; - grub_int16_t yoff; - grub_int16_t dwidth; -- int len; -+ grub_ssize_t len; -+ grub_size_t sz; - - if (index_entry->glyph) - /* Return cached glyph. */ -@@ -768,9 +769,17 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code) - return 0; - } - -- len = (width * height + 7) / 8; -- glyph = grub_malloc (sizeof (struct grub_font_glyph) + len); -- if (!glyph) -+ /* Calculate real struct size of current glyph. */ -+ if (grub_video_bitmap_calc_1bpp_bufsz (width, height, &len) || -+ grub_add (sizeof (struct grub_font_glyph), len, &sz)) -+ { -+ remove_font (font); -+ return 0; -+ } -+ -+ /* Allocate and initialize the glyph struct. */ -+ glyph = grub_malloc (sz); -+ if (glyph == NULL) - { - remove_font (font); - return 0; -diff --git a/include/grub/bitmap.h b/include/grub/bitmap.h -index 5728f8ca3a..0d9603f619 100644 ---- a/include/grub/bitmap.h -+++ b/include/grub/bitmap.h -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - - struct grub_video_bitmap - { -@@ -79,6 +80,23 @@ grub_video_bitmap_get_height (struct grub_video_bitmap *bitmap) - return bitmap->mode_info.height; - } - -+/* -+ * Calculate and store the size of data buffer of 1bit bitmap in result. -+ * Equivalent to "*result = (width * height + 7) / 8" if no overflow occurs. -+ * Return true when overflow occurs or false if there is no overflow. -+ * This function is intentionally implemented as a macro instead of -+ * an inline function. Although a bit awkward, it preserves data types for -+ * safemath macros and reduces macro side effects as much as possible. -+ * -+ * XXX: Will report false overflow if width * height > UINT64_MAX. -+ */ -+#define grub_video_bitmap_calc_1bpp_bufsz(width, height, result) \ -+({ \ -+ grub_uint64_t _bitmap_pixels; \ -+ grub_mul ((width), (height), &_bitmap_pixels) ? 1 : \ -+ grub_cast (_bitmap_pixels / GRUB_CHAR_BIT + !!(_bitmap_pixels % GRUB_CHAR_BIT), (result)); \ -+}) -+ - void EXPORT_FUNC (grub_video_bitmap_get_mode_info) (struct grub_video_bitmap *bitmap, - struct grub_video_mode_info *mode_info); - -diff --git a/include/grub/safemath.h b/include/grub/safemath.h -index c17b89bba1..bb0f826de1 100644 ---- a/include/grub/safemath.h -+++ b/include/grub/safemath.h -@@ -30,6 +30,8 @@ - #define grub_sub(a, b, res) __builtin_sub_overflow(a, b, res) - #define grub_mul(a, b, res) __builtin_mul_overflow(a, b, res) - -+#define grub_cast(a, res) grub_add ((a), 0, (res)) -+ - #else - #error gcc 5.1 or newer or clang 3.8 or newer is required - #endif diff --git a/0355-grub2-mkconfig-Pass-all-boot-params-when-used-by-ana.patch b/0280-grub2-mkconfig-Pass-all-boot-params-when-used-by-ana.patch similarity index 92% rename from 0355-grub2-mkconfig-Pass-all-boot-params-when-used-by-ana.patch rename to 0280-grub2-mkconfig-Pass-all-boot-params-when-used-by-ana.patch index 916affd..41b78cc 100644 --- a/0355-grub2-mkconfig-Pass-all-boot-params-when-used-by-ana.patch +++ b/0280-grub2-mkconfig-Pass-all-boot-params-when-used-by-ana.patch @@ -14,10 +14,10 @@ Signed-off-by: Marta Lewandowska 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in -index 72b75effe448..041a11529588 100644 +index c258aa3cd81..7cf37e9ea68 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in -@@ -265,7 +265,11 @@ if [ -z "\${kernelopts}" ]; then +@@ -267,7 +267,11 @@ if [ -z "\${kernelopts}" ]; then fi EOF diff --git a/0281-font-Fix-several-integer-overflows-in-grub_font_cons.patch b/0281-font-Fix-several-integer-overflows-in-grub_font_cons.patch deleted file mode 100644 index 3c76eb4..0000000 --- a/0281-font-Fix-several-integer-overflows-in-grub_font_cons.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Fri, 5 Aug 2022 01:58:27 +0800 -Subject: [PATCH] font: Fix several integer overflows in - grub_font_construct_glyph() - -This patch fixes several integer overflows in grub_font_construct_glyph(). -Glyphs of invalid size, zero or leading to an overflow, are rejected. -The inconsistency between "glyph" and "max_glyph_size" when grub_malloc() -returns NULL is fixed too. - -Fixes: CVE-2022-2601 - -Reported-by: Zhang Boyang -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit b1805f251b31a9d3cfae5c3572ddfa630145dbbf) ---- - grub-core/font/font.c | 29 +++++++++++++++++------------ - 1 file changed, 17 insertions(+), 12 deletions(-) - -diff --git a/grub-core/font/font.c b/grub-core/font/font.c -index 6a3fbebbd8..1fa181d4ca 100644 ---- a/grub-core/font/font.c -+++ b/grub-core/font/font.c -@@ -1517,6 +1517,7 @@ grub_font_construct_glyph (grub_font_t hinted_font, - struct grub_video_signed_rect bounds; - static struct grub_font_glyph *glyph = 0; - static grub_size_t max_glyph_size = 0; -+ grub_size_t cur_glyph_size; - - ensure_comb_space (glyph_id); - -@@ -1533,29 +1534,33 @@ grub_font_construct_glyph (grub_font_t hinted_font, - if (!glyph_id->ncomb && !glyph_id->attributes) - return main_glyph; - -- if (max_glyph_size < sizeof (*glyph) + (bounds.width * bounds.height + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT) -+ if (grub_video_bitmap_calc_1bpp_bufsz (bounds.width, bounds.height, &cur_glyph_size) || -+ grub_add (sizeof (*glyph), cur_glyph_size, &cur_glyph_size)) -+ return main_glyph; -+ -+ if (max_glyph_size < cur_glyph_size) - { - grub_free (glyph); -- max_glyph_size = (sizeof (*glyph) + (bounds.width * bounds.height + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT) * 2; -- if (max_glyph_size < 8) -- max_glyph_size = 8; -- glyph = grub_malloc (max_glyph_size); -+ if (grub_mul (cur_glyph_size, 2, &max_glyph_size)) -+ max_glyph_size = 0; -+ glyph = max_glyph_size > 0 ? grub_malloc (max_glyph_size) : NULL; - } - if (!glyph) - { -+ max_glyph_size = 0; - grub_errno = GRUB_ERR_NONE; - return main_glyph; - } - -- grub_memset (glyph, 0, sizeof (*glyph) -- + (bounds.width * bounds.height -- + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT); -+ grub_memset (glyph, 0, cur_glyph_size); - - glyph->font = main_glyph->font; -- glyph->width = bounds.width; -- glyph->height = bounds.height; -- glyph->offset_x = bounds.x; -- glyph->offset_y = bounds.y; -+ if (bounds.width == 0 || bounds.height == 0 || -+ grub_cast (bounds.width, &glyph->width) || -+ grub_cast (bounds.height, &glyph->height) || -+ grub_cast (bounds.x, &glyph->offset_x) || -+ grub_cast (bounds.y, &glyph->offset_y)) -+ return main_glyph; - - if (glyph_id->attributes & GRUB_UNICODE_GLYPH_ATTRIBUTE_MIRROR) - grub_font_blit_glyph_mirror (glyph, main_glyph, diff --git a/0282-font-Remove-grub_font_dup_glyph.patch b/0282-font-Remove-grub_font_dup_glyph.patch deleted file mode 100644 index 4c3db92..0000000 --- a/0282-font-Remove-grub_font_dup_glyph.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Fri, 5 Aug 2022 02:13:29 +0800 -Subject: [PATCH] font: Remove grub_font_dup_glyph() - -Remove grub_font_dup_glyph() since nobody is using it since 2013, and -I'm too lazy to fix the integer overflow problem in it. - -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit 25ad31c19c331aaa2dbd9bd2b2e2655de5766a9d) ---- - grub-core/font/font.c | 14 -------------- - 1 file changed, 14 deletions(-) - -diff --git a/grub-core/font/font.c b/grub-core/font/font.c -index 1fa181d4ca..a115a63b0c 100644 ---- a/grub-core/font/font.c -+++ b/grub-core/font/font.c -@@ -1055,20 +1055,6 @@ grub_font_get_glyph_with_fallback (grub_font_t font, grub_uint32_t code) - return best_glyph; - } - --#if 0 --static struct grub_font_glyph * --grub_font_dup_glyph (struct grub_font_glyph *glyph) --{ -- static struct grub_font_glyph *ret; -- ret = grub_malloc (sizeof (*ret) + (glyph->width * glyph->height + 7) / 8); -- if (!ret) -- return NULL; -- grub_memcpy (ret, glyph, sizeof (*ret) -- + (glyph->width * glyph->height + 7) / 8); -- return ret; --} --#endif -- - /* FIXME: suboptimal. */ - static void - grub_font_blit_glyph (struct grub_font_glyph *target, diff --git a/0283-font-Fix-integer-overflow-in-ensure_comb_space.patch b/0283-font-Fix-integer-overflow-in-ensure_comb_space.patch deleted file mode 100644 index 6b73038..0000000 --- a/0283-font-Fix-integer-overflow-in-ensure_comb_space.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Fri, 5 Aug 2022 02:27:05 +0800 -Subject: [PATCH] font: Fix integer overflow in ensure_comb_space() - -In fact it can't overflow at all because glyph_id->ncomb is only 8-bit -wide. But let's keep safe if somebody changes the width of glyph_id->ncomb -in the future. This patch also fixes the inconsistency between -render_max_comb_glyphs and render_combining_glyphs when grub_malloc() -returns NULL. - -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit b2740b7e4a03bb8331d48b54b119afea76bb9d5f) ---- - grub-core/font/font.c | 14 +++++++++----- - 1 file changed, 9 insertions(+), 5 deletions(-) - -diff --git a/grub-core/font/font.c b/grub-core/font/font.c -index a115a63b0c..d0e6340404 100644 ---- a/grub-core/font/font.c -+++ b/grub-core/font/font.c -@@ -1468,14 +1468,18 @@ ensure_comb_space (const struct grub_unicode_glyph *glyph_id) - if (glyph_id->ncomb <= render_max_comb_glyphs) - return; - -- render_max_comb_glyphs = 2 * glyph_id->ncomb; -- if (render_max_comb_glyphs < 8) -+ if (grub_mul (glyph_id->ncomb, 2, &render_max_comb_glyphs)) -+ render_max_comb_glyphs = 0; -+ if (render_max_comb_glyphs > 0 && render_max_comb_glyphs < 8) - render_max_comb_glyphs = 8; - grub_free (render_combining_glyphs); -- render_combining_glyphs = grub_malloc (render_max_comb_glyphs -- * sizeof (render_combining_glyphs[0])); -+ render_combining_glyphs = (render_max_comb_glyphs > 0) ? -+ grub_calloc (render_max_comb_glyphs, sizeof (render_combining_glyphs[0])) : NULL; - if (!render_combining_glyphs) -- grub_errno = 0; -+ { -+ render_max_comb_glyphs = 0; -+ grub_errno = GRUB_ERR_NONE; -+ } - } - - int diff --git a/0284-font-Fix-integer-overflow-in-BMP-index.patch b/0284-font-Fix-integer-overflow-in-BMP-index.patch deleted file mode 100644 index 5e10699..0000000 --- a/0284-font-Fix-integer-overflow-in-BMP-index.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Mon, 15 Aug 2022 02:04:58 +0800 -Subject: [PATCH] font: Fix integer overflow in BMP index - -The BMP index (font->bmp_idx) is designed as a reverse lookup table of -char entries (font->char_index), in order to speed up lookups for BMP -chars (i.e. code < 0x10000). The values in BMP index are the subscripts -of the corresponding char entries, stored in grub_uint16_t, while 0xffff -means not found. - -This patch fixes the problem of large subscript truncated to grub_uint16_t, -leading BMP index to return wrong char entry or report false miss. The -code now checks for bounds and uses BMP index as a hint, and fallbacks -to binary-search if necessary. - -On the occasion add a comment about BMP index is initialized to 0xffff. - -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit afda8b60ba0712abe01ae1e64c5f7a067a0e6492) ---- - grub-core/font/font.c | 13 +++++++++---- - 1 file changed, 9 insertions(+), 4 deletions(-) - -diff --git a/grub-core/font/font.c b/grub-core/font/font.c -index d0e6340404..b208a28717 100644 ---- a/grub-core/font/font.c -+++ b/grub-core/font/font.c -@@ -300,6 +300,8 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct - font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t)); - if (!font->bmp_idx) - return 1; -+ -+ /* Init the BMP index array to 0xffff. */ - grub_memset (font->bmp_idx, 0xff, 0x10000 * sizeof (grub_uint16_t)); - - -@@ -328,7 +330,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct - return 1; - } - -- if (entry->code < 0x10000) -+ if (entry->code < 0x10000 && i < 0xffff) - font->bmp_idx[entry->code] = i; - - last_code = entry->code; -@@ -696,9 +698,12 @@ find_glyph (const grub_font_t font, grub_uint32_t code) - /* Use BMP index if possible. */ - if (code < 0x10000 && font->bmp_idx) - { -- if (font->bmp_idx[code] == 0xffff) -- return 0; -- return &table[font->bmp_idx[code]]; -+ if (font->bmp_idx[code] < 0xffff) -+ return &table[font->bmp_idx[code]]; -+ /* -+ * When we are here then lookup in BMP index result in miss, -+ * fallthough to binary-search. -+ */ - } - - /* Do a binary search in `char_index', which is ordered by code point. */ diff --git a/0285-font-Fix-integer-underflow-in-binary-search-of-char-.patch b/0285-font-Fix-integer-underflow-in-binary-search-of-char-.patch deleted file mode 100644 index e81824b..0000000 --- a/0285-font-Fix-integer-underflow-in-binary-search-of-char-.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Sun, 14 Aug 2022 18:09:38 +0800 -Subject: [PATCH] font: Fix integer underflow in binary search of char index - -If search target is less than all entries in font->index then "hi" -variable is set to -1, which translates to SIZE_MAX and leads to errors. - -This patch fixes the problem by replacing the entire binary search code -with the libstdc++'s std::lower_bound() implementation. - -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit c140a086838e7c9af87842036f891b8393a8c4bc) ---- - grub-core/font/font.c | 40 ++++++++++++++++++++++------------------ - 1 file changed, 22 insertions(+), 18 deletions(-) - -diff --git a/grub-core/font/font.c b/grub-core/font/font.c -index b208a28717..193dfec045 100644 ---- a/grub-core/font/font.c -+++ b/grub-core/font/font.c -@@ -688,12 +688,12 @@ read_be_int16 (grub_file_t file, grub_int16_t * value) - static inline struct char_index_entry * - find_glyph (const grub_font_t font, grub_uint32_t code) - { -- struct char_index_entry *table; -- grub_size_t lo; -- grub_size_t hi; -- grub_size_t mid; -+ struct char_index_entry *table, *first, *end; -+ grub_size_t len; - - table = font->char_index; -+ if (table == NULL) -+ return NULL; - - /* Use BMP index if possible. */ - if (code < 0x10000 && font->bmp_idx) -@@ -706,25 +706,29 @@ find_glyph (const grub_font_t font, grub_uint32_t code) - */ - } - -- /* Do a binary search in `char_index', which is ordered by code point. */ -- lo = 0; -- hi = font->num_chars - 1; -+ /* -+ * Do a binary search in char_index which is ordered by code point. -+ * The code below is the same as libstdc++'s std::lower_bound(). -+ */ -+ first = table; -+ len = font->num_chars; -+ end = first + len; - -- if (!table) -- return 0; -- -- while (lo <= hi) -+ while (len > 0) - { -- mid = lo + (hi - lo) / 2; -- if (code < table[mid].code) -- hi = mid - 1; -- else if (code > table[mid].code) -- lo = mid + 1; -+ grub_size_t half = len >> 1; -+ struct char_index_entry *middle = first + half; -+ -+ if (middle->code < code) -+ { -+ first = middle + 1; -+ len = len - half - 1; -+ } - else -- return &table[mid]; -+ len = half; - } - -- return 0; -+ return (first < end && first->code == code) ? first : NULL; - } - - /* Get a glyph for the Unicode character CODE in FONT. The glyph is loaded diff --git a/0286-kern-efi-sb-Enforce-verification-of-font-files.patch b/0286-kern-efi-sb-Enforce-verification-of-font-files.patch deleted file mode 100644 index 1a381b0..0000000 --- a/0286-kern-efi-sb-Enforce-verification-of-font-files.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Sun, 14 Aug 2022 15:51:54 +0800 -Subject: [PATCH] kern/efi/sb: Enforce verification of font files - -As a mitigation and hardening measure enforce verification of font -files. Then only trusted font files can be load. This will reduce the -attack surface at cost of losing the ability of end-users to customize -fonts if e.g. UEFI Secure Boot is enabled. Vendors can always customize -fonts because they have ability to pack fonts into their GRUB bundles. - -This goal is achieved by: - - * Removing GRUB_FILE_TYPE_FONT from shim lock verifier's - skip-verification list. - - * Adding GRUB_FILE_TYPE_FONT to lockdown verifier's defer-auth list, - so font files must be verified by a verifier before they can be loaded. - -Suggested-by: Daniel Kiper -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit 630deb8c0d8b02b670ced4b7030414bcf17aa080) ---- - grub-core/kern/efi/sb.c | 1 - - grub-core/kern/lockdown.c | 1 + - 2 files changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/kern/efi/sb.c b/grub-core/kern/efi/sb.c -index 89c4bb3fd1..db42c2539f 100644 ---- a/grub-core/kern/efi/sb.c -+++ b/grub-core/kern/efi/sb.c -@@ -145,7 +145,6 @@ shim_lock_verifier_init (grub_file_t io __attribute__ ((unused)), - case GRUB_FILE_TYPE_PRINT_BLOCKLIST: - case GRUB_FILE_TYPE_TESTLOAD: - case GRUB_FILE_TYPE_GET_SIZE: -- case GRUB_FILE_TYPE_FONT: - case GRUB_FILE_TYPE_ZFS_ENCRYPTION_KEY: - case GRUB_FILE_TYPE_CAT: - case GRUB_FILE_TYPE_HEXCAT: -diff --git a/grub-core/kern/lockdown.c b/grub-core/kern/lockdown.c -index 0bc70fd42d..af6d493cd3 100644 ---- a/grub-core/kern/lockdown.c -+++ b/grub-core/kern/lockdown.c -@@ -51,6 +51,7 @@ lockdown_verifier_init (grub_file_t io __attribute__ ((unused)), - case GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE: - case GRUB_FILE_TYPE_ACPI_TABLE: - case GRUB_FILE_TYPE_DEVICE_TREE_IMAGE: -+ case GRUB_FILE_TYPE_FONT: - *flags = GRUB_VERIFY_FLAGS_DEFER_AUTH; - - /* Fall through. */ diff --git a/0287-fbutil-Fix-integer-overflow.patch b/0287-fbutil-Fix-integer-overflow.patch deleted file mode 100644 index 4d32dbd..0000000 --- a/0287-fbutil-Fix-integer-overflow.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Tue, 6 Sep 2022 03:03:21 +0800 -Subject: [PATCH] fbutil: Fix integer overflow - -Expressions like u64 = u32 * u32 are unsafe because their products are -truncated to u32 even if left hand side is u64. This patch fixes all -problems like that one in fbutil. - -To get right result not only left hand side have to be u64 but it's also -necessary to cast at least one of the operands of all leaf operators of -right hand side to u64, e.g. u64 = u32 * u32 + u32 * u32 should be -u64 = (u64)u32 * u32 + (u64)u32 * u32. - -For 1-bit bitmaps grub_uint64_t have to be used. It's safe because any -combination of values in (grub_uint64_t)u32 * u32 + u32 expression will -not overflow grub_uint64_t. - -Other expressions like ptr + u32 * u32 + u32 * u32 are also vulnerable. -They should be ptr + (grub_addr_t)u32 * u32 + (grub_addr_t)u32 * u32. - -This patch also adds a comment to grub_video_fb_get_video_ptr() which -says it's arguments must be valid and no sanity check is performed -(like its siblings in grub-core/video/fb/fbutil.c). - -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit 50a11a81bc842c58962244a2dc86bbd31a426e12) ---- - grub-core/video/fb/fbutil.c | 4 ++-- - include/grub/fbutil.h | 13 +++++++++---- - 2 files changed, 11 insertions(+), 6 deletions(-) - -diff --git a/grub-core/video/fb/fbutil.c b/grub-core/video/fb/fbutil.c -index b98bb51fe8..25ef39f47d 100644 ---- a/grub-core/video/fb/fbutil.c -+++ b/grub-core/video/fb/fbutil.c -@@ -67,7 +67,7 @@ get_pixel (struct grub_video_fbblit_info *source, - case 1: - if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED) - { -- int bit_index = y * source->mode_info->width + x; -+ grub_uint64_t bit_index = (grub_uint64_t) y * source->mode_info->width + x; - grub_uint8_t *ptr = source->data + bit_index / 8; - int bit_pos = 7 - bit_index % 8; - color = (*ptr >> bit_pos) & 0x01; -@@ -138,7 +138,7 @@ set_pixel (struct grub_video_fbblit_info *source, - case 1: - if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED) - { -- int bit_index = y * source->mode_info->width + x; -+ grub_uint64_t bit_index = (grub_uint64_t) y * source->mode_info->width + x; - grub_uint8_t *ptr = source->data + bit_index / 8; - int bit_pos = 7 - bit_index % 8; - *ptr = (*ptr & ~(1 << bit_pos)) | ((color & 0x01) << bit_pos); -diff --git a/include/grub/fbutil.h b/include/grub/fbutil.h -index 4205eb917f..78a1ab3b45 100644 ---- a/include/grub/fbutil.h -+++ b/include/grub/fbutil.h -@@ -31,14 +31,19 @@ struct grub_video_fbblit_info - grub_uint8_t *data; - }; - --/* Don't use for 1-bit bitmaps, addressing needs to be done at the bit level -- and it doesn't make sense, in general, to ask for a pointer -- to a particular pixel's data. */ -+/* -+ * Don't use for 1-bit bitmaps, addressing needs to be done at the bit level -+ * and it doesn't make sense, in general, to ask for a pointer -+ * to a particular pixel's data. -+ * -+ * This function assumes that bounds checking has been done in previous phase -+ * and they are opted out in here. -+ */ - static inline void * - grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source, - unsigned int x, unsigned int y) - { -- return source->data + y * source->mode_info->pitch + x * source->mode_info->bytes_per_pixel; -+ return source->data + (grub_addr_t) y * source->mode_info->pitch + (grub_addr_t) x * source->mode_info->bytes_per_pixel; - } - - /* Advance pointer by VAL bytes. If there is no unaligned access available, diff --git a/0288-font-Fix-an-integer-underflow-in-blit_comb.patch b/0288-font-Fix-an-integer-underflow-in-blit_comb.patch deleted file mode 100644 index 72f4308..0000000 --- a/0288-font-Fix-an-integer-underflow-in-blit_comb.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Mon, 24 Oct 2022 08:05:35 +0800 -Subject: [PATCH] font: Fix an integer underflow in blit_comb() - -The expression (ctx.bounds.height - combining_glyphs[i]->height) / 2 may -evaluate to a very big invalid value even if both ctx.bounds.height and -combining_glyphs[i]->height are small integers. For example, if -ctx.bounds.height is 10 and combining_glyphs[i]->height is 12, this -expression evaluates to 2147483647 (expected -1). This is because -coordinates are allowed to be negative but ctx.bounds.height is an -unsigned int. So, the subtraction operates on unsigned ints and -underflows to a very big value. The division makes things even worse. -The quotient is still an invalid value even if converted back to int. - -This patch fixes the problem by casting ctx.bounds.height to int. As -a result the subtraction will operate on int and grub_uint16_t which -will be promoted to an int. So, the underflow will no longer happen. Other -uses of ctx.bounds.height (and ctx.bounds.width) are also casted to int, -to ensure coordinates are always calculated on signed integers. - -Fixes: CVE-2022-3775 - -Reported-by: Daniel Axtens -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit 6d2668dea3774ed74c4cd1eadd146f1b846bc3d4) ---- - grub-core/font/font.c | 16 ++++++++-------- - 1 file changed, 8 insertions(+), 8 deletions(-) - -diff --git a/grub-core/font/font.c b/grub-core/font/font.c -index 193dfec045..12a5f0d08c 100644 ---- a/grub-core/font/font.c -+++ b/grub-core/font/font.c -@@ -1203,12 +1203,12 @@ blit_comb (const struct grub_unicode_glyph *glyph_id, - ctx.bounds.height = main_glyph->height; - - above_rightx = main_glyph->offset_x + main_glyph->width; -- above_righty = ctx.bounds.y + ctx.bounds.height; -+ above_righty = ctx.bounds.y + (int) ctx.bounds.height; - - above_leftx = main_glyph->offset_x; -- above_lefty = ctx.bounds.y + ctx.bounds.height; -+ above_lefty = ctx.bounds.y + (int) ctx.bounds.height; - -- below_rightx = ctx.bounds.x + ctx.bounds.width; -+ below_rightx = ctx.bounds.x + (int) ctx.bounds.width; - below_righty = ctx.bounds.y; - - comb = grub_unicode_get_comb (glyph_id); -@@ -1221,7 +1221,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id, - - if (!combining_glyphs[i]) - continue; -- targetx = (ctx.bounds.width - combining_glyphs[i]->width) / 2 + ctx.bounds.x; -+ targetx = ((int) ctx.bounds.width - combining_glyphs[i]->width) / 2 + ctx.bounds.x; - /* CGJ is to avoid diacritics reordering. */ - if (comb[i].code - == GRUB_UNICODE_COMBINING_GRAPHEME_JOINER) -@@ -1231,8 +1231,8 @@ blit_comb (const struct grub_unicode_glyph *glyph_id, - case GRUB_UNICODE_COMB_OVERLAY: - do_blit (combining_glyphs[i], - targetx, -- (ctx.bounds.height - combining_glyphs[i]->height) / 2 -- - (ctx.bounds.height + ctx.bounds.y), &ctx); -+ ((int) ctx.bounds.height - combining_glyphs[i]->height) / 2 -+ - ((int) ctx.bounds.height + ctx.bounds.y), &ctx); - if (min_devwidth < combining_glyphs[i]->width) - min_devwidth = combining_glyphs[i]->width; - break; -@@ -1305,7 +1305,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id, - /* Fallthrough. */ - case GRUB_UNICODE_STACK_ATTACHED_ABOVE: - do_blit (combining_glyphs[i], targetx, -- -(ctx.bounds.height + ctx.bounds.y + space -+ -((int) ctx.bounds.height + ctx.bounds.y + space - + combining_glyphs[i]->height), &ctx); - if (min_devwidth < combining_glyphs[i]->width) - min_devwidth = combining_glyphs[i]->width; -@@ -1313,7 +1313,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id, - - case GRUB_UNICODE_COMB_HEBREW_DAGESH: - do_blit (combining_glyphs[i], targetx, -- -(ctx.bounds.height / 2 + ctx.bounds.y -+ -((int) ctx.bounds.height / 2 + ctx.bounds.y - + combining_glyphs[i]->height / 2), &ctx); - if (min_devwidth < combining_glyphs[i]->width) - min_devwidth = combining_glyphs[i]->width; diff --git a/0289-font-Harden-grub_font_blit_glyph-and-grub_font_blit_.patch b/0289-font-Harden-grub_font_blit_glyph-and-grub_font_blit_.patch deleted file mode 100644 index 5207c12..0000000 --- a/0289-font-Harden-grub_font_blit_glyph-and-grub_font_blit_.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Mon, 24 Oct 2022 07:15:41 +0800 -Subject: [PATCH] font: Harden grub_font_blit_glyph() and - grub_font_blit_glyph_mirror() - -As a mitigation and hardening measure add sanity checks to -grub_font_blit_glyph() and grub_font_blit_glyph_mirror(). This patch -makes these two functions do nothing if target blitting area isn't fully -contained in target bitmap. Therefore, if complex calculations in caller -overflows and malicious coordinates are given, we are still safe because -any coordinates which result in out-of-bound-write are rejected. However, -this patch only checks for invalid coordinates, and doesn't provide any -protection against invalid source glyph or destination glyph, e.g. -mismatch between glyph size and buffer size. - -This hardening measure is designed to mitigate possible overflows in -blit_comb(). If overflow occurs, it may return invalid bounding box -during dry run and call grub_font_blit_glyph() with malicious -coordinates during actual blitting. However, we are still safe because -the scratch glyph itself is valid, although its size makes no sense, and -any invalid coordinates are rejected. - -It would be better to call grub_fatal() if illegal parameter is detected. -However, doing this may end up in a dangerous recursion because grub_fatal() -would print messages to the screen and we are in the progress of drawing -characters on the screen. - -Reported-by: Daniel Axtens -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit fcd7aa0c278f7cf3fb9f93f1a3966e1792339eb6) ---- - grub-core/font/font.c | 14 ++++++++++++++ - 1 file changed, 14 insertions(+) - -diff --git a/grub-core/font/font.c b/grub-core/font/font.c -index 12a5f0d08c..29fbb94294 100644 ---- a/grub-core/font/font.c -+++ b/grub-core/font/font.c -@@ -1069,8 +1069,15 @@ static void - grub_font_blit_glyph (struct grub_font_glyph *target, - struct grub_font_glyph *src, unsigned dx, unsigned dy) - { -+ grub_uint16_t max_x, max_y; - unsigned src_bit, tgt_bit, src_byte, tgt_byte; - unsigned i, j; -+ -+ /* Harden against out-of-bound writes. */ -+ if ((grub_add (dx, src->width, &max_x) || max_x > target->width) || -+ (grub_add (dy, src->height, &max_y) || max_y > target->height)) -+ return; -+ - for (i = 0; i < src->height; i++) - { - src_bit = (src->width * i) % 8; -@@ -1102,9 +1109,16 @@ grub_font_blit_glyph_mirror (struct grub_font_glyph *target, - struct grub_font_glyph *src, - unsigned dx, unsigned dy) - { -+ grub_uint16_t max_x, max_y; - unsigned tgt_bit, src_byte, tgt_byte; - signed src_bit; - unsigned i, j; -+ -+ /* Harden against out-of-bound writes. */ -+ if ((grub_add (dx, src->width, &max_x) || max_x > target->width) || -+ (grub_add (dy, src->height, &max_y) || max_y > target->height)) -+ return; -+ - for (i = 0; i < src->height; i++) - { - src_bit = (src->width * i + src->width - 1) % 8; diff --git a/0290-font-Assign-null_font-to-glyphs-in-ascii_font_glyph.patch b/0290-font-Assign-null_font-to-glyphs-in-ascii_font_glyph.patch deleted file mode 100644 index c2bcc18..0000000 --- a/0290-font-Assign-null_font-to-glyphs-in-ascii_font_glyph.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Fri, 28 Oct 2022 17:29:16 +0800 -Subject: [PATCH] font: Assign null_font to glyphs in ascii_font_glyph[] - -The calculations in blit_comb() need information from glyph's font, e.g. -grub_font_get_xheight(main_glyph->font). However, main_glyph->font is -NULL if main_glyph comes from ascii_font_glyph[]. Therefore -grub_font_get_*() crashes because of NULL pointer. - -There is already a solution, the null_font. So, assign it to those glyphs -in ascii_font_glyph[]. - -Reported-by: Daniel Axtens -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit dd539d695482069d28b40f2d3821f710cdcf6ee6) ---- - grub-core/font/font.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/font/font.c b/grub-core/font/font.c -index 29fbb94294..e6616e610c 100644 ---- a/grub-core/font/font.c -+++ b/grub-core/font/font.c -@@ -137,7 +137,7 @@ ascii_glyph_lookup (grub_uint32_t code) - ascii_font_glyph[current]->offset_x = 0; - ascii_font_glyph[current]->offset_y = -2; - ascii_font_glyph[current]->device_width = 8; -- ascii_font_glyph[current]->font = NULL; -+ ascii_font_glyph[current]->font = &null_font; - - grub_memcpy (ascii_font_glyph[current]->bitmap, - &ascii_bitmaps[current * ASCII_BITMAP_SIZE], diff --git a/0291-normal-charset-Fix-an-integer-overflow-in-grub_unico.patch b/0291-normal-charset-Fix-an-integer-overflow-in-grub_unico.patch deleted file mode 100644 index ec2184f..0000000 --- a/0291-normal-charset-Fix-an-integer-overflow-in-grub_unico.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Fri, 28 Oct 2022 21:31:39 +0800 -Subject: [PATCH] normal/charset: Fix an integer overflow in - grub_unicode_aglomerate_comb() - -The out->ncomb is a bit-field of 8 bits. So, the max possible value is 255. -However, code in grub_unicode_aglomerate_comb() doesn't check for an -overflow when incrementing out->ncomb. If out->ncomb is already 255, -after incrementing it will get 0 instead of 256, and cause illegal -memory access in subsequent processing. - -This patch introduces GRUB_UNICODE_NCOMB_MAX to represent the max -acceptable value of ncomb. The code now checks for this limit and -ignores additional combining characters when limit is reached. - -Reported-by: Daniel Axtens -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit da90d62316a3b105d2fbd7334d6521936bd6dcf6) ---- - grub-core/normal/charset.c | 3 +++ - include/grub/unicode.h | 2 ++ - 2 files changed, 5 insertions(+) - -diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c -index 7a5a7c153c..c243ca6dae 100644 ---- a/grub-core/normal/charset.c -+++ b/grub-core/normal/charset.c -@@ -472,6 +472,9 @@ grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen, - if (!haveout) - continue; - -+ if (out->ncomb == GRUB_UNICODE_NCOMB_MAX) -+ continue; -+ - if (comb_type == GRUB_UNICODE_COMB_MC - || comb_type == GRUB_UNICODE_COMB_ME - || comb_type == GRUB_UNICODE_COMB_MN) -diff --git a/include/grub/unicode.h b/include/grub/unicode.h -index 4de986a857..c4f6fca043 100644 ---- a/include/grub/unicode.h -+++ b/include/grub/unicode.h -@@ -147,7 +147,9 @@ struct grub_unicode_glyph - grub_uint8_t bidi_level:6; /* minimum: 6 */ - enum grub_bidi_type bidi_type:5; /* minimum: :5 */ - -+#define GRUB_UNICODE_NCOMB_MAX ((1 << 8) - 1) - unsigned ncomb:8; -+ - /* Hint by unicode subsystem how wide this character usually is. - Real width is determined by font. Set only in UTF-8 stream. */ - int estimated_width:8; diff --git a/0292-font-Try-opening-fonts-from-the-bundled-memdisk.patch b/0292-font-Try-opening-fonts-from-the-bundled-memdisk.patch deleted file mode 100644 index bad9d90..0000000 --- a/0292-font-Try-opening-fonts-from-the-bundled-memdisk.patch +++ /dev/null @@ -1,78 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Chris Coulson -Date: Wed, 16 Nov 2022 14:40:04 +0000 -Subject: [PATCH] font: Try opening fonts from the bundled memdisk - -Signed-off-by: Robbie Harwood ---- - grub-core/font/font.c | 48 +++++++++++++++++++++++++++++++----------------- - 1 file changed, 31 insertions(+), 17 deletions(-) - -diff --git a/grub-core/font/font.c b/grub-core/font/font.c -index e6616e610c..e421d1ae6f 100644 ---- a/grub-core/font/font.c -+++ b/grub-core/font/font.c -@@ -409,6 +409,27 @@ read_section_as_short (struct font_file_section *section, - return 0; - } - -+static grub_file_t -+try_open_from_prefix (const char *prefix, const char *filename) -+{ -+ grub_file_t file; -+ char *fullname, *ptr; -+ -+ fullname = grub_malloc (grub_strlen (prefix) + grub_strlen (filename) + 1 -+ + sizeof ("/fonts/") + sizeof (".pf2")); -+ if (!fullname) -+ return 0; -+ ptr = grub_stpcpy (fullname, prefix); -+ ptr = grub_stpcpy (ptr, "/fonts/"); -+ ptr = grub_stpcpy (ptr, filename); -+ ptr = grub_stpcpy (ptr, ".pf2"); -+ *ptr = 0; -+ -+ file = grub_buffile_open (fullname, GRUB_FILE_TYPE_FONT, 1024); -+ grub_free (fullname); -+ return file; -+} -+ - /* Load a font and add it to the beginning of the global font list. - Returns 0 upon success, nonzero upon failure. */ - grub_font_t -@@ -427,25 +448,18 @@ grub_font_load (const char *filename) - file = grub_buffile_open (filename, GRUB_FILE_TYPE_FONT, 1024); - else - { -- const char *prefix = grub_env_get ("prefix"); -- char *fullname, *ptr; -- if (!prefix) -+ file = try_open_from_prefix ("(memdisk)", filename); -+ if (!file) - { -- grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), -- "prefix"); -- goto fail; -+ const char *prefix = grub_env_get ("prefix"); -+ if (!prefix) -+ { -+ grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), -+ "prefix"); -+ goto fail; -+ } -+ file = try_open_from_prefix (prefix, filename); - } -- fullname = grub_malloc (grub_strlen (prefix) + grub_strlen (filename) + 1 -- + sizeof ("/fonts/") + sizeof (".pf2")); -- if (!fullname) -- goto fail; -- ptr = grub_stpcpy (fullname, prefix); -- ptr = grub_stpcpy (ptr, "/fonts/"); -- ptr = grub_stpcpy (ptr, filename); -- ptr = grub_stpcpy (ptr, ".pf2"); -- *ptr = 0; -- file = grub_buffile_open (fullname, GRUB_FILE_TYPE_FONT, 1024); -- grub_free (fullname); - } - if (!file) - goto fail; diff --git a/0293-mm-Clarify-grub_real_malloc.patch b/0293-mm-Clarify-grub_real_malloc.patch deleted file mode 100644 index 0a99c08..0000000 --- a/0293-mm-Clarify-grub_real_malloc.patch +++ /dev/null @@ -1,183 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Thu, 25 Nov 2021 02:22:46 +1100 -Subject: [PATCH] mm: Clarify grub_real_malloc() - -When iterating through the singly linked list of free blocks, -grub_real_malloc() uses p and q for the current and previous blocks -respectively. This isn't super clear, so swap to using prev and cur. - -This makes another quirk more obvious. The comment at the top of -grub_real_malloc() might lead you to believe that the function will -allocate from *first if there is space in that block. - -It actually doesn't do that, and it can't do that with the current -data structures. If we used up all of *first, we would need to change -the ->next of the previous block to point to *first->next, but we -can't do that because it's a singly linked list and we don't have -access to *first's previous block. - -What grub_real_malloc() actually does is set *first to the initial -previous block, and *first->next is the block we try to allocate -from. That allows us to keep all the data structures consistent. - -Document that. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 246ad6a44c281bb13486ddea0a26bb661db73106) ---- - grub-core/kern/mm.c | 76 +++++++++++++++++++++++++++++------------------------ - 1 file changed, 41 insertions(+), 35 deletions(-) - -diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index d8c8377578..fb20e93acf 100644 ---- a/grub-core/kern/mm.c -+++ b/grub-core/kern/mm.c -@@ -178,13 +178,20 @@ grub_mm_init_region (void *addr, grub_size_t size) - } - - /* Allocate the number of units N with the alignment ALIGN from the ring -- buffer starting from *FIRST. ALIGN must be a power of two. Both N and -- ALIGN are in units of GRUB_MM_ALIGN. Return a non-NULL if successful, -- otherwise return NULL. */ -+ * buffer given in *FIRST. ALIGN must be a power of two. Both N and -+ * ALIGN are in units of GRUB_MM_ALIGN. Return a non-NULL if successful, -+ * otherwise return NULL. -+ * -+ * Note: because in certain circumstances we need to adjust the ->next -+ * pointer of the previous block, we iterate over the singly linked -+ * list with the pair (prev, cur). *FIRST is our initial previous, and -+ * *FIRST->next is our initial current pointer. So we will actually -+ * allocate from *FIRST->next first and *FIRST itself last. -+ */ - static void * - grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) - { -- grub_mm_header_t p, q; -+ grub_mm_header_t cur, prev; - - /* When everything is allocated side effect is that *first will have alloc - magic marked, meaning that there is no room in this region. */ -@@ -192,24 +199,24 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) - return 0; - - /* Try to search free slot for allocation in this memory region. */ -- for (q = *first, p = q->next; ; q = p, p = p->next) -+ for (prev = *first, cur = prev->next; ; prev = cur, cur = cur->next) - { - grub_off_t extra; - -- extra = ((grub_addr_t) (p + 1) >> GRUB_MM_ALIGN_LOG2) & (align - 1); -+ extra = ((grub_addr_t) (cur + 1) >> GRUB_MM_ALIGN_LOG2) & (align - 1); - if (extra) - extra = align - extra; - -- if (! p) -+ if (! cur) - grub_fatal ("null in the ring"); - -- if (p->magic != GRUB_MM_FREE_MAGIC) -- grub_fatal ("free magic is broken at %p: 0x%x", p, p->magic); -+ if (cur->magic != GRUB_MM_FREE_MAGIC) -+ grub_fatal ("free magic is broken at %p: 0x%x", cur, cur->magic); - -- if (p->size >= n + extra) -+ if (cur->size >= n + extra) - { -- extra += (p->size - extra - n) & (~(align - 1)); -- if (extra == 0 && p->size == n) -+ extra += (cur->size - extra - n) & (~(align - 1)); -+ if (extra == 0 && cur->size == n) - { - /* There is no special alignment requirement and memory block - is complete match. -@@ -222,9 +229,9 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) - | alloc, size=n | | - +---------------+ v - */ -- q->next = p->next; -+ prev->next = cur->next; - } -- else if (align == 1 || p->size == n + extra) -+ else if (align == 1 || cur->size == n + extra) - { - /* There might be alignment requirement, when taking it into - account memory block fits in. -@@ -241,23 +248,22 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) - | alloc, size=n | | - +---------------+ v - */ -- -- p->size -= n; -- p += p->size; -+ cur->size -= n; -+ cur += cur->size; - } - else if (extra == 0) - { - grub_mm_header_t r; - -- r = p + extra + n; -+ r = cur + extra + n; - r->magic = GRUB_MM_FREE_MAGIC; -- r->size = p->size - extra - n; -- r->next = p->next; -- q->next = r; -+ r->size = cur->size - extra - n; -+ r->next = cur->next; -+ prev->next = r; - -- if (q == p) -+ if (prev == cur) - { -- q = r; -+ prev = r; - r->next = r; - } - } -@@ -284,32 +290,32 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) - */ - grub_mm_header_t r; - -- r = p + extra + n; -+ r = cur + extra + n; - r->magic = GRUB_MM_FREE_MAGIC; -- r->size = p->size - extra - n; -- r->next = p; -+ r->size = cur->size - extra - n; -+ r->next = cur; - -- p->size = extra; -- q->next = r; -- p += extra; -+ cur->size = extra; -+ prev->next = r; -+ cur += extra; - } - -- p->magic = GRUB_MM_ALLOC_MAGIC; -- p->size = n; -+ cur->magic = GRUB_MM_ALLOC_MAGIC; -+ cur->size = n; - - /* Mark find as a start marker for next allocation to fasten it. - This will have side effect of fragmenting memory as small - pieces before this will be un-used. */ - /* So do it only for chunks under 64K. */ - if (n < (0x8000 >> GRUB_MM_ALIGN_LOG2) -- || *first == p) -- *first = q; -+ || *first == cur) -+ *first = prev; - -- return p + 1; -+ return cur + 1; - } - - /* Search was completed without result. */ -- if (p == *first) -+ if (cur == *first) - break; - } - diff --git a/0294-mm-grub_real_malloc-Make-small-allocs-comment-match-.patch b/0294-mm-grub_real_malloc-Make-small-allocs-comment-match-.patch deleted file mode 100644 index a5601c9..0000000 --- a/0294-mm-grub_real_malloc-Make-small-allocs-comment-match-.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Thu, 25 Nov 2021 02:22:47 +1100 -Subject: [PATCH] mm: grub_real_malloc(): Make small allocs comment match code - -Small allocations move the region's *first pointer. The comment -says that this happens for allocations under 64K. The code says -it's for allocations under 32K. Commit 45bf8b3a7549 changed the -code intentionally: make the comment match. - -Fixes: 45bf8b3a7549 (* grub-core/kern/mm.c (grub_real_malloc): Decrease cut-off of moving the) - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit a847895a8d000bdf27ad4d4326f883a0eed769ca) ---- - grub-core/kern/mm.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index fb20e93acf..db7e0b2a5b 100644 ---- a/grub-core/kern/mm.c -+++ b/grub-core/kern/mm.c -@@ -306,7 +306,7 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align) - /* Mark find as a start marker for next allocation to fasten it. - This will have side effect of fragmenting memory as small - pieces before this will be un-used. */ -- /* So do it only for chunks under 64K. */ -+ /* So do it only for chunks under 32K. */ - if (n < (0x8000 >> GRUB_MM_ALIGN_LOG2) - || *first == cur) - *first = prev; diff --git a/0295-mm-Document-grub_free.patch b/0295-mm-Document-grub_free.patch deleted file mode 100644 index 6c9b7cc..0000000 --- a/0295-mm-Document-grub_free.patch +++ /dev/null @@ -1,120 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Thu, 25 Nov 2021 02:22:48 +1100 -Subject: [PATCH] mm: Document grub_free() - -The grub_free() possesses a surprising number of quirks, and also -uses single-letter variable names confusingly to iterate through -the free list. - -Document what's going on. - -Use prev and cur to iterate over the free list. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 1f8d0b01738e49767d662d6426af3570a64565f0) ---- - grub-core/kern/mm.c | 63 ++++++++++++++++++++++++++++++++++------------------- - 1 file changed, 41 insertions(+), 22 deletions(-) - -diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index db7e0b2a5b..0351171cf9 100644 ---- a/grub-core/kern/mm.c -+++ b/grub-core/kern/mm.c -@@ -446,54 +446,73 @@ grub_free (void *ptr) - } - else - { -- grub_mm_header_t q, s; -+ grub_mm_header_t cur, prev; - - #if 0 -- q = r->first; -+ cur = r->first; - do - { - grub_printf ("%s:%d: q=%p, q->size=0x%x, q->magic=0x%x\n", -- GRUB_FILE, __LINE__, q, q->size, q->magic); -- q = q->next; -+ GRUB_FILE, __LINE__, cur, cur->size, cur->magic); -+ cur = cur->next; - } -- while (q != r->first); -+ while (cur != r->first); - #endif -- -- for (s = r->first, q = s->next; q <= p || q->next >= p; s = q, q = s->next) -+ /* Iterate over all blocks in the free ring. -+ * -+ * The free ring is arranged from high addresses to low -+ * addresses, modulo wraparound. -+ * -+ * We are looking for a block with a higher address than p or -+ * whose next address is lower than p. -+ */ -+ for (prev = r->first, cur = prev->next; cur <= p || cur->next >= p; -+ prev = cur, cur = prev->next) - { -- if (q->magic != GRUB_MM_FREE_MAGIC) -- grub_fatal ("free magic is broken at %p: 0x%x", q, q->magic); -+ if (cur->magic != GRUB_MM_FREE_MAGIC) -+ grub_fatal ("free magic is broken at %p: 0x%x", cur, cur->magic); - -- if (q <= q->next && (q > p || q->next < p)) -+ /* Deal with wrap-around */ -+ if (cur <= cur->next && (cur > p || cur->next < p)) - break; - } - -+ /* mark p as free and insert it between cur and cur->next */ - p->magic = GRUB_MM_FREE_MAGIC; -- p->next = q->next; -- q->next = p; -+ p->next = cur->next; -+ cur->next = p; - -+ /* -+ * If the block we are freeing can be merged with the next -+ * free block, do that. -+ */ - if (p->next + p->next->size == p) - { - p->magic = 0; - - p->next->size += p->size; -- q->next = p->next; -+ cur->next = p->next; - p = p->next; - } - -- r->first = q; -+ r->first = cur; - -- if (q == p + p->size) -+ /* Likewise if can be merged with the preceeding free block */ -+ if (cur == p + p->size) - { -- q->magic = 0; -- p->size += q->size; -- if (q == s) -- s = p; -- s->next = p; -- q = s; -+ cur->magic = 0; -+ p->size += cur->size; -+ if (cur == prev) -+ prev = p; -+ prev->next = p; -+ cur = prev; - } - -- r->first = q; -+ /* -+ * Set r->first such that the just free()d block is tried first. -+ * (An allocation is tried from *first->next, and cur->next == p.) -+ */ -+ r->first = cur; - } - } - diff --git a/0296-mm-Document-grub_mm_init_region.patch b/0296-mm-Document-grub_mm_init_region.patch deleted file mode 100644 index 0173f04..0000000 --- a/0296-mm-Document-grub_mm_init_region.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Thu, 25 Nov 2021 02:22:49 +1100 -Subject: [PATCH] mm: Document grub_mm_init_region() - -The grub_mm_init_region() does some things that seem magical, especially -around region merging. Make it a bit clearer. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 246d69b7ea619fc1e77dcc5960e37aea45a9808c) ---- - grub-core/kern/mm.c | 31 ++++++++++++++++++++++++++++++- - 1 file changed, 30 insertions(+), 1 deletion(-) - -diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index 0351171cf9..1cbf98c7ab 100644 ---- a/grub-core/kern/mm.c -+++ b/grub-core/kern/mm.c -@@ -128,23 +128,52 @@ grub_mm_init_region (void *addr, grub_size_t size) - if (((grub_addr_t) addr + 0x1000) > ~(grub_addr_t) size) - size = ((grub_addr_t) -0x1000) - (grub_addr_t) addr; - -+ /* Attempt to merge this region with every existing region */ - for (p = &grub_mm_base, q = *p; q; p = &(q->next), q = *p) -+ /* -+ * Is the new region immediately below an existing region? That -+ * is, is the address of the memory we're adding now (addr) + size -+ * of the memory we're adding (size) + the bytes we couldn't use -+ * at the start of the region we're considering (q->pre_size) -+ * equal to the address of q? In other words, does the memory -+ * looks like this? -+ * -+ * addr q -+ * |----size-----|-q->pre_size-|| -+ */ - if ((grub_uint8_t *) addr + size + q->pre_size == (grub_uint8_t *) q) - { -+ /* -+ * Yes, we can merge the memory starting at addr into the -+ * existing region from below. Align up addr to GRUB_MM_ALIGN -+ * so that our new region has proper alignment. -+ */ - r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN); -+ /* Copy the region data across */ - *r = *q; -+ /* Consider all the new size as pre-size */ - r->pre_size += size; -- -+ -+ /* -+ * If we have enough pre-size to create a block, create a -+ * block with it. Mark it as allocated and pass it to -+ * grub_free (), which will sort out getting it into the free -+ * list. -+ */ - if (r->pre_size >> GRUB_MM_ALIGN_LOG2) - { - h = (grub_mm_header_t) (r + 1); -+ /* block size is pre-size converted to cells */ - h->size = (r->pre_size >> GRUB_MM_ALIGN_LOG2); - h->magic = GRUB_MM_ALLOC_MAGIC; -+ /* region size grows by block size converted back to bytes */ - r->size += h->size << GRUB_MM_ALIGN_LOG2; -+ /* adjust pre_size to be accurate */ - r->pre_size &= (GRUB_MM_ALIGN - 1); - *p = r; - grub_free (h + 1); - } -+ /* Replace the old region with the new region */ - *p = r; - return; - } diff --git a/0297-mm-Document-GRUB-internal-memory-management-structur.patch b/0297-mm-Document-GRUB-internal-memory-management-structur.patch deleted file mode 100644 index c793926..0000000 --- a/0297-mm-Document-GRUB-internal-memory-management-structur.patch +++ /dev/null @@ -1,78 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Thu, 25 Nov 2021 02:22:45 +1100 -Subject: [PATCH] mm: Document GRUB internal memory management structures - -I spent more than a trivial quantity of time figuring out pre_size and -whether a memory region's size contains the header cell or not. - -Document the meanings of all the properties. Hopefully now no-one else -has to figure it out! - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit a6c5c52ccffd2674d43db25fb4baa9c528526aa0) ---- - include/grub/mm_private.h | 28 ++++++++++++++++++++++++++++ - 1 file changed, 28 insertions(+) - -diff --git a/include/grub/mm_private.h b/include/grub/mm_private.h -index c2c4cb1511..203533cc3d 100644 ---- a/include/grub/mm_private.h -+++ b/include/grub/mm_private.h -@@ -21,15 +21,27 @@ - - #include - -+/* For context, see kern/mm.c */ -+ - /* Magic words. */ - #define GRUB_MM_FREE_MAGIC 0x2d3c2808 - #define GRUB_MM_ALLOC_MAGIC 0x6db08fa4 - -+/* A header describing a block of memory - either allocated or free */ - typedef struct grub_mm_header - { -+ /* -+ * The 'next' free block in this region's circular free list. -+ * Only meaningful if the block is free. -+ */ - struct grub_mm_header *next; -+ /* The block size, not in bytes but the number of cells of -+ * GRUB_MM_ALIGN bytes. Includes the header cell. -+ */ - grub_size_t size; -+ /* either free or alloc magic, depending on the block type. */ - grub_size_t magic; -+ /* pad to cell size: see the top of kern/mm.c. */ - #if GRUB_CPU_SIZEOF_VOID_P == 4 - char padding[4]; - #elif GRUB_CPU_SIZEOF_VOID_P == 8 -@@ -48,11 +60,27 @@ typedef struct grub_mm_header - - #define GRUB_MM_ALIGN (1 << GRUB_MM_ALIGN_LOG2) - -+/* A region from which we can make allocations. */ - typedef struct grub_mm_region - { -+ /* The first free block in this region. */ - struct grub_mm_header *first; -+ -+ /* -+ * The next region in the linked list of regions. Regions are initially -+ * sorted in order of increasing size, but can grow, in which case the -+ * ordering may not be preserved. -+ */ - struct grub_mm_region *next; -+ -+ /* -+ * A grub_mm_region will always be aligned to cell size. The pre-size is -+ * the number of bytes we were given but had to skip in order to get that -+ * alignment. -+ */ - grub_size_t pre_size; -+ -+ /* How many bytes are in this region? (free and allocated) */ - grub_size_t size; - } - *grub_mm_region_t; diff --git a/0298-mm-Assert-that-we-preserve-header-vs-region-alignmen.patch b/0298-mm-Assert-that-we-preserve-header-vs-region-alignmen.patch deleted file mode 100644 index 2893784..0000000 --- a/0298-mm-Assert-that-we-preserve-header-vs-region-alignmen.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Thu, 21 Apr 2022 15:24:14 +1000 -Subject: [PATCH] mm: Assert that we preserve header vs region alignment - -grub_mm_region_init() does: - - h = (grub_mm_header_t) (r + 1); - -where h is a grub_mm_header_t and r is a grub_mm_region_t. - -Cells are supposed to be GRUB_MM_ALIGN aligned, but while grub_mm_dump -ensures this vs the region header, grub_mm_region_init() does not. - -It's better to be explicit than implicit here: rather than changing -grub_mm_region_init() to ALIGN_UP(), require that the struct is -explicitly a multiple of the header size. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -Tested-by: Patrick Steinhardt -(cherry picked from commit 1df8fe66c57087eb33bd6dc69f786ed124615aa7) ---- - include/grub/mm_private.h | 14 ++++++++++++++ - 1 file changed, 14 insertions(+) - -diff --git a/include/grub/mm_private.h b/include/grub/mm_private.h -index 203533cc3d..a688b92a83 100644 ---- a/include/grub/mm_private.h -+++ b/include/grub/mm_private.h -@@ -20,6 +20,7 @@ - #define GRUB_MM_PRIVATE_H 1 - - #include -+#include - - /* For context, see kern/mm.c */ - -@@ -89,4 +90,17 @@ typedef struct grub_mm_region - extern grub_mm_region_t EXPORT_VAR (grub_mm_base); - #endif - -+static inline void -+grub_mm_size_sanity_check (void) { -+ /* Ensure we preserve alignment when doing h = (grub_mm_header_t) (r + 1). */ -+ COMPILE_TIME_ASSERT ((sizeof (struct grub_mm_region) % -+ sizeof (struct grub_mm_header)) == 0); -+ -+ /* -+ * GRUB_MM_ALIGN is supposed to represent cell size, and a mm_header is -+ * supposed to be 1 cell. -+ */ -+ COMPILE_TIME_ASSERT (sizeof (struct grub_mm_header) == GRUB_MM_ALIGN); -+} -+ - #endif diff --git a/0299-mm-When-adding-a-region-merge-with-region-after-as-w.patch b/0299-mm-When-adding-a-region-merge-with-region-after-as-w.patch deleted file mode 100644 index 52cfeee..0000000 --- a/0299-mm-When-adding-a-region-merge-with-region-after-as-w.patch +++ /dev/null @@ -1,203 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Thu, 21 Apr 2022 15:24:15 +1000 -Subject: [PATCH] mm: When adding a region, merge with region after as well as - before - -On x86_64-efi (at least) regions seem to be added from top down. The mm -code will merge a new region with an existing region that comes -immediately before the new region. This allows larger allocations to be -satisfied that would otherwise be the case. - -On powerpc-ieee1275, however, regions are added from bottom up. So if -we add 3x 32MB regions, we can still only satisfy a 32MB allocation, -rather than the 96MB allocation we might otherwise be able to satisfy. - - * Define 'post_size' as being bytes lost to the end of an allocation - due to being given weird sizes from firmware that are not multiples - of GRUB_MM_ALIGN. - - * Allow merging of regions immediately _after_ existing regions, not - just before. As with the other approach, we create an allocated - block to represent the new space and the pass it to grub_free() to - get the metadata right. - -Signed-off-by: Daniel Axtens -Tested-by: Stefan Berger -Reviewed-by: Daniel Kiper -Tested-by: Patrick Steinhardt -(cherry picked from commit 052e6068be622ff53f1238b449c300dbd0a8abcd) ---- - grub-core/kern/mm.c | 128 +++++++++++++++++++++++++++++----------------- - include/grub/mm_private.h | 9 ++++ - 2 files changed, 91 insertions(+), 46 deletions(-) - -diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index 1cbf98c7ab..7be33e23bf 100644 ---- a/grub-core/kern/mm.c -+++ b/grub-core/kern/mm.c -@@ -130,53 +130,88 @@ grub_mm_init_region (void *addr, grub_size_t size) - - /* Attempt to merge this region with every existing region */ - for (p = &grub_mm_base, q = *p; q; p = &(q->next), q = *p) -- /* -- * Is the new region immediately below an existing region? That -- * is, is the address of the memory we're adding now (addr) + size -- * of the memory we're adding (size) + the bytes we couldn't use -- * at the start of the region we're considering (q->pre_size) -- * equal to the address of q? In other words, does the memory -- * looks like this? -- * -- * addr q -- * |----size-----|-q->pre_size-|| -- */ -- if ((grub_uint8_t *) addr + size + q->pre_size == (grub_uint8_t *) q) -- { -- /* -- * Yes, we can merge the memory starting at addr into the -- * existing region from below. Align up addr to GRUB_MM_ALIGN -- * so that our new region has proper alignment. -- */ -- r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN); -- /* Copy the region data across */ -- *r = *q; -- /* Consider all the new size as pre-size */ -- r->pre_size += size; -+ { -+ /* -+ * Is the new region immediately below an existing region? That -+ * is, is the address of the memory we're adding now (addr) + size -+ * of the memory we're adding (size) + the bytes we couldn't use -+ * at the start of the region we're considering (q->pre_size) -+ * equal to the address of q? In other words, does the memory -+ * looks like this? -+ * -+ * addr q -+ * |----size-----|-q->pre_size-|| -+ */ -+ if ((grub_uint8_t *) addr + size + q->pre_size == (grub_uint8_t *) q) -+ { -+ /* -+ * Yes, we can merge the memory starting at addr into the -+ * existing region from below. Align up addr to GRUB_MM_ALIGN -+ * so that our new region has proper alignment. -+ */ -+ r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN); -+ /* Copy the region data across */ -+ *r = *q; -+ /* Consider all the new size as pre-size */ -+ r->pre_size += size; - -- /* -- * If we have enough pre-size to create a block, create a -- * block with it. Mark it as allocated and pass it to -- * grub_free (), which will sort out getting it into the free -- * list. -- */ -- if (r->pre_size >> GRUB_MM_ALIGN_LOG2) -- { -- h = (grub_mm_header_t) (r + 1); -- /* block size is pre-size converted to cells */ -- h->size = (r->pre_size >> GRUB_MM_ALIGN_LOG2); -- h->magic = GRUB_MM_ALLOC_MAGIC; -- /* region size grows by block size converted back to bytes */ -- r->size += h->size << GRUB_MM_ALIGN_LOG2; -- /* adjust pre_size to be accurate */ -- r->pre_size &= (GRUB_MM_ALIGN - 1); -- *p = r; -- grub_free (h + 1); -- } -- /* Replace the old region with the new region */ -- *p = r; -- return; -- } -+ /* -+ * If we have enough pre-size to create a block, create a -+ * block with it. Mark it as allocated and pass it to -+ * grub_free (), which will sort out getting it into the free -+ * list. -+ */ -+ if (r->pre_size >> GRUB_MM_ALIGN_LOG2) -+ { -+ h = (grub_mm_header_t) (r + 1); -+ /* block size is pre-size converted to cells */ -+ h->size = (r->pre_size >> GRUB_MM_ALIGN_LOG2); -+ h->magic = GRUB_MM_ALLOC_MAGIC; -+ /* region size grows by block size converted back to bytes */ -+ r->size += h->size << GRUB_MM_ALIGN_LOG2; -+ /* adjust pre_size to be accurate */ -+ r->pre_size &= (GRUB_MM_ALIGN - 1); -+ *p = r; -+ grub_free (h + 1); -+ } -+ /* Replace the old region with the new region */ -+ *p = r; -+ return; -+ } -+ -+ /* -+ * Is the new region immediately above an existing region? That -+ * is: -+ * q addr -+ * ||-q->post_size-|----size-----| -+ */ -+ if ((grub_uint8_t *) q + sizeof (*q) + q->size + q->post_size == -+ (grub_uint8_t *) addr) -+ { -+ /* -+ * Yes! Follow a similar pattern to above, but simpler. -+ * Our header starts at address - post_size, which should align us -+ * to a cell boundary. -+ * -+ * Cast to (void *) first to avoid the following build error: -+ * kern/mm.c: In function ‘grub_mm_init_region’: -+ * kern/mm.c:211:15: error: cast increases required alignment of target type [-Werror=cast-align] -+ * 211 | h = (grub_mm_header_t) ((grub_uint8_t *) addr - q->post_size); -+ * | ^ -+ * It is safe to do that because proper alignment is enforced in grub_mm_size_sanity_check(). -+ */ -+ h = (grub_mm_header_t)(void *) ((grub_uint8_t *) addr - q->post_size); -+ /* our size is the allocated size plus post_size, in cells */ -+ h->size = (size + q->post_size) >> GRUB_MM_ALIGN_LOG2; -+ h->magic = GRUB_MM_ALLOC_MAGIC; -+ /* region size grows by block size converted back to bytes */ -+ q->size += h->size << GRUB_MM_ALIGN_LOG2; -+ /* adjust new post_size to be accurate */ -+ q->post_size = (q->post_size + size) & (GRUB_MM_ALIGN - 1); -+ grub_free (h + 1); -+ return; -+ } -+ } - - /* Allocate a region from the head. */ - r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN); -@@ -195,6 +230,7 @@ grub_mm_init_region (void *addr, grub_size_t size) - r->first = h; - r->pre_size = (grub_addr_t) r - (grub_addr_t) addr; - r->size = (h->size << GRUB_MM_ALIGN_LOG2); -+ r->post_size = size - r->size; - - /* Find where to insert this region. Put a smaller one before bigger ones, - to prevent fragmentation. */ -diff --git a/include/grub/mm_private.h b/include/grub/mm_private.h -index a688b92a83..96c2d816be 100644 ---- a/include/grub/mm_private.h -+++ b/include/grub/mm_private.h -@@ -81,8 +81,17 @@ typedef struct grub_mm_region - */ - grub_size_t pre_size; - -+ /* -+ * Likewise, the post-size is the number of bytes we wasted at the end -+ * of the allocation because it wasn't a multiple of GRUB_MM_ALIGN -+ */ -+ grub_size_t post_size; -+ - /* How many bytes are in this region? (free and allocated) */ - grub_size_t size; -+ -+ /* pad to a multiple of cell size */ -+ char padding[3 * GRUB_CPU_SIZEOF_VOID_P]; - } - *grub_mm_region_t; - diff --git a/0300-mm-Debug-support-for-region-operations.patch b/0300-mm-Debug-support-for-region-operations.patch deleted file mode 100644 index f434260..0000000 --- a/0300-mm-Debug-support-for-region-operations.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Thu, 21 Apr 2022 15:24:16 +1000 -Subject: [PATCH] mm: Debug support for region operations - -This is handy for debugging. Enable with "set debug=regions". - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -Tested-by: Patrick Steinhardt -(cherry picked from commit 8afa5ef45b797ba5d8147ceee85ac2c59dcc7f09) ---- - grub-core/kern/mm.c | 19 ++++++++++++++++--- - 1 file changed, 16 insertions(+), 3 deletions(-) - -diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index 7be33e23bf..38bfb01df9 100644 ---- a/grub-core/kern/mm.c -+++ b/grub-core/kern/mm.c -@@ -115,9 +115,8 @@ grub_mm_init_region (void *addr, grub_size_t size) - grub_mm_header_t h; - grub_mm_region_t r, *p, q; - --#if 0 -- grub_printf ("Using memory for heap: start=%p, end=%p\n", addr, addr + (unsigned int) size); --#endif -+ grub_dprintf ("regions", "Using memory for heap: start=%p, end=%p\n", -+ addr, (char *) addr + (unsigned int) size); - - /* Exclude last 4K to avoid overflows. */ - /* If addr + 0x1000 overflows then whole region is in excluded zone. */ -@@ -142,8 +141,14 @@ grub_mm_init_region (void *addr, grub_size_t size) - * addr q - * |----size-----|-q->pre_size-|| - */ -+ grub_dprintf ("regions", "Can we extend into region above?" -+ " %p + %" PRIxGRUB_SIZE " + %" PRIxGRUB_SIZE " ?=? %p\n", -+ (grub_uint8_t *) addr, size, q->pre_size, (grub_uint8_t *) q); - if ((grub_uint8_t *) addr + size + q->pre_size == (grub_uint8_t *) q) - { -+ grub_dprintf ("regions", "Yes: extending a region: (%p -> %p) -> (%p -> %p)\n", -+ q, (grub_uint8_t *) q + sizeof (*q) + q->size, -+ addr, (grub_uint8_t *) q + sizeof (*q) + q->size); - /* - * Yes, we can merge the memory starting at addr into the - * existing region from below. Align up addr to GRUB_MM_ALIGN -@@ -185,9 +190,15 @@ grub_mm_init_region (void *addr, grub_size_t size) - * q addr - * ||-q->post_size-|----size-----| - */ -+ grub_dprintf ("regions", "Can we extend into region below?" -+ " %p + %" PRIxGRUB_SIZE " + %" PRIxGRUB_SIZE " + %" PRIxGRUB_SIZE " ?=? %p\n", -+ (grub_uint8_t *) q, sizeof(*q), q->size, q->post_size, (grub_uint8_t *) addr); - if ((grub_uint8_t *) q + sizeof (*q) + q->size + q->post_size == - (grub_uint8_t *) addr) - { -+ grub_dprintf ("regions", "Yes: extending a region: (%p -> %p) -> (%p -> %p)\n", -+ q, (grub_uint8_t *) q + sizeof (*q) + q->size, -+ q, (grub_uint8_t *) addr + size); - /* - * Yes! Follow a similar pattern to above, but simpler. - * Our header starts at address - post_size, which should align us -@@ -213,6 +224,8 @@ grub_mm_init_region (void *addr, grub_size_t size) - } - } - -+ grub_dprintf ("regions", "No: considering a new region at %p of size %" PRIxGRUB_SIZE "\n", -+ addr, size); - /* Allocate a region from the head. */ - r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN); - diff --git a/0301-mm-Drop-unused-unloading-of-modules-on-OOM.patch b/0301-mm-Drop-unused-unloading-of-modules-on-OOM.patch deleted file mode 100644 index a18d912..0000000 --- a/0301-mm-Drop-unused-unloading-of-modules-on-OOM.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Patrick Steinhardt -Date: Thu, 21 Apr 2022 15:24:17 +1000 -Subject: [PATCH] mm: Drop unused unloading of modules on OOM - -In grub_memalign(), there's a commented section which would allow for -unloading of unneeded modules in case where there is not enough free -memory available to satisfy a request. Given that this code is never -compiled in, let's remove it together with grub_dl_unload_unneeded(). - -Signed-off-by: Patrick Steinhardt -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -Tested-by: Patrick Steinhardt -(cherry picked from commit 139fd9b134a01e0b5fe0ebefafa7f48d1ffb6d60) ---- - grub-core/kern/dl.c | 20 -------------------- - grub-core/kern/mm.c | 8 -------- - include/grub/dl.h | 1 - - 3 files changed, 29 deletions(-) - -diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c -index d5de80186f..ab9101a5ad 100644 ---- a/grub-core/kern/dl.c -+++ b/grub-core/kern/dl.c -@@ -998,23 +998,3 @@ grub_dl_unload (grub_dl_t mod) - grub_free (mod); - return 1; - } -- --/* Unload unneeded modules. */ --void --grub_dl_unload_unneeded (void) --{ -- /* Because grub_dl_remove modifies the list of modules, this -- implementation is tricky. */ -- grub_dl_t p = grub_dl_head; -- -- while (p) -- { -- if (grub_dl_unload (p)) -- { -- p = grub_dl_head; -- continue; -- } -- -- p = p->next; -- } --} -diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index 38bfb01df9..1825dc8289 100644 ---- a/grub-core/kern/mm.c -+++ b/grub-core/kern/mm.c -@@ -444,14 +444,6 @@ grub_memalign (grub_size_t align, grub_size_t size) - count++; - goto again; - --#if 0 -- case 1: -- /* Unload unneeded modules. */ -- grub_dl_unload_unneeded (); -- count++; -- goto again; --#endif -- - default: - break; - } -diff --git a/include/grub/dl.h b/include/grub/dl.h -index 45ac8e339f..6bc2560bf0 100644 ---- a/include/grub/dl.h -+++ b/include/grub/dl.h -@@ -206,7 +206,6 @@ grub_dl_t EXPORT_FUNC(grub_dl_load) (const char *name); - grub_dl_t grub_dl_load_core (void *addr, grub_size_t size); - grub_dl_t EXPORT_FUNC(grub_dl_load_core_noinit) (void *addr, grub_size_t size); - int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod); --extern void grub_dl_unload_unneeded (void); - extern int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod); - extern int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod); - extern int EXPORT_FUNC(grub_dl_ref_count) (grub_dl_t mod); diff --git a/0302-mm-Allow-dynamically-requesting-additional-memory-re.patch b/0302-mm-Allow-dynamically-requesting-additional-memory-re.patch deleted file mode 100644 index d225c10..0000000 --- a/0302-mm-Allow-dynamically-requesting-additional-memory-re.patch +++ /dev/null @@ -1,130 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Patrick Steinhardt -Date: Thu, 21 Apr 2022 15:24:18 +1000 -Subject: [PATCH] mm: Allow dynamically requesting additional memory regions - -Currently, all platforms will set up their heap on initialization of the -platform code. While this works mostly fine, it poses some limitations -on memory management on us. Most notably, allocating big chunks of -memory in the gigabyte range would require us to pre-request this many -bytes from the firmware and add it to the heap from the beginning on -some platforms like EFI. As this isn't needed for most configurations, -it is inefficient and may even negatively impact some usecases when, -e.g., chainloading. Nonetheless, allocating big chunks of memory is -required sometimes, where one example is the upcoming support for the -Argon2 key derival function in LUKS2. - -In order to avoid pre-allocating big chunks of memory, this commit -implements a runtime mechanism to add more pages to the system. When -a given allocation cannot be currently satisfied, we'll call a given -callback set up by the platform's own memory management subsystem, -asking it to add a memory area with at least "n" bytes. If this -succeeds, we retry searching for a valid memory region, which should -now succeed. - -If this fails, we try asking for "n" bytes, possibly spread across -multiple regions, in hopes that region merging means that we end up -with enough memory for things to work out. - -Signed-off-by: Patrick Steinhardt -Signed-off-by: Daniel Axtens -Tested-by: Stefan Berger -Reviewed-by: Daniel Kiper -Tested-by: Patrick Steinhardt -(cherry picked from commit 887f98f0db43e33fba4ec1f85e42fae1185700bc) ---- - grub-core/kern/mm.c | 30 ++++++++++++++++++++++++++++++ - include/grub/mm.h | 18 ++++++++++++++++++ - 2 files changed, 48 insertions(+) - -diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index 1825dc8289..f2e27f263b 100644 ---- a/grub-core/kern/mm.c -+++ b/grub-core/kern/mm.c -@@ -28,6 +28,9 @@ - - multiple regions may be used as free space. They may not be - contiguous. - -+ - if existing regions are insufficient to satisfy an allocation, a new -+ region can be requested from firmware. -+ - Regions are managed by a singly linked list, and the meta information is - stored in the beginning of each region. Space after the meta information - is used to allocate memory. -@@ -81,6 +84,7 @@ - - - grub_mm_region_t grub_mm_base; -+grub_mm_add_region_func_t grub_mm_add_region_fn; - - /* Get a header from the pointer PTR, and set *P and *R to a pointer - to the header and a pointer to its region, respectively. PTR must -@@ -444,6 +448,32 @@ grub_memalign (grub_size_t align, grub_size_t size) - count++; - goto again; - -+ case 1: -+ /* Request additional pages, contiguous */ -+ count++; -+ -+ if (grub_mm_add_region_fn != NULL && -+ grub_mm_add_region_fn (size, GRUB_MM_ADD_REGION_CONSECUTIVE) == GRUB_ERR_NONE) -+ goto again; -+ -+ /* fallthrough */ -+ -+ case 2: -+ /* Request additional pages, anything at all */ -+ count++; -+ -+ if (grub_mm_add_region_fn != NULL) -+ { -+ /* -+ * Try again even if this fails, in case it was able to partially -+ * satisfy the request -+ */ -+ grub_mm_add_region_fn (size, GRUB_MM_ADD_REGION_NONE); -+ goto again; -+ } -+ -+ /* fallthrough */ -+ - default: - break; - } -diff --git a/include/grub/mm.h b/include/grub/mm.h -index d81623d226..7c6f925ffd 100644 ---- a/include/grub/mm.h -+++ b/include/grub/mm.h -@@ -20,6 +20,7 @@ - #ifndef GRUB_MM_H - #define GRUB_MM_H 1 - -+#include - #include - #include - #include -@@ -29,6 +30,23 @@ - # define NULL ((void *) 0) - #endif - -+#define GRUB_MM_ADD_REGION_NONE 0 -+#define GRUB_MM_ADD_REGION_CONSECUTIVE (1 << 0) -+ -+/* -+ * Function used to request memory regions of `grub_size_t` bytes. The second -+ * parameter is a bitfield of `GRUB_MM_ADD_REGION` flags. -+ */ -+typedef grub_err_t (*grub_mm_add_region_func_t) (grub_size_t, unsigned int); -+ -+/* -+ * Set this function pointer to enable adding memory-regions at runtime in case -+ * a memory allocation cannot be satisfied with existing regions. -+ */ -+#ifndef GRUB_MACHINE_EMU -+extern grub_mm_add_region_func_t EXPORT_VAR(grub_mm_add_region_fn); -+#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); diff --git a/0303-kern-efi-mm-Always-request-a-fixed-number-of-pages-o.patch b/0303-kern-efi-mm-Always-request-a-fixed-number-of-pages-o.patch deleted file mode 100644 index 6fa378c..0000000 --- a/0303-kern-efi-mm-Always-request-a-fixed-number-of-pages-o.patch +++ /dev/null @@ -1,103 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Patrick Steinhardt -Date: Thu, 21 Apr 2022 15:24:19 +1000 -Subject: [PATCH] kern/efi/mm: Always request a fixed number of pages on init - -When initializing the EFI memory subsystem, we will by default request -a quarter of the available memory, bounded by a minimum/maximum value. -Given that we're about to extend the EFI memory system to dynamically -request additional pages from the firmware as required, this scaling of -requested memory based on available memory will not make a lot of sense -anymore. - -Remove this logic as a preparatory patch such that we'll instead defer -to the runtime memory allocator. Note that ideally, we'd want to change -this after dynamic requesting of pages has been implemented for the EFI -platform. But because we'll need to split up initialization of the -memory subsystem and the request of pages from the firmware, we'd have -to duplicate quite some logic at first only to remove it afterwards -again. This seems quite pointless, so we instead have patches slightly -out of order. - -Signed-off-by: Patrick Steinhardt -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -Tested-by: Patrick Steinhardt -(cherry picked from commit 938c3760b8c0fca759140be48307179b50107ff6) ---- - grub-core/kern/efi/mm.c | 35 +++-------------------------------- - 1 file changed, 3 insertions(+), 32 deletions(-) - -diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index e460b072e6..782a1365a1 100644 ---- a/grub-core/kern/efi/mm.c -+++ b/grub-core/kern/efi/mm.c -@@ -38,9 +38,8 @@ - a multiplier of 4KB. */ - #define MEMORY_MAP_SIZE 0x3000 - --/* The minimum and maximum heap size for GRUB itself. */ --#define MIN_HEAP_SIZE 0x100000 --#define MAX_HEAP_SIZE (1600 * 0x100000) -+/* The default heap size for GRUB itself in bytes. */ -+#define DEFAULT_HEAP_SIZE 0x100000 - - static void *finish_mmap_buf = 0; - static grub_efi_uintn_t finish_mmap_size = 0; -@@ -514,23 +513,6 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, - return filtered_desc; - } - --/* Return the total number of pages. */ --static grub_efi_uint64_t --get_total_pages (grub_efi_memory_descriptor_t *memory_map, -- grub_efi_uintn_t desc_size, -- grub_efi_memory_descriptor_t *memory_map_end) --{ -- grub_efi_memory_descriptor_t *desc; -- grub_efi_uint64_t total = 0; -- -- for (desc = memory_map; -- desc < memory_map_end; -- desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size)) -- total += desc->num_pages; -- -- return total; --} -- - /* Add memory regions. */ - static void - add_memory_regions (grub_efi_memory_descriptor_t *memory_map, -@@ -694,8 +676,6 @@ grub_efi_mm_init (void) - grub_efi_memory_descriptor_t *filtered_memory_map_end; - grub_efi_uintn_t map_size; - grub_efi_uintn_t desc_size; -- grub_efi_uint64_t total_pages; -- grub_efi_uint64_t required_pages; - int mm_status; - - grub_nx_init (); -@@ -737,22 +717,13 @@ grub_efi_mm_init (void) - filtered_memory_map_end = filter_memory_map (memory_map, filtered_memory_map, - desc_size, memory_map_end); - -- /* By default, request a quarter of the available memory. */ -- total_pages = get_total_pages (filtered_memory_map, desc_size, -- filtered_memory_map_end); -- required_pages = (total_pages >> 2); -- if (required_pages < BYTES_TO_PAGES (MIN_HEAP_SIZE)) -- required_pages = BYTES_TO_PAGES (MIN_HEAP_SIZE); -- else if (required_pages > BYTES_TO_PAGES (MAX_HEAP_SIZE)) -- required_pages = BYTES_TO_PAGES (MAX_HEAP_SIZE); -- - /* Sort the filtered descriptors, so that GRUB can allocate pages - from smaller regions. */ - sort_memory_map (filtered_memory_map, desc_size, filtered_memory_map_end); - - /* Allocate memory regions for GRUB's memory management. */ - add_memory_regions (filtered_memory_map, desc_size, -- filtered_memory_map_end, required_pages); -+ filtered_memory_map_end, BYTES_TO_PAGES (DEFAULT_HEAP_SIZE)); - - #if 0 - /* For debug. */ diff --git a/0304-kern-efi-mm-Extract-function-to-add-memory-regions.patch b/0304-kern-efi-mm-Extract-function-to-add-memory-regions.patch deleted file mode 100644 index 28cf2e7..0000000 --- a/0304-kern-efi-mm-Extract-function-to-add-memory-regions.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Patrick Steinhardt -Date: Thu, 21 Apr 2022 15:24:20 +1000 -Subject: [PATCH] kern/efi/mm: Extract function to add memory regions - -In preparation of support for runtime-allocating additional memory -region, this patch extracts the function to retrieve the EFI memory -map and add a subset of it to GRUB's own memory regions. - -Signed-off-by: Patrick Steinhardt -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -Tested-by: Patrick Steinhardt -(cherry picked from commit 96a7ea29e3cb61b6c2302e260e8e6a6117e17fa3) -[rharwood: backport around our nx] ---- - grub-core/kern/efi/mm.c | 21 +++++++++++++++------ - 1 file changed, 15 insertions(+), 6 deletions(-) - -diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index 782a1365a1..a1d3b51fe6 100644 ---- a/grub-core/kern/efi/mm.c -+++ b/grub-core/kern/efi/mm.c -@@ -667,8 +667,8 @@ grub_nx_init (void) - } - } - --void --grub_efi_mm_init (void) -+static grub_err_t -+grub_efi_mm_add_regions (grub_size_t required_bytes) - { - grub_efi_memory_descriptor_t *memory_map; - grub_efi_memory_descriptor_t *memory_map_end; -@@ -683,7 +683,7 @@ grub_efi_mm_init (void) - /* Prepare a memory region to store two memory maps. */ - memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); - if (! memory_map) -- grub_fatal ("cannot allocate memory"); -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory for memory map"); - - /* Obtain descriptors for available memory. */ - map_size = MEMORY_MAP_SIZE; -@@ -701,14 +701,14 @@ grub_efi_mm_init (void) - - memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (map_size)); - if (! memory_map) -- grub_fatal ("cannot allocate memory"); -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory for new memory map"); - - mm_status = grub_efi_get_memory_map (&map_size, memory_map, 0, - &desc_size, 0); - } - - if (mm_status < 0) -- grub_fatal ("cannot get memory map"); -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, "error fetching memory map from EFI"); - - memory_map_end = NEXT_MEMORY_DESCRIPTOR (memory_map, map_size); - -@@ -723,7 +723,7 @@ grub_efi_mm_init (void) - - /* Allocate memory regions for GRUB's memory management. */ - add_memory_regions (filtered_memory_map, desc_size, -- filtered_memory_map_end, BYTES_TO_PAGES (DEFAULT_HEAP_SIZE)); -+ filtered_memory_map_end, BYTES_TO_PAGES (required_bytes)); - - #if 0 - /* For debug. */ -@@ -741,6 +741,15 @@ grub_efi_mm_init (void) - /* Release the memory maps. */ - grub_efi_free_pages ((grub_addr_t) memory_map, - 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); -+ -+ return GRUB_ERR_NONE; -+} -+ -+void -+grub_efi_mm_init (void) -+{ -+ if (grub_efi_mm_add_regions (DEFAULT_HEAP_SIZE) != GRUB_ERR_NONE) -+ grub_fatal ("%s", grub_errmsg); - } - - #if defined (__aarch64__) || defined (__arm__) || defined (__riscv) diff --git a/0305-kern-efi-mm-Pass-up-errors-from-add_memory_regions.patch b/0305-kern-efi-mm-Pass-up-errors-from-add_memory_regions.patch deleted file mode 100644 index b4b7891..0000000 --- a/0305-kern-efi-mm-Pass-up-errors-from-add_memory_regions.patch +++ /dev/null @@ -1,87 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Patrick Steinhardt -Date: Thu, 21 Apr 2022 15:24:21 +1000 -Subject: [PATCH] kern/efi/mm: Pass up errors from add_memory_regions() - -The function add_memory_regions() is currently only called on system -initialization to allocate a fixed amount of pages. As such, it didn't -need to return any errors: in case it failed, we cannot proceed anyway. -This will change with the upcoming support for requesting more memory -from the firmware at runtime, where it doesn't make sense anymore to -fail hard. - -Refactor the function to return an error to prepare for this. Note that -this does not change the behaviour when initializing the memory system -because grub_efi_mm_init() knows to call grub_fatal() in case -grub_efi_mm_add_regions() returns an error. - -Signed-off-by: Patrick Steinhardt -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -Tested-by: Patrick Steinhardt -(cherry picked from commit 15a015698921240adc1ac266a3b5bc5fcbd81521) ---- - grub-core/kern/efi/mm.c | 22 +++++++++++++++------- - 1 file changed, 15 insertions(+), 7 deletions(-) - -diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index a1d3b51fe6..e0ebc65dba 100644 ---- a/grub-core/kern/efi/mm.c -+++ b/grub-core/kern/efi/mm.c -@@ -514,7 +514,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map, - } - - /* Add memory regions. */ --static void -+static grub_err_t - add_memory_regions (grub_efi_memory_descriptor_t *memory_map, - grub_efi_uintn_t desc_size, - grub_efi_memory_descriptor_t *memory_map_end, -@@ -542,9 +542,9 @@ add_memory_regions (grub_efi_memory_descriptor_t *memory_map, - 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), -- (unsigned) pages); -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ "Memory starting at %p (%u pages) marked as free, but EFI would not allocate", -+ (void *) ((grub_addr_t) start), (unsigned) pages); - - grub_mm_init_region (addr, PAGES_TO_BYTES (pages)); - -@@ -554,7 +554,11 @@ add_memory_regions (grub_efi_memory_descriptor_t *memory_map, - } - - if (required_pages > 0) -- grub_fatal ("too little memory"); -+ return grub_error (GRUB_ERR_OUT_OF_MEMORY, -+ "could not allocate all requested memory: %" PRIuGRUB_UINT64_T " pages still required after iterating EFI memory map", -+ required_pages); -+ -+ return GRUB_ERR_NONE; - } - - void -@@ -676,6 +680,7 @@ grub_efi_mm_add_regions (grub_size_t required_bytes) - grub_efi_memory_descriptor_t *filtered_memory_map_end; - grub_efi_uintn_t map_size; - grub_efi_uintn_t desc_size; -+ grub_err_t err; - int mm_status; - - grub_nx_init (); -@@ -722,8 +727,11 @@ grub_efi_mm_add_regions (grub_size_t required_bytes) - sort_memory_map (filtered_memory_map, desc_size, filtered_memory_map_end); - - /* Allocate memory regions for GRUB's memory management. */ -- add_memory_regions (filtered_memory_map, desc_size, -- filtered_memory_map_end, BYTES_TO_PAGES (required_bytes)); -+ err = add_memory_regions (filtered_memory_map, desc_size, -+ filtered_memory_map_end, -+ BYTES_TO_PAGES (required_bytes)); -+ if (err != GRUB_ERR_NONE) -+ return err; - - #if 0 - /* For debug. */ diff --git a/0306-kern-efi-mm-Implement-runtime-addition-of-pages.patch b/0306-kern-efi-mm-Implement-runtime-addition-of-pages.patch deleted file mode 100644 index 1f52581..0000000 --- a/0306-kern-efi-mm-Implement-runtime-addition-of-pages.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Patrick Steinhardt -Date: Thu, 21 Apr 2022 15:24:22 +1000 -Subject: [PATCH] kern/efi/mm: Implement runtime addition of pages - -Adjust the interface of grub_efi_mm_add_regions() to take a set of -GRUB_MM_ADD_REGION_* flags, which most notably is currently only the -GRUB_MM_ADD_REGION_CONSECUTIVE flag. This allows us to set the function -up as callback for the memory subsystem and have it call out to us in -case there's not enough pages available in the current heap. - -Signed-off-by: Patrick Steinhardt -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -Tested-by: Patrick Steinhardt -(cherry picked from commit 1df2934822df4c1170dde069d97cfbf7a9572bba) ---- - grub-core/kern/efi/mm.c | 15 +++++++++++---- - 1 file changed, 11 insertions(+), 4 deletions(-) - -diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index e0ebc65dba..016ba6cf2f 100644 ---- a/grub-core/kern/efi/mm.c -+++ b/grub-core/kern/efi/mm.c -@@ -518,7 +518,8 @@ static grub_err_t - add_memory_regions (grub_efi_memory_descriptor_t *memory_map, - grub_efi_uintn_t desc_size, - grub_efi_memory_descriptor_t *memory_map_end, -- grub_efi_uint64_t required_pages) -+ grub_efi_uint64_t required_pages, -+ unsigned int flags) - { - grub_efi_memory_descriptor_t *desc; - -@@ -532,6 +533,10 @@ add_memory_regions (grub_efi_memory_descriptor_t *memory_map, - - start = desc->physical_start; - pages = desc->num_pages; -+ -+ if (pages < required_pages && (flags & GRUB_MM_ADD_REGION_CONSECUTIVE)) -+ continue; -+ - if (pages > required_pages) - { - start += PAGES_TO_BYTES (pages - required_pages); -@@ -672,7 +677,7 @@ grub_nx_init (void) - } - - static grub_err_t --grub_efi_mm_add_regions (grub_size_t required_bytes) -+grub_efi_mm_add_regions (grub_size_t required_bytes, unsigned int flags) - { - grub_efi_memory_descriptor_t *memory_map; - grub_efi_memory_descriptor_t *memory_map_end; -@@ -729,7 +734,8 @@ grub_efi_mm_add_regions (grub_size_t required_bytes) - /* Allocate memory regions for GRUB's memory management. */ - err = add_memory_regions (filtered_memory_map, desc_size, - filtered_memory_map_end, -- BYTES_TO_PAGES (required_bytes)); -+ BYTES_TO_PAGES (required_bytes), -+ flags); - if (err != GRUB_ERR_NONE) - return err; - -@@ -756,8 +762,9 @@ grub_efi_mm_add_regions (grub_size_t required_bytes) - void - grub_efi_mm_init (void) - { -- if (grub_efi_mm_add_regions (DEFAULT_HEAP_SIZE) != GRUB_ERR_NONE) -+ if (grub_efi_mm_add_regions (DEFAULT_HEAP_SIZE, GRUB_MM_ADD_REGION_NONE) != GRUB_ERR_NONE) - grub_fatal ("%s", grub_errmsg); -+ grub_mm_add_region_fn = grub_efi_mm_add_regions; - } - - #if defined (__aarch64__) || defined (__arm__) || defined (__riscv) diff --git a/0307-efi-Increase-default-memory-allocation-to-32-MiB.patch b/0307-efi-Increase-default-memory-allocation-to-32-MiB.patch deleted file mode 100644 index b70c3cc..0000000 --- a/0307-efi-Increase-default-memory-allocation-to-32-MiB.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Tue, 20 Sep 2022 00:30:30 +1000 -Subject: [PATCH] efi: Increase default memory allocation to 32 MiB - -We have multiple reports of things being slower with a 1 MiB initial static -allocation, and a report (more difficult to nail down) of a boot failure -as a result of the smaller initial allocation. - -Make the initial memory allocation 32 MiB. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 75e38e86e7d9202f050b093f20500d9ad4c6dad9) ---- - grub-core/kern/efi/mm.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c -index 016ba6cf2f..b27e966e1f 100644 ---- a/grub-core/kern/efi/mm.c -+++ b/grub-core/kern/efi/mm.c -@@ -39,7 +39,7 @@ - #define MEMORY_MAP_SIZE 0x3000 - - /* The default heap size for GRUB itself in bytes. */ --#define DEFAULT_HEAP_SIZE 0x100000 -+#define DEFAULT_HEAP_SIZE 0x2000000 - - static void *finish_mmap_buf = 0; - static grub_efi_uintn_t finish_mmap_size = 0; diff --git a/0308-mm-Try-invalidate-disk-caches-last-when-out-of-memor.patch b/0308-mm-Try-invalidate-disk-caches-last-when-out-of-memor.patch deleted file mode 100644 index c919891..0000000 --- a/0308-mm-Try-invalidate-disk-caches-last-when-out-of-memor.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Sat, 15 Oct 2022 22:15:11 +0800 -Subject: [PATCH] mm: Try invalidate disk caches last when out of memory - -Every heap grow will cause all disk caches invalidated which decreases -performance severely. This patch moves disk cache invalidation code to -the last of memory squeezing measures. So, disk caches are released only -when there are no other ways to get free memory. - -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -Reviewed-by: Patrick Steinhardt -(cherry picked from commit 17975d10a80e2457e5237f87fa58a7943031983e) ---- - grub-core/kern/mm.c | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index f2e27f263b..da1ac9427c 100644 ---- a/grub-core/kern/mm.c -+++ b/grub-core/kern/mm.c -@@ -443,12 +443,6 @@ grub_memalign (grub_size_t align, grub_size_t size) - switch (count) - { - case 0: -- /* Invalidate disk caches. */ -- grub_disk_cache_invalidate_all (); -- count++; -- goto again; -- -- case 1: - /* Request additional pages, contiguous */ - count++; - -@@ -458,7 +452,7 @@ grub_memalign (grub_size_t align, grub_size_t size) - - /* fallthrough */ - -- case 2: -+ case 1: - /* Request additional pages, anything at all */ - count++; - -@@ -474,6 +468,12 @@ grub_memalign (grub_size_t align, grub_size_t size) - - /* fallthrough */ - -+ case 2: -+ /* Invalidate disk caches. */ -+ grub_disk_cache_invalidate_all (); -+ count++; -+ goto again; -+ - default: - break; - } diff --git a/0311-loader-Add-support-for-grub-emu-to-kexec-Linux-menu-.patch b/0311-loader-Add-support-for-grub-emu-to-kexec-Linux-menu-.patch deleted file mode 100644 index 65834d8..0000000 --- a/0311-loader-Add-support-for-grub-emu-to-kexec-Linux-menu-.patch +++ /dev/null @@ -1,431 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Raymund Will -Date: Mon, 24 Oct 2022 14:33:50 -0400 -Subject: [PATCH] loader: Add support for grub-emu to kexec Linux menu entries - -The GRUB emulator is used as a debugging utility but it could also be -used as a user-space bootloader if there is support to boot an operating -system. - -The Linux kernel is already able to (re)boot another kernel via the -kexec boot mechanism. So the grub-emu tool could rely on this feature -and have linux and initrd commands that are used to pass a kernel, -initramfs image and command line parameters to kexec for booting -a selected menu entry. - -By default the systemctl kexec option is used so systemd can shutdown -all of the running services before doing a reboot using kexec. But if -this is not present, it can fall back to executing the kexec user-space -tool directly. The ability to force a kexec-reboot when systemctl kexec -fails must only be used in controlled environments to avoid possible -filesystem corruption and data loss. - -Signed-off-by: Raymund Will -Signed-off-by: John Jolly -Signed-off-by: Javier Martinez Canillas -Signed-off-by: Robbie Harwood -Reviewed-by: Daniel Kiper -(cherry picked from commit e364307f6acc2f631b4c1fefda0791b9ce1f205f) -[rharwood: conflicts around makefile and grub_exit return code] ---- - grub-core/Makefile.core.def | 3 - - grub-core/kern/emu/main.c | 4 + - grub-core/kern/emu/misc.c | 18 ++++- - grub-core/loader/emu/linux.c | 178 +++++++++++++++++++++++++++++++++++++++++++ - include/grub/emu/exec.h | 4 +- - include/grub/emu/hostfile.h | 3 +- - include/grub/emu/misc.h | 3 + - docs/grub.texi | 30 ++++++-- - grub-core/Makefile.am | 1 + - 9 files changed, 230 insertions(+), 14 deletions(-) - create mode 100644 grub-core/loader/emu/linux.c - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index 741a033978..f21da23213 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -1864,11 +1864,8 @@ module = { - riscv32 = loader/riscv/linux.c; - riscv64 = loader/riscv/linux.c; - emu = loader/emu/linux.c; -- - common = loader/linux.c; - common = lib/cmdline.c; -- enable = noemu; -- - efi = loader/efi/linux.c; - }; - -diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c -index 12277c34d2..68e2b283bb 100644 ---- a/grub-core/kern/emu/main.c -+++ b/grub-core/kern/emu/main.c -@@ -107,6 +107,7 @@ static struct argp_option options[] = { - N_("use GRUB files in the directory DIR [default=%s]"), 0}, - {"verbose", 'v', 0, 0, N_("print verbose messages."), 0}, - {"hold", 'H', N_("SECS"), OPTION_ARG_OPTIONAL, N_("wait until a debugger will attach"), 0}, -+ {"kexec", 'X', 0, 0, N_("use kexec to boot Linux kernels via systemctl (pass twice to enable dangerous fallback to non-systemctl)."), 0}, - { 0, 0, 0, 0, 0, 0 } - }; - -@@ -164,6 +165,9 @@ argp_parser (int key, char *arg, struct argp_state *state) - case 'v': - verbosity++; - break; -+ case 'X': -+ grub_util_set_kexecute (); -+ break; - - case ARGP_KEY_ARG: - { -diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c -index d278c2921f..02d27c3440 100644 ---- a/grub-core/kern/emu/misc.c -+++ b/grub-core/kern/emu/misc.c -@@ -39,6 +39,7 @@ - #include - - int verbosity; -+int kexecute; - - void - grub_util_warn (const char *fmt, ...) -@@ -82,7 +83,7 @@ grub_util_error (const char *fmt, ...) - vfprintf (stderr, fmt, ap); - va_end (ap); - fprintf (stderr, ".\n"); -- exit (1); -+ grub_exit (1); - } - - void * -@@ -154,6 +155,9 @@ void - __attribute__ ((noreturn)) - grub_exit (int rc) - { -+#if defined (GRUB_KERNEL) -+ grub_reboot (); -+#endif - exit (rc < 0 ? 1 : rc); - } - #endif -@@ -215,3 +219,15 @@ grub_util_load_image (const char *path, char *buf) - - fclose (fp); - } -+ -+void -+grub_util_set_kexecute (void) -+{ -+ kexecute++; -+} -+ -+int -+grub_util_get_kexecute (void) -+{ -+ return kexecute; -+} -diff --git a/grub-core/loader/emu/linux.c b/grub-core/loader/emu/linux.c -new file mode 100644 -index 0000000000..0cf378a376 ---- /dev/null -+++ b/grub-core/loader/emu/linux.c -@@ -0,0 +1,178 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2022 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+"); -+ -+static grub_dl_t my_mod; -+ -+static char *kernel_path; -+static char *initrd_path; -+static char *boot_cmdline; -+ -+static grub_err_t -+grub_linux_boot (void) -+{ -+ grub_err_t rc = GRUB_ERR_NONE; -+ char *initrd_param; -+ const char *kexec[] = {"kexec", "-la", kernel_path, boot_cmdline, NULL, NULL}; -+ const char *systemctl[] = {"systemctl", "kexec", NULL}; -+ int kexecute = grub_util_get_kexecute (); -+ -+ if (initrd_path) -+ { -+ initrd_param = grub_xasprintf ("--initrd=%s", initrd_path); -+ kexec[3] = initrd_param; -+ kexec[4] = boot_cmdline; -+ } -+ else -+ initrd_param = grub_xasprintf ("%s", ""); -+ -+ grub_dprintf ("linux", "%serforming 'kexec -la %s %s %s'\n", -+ (kexecute) ? "P" : "Not p", -+ kernel_path, initrd_param, boot_cmdline); -+ -+ if (kexecute) -+ rc = grub_util_exec (kexec); -+ -+ grub_free (initrd_param); -+ -+ if (rc != GRUB_ERR_NONE) -+ { -+ grub_error (rc, N_("error trying to perform kexec load operation")); -+ grub_sleep (3); -+ return rc; -+ } -+ -+ if (kexecute < 1) -+ grub_fatal (N_("use '"PACKAGE"-emu --kexec' to force a system restart")); -+ -+ grub_dprintf ("linux", "Performing 'systemctl kexec' (%s) ", -+ (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': %d"), rc); -+ -+ /* -+ * WARNING: forcible reset should only be used in read-only environments. -+ * grub-emu cannot check for these - users beware. -+ */ -+ grub_dprintf ("linux", "Performing 'kexec -ex'"); -+ kexec[1] = "-ex"; -+ kexec[2] = NULL; -+ rc = grub_util_exec (kexec); -+ if (rc != GRUB_ERR_NONE) -+ grub_fatal (N_("error trying to directly perform 'kexec -ex': %d"), rc); -+ -+ return rc; -+} -+ -+static grub_err_t -+grub_linux_unload (void) -+{ -+ /* Unloading: we're no longer in use. */ -+ grub_dl_unref (my_mod); -+ grub_free (boot_cmdline); -+ boot_cmdline = NULL; -+ return GRUB_ERR_NONE; -+} -+ -+static grub_err_t -+grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), int argc, -+ char *argv[]) -+{ -+ int i; -+ char *tempstr; -+ -+ /* Mark ourselves as in-use. */ -+ grub_dl_ref (my_mod); -+ -+ if (argc == 0) -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -+ -+ if (!grub_util_is_regular (argv[0])) -+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, -+ N_("cannot find kernel file %s"), argv[0]); -+ -+ grub_free (kernel_path); -+ kernel_path = grub_xasprintf ("%s", argv[0]); -+ -+ grub_free (boot_cmdline); -+ boot_cmdline = NULL; -+ -+ if (argc > 1) -+ { -+ boot_cmdline = grub_xasprintf ("--command-line=%s", argv[1]); -+ for (i = 2; i < argc; i++) -+ { -+ tempstr = grub_xasprintf ("%s %s", boot_cmdline, argv[i]); -+ grub_free (boot_cmdline); -+ boot_cmdline = tempstr; -+ } -+ } -+ -+ grub_loader_set (grub_linux_boot, grub_linux_unload, 0); -+ -+ return GRUB_ERR_NONE; -+} -+ -+static grub_err_t -+grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, -+ char *argv[]) -+{ -+ if (argc == 0) -+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); -+ -+ if (!grub_util_is_regular (argv[0])) -+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, -+ N_("Cannot find initrd file %s"), argv[0]); -+ -+ grub_free (initrd_path); -+ initrd_path = grub_xasprintf ("%s", argv[0]); -+ -+ /* We are done - mark ourselves as on longer in use. */ -+ grub_dl_unref (my_mod); -+ -+ return GRUB_ERR_NONE; -+} -+ -+static grub_command_t cmd_linux, cmd_initrd; -+ -+GRUB_MOD_INIT (linux) -+{ -+ cmd_linux = grub_register_command ("linux", grub_cmd_linux, 0, -+ N_("Load Linux.")); -+ cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, 0, -+ N_("Load initrd.")); -+ my_mod = mod; -+} -+ -+GRUB_MOD_FINI (linux) -+{ -+ grub_unregister_command (cmd_linux); -+ grub_unregister_command (cmd_initrd); -+} -diff --git a/include/grub/emu/exec.h b/include/grub/emu/exec.h -index d1073ef86a..1b61b4a2e5 100644 ---- a/include/grub/emu/exec.h -+++ b/include/grub/emu/exec.h -@@ -23,6 +23,8 @@ - #include - - #include -+#include -+ - pid_t - grub_util_exec_pipe (const char *const *argv, int *fd); - pid_t -@@ -32,7 +34,7 @@ int - grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file, - const char *stdout_file, const char *stderr_file); - int --grub_util_exec (const char *const *argv); -+EXPORT_FUNC(grub_util_exec) (const char *const *argv); - int - 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 cfb1e2b566..a61568e36e 100644 ---- a/include/grub/emu/hostfile.h -+++ b/include/grub/emu/hostfile.h -@@ -22,6 +22,7 @@ - #include - #include - #include -+#include - #include - - int -@@ -29,7 +30,7 @@ grub_util_is_directory (const char *path); - int - grub_util_is_special_file (const char *path); - int --grub_util_is_regular (const char *path); -+EXPORT_FUNC(grub_util_is_regular) (const char *path); - - char * - grub_util_path_concat (size_t n, ...); -diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h -index ff9c48a649..01056954b9 100644 ---- a/include/grub/emu/misc.h -+++ b/include/grub/emu/misc.h -@@ -57,6 +57,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; -+ - grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void); - - #ifdef HAVE_DEVICE_MAPPER -diff --git a/docs/grub.texi b/docs/grub.texi -index a4da9c2a1b..1750b72ee9 100644 ---- a/docs/grub.texi -+++ b/docs/grub.texi -@@ -923,17 +923,17 @@ magic. - @node General boot methods - @section How to boot operating systems - --GRUB has two distinct boot methods. One of the two is to load an --operating system directly, and the other is to chain-load another boot --loader which then will load an operating system actually. Generally --speaking, the former is more desirable, because you don't need to --install or maintain other boot loaders and GRUB is flexible enough to --load an operating system from an arbitrary disk/partition. However, --the latter is sometimes required, since GRUB doesn't support all the --existing operating systems natively. -+GRUB has three distinct boot methods: loading an operating system -+directly, using kexec from userspace, and chainloading another -+bootloader. Generally speaking, the first two are more desirable -+because you don't need to install or maintain other boot loaders and -+GRUB is flexible enough to load an operating system from an arbitrary -+disk/partition. However, chainloading is sometimes required, as GRUB -+doesn't support all existing operating systems natively. - - @menu - * Loading an operating system directly:: -+* Kexec:: - * Chain-loading:: - @end menu - -@@ -959,6 +959,20 @@ use more complicated instructions. @xref{DOS/Windows}, for more - information. - - -+@node Kexec -+@subsection Kexec with grub2-emu -+ -+GRUB can be run in userspace by invoking the grub2-emu tool. It will -+read all configuration scripts as if booting directly (see @xref{Loading -+an operating system directly}). With the @code{--kexec} flag, and -+kexec(8) support from the operating system, the @command{linux} command -+will directly boot the target image. For systems that lack working -+systemctl(1) support for kexec, passing the @code{--kexec} flag twice -+will fallback to invoking kexec(8) directly; note however that this -+fallback may be unsafe outside read-only environments, as it does not -+invoke shutdown machinery. -+ -+ - @node Chain-loading - @subsection Chain-loading an OS - -diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am -index c2e8a82bce..dd49939aaa 100644 ---- a/grub-core/Makefile.am -+++ b/grub-core/Makefile.am -@@ -309,6 +309,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/0312-powerpc-Drop-Open-Hack-Ware-remove-GRUB_IEEE1275_FLA.patch b/0312-powerpc-Drop-Open-Hack-Ware-remove-GRUB_IEEE1275_FLA.patch deleted file mode 100644 index 735075a..0000000 --- a/0312-powerpc-Drop-Open-Hack-Ware-remove-GRUB_IEEE1275_FLA.patch +++ /dev/null @@ -1,111 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Mon, 6 Sep 2021 15:46:12 +1000 -Subject: [PATCH] powerpc: Drop Open Hack'Ware - remove - GRUB_IEEE1275_FLAG_FORCE_CLAIM - -Open Hack'Ware was the only user. It added a lot of complexity. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 333e63b356f1ce833cda1937ed8351618cbdf9d3) ---- - grub-core/kern/ieee1275/init.c | 6 +----- - grub-core/lib/ieee1275/relocator.c | 4 ---- - grub-core/loader/powerpc/ieee1275/linux.c | 14 -------------- - include/grub/ieee1275/ieee1275.h | 11 ----------- - 4 files changed, 1 insertion(+), 34 deletions(-) - -diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 0dcd114ce5..6581c2c996 100644 ---- a/grub-core/kern/ieee1275/init.c -+++ b/grub-core/kern/ieee1275/init.c -@@ -207,11 +207,7 @@ grub_claim_heap (void) - { - unsigned long total = 0; - -- if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_FORCE_CLAIM)) -- heap_init (GRUB_IEEE1275_STATIC_HEAP_START, GRUB_IEEE1275_STATIC_HEAP_LEN, -- 1, &total); -- else -- grub_machine_mmap_iterate (heap_init, &total); -+ grub_machine_mmap_iterate (heap_init, &total); - } - #endif - -diff --git a/grub-core/lib/ieee1275/relocator.c b/grub-core/lib/ieee1275/relocator.c -index c6dd8facb0..d1bb45c75e 100644 ---- a/grub-core/lib/ieee1275/relocator.c -+++ b/grub-core/lib/ieee1275/relocator.c -@@ -38,8 +38,6 @@ grub_relocator_firmware_get_max_events (void) - { - int counter = 0; - -- if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_FORCE_CLAIM)) -- return 0; - grub_machine_mmap_iterate (count, &counter); - return 2 * counter; - } -@@ -92,8 +90,6 @@ grub_relocator_firmware_fill_events (struct grub_relocator_mmap_event *events) - .counter = 0 - }; - -- if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_FORCE_CLAIM)) -- return 0; - grub_machine_mmap_iterate (grub_relocator_firmware_fill_events_iter, &ctx); - return ctx.counter; - } -diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c -index 818b2a86d1..6fdd863130 100644 ---- a/grub-core/loader/powerpc/ieee1275/linux.c -+++ b/grub-core/loader/powerpc/ieee1275/linux.c -@@ -111,20 +111,6 @@ grub_linux_claimmap_iterate (grub_addr_t target, grub_size_t size, - .found_addr = (grub_addr_t) -1 - }; - -- if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_FORCE_CLAIM)) -- { -- grub_uint64_t addr = target; -- if (addr < GRUB_IEEE1275_STATIC_HEAP_START -- + GRUB_IEEE1275_STATIC_HEAP_LEN) -- addr = GRUB_IEEE1275_STATIC_HEAP_START -- + GRUB_IEEE1275_STATIC_HEAP_LEN; -- addr = ALIGN_UP (addr, align); -- if (grub_claimmap (addr, size) == GRUB_ERR_NONE) -- return addr; -- return (grub_addr_t) -1; -- } -- -- - grub_machine_mmap_iterate (alloc_mem, &ctx); - - return ctx.found_addr; -diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h -index b5a1d49bbc..6a1d3e5d70 100644 ---- a/include/grub/ieee1275/ieee1275.h -+++ b/include/grub/ieee1275/ieee1275.h -@@ -85,14 +85,6 @@ extern grub_ieee1275_ihandle_t EXPORT_VAR(grub_ieee1275_mmu); - - extern int (* EXPORT_VAR(grub_ieee1275_entry_fn)) (void *) GRUB_IEEE1275_ENTRY_FN_ATTRIBUTE; - --/* Static heap, used only if FORCE_CLAIM is set, -- happens on Open Hack'Ware. Should be in platform-specific -- header but is used only on PPC anyway. --*/ --#define GRUB_IEEE1275_STATIC_HEAP_START 0x1000000 --#define GRUB_IEEE1275_STATIC_HEAP_LEN 0x1000000 -- -- - enum grub_ieee1275_flag - { - /* Old World Macintosh firmware fails seek when "dev:0" is opened. */ -@@ -119,9 +111,6 @@ enum grub_ieee1275_flag - /* Open Hack'Ware stops when grub_ieee1275_interpret is used. */ - GRUB_IEEE1275_FLAG_CANNOT_INTERPRET, - -- /* Open Hack'Ware has no memory map, just claim what we need. */ -- GRUB_IEEE1275_FLAG_FORCE_CLAIM, -- - /* Open Hack'Ware don't support the ANSI sequence. */ - GRUB_IEEE1275_FLAG_NO_ANSI, - diff --git a/0313-ieee1275-request-memory-with-ibm-client-architecture.patch b/0313-ieee1275-request-memory-with-ibm-client-architecture.patch deleted file mode 100644 index 4e95630..0000000 --- a/0313-ieee1275-request-memory-with-ibm-client-architecture.patch +++ /dev/null @@ -1,308 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Mon, 6 Feb 2023 10:03:20 -0500 -Subject: [PATCH] ieee1275: request memory with ibm, - client-architecture-support - -On PowerVM, the first time we boot a Linux partition, we may only get -256MB of real memory area, even if the partition has more memory. - -This isn't enough to reliably verify a kernel. Fortunately, the Power -Architecture Platform Reference (PAPR) defines a method we can call to ask -for more memory: the broad and powerful ibm,client-architecture-support -(CAS) method. - -CAS can do an enormous amount of things on a PAPR platform: as well as -asking for memory, you can set the supported processor level, the interrupt -controller, hash vs radix mmu, and so on. - -If: - - - we are running under what we think is PowerVM (compatible property of / - begins with "IBM"), and - - - the full amount of RMA is less than 512MB (as determined by the reg - property of /memory) - -then call CAS as follows: (refer to the Linux on Power Architecture -Reference, LoPAR, which is public, at B.5.2.3): - - - Use the "any" PVR value and supply 2 option vectors. - - - Set option vector 1 (PowerPC Server Processor Architecture Level) - to "ignore". - - - Set option vector 2 with default or Linux-like options, including a - min-rma-size of 512MB. - - - Set option vector 3 to request Floating Point, VMX and Decimal Floating - point, but don't abort the boot if we can't get them. - - - Set option vector 4 to request a minimum VP percentage to 1%, which is - what Linux requests, and is below the default of 10%. Without this, - some systems with very large or very small configurations fail to boot. - -This will cause a CAS reboot and the partition will restart with 512MB -of RMA. Importantly, grub will notice the 512MB and not call CAS again. - -Notes about the choices of parameters: - - - A partition can be configured with only 256MB of memory, which would - mean this request couldn't be satisfied, but PFW refuses to load with - only 256MB of memory, so it's a bit moot. SLOF will run fine with 256MB, - but we will never call CAS under qemu/SLOF because /compatible won't - begin with "IBM".) - - - unspecified CAS vectors take on default values. Some of these values - might restrict the ability of certain hardware configurations to boot. - This is why we need to specify the VP percentage in vector 4, which is - in turn why we need to specify vector 3. - -Finally, we should have enough memory to verify a kernel, and we will -reach Linux. One of the first things Linux does while still running under -OpenFirmware is to call CAS with a much fuller set of options (including -asking for 512MB of memory). Linux includes a much more restrictive set of -PVR values and processor support levels, and this CAS invocation will likely -induce another reboot. On this reboot grub will again notice the higher RMA, -and not call CAS. We will get to Linux again, Linux will call CAS again, but -because the values are now set for Linux this will not induce another CAS -reboot and we will finally boot all the way to userspace. - -On all subsequent boots, everything will be configured with 512MB of RMA, -so there will be no further CAS reboots from grub. (phyp is super sticky -with the RMA size - it persists even on cold boots. So if you've ever booted -Linux in a partition, you'll probably never have grub call CAS. It'll only -ever fire the first time a partition loads grub, or if you deliberately lower -the amount of memory your partition has below 512MB.) - -Signed-off-by: Daniel Axtens -Signed-off-by: Stefan Berger -Reviewed-by: Daniel Kiper -(cherry picked from commit d5571590b7de61887efac1c298901455697ba307) ---- - grub-core/kern/ieee1275/cmain.c | 5 ++ - grub-core/kern/ieee1275/init.c | 167 ++++++++++++++++++++++++++++++++++++++- - include/grub/ieee1275/ieee1275.h | 12 ++- - 3 files changed, 182 insertions(+), 2 deletions(-) - -diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c -index 04df9d2c66..dce7b84922 100644 ---- a/grub-core/kern/ieee1275/cmain.c -+++ b/grub-core/kern/ieee1275/cmain.c -@@ -127,6 +127,11 @@ grub_ieee1275_find_options (void) - break; - } - } -+ -+#if defined(__powerpc__) -+ if (grub_strncmp (tmp, "IBM,", 4) == 0) -+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_CAN_TRY_CAS_FOR_MORE_MEMORY); -+#endif - } - - if (is_smartfirmware) -diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 6581c2c996..8ae405bc79 100644 ---- a/grub-core/kern/ieee1275/init.c -+++ b/grub-core/kern/ieee1275/init.c -@@ -202,11 +202,176 @@ heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, - return 0; - } - --static void -+/* -+ * How much memory does OF believe it has? (regardless of whether -+ * it's accessible or not) -+ */ -+static grub_err_t -+grub_ieee1275_total_mem (grub_uint64_t *total) -+{ -+ grub_ieee1275_phandle_t root; -+ grub_ieee1275_phandle_t memory; -+ grub_uint32_t reg[4]; -+ grub_ssize_t reg_size; -+ grub_uint32_t address_cells = 1; -+ grub_uint32_t size_cells = 1; -+ grub_uint64_t size; -+ -+ /* If we fail to get to the end, report 0. */ -+ *total = 0; -+ -+ /* Determine the format of each entry in `reg'. */ -+ if (grub_ieee1275_finddevice ("/", &root)) -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "couldn't find / node"); -+ if (grub_ieee1275_get_integer_property (root, "#address-cells", &address_cells, -+ sizeof (address_cells), 0)) -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "couldn't examine #address-cells"); -+ if (grub_ieee1275_get_integer_property (root, "#size-cells", &size_cells, -+ sizeof (size_cells), 0)) -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "couldn't examine #size-cells"); -+ -+ if (size_cells > address_cells) -+ address_cells = size_cells; -+ -+ /* Load `/memory/reg'. */ -+ if (grub_ieee1275_finddevice ("/memory", &memory)) -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "couldn't find /memory node"); -+ if (grub_ieee1275_get_integer_property (memory, "reg", reg, -+ sizeof (reg), ®_size)) -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "couldn't examine /memory/reg property"); -+ if (reg_size < 0 || (grub_size_t) reg_size > sizeof (reg)) -+ return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "/memory response buffer exceeded"); -+ -+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS)) -+ { -+ address_cells = 1; -+ size_cells = 1; -+ } -+ -+ /* Decode only the size */ -+ size = reg[address_cells]; -+ if (size_cells == 2) -+ size = (size << 32) | reg[address_cells + 1]; -+ -+ *total = size; -+ -+ return grub_errno; -+} -+ -+#if defined(__powerpc__) -+ -+/* See PAPR or arch/powerpc/kernel/prom_init.c */ -+struct option_vector2 -+{ -+ grub_uint8_t byte1; -+ grub_uint16_t reserved; -+ grub_uint32_t real_base; -+ grub_uint32_t real_size; -+ grub_uint32_t virt_base; -+ grub_uint32_t virt_size; -+ grub_uint32_t load_base; -+ grub_uint32_t min_rma; -+ grub_uint32_t min_load; -+ grub_uint8_t min_rma_percent; -+ grub_uint8_t max_pft_size; -+} GRUB_PACKED; -+ -+struct pvr_entry -+{ -+ grub_uint32_t mask; -+ grub_uint32_t entry; -+}; -+ -+struct cas_vector -+{ -+ struct -+ { -+ struct pvr_entry terminal; -+ } pvr_list; -+ grub_uint8_t num_vecs; -+ grub_uint8_t vec1_size; -+ grub_uint8_t vec1; -+ grub_uint8_t vec2_size; -+ struct option_vector2 vec2; -+ grub_uint8_t vec3_size; -+ grub_uint16_t vec3; -+ grub_uint8_t vec4_size; -+ grub_uint16_t vec4; -+} GRUB_PACKED; -+ -+/* -+ * Call ibm,client-architecture-support to try to get more RMA. -+ * We ask for 512MB which should be enough to verify a distro kernel. -+ * We ignore most errors: if we don't succeed we'll proceed with whatever -+ * memory we have. -+ */ -+static void -+grub_ieee1275_ibm_cas (void) -+{ -+ int rc; -+ grub_ieee1275_ihandle_t root; -+ struct cas_args -+ { -+ struct grub_ieee1275_common_hdr common; -+ grub_ieee1275_cell_t method; -+ grub_ieee1275_ihandle_t ihandle; -+ grub_ieee1275_cell_t cas_addr; -+ grub_ieee1275_cell_t result; -+ } args; -+ struct cas_vector vector = -+ { -+ .pvr_list = { { 0x00000000, 0xffffffff } }, /* any processor */ -+ .num_vecs = 4 - 1, -+ .vec1_size = 0, -+ .vec1 = 0x80, /* ignore */ -+ .vec2_size = 1 + sizeof (struct option_vector2) - 2, -+ .vec2 = { -+ 0, 0, -1, -1, -1, -1, -1, 512, -1, 0, 48 -+ }, -+ .vec3_size = 2 - 1, -+ .vec3 = 0x00e0, /* ask for FP + VMX + DFP but don't halt if unsatisfied */ -+ .vec4_size = 2 - 1, -+ .vec4 = 0x0001, /* set required minimum capacity % to the lowest value */ -+ }; -+ -+ INIT_IEEE1275_COMMON (&args.common, "call-method", 3, 2); -+ args.method = (grub_ieee1275_cell_t) "ibm,client-architecture-support"; -+ rc = grub_ieee1275_open ("/", &root); -+ if (rc) -+ { -+ grub_error (GRUB_ERR_IO, "could not open root when trying to call CAS"); -+ return; -+ } -+ args.ihandle = root; -+ args.cas_addr = (grub_ieee1275_cell_t) &vector; -+ -+ grub_printf ("Calling ibm,client-architecture-support from grub..."); -+ IEEE1275_CALL_ENTRY_FN (&args); -+ grub_printf ("done\n"); -+ -+ grub_ieee1275_close (root); -+} -+ -+#endif /* __powerpc__ */ -+ -+static void - grub_claim_heap (void) - { - unsigned long total = 0; - -+#if defined(__powerpc__) -+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CAN_TRY_CAS_FOR_MORE_MEMORY)) -+ { -+ grub_uint64_t rma_size; -+ grub_err_t err; -+ -+ err = grub_ieee1275_total_mem (&rma_size); -+ /* if we have an error, don't call CAS, just hope for the best */ -+ if (err == GRUB_ERR_NONE && rma_size < (512 * 1024 * 1024)) -+ grub_ieee1275_ibm_cas (); -+ } -+#endif -+ - grub_machine_mmap_iterate (heap_init, &total); - } - #endif -diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h -index 6a1d3e5d70..560c968460 100644 ---- a/include/grub/ieee1275/ieee1275.h -+++ b/include/grub/ieee1275/ieee1275.h -@@ -138,7 +138,17 @@ enum grub_ieee1275_flag - - GRUB_IEEE1275_FLAG_RAW_DEVNAMES, - -- GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT -+ GRUB_IEEE1275_FLAG_DISABLE_VIDEO_SUPPORT, -+ -+#if defined(__powerpc__) -+ /* -+ * On PFW, the first time we boot a Linux partition, we may only get 256MB of -+ * real memory area, even if the partition has more memory. Set this flag if -+ * we think we're running under PFW. Then, if this flag is set, and the RMA is -+ * only 256MB in size, try asking for more with CAS. -+ */ -+ GRUB_IEEE1275_FLAG_CAN_TRY_CAS_FOR_MORE_MEMORY, -+#endif - }; - - extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag); diff --git a/0314-ieee1275-drop-len-1-quirk-in-heap_init.patch b/0314-ieee1275-drop-len-1-quirk-in-heap_init.patch deleted file mode 100644 index 4ce064b..0000000 --- a/0314-ieee1275-drop-len-1-quirk-in-heap_init.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Mon, 6 Feb 2023 10:03:21 -0500 -Subject: [PATCH] ieee1275: drop len -= 1 quirk in heap_init - -This was apparently 'required by some firmware': commit dc9468500919 -("2007-02-12 Hollis Blanchard "). - -It's not clear what firmware that was, and what platform from 14 years ago -which exhibited the bug then is still both in use and buggy now. - -It doesn't cause issues on qemu (mac99 or pseries) or under PFW for Power8. - -I don't have access to old Mac hardware, but if anyone feels especially -strongly we can put it under some feature flag. I really want to disable -it under pseries because it will mess with region merging. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit fc639d430297321ee4f77c5d2d698f698cec0dc7) ---- - grub-core/kern/ieee1275/init.c | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 8ae405bc79..c8d551759d 100644 ---- a/grub-core/kern/ieee1275/init.c -+++ b/grub-core/kern/ieee1275/init.c -@@ -168,7 +168,6 @@ heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, - addr = 0x180000; - } - } -- len -= 1; /* Required for some firmware. */ - - /* Never exceed HEAP_MAX_SIZE */ - if (*total + len > HEAP_MAX_SIZE) diff --git a/0315-ieee1275-support-runtime-memory-claiming.patch b/0315-ieee1275-support-runtime-memory-claiming.patch deleted file mode 100644 index 17ad61d..0000000 --- a/0315-ieee1275-support-runtime-memory-claiming.patch +++ /dev/null @@ -1,435 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Mon, 6 Feb 2023 10:03:22 -0500 -Subject: [PATCH] ieee1275: support runtime memory claiming - -On powerpc-ieee1275, we are running out of memory trying to verify -anything. This is because: - - - we have to load an entire file into memory to verify it. This is - difficult to change with appended signatures. - - We only have 32MB of heap. - - Distro kernels are now often around 30MB. - -So we want to be able to claim more memory from OpenFirmware for our heap -at runtime. - -There are some complications: - - - The grub mm code isn't the only thing that will make claims on - memory from OpenFirmware: - - * PFW/SLOF will have claimed some for their own use. - - * The ieee1275 loader will try to find other bits of memory that we - haven't claimed to place the kernel and initrd when we go to boot. - - * Once we load Linux, it will also try to claim memory. It claims - memory without any reference to /memory/available, it just starts - at min(top of RMO, 768MB) and works down. So we need to avoid this - area. See arch/powerpc/kernel/prom_init.c as of v5.11. - - - The smallest amount of memory a ppc64 KVM guest can have is 256MB. - It doesn't work with distro kernels but can work with custom kernels. - We should maintain support for that. (ppc32 can boot with even less, - and we shouldn't break that either.) - - - Even if a VM has more memory, the memory OpenFirmware makes available - as Real Memory Area can be restricted. Even with our CAS work, an LPAR - on a PowerVM box is likely to have only 512MB available to OpenFirmware - even if it has many gigabytes of memory allocated. - -What should we do? - -We don't know in advance how big the kernel and initrd are going to be, -which makes figuring out how much memory we can take a bit tricky. - -To figure out how much memory we should leave unused, I looked at: - - - an Ubuntu 20.04.1 ppc64le pseries KVM guest: - vmlinux: ~30MB - initrd: ~50MB - - - a RHEL8.2 ppc64le pseries KVM guest: - vmlinux: ~30MB - initrd: ~30MB - -So to give us a little wriggle room, I think we want to leave at least -128MB for the loader to put vmlinux and initrd in memory and leave Linux -with space to satisfy its early allocations. - -Allow other space to be allocated at runtime. - -Tested-by: Stefan Berger -Signed-off-by: Daniel Axtens -(cherry picked from commit a5c710789ccdd27a84ae4a34c7d453bd585e2b66) -[rharwood: _start?] ---- - grub-core/kern/ieee1275/init.c | 270 ++++++++++++++++++++++++++++++++++++++--- - docs/grub-dev.texi | 7 +- - 2 files changed, 257 insertions(+), 20 deletions(-) - -diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index c8d551759d..85af8fa97b 100644 ---- a/grub-core/kern/ieee1275/init.c -+++ b/grub-core/kern/ieee1275/init.c -@@ -46,13 +46,26 @@ - #endif - #include - --/* The maximum heap size we're going to claim */ -+/* The maximum heap size we're going to claim at boot. Not used by sparc. */ - #ifdef __i386__ - #define HEAP_MAX_SIZE (unsigned long) (64 * 1024 * 1024) --#else -+#else /* __powerpc__ */ - #define HEAP_MAX_SIZE (unsigned long) (32 * 1024 * 1024) - #endif - -+/* RMO max. address at 768 MB */ -+#define RMO_ADDR_MAX (grub_uint64_t) (768 * 1024 * 1024) -+ -+/* -+ * The amount of OF space we will not claim here so as to leave space for -+ * the loader and linux to service early allocations. -+ * -+ * In 2021, Daniel Axtens claims that we should leave at least 128MB to -+ * ensure we can load a stock kernel and initrd on a pseries guest with -+ * a 512MB real memory area under PowerVM. -+ */ -+#define RUNTIME_MIN_SPACE (128UL * 1024 * 1024) -+ - extern char _end[]; - - #ifdef __sparc__ -@@ -147,16 +160,52 @@ grub_claim_heap (void) - + GRUB_KERNEL_MACHINE_STACK_SIZE), 0x200000); - } - #else --/* Helper for grub_claim_heap. */ -+/* Helpers for mm on powerpc. */ -+ -+/* -+ * How much memory does OF believe exists in total? -+ * -+ * This isn't necessarily the true total. It can be the total memory -+ * accessible in real mode for a pseries guest, for example. -+ */ -+static grub_uint64_t rmo_top; -+ - static int --heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, -- void *data) -+count_free (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, -+ void *data) - { -- unsigned long *total = data; -+ if (type != GRUB_MEMORY_AVAILABLE) -+ return 0; -+ -+ /* Do not consider memory beyond 4GB */ -+ if (addr > 0xffffffffULL) -+ return 0; -+ -+ if (addr + len > 0xffffffffULL) -+ len = 0xffffffffULL - addr; -+ -+ *(grub_uint32_t *) data += len; -+ -+ return 0; -+} -+ -+static int -+regions_claim (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, -+ unsigned int flags, void *data) -+{ -+ grub_uint32_t total = *(grub_uint32_t *) data; -+ grub_uint64_t linux_rmo_save; - - if (type != GRUB_MEMORY_AVAILABLE) - return 0; - -+ /* Do not consider memory beyond 4GB */ -+ if (addr > 0xffffffffULL) -+ return 0; -+ -+ if (addr + len > 0xffffffffULL) -+ len = 0xffffffffULL - addr; -+ - if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM)) - { - if (addr + len <= 0x180000) -@@ -169,10 +218,6 @@ heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, - } - } - -- /* Never exceed HEAP_MAX_SIZE */ -- if (*total + len > HEAP_MAX_SIZE) -- len = HEAP_MAX_SIZE - *total; -- - /* In theory, firmware should already prevent this from happening by not - listing our own image in /memory/available. The check below is intended - as a safeguard in case that doesn't happen. However, it doesn't protect -@@ -184,6 +229,108 @@ heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, - len = 0; - } - -+ /* -+ * Linux likes to claim memory at min(RMO top, 768MB) and works down -+ * without reference to /memory/available. (See prom_init.c::alloc_down) -+ * -+ * If this block contains min(RMO top, 768MB), do not claim below that for -+ * at least a few MB (this is where RTAS, SML and potentially TCEs live). -+ * -+ * We also need to leave enough space for the DT in the RMA. (See -+ * prom_init.c::alloc_up) -+ * -+ * Finally, we also want to make sure that when grub loads the kernel, -+ * it isn't going to use up all the memory we're trying to reserve! So -+ * enforce our entire RUNTIME_MIN_SPACE here: -+ * -+ * |---------- Top of memory ----------| -+ * | | -+ * | available | -+ * | | -+ * |---------- 768 MB ----------| -+ * | | -+ * | reserved | -+ * | | -+ * |--- 768 MB - runtime min space ---| -+ * | | -+ * | available | -+ * | | -+ * |---------- 0 MB ----------| -+ * -+ * Edge cases: -+ * -+ * - Total memory less than RUNTIME_MIN_SPACE: only claim up to HEAP_MAX_SIZE. -+ * (enforced elsewhere) -+ * -+ * - Total memory between RUNTIME_MIN_SPACE and 768MB: -+ * -+ * |---------- Top of memory ----------| -+ * | | -+ * | reserved | -+ * | | -+ * |---- top - runtime min space ----| -+ * | | -+ * | available | -+ * | | -+ * |---------- 0 MB ----------| -+ * -+ * This by itself would not leave us with RUNTIME_MIN_SPACE of free bytes: if -+ * rmo_top < 768MB, we will almost certainly have FW claims in the reserved -+ * region. We try to address that elsewhere: grub_ieee1275_mm_add_region will -+ * not call us if the resulting free space would be less than RUNTIME_MIN_SPACE. -+ */ -+ linux_rmo_save = grub_min (RMO_ADDR_MAX, rmo_top) - RUNTIME_MIN_SPACE; -+ if (rmo_top > RUNTIME_MIN_SPACE) -+ { -+ if (rmo_top <= RMO_ADDR_MAX) -+ { -+ if (addr > linux_rmo_save) -+ { -+ grub_dprintf ("ieee1275", "rejecting region in RUNTIME_MIN_SPACE reservation (%llx)\n", -+ addr); -+ return 0; -+ } -+ else if (addr + len > linux_rmo_save) -+ { -+ grub_dprintf ("ieee1275", "capping region: (%llx -> %llx) -> (%llx -> %llx)\n", -+ addr, addr + len, addr, rmo_top - RUNTIME_MIN_SPACE); -+ len = linux_rmo_save - addr; -+ } -+ } -+ else -+ { -+ /* -+ * we order these cases to prefer higher addresses and avoid some -+ * splitting issues -+ */ -+ if (addr < RMO_ADDR_MAX && (addr + len) > RMO_ADDR_MAX) -+ { -+ grub_dprintf ("ieee1275", -+ "adjusting region for RUNTIME_MIN_SPACE: (%llx -> %llx) -> (%llx -> %llx)\n", -+ addr, addr + len, RMO_ADDR_MAX, addr + len); -+ len = (addr + len) - RMO_ADDR_MAX; -+ addr = RMO_ADDR_MAX; -+ } -+ else if ((addr < linux_rmo_save) && ((addr + len) > linux_rmo_save)) -+ { -+ grub_dprintf ("ieee1275", "capping region: (%llx -> %llx) -> (%llx -> %llx)\n", -+ addr, addr + len, addr, linux_rmo_save); -+ len = linux_rmo_save - addr; -+ } -+ else if (addr >= linux_rmo_save && (addr + len) <= RMO_ADDR_MAX) -+ { -+ grub_dprintf ("ieee1275", "rejecting region in RUNTIME_MIN_SPACE reservation (%llx)\n", -+ addr); -+ return 0; -+ } -+ } -+ } -+ if (flags & GRUB_MM_ADD_REGION_CONSECUTIVE && len < total) -+ return 0; -+ -+ if (len > total) -+ len = total; -+ - if (len) - { - grub_err_t err; -@@ -192,15 +339,95 @@ heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, - if (err) - return err; - grub_mm_init_region ((void *) (grub_addr_t) addr, len); -+ total -= len; - } - -- *total += len; -- if (*total >= HEAP_MAX_SIZE) -+ *(grub_uint32_t *) data = total; -+ -+ if (total == 0) - return 1; - - return 0; - } - -+static int -+heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, -+ void *data) -+{ -+ return regions_claim (addr, len, type, GRUB_MM_ADD_REGION_NONE, data); -+} -+ -+static int -+region_claim (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, -+ void *data) -+{ -+ return regions_claim (addr, len, type, GRUB_MM_ADD_REGION_CONSECUTIVE, data); -+} -+ -+static grub_err_t -+grub_ieee1275_mm_add_region (grub_size_t size, unsigned int flags) -+{ -+ grub_uint32_t free_memory = 0; -+ grub_uint32_t avail = 0; -+ grub_uint32_t total; -+ -+ grub_dprintf ("ieee1275", "mm requested region of size %x, flags %x\n", -+ size, flags); -+ -+ /* -+ * Update free memory each time, which is a bit inefficient but guards us -+ * against a situation where some OF driver goes out to firmware for -+ * memory and we don't realise. -+ */ -+ grub_machine_mmap_iterate (count_free, &free_memory); -+ -+ /* Ensure we leave enough space to boot. */ -+ if (free_memory <= RUNTIME_MIN_SPACE + size) -+ { -+ grub_dprintf ("ieee1275", "Cannot satisfy allocation and retain minimum runtime space\n"); -+ return GRUB_ERR_OUT_OF_MEMORY; -+ } -+ -+ if (free_memory > RUNTIME_MIN_SPACE) -+ avail = free_memory - RUNTIME_MIN_SPACE; -+ -+ grub_dprintf ("ieee1275", "free = 0x%x available = 0x%x\n", free_memory, avail); -+ -+ if (flags & GRUB_MM_ADD_REGION_CONSECUTIVE) -+ { -+ /* first try rounding up hard for the sake of speed */ -+ total = grub_max (ALIGN_UP (size, 1024 * 1024) + 1024 * 1024, 32 * 1024 * 1024); -+ total = grub_min (avail, total); -+ -+ grub_dprintf ("ieee1275", "looking for %x bytes of memory (%x requested)\n", total, size); -+ -+ grub_machine_mmap_iterate (region_claim, &total); -+ grub_dprintf ("ieee1275", "get memory from fw %s\n", total == 0 ? "succeeded" : "failed"); -+ -+ if (total != 0) -+ { -+ total = grub_min (avail, size); -+ -+ grub_dprintf ("ieee1275", "fallback for %x bytes of memory (%x requested)\n", total, size); -+ -+ grub_machine_mmap_iterate (region_claim, &total); -+ grub_dprintf ("ieee1275", "fallback from fw %s\n", total == 0 ? "succeeded" : "failed"); -+ } -+ } -+ else -+ { -+ /* provide padding for a grub_mm_header_t and region */ -+ total = grub_min (avail, size); -+ grub_machine_mmap_iterate (heap_init, &total); -+ grub_dprintf ("ieee1275", "get noncontig memory from fw %s\n", total == 0 ? "succeeded" : "failed"); -+ } -+ -+ if (total == 0) -+ return GRUB_ERR_NONE; -+ else -+ return GRUB_ERR_OUT_OF_MEMORY; -+} -+ - /* - * How much memory does OF believe it has? (regardless of whether - * it's accessible or not) -@@ -356,17 +583,24 @@ grub_ieee1275_ibm_cas (void) - static void - grub_claim_heap (void) - { -- unsigned long total = 0; -+ grub_err_t err; -+ grub_uint32_t total = HEAP_MAX_SIZE; -+ -+ err = grub_ieee1275_total_mem (&rmo_top); -+ -+ /* -+ * If we cannot size the available memory, we can't be sure we're leaving -+ * space for the kernel, initrd and things Linux loads early in boot. So only -+ * allow further allocations from firmware on success -+ */ -+ if (err == GRUB_ERR_NONE) -+ grub_mm_add_region_fn = grub_ieee1275_mm_add_region; - - #if defined(__powerpc__) - if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CAN_TRY_CAS_FOR_MORE_MEMORY)) - { -- grub_uint64_t rma_size; -- grub_err_t err; -- -- err = grub_ieee1275_total_mem (&rma_size); - /* if we have an error, don't call CAS, just hope for the best */ -- if (err == GRUB_ERR_NONE && rma_size < (512 * 1024 * 1024)) -+ if (err == GRUB_ERR_NONE && rmo_top < (512 * 1024 * 1024)) - grub_ieee1275_ibm_cas (); - } - #endif -diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi -index 7b2455a8fe..7edc5b7e2b 100644 ---- a/docs/grub-dev.texi -+++ b/docs/grub-dev.texi -@@ -1047,7 +1047,10 @@ space is limited to 4GiB. GRUB allocates pages from EFI for its heap, at most - 1.6 GiB. - - On i386-ieee1275 and powerpc-ieee1275 GRUB uses same stack as IEEE1275. --It allocates at most 32MiB for its heap. -+ -+On i386-ieee1275 and powerpc-ieee1275, GRUB will allocate 32MiB for its heap on -+startup. It may allocate more at runtime, as long as at least 128MiB remain free -+in OpenFirmware. - - On sparc64-ieee1275 stack is 256KiB and heap is 2MiB. - -@@ -1075,7 +1078,7 @@ In short: - @item i386-qemu @tab 60 KiB @tab < 4 GiB - @item *-efi @tab ? @tab < 1.6 GiB - @item i386-ieee1275 @tab ? @tab < 32 MiB --@item powerpc-ieee1275 @tab ? @tab < 32 MiB -+@item powerpc-ieee1275 @tab ? @tab available memory - 128MiB - @item sparc64-ieee1275 @tab 256KiB @tab 2 MiB - @item arm-uboot @tab 256KiB @tab 2 MiB - @item mips(el)-qemu_mips @tab 2MiB @tab 253 MiB diff --git a/0316-ieee1275-implement-vec5-for-cas-negotiation.patch b/0316-ieee1275-implement-vec5-for-cas-negotiation.patch deleted file mode 100644 index fad39db..0000000 --- a/0316-ieee1275-implement-vec5-for-cas-negotiation.patch +++ /dev/null @@ -1,74 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Diego Domingos -Date: Mon, 6 Feb 2023 10:03:23 -0500 -Subject: [PATCH] ieee1275: implement vec5 for cas negotiation - -As a legacy support, if the vector 5 is not implemented, Power Hypervisor will -consider the max CPUs as 64 instead 256 currently supported during -client-architecture-support negotiation. - -This patch implements the vector 5 and set the MAX CPUs to 256 while setting the -others values to 0 (default). - -Signed-off-by: Diego Domingos -Acked-by: Daniel Axtens -Signed-off-by: Stefan Berger -Signed-off-by: Avnish Chouhan -(cherry picked from commit 942f19959fe7465fb52a1da39ff271a7ab704892) ---- - grub-core/kern/ieee1275/init.c | 21 ++++++++++++++++++++- - 1 file changed, 20 insertions(+), 1 deletion(-) - -diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 85af8fa97b..72d4fed312 100644 ---- a/grub-core/kern/ieee1275/init.c -+++ b/grub-core/kern/ieee1275/init.c -@@ -502,6 +502,19 @@ struct option_vector2 - grub_uint8_t max_pft_size; - } GRUB_PACKED; - -+struct option_vector5 -+{ -+ grub_uint8_t byte1; -+ grub_uint8_t byte2; -+ grub_uint8_t byte3; -+ grub_uint8_t cmo; -+ grub_uint8_t associativity; -+ grub_uint8_t bin_opts; -+ grub_uint8_t micro_checkpoint; -+ grub_uint8_t reserved0; -+ grub_uint32_t max_cpus; -+} GRUB_PACKED; -+ - struct pvr_entry - { - grub_uint32_t mask; -@@ -523,6 +536,8 @@ struct cas_vector - grub_uint16_t vec3; - grub_uint8_t vec4_size; - grub_uint16_t vec4; -+ grub_uint8_t vec5_size; -+ struct option_vector5 vec5; - } GRUB_PACKED; - - /* -@@ -547,7 +562,7 @@ grub_ieee1275_ibm_cas (void) - struct cas_vector vector = - { - .pvr_list = { { 0x00000000, 0xffffffff } }, /* any processor */ -- .num_vecs = 4 - 1, -+ .num_vecs = 5 - 1, - .vec1_size = 0, - .vec1 = 0x80, /* ignore */ - .vec2_size = 1 + sizeof (struct option_vector2) - 2, -@@ -558,6 +573,10 @@ grub_ieee1275_ibm_cas (void) - .vec3 = 0x00e0, /* ask for FP + VMX + DFP but don't halt if unsatisfied */ - .vec4_size = 2 - 1, - .vec4 = 0x0001, /* set required minimum capacity % to the lowest value */ -+ .vec5_size = 1 + sizeof (struct option_vector5) - 2, -+ .vec5 = { -+ 0, 192, 0, 128, 0, 0, 0, 0, 256 -+ } - }; - - INIT_IEEE1275_COMMON (&args.common, "call-method", 3, 2); diff --git a/0317-ibmvtpm-Add-support-for-trusted-boot-using-a-vTPM-2..patch b/0317-ibmvtpm-Add-support-for-trusted-boot-using-a-vTPM-2..patch deleted file mode 100644 index 02c0282..0000000 --- a/0317-ibmvtpm-Add-support-for-trusted-boot-using-a-vTPM-2..patch +++ /dev/null @@ -1,246 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Stefan Berger -Date: Mon, 6 Feb 2023 10:03:25 -0500 -Subject: [PATCH] ibmvtpm: Add support for trusted boot using a vTPM 2.0 - -Add support for trusted boot using a vTPM 2.0 on the IBM IEEE1275 -PowerPC platform. With this patch grub now measures text and binary data -into the TPM's PCRs 8 and 9 in the same way as the x86_64 platform -does. - -This patch requires Daniel Axtens's patches for claiming more memory. - -Note: The tpm_init() function cannot be called from GRUB_MOD_INIT() since -it does not find the device nodes upon module initialization and -therefore the call to tpm_init() must be deferred to grub_tpm_measure(). - -For vTPM support to work on PowerVM, system driver levels 1010.30 -or 1020.00 are required. - -Note: Previous versions of firmware levels with the 2hash-ext-log -API call have a bug that, once this API call is invoked, has the -effect of disabling the vTPM driver under Linux causing an error -message to be displayed in the Linux kernel log. Those users will -have to update their machines to the firmware levels mentioned -above. - -Cc: Eric Snowberg -Signed-off-by: Stefan Berger -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit 2aa5ef83743dfea79377309ff4f5e9c9a55de355) ---- - grub-core/Makefile.core.def | 7 ++ - grub-core/commands/ieee1275/ibmvtpm.c | 155 ++++++++++++++++++++++++++++++++++ - include/grub/ieee1275/ieee1275.h | 3 + - docs/grub.texi | 3 +- - 4 files changed, 167 insertions(+), 1 deletion(-) - create mode 100644 grub-core/commands/ieee1275/ibmvtpm.c - -diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def -index f21da23213..02ea718652 100644 ---- a/grub-core/Makefile.core.def -+++ b/grub-core/Makefile.core.def -@@ -1175,6 +1175,13 @@ module = { - enable = powerpc_ieee1275; - }; - -+module = { -+ name = tpm; -+ common = commands/tpm.c; -+ ieee1275 = commands/ieee1275/ibmvtpm.c; -+ enable = powerpc_ieee1275; -+}; -+ - module = { - name = terminal; - common = commands/terminal.c; -diff --git a/grub-core/commands/ieee1275/ibmvtpm.c b/grub-core/commands/ieee1275/ibmvtpm.c -new file mode 100644 -index 0000000000..239942d27e ---- /dev/null -+++ b/grub-core/commands/ieee1275/ibmvtpm.c -@@ -0,0 +1,155 @@ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2022 Free Software Foundation, Inc. -+ * Copyright (C) 2022 IBM Corporation -+ * -+ * 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 . -+ * -+ * IBM vTPM support code. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+static grub_ieee1275_ihandle_t tpm_ihandle; -+static grub_uint8_t tpm_version; -+ -+#define IEEE1275_IHANDLE_INVALID ((grub_ieee1275_ihandle_t) 0) -+ -+static void -+tpm_get_tpm_version (void) -+{ -+ grub_ieee1275_phandle_t vtpm; -+ char buffer[20]; -+ -+ if (!grub_ieee1275_finddevice ("/vdevice/vtpm", &vtpm) && -+ !grub_ieee1275_get_property (vtpm, "compatible", buffer, -+ sizeof (buffer), NULL) && -+ !grub_strcmp (buffer, "IBM,vtpm20")) -+ tpm_version = 2; -+} -+ -+static grub_err_t -+tpm_init (void) -+{ -+ static int init_success = 0; -+ -+ if (!init_success) -+ { -+ if (grub_ieee1275_open ("/vdevice/vtpm", &tpm_ihandle) < 0) -+ { -+ tpm_ihandle = IEEE1275_IHANDLE_INVALID; -+ return GRUB_ERR_UNKNOWN_DEVICE; -+ } -+ -+ init_success = 1; -+ -+ tpm_get_tpm_version (); -+ } -+ -+ return GRUB_ERR_NONE; -+} -+ -+static int -+ibmvtpm_2hash_ext_log (grub_uint8_t pcrindex, -+ grub_uint32_t eventtype, -+ const char *description, -+ grub_size_t description_size, -+ void *buf, grub_size_t size) -+{ -+ struct tpm_2hash_ext_log -+ { -+ 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 buf; -+ grub_ieee1275_cell_t description_size; -+ grub_ieee1275_cell_t description; -+ grub_ieee1275_cell_t eventtype; -+ grub_ieee1275_cell_t pcrindex; -+ grub_ieee1275_cell_t catch_result; -+ grub_ieee1275_cell_t rc; -+ }; -+ struct tpm_2hash_ext_log args; -+ -+ INIT_IEEE1275_COMMON (&args.common, "call-method", 8, 2); -+ args.method = (grub_ieee1275_cell_t) "2hash-ext-log"; -+ args.ihandle = tpm_ihandle; -+ args.pcrindex = pcrindex; -+ args.eventtype = eventtype; -+ args.description = (grub_ieee1275_cell_t) description; -+ args.description_size = description_size; -+ args.buf = (grub_ieee1275_cell_t) buf; -+ args.size = (grub_ieee1275_cell_t) size; -+ -+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1) -+ return -1; -+ -+ /* -+ * catch_result is set if firmware does not support 2hash-ext-log -+ * rc is GRUB_IEEE1275_CELL_FALSE (0) on failure -+ */ -+ if ((args.catch_result) || args.rc == GRUB_IEEE1275_CELL_FALSE) -+ return -1; -+ -+ return 0; -+} -+ -+static grub_err_t -+tpm2_log_event (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, -+ const char *description) -+{ -+ static int error_displayed = 0; -+ int rc; -+ -+ rc = ibmvtpm_2hash_ext_log (pcr, EV_IPL, -+ description, grub_strlen(description) + 1, -+ buf, size); -+ if (rc && !error_displayed) -+ { -+ error_displayed++; -+ return grub_error (GRUB_ERR_BAD_DEVICE, -+ "2HASH-EXT-LOG failed: Firmware is likely too old.\n"); -+ } -+ -+ return GRUB_ERR_NONE; -+} -+ -+grub_err_t -+grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, -+ const char *description) -+{ -+ /* -+ * Call tpm_init() 'late' rather than from GRUB_MOD_INIT() so that device nodes -+ * can be found. -+ */ -+ grub_err_t err = tpm_init (); -+ -+ /* Absence of a TPM isn't a failure. */ -+ if (err != GRUB_ERR_NONE) -+ return GRUB_ERR_NONE; -+ -+ grub_dprintf ("tpm", "log_event, pcr = %d, size = 0x%" PRIxGRUB_SIZE ", %s\n", -+ pcr, size, description); -+ -+ if (tpm_version == 2) -+ return tpm2_log_event (buf, size, pcr, description); -+ -+ return GRUB_ERR_NONE; -+} -diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h -index 560c968460..27b9cf259b 100644 ---- a/include/grub/ieee1275/ieee1275.h -+++ b/include/grub/ieee1275/ieee1275.h -@@ -24,6 +24,9 @@ - #include - #include - -+#define GRUB_IEEE1275_CELL_FALSE ((grub_ieee1275_cell_t) 0) -+#define GRUB_IEEE1275_CELL_TRUE ((grub_ieee1275_cell_t) -1) -+ - struct grub_ieee1275_mem_region - { - unsigned int start; -diff --git a/docs/grub.texi b/docs/grub.texi -index 1750b72ee9..825278a7f3 100644 ---- a/docs/grub.texi -+++ b/docs/grub.texi -@@ -6235,7 +6235,8 @@ tpm module is loaded. As such it is recommended that the tpm module be built - into @file{core.img} in order to avoid a potential gap in measurement between - @file{core.img} being loaded and the tpm module being loaded. - --Measured boot is currently only supported on EFI platforms. -+Measured boot is currently only supported on EFI and IBM IEEE1275 PowerPC -+platforms. - - @node Lockdown - @section Lockdown when booting on a secure setup diff --git a/0318-powerpc-Drop-Open-Hack-Ware.patch b/0318-powerpc-Drop-Open-Hack-Ware.patch deleted file mode 100644 index 1d201d3..0000000 --- a/0318-powerpc-Drop-Open-Hack-Ware.patch +++ /dev/null @@ -1,69 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Daniel Axtens -Date: Mon, 6 Sep 2021 15:46:11 +1000 -Subject: [PATCH] powerpc: Drop Open Hack'Ware - -Open Hack'Ware was an alternative firmware of powerpc under QEMU. - -The last commit to any Open Hack'Ware repo I can find is from 2014 [1]. - -Open Hack'Ware was used for the QEMU "prep" machine type, which was -deprecated in QEMU in commit 54c86f5a4844 (hw/ppc: deprecate the -machine type 'prep', replaced by '40p') in QEMU v3.1, and had reportedly -been broken for years before without anyone noticing. Support was removed -in February 2020 by commit b2ce76a0730e (hw/ppc/prep: Remove the -deprecated "prep" machine and the OpenHackware BIOS). - -Open Hack'Ware's limitations require some messy code in GRUB. This -complexity is not worth carrying any more. - -Remove detection of Open Hack'Ware. We will clean up the feature flags -in following commits. - -[1]: https://github.com/qemu/openhackware and - https://repo.or.cz/w/openhackware.git are QEMU submodules. They have - only small changes on top of OHW v0.4.1, which was imported into - QEMU SCM in 2010. I can't find anything resembling an official repo - any more. - -Signed-off-by: Daniel Axtens -Reviewed-by: Daniel Kiper -(cherry picked from commit f9ce538eec88c5cffbfde021c4e8a95a5e9d0e8f) ---- - grub-core/kern/ieee1275/cmain.c | 16 ---------------- - 1 file changed, 16 deletions(-) - -diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c -index dce7b84922..cb42f60ebe 100644 ---- a/grub-core/kern/ieee1275/cmain.c -+++ b/grub-core/kern/ieee1275/cmain.c -@@ -49,7 +49,6 @@ grub_ieee1275_find_options (void) - grub_ieee1275_phandle_t root; - grub_ieee1275_phandle_t options; - grub_ieee1275_phandle_t openprom; -- grub_ieee1275_phandle_t bootrom; - int rc; - grub_uint32_t realmode = 0; - char tmp[256]; -@@ -198,21 +197,6 @@ grub_ieee1275_find_options (void) - - grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_HAS_CURSORONOFF); - } -- -- if (! grub_ieee1275_finddevice ("/rom/boot-rom", &bootrom) -- || ! grub_ieee1275_finddevice ("/boot-rom", &bootrom)) -- { -- rc = grub_ieee1275_get_property (bootrom, "model", tmp, sizeof (tmp), 0); -- if (rc >= 0 && !grub_strncmp (tmp, "PPC Open Hack'Ware", -- sizeof ("PPC Open Hack'Ware") - 1)) -- { -- grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT); -- grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_CANNOT_SET_COLORS); -- grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_CANNOT_INTERPRET); -- grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_FORCE_CLAIM); -- grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_ANSI); -- } -- } - } - - void diff --git a/0319-osdep-linux-hostdisk-Modify-sector-by-sysfs-as-disk-.patch b/0319-osdep-linux-hostdisk-Modify-sector-by-sysfs-as-disk-.patch deleted file mode 100644 index 6e7b17f..0000000 --- a/0319-osdep-linux-hostdisk-Modify-sector-by-sysfs-as-disk-.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Mukesh Kumar Chaurasiya -Date: Thu, 9 Feb 2023 13:09:16 +0530 -Subject: [PATCH] osdep/linux/hostdisk: Modify sector by sysfs as disk sector - -The disk sector size provided by sysfs file system considers the sector -size of 512 irrespective of disk sector size, thus causing the read by -the GRUB to an incorrect offset from what was originally intended. - -Considering the 512 sector size of sysfs data the actual sector needs to -be modified corresponding to disk sector size. - -Signed-off-by: Mukesh Kumar Chaurasiya -Reviewed-by: Daniel Kiper -(cherry picked from commit f7564844f82b57078d601befadc438b5bc1fa01b) ---- - grub-core/osdep/linux/hostdisk.c | 7 ++++--- - include/grub/disk.h | 7 +++++++ - 2 files changed, 11 insertions(+), 3 deletions(-) - -diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c -index 7bc99ac1c1..a9ea0bb465 100644 ---- a/grub-core/osdep/linux/hostdisk.c -+++ b/grub-core/osdep/linux/hostdisk.c -@@ -240,7 +240,8 @@ have_devfs (void) - #pragma GCC diagnostic ignored "-Wformat-nonliteral" - - static int --grub_hostdisk_linux_find_partition (char *dev, grub_disk_addr_t sector) -+grub_hostdisk_linux_find_partition (const grub_disk_t disk, char *dev, -+ grub_disk_addr_t sector) - { - size_t len = strlen (dev); - const char *format; -@@ -305,7 +306,7 @@ grub_hostdisk_linux_find_partition (char *dev, grub_disk_addr_t sector) - if (fstat (fd, &st) < 0 - || !grub_util_device_is_mapped_stat (&st) - || !grub_util_get_dm_node_linear_info (st.st_rdev, 0, 0, &start)) -- start = grub_util_find_partition_start_os (real_dev); -+ start = grub_disk_to_native_sector (disk, grub_util_find_partition_start_os (real_dev)); - /* We don't care about errors here. */ - grub_errno = GRUB_ERR_NONE; - -@@ -386,7 +387,7 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f - && strncmp (dev, "/dev/", 5) == 0) - { - if (sector >= part_start) -- is_partition = grub_hostdisk_linux_find_partition (dev, part_start); -+ is_partition = grub_hostdisk_linux_find_partition (disk, dev, part_start); - else - *max = part_start - sector; - } -diff --git a/include/grub/disk.h b/include/grub/disk.h -index 06210a7049..881addcc77 100644 ---- a/include/grub/disk.h -+++ b/include/grub/disk.h -@@ -208,6 +208,13 @@ grub_disk_from_native_sector (grub_disk_t disk, grub_disk_addr_t sector) - return sector << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS); - } - -+/* Convert from GRUB native disk sized sector to disk sized sector. */ -+static inline grub_disk_addr_t -+grub_disk_to_native_sector (grub_disk_t disk, grub_disk_addr_t sector) -+{ -+ return sector >> (disk->log_sector_size - GRUB_DISK_SECTOR_BITS); -+} -+ - /* This is called from the memory manager. */ - void grub_disk_cache_invalidate_all (void); - diff --git a/0320-mm-Adjust-new-region-size-to-take-management-overhea.patch b/0320-mm-Adjust-new-region-size-to-take-management-overhea.patch deleted file mode 100644 index 456f8f7..0000000 --- a/0320-mm-Adjust-new-region-size-to-take-management-overhea.patch +++ /dev/null @@ -1,145 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Sun, 29 Jan 2023 19:49:31 +0800 -Subject: [PATCH] mm: Adjust new region size to take management overhead into - account - -When grub_memalign() encounters out-of-memory, it will try -grub_mm_add_region_fn() to request more memory from system firmware. -However, the size passed to it doesn't take region management overhead -into account. Adding a memory area of "size" bytes may result in a heap -region of less than "size" bytes really available. Thus, the new region -may not be adequate for current allocation request, confusing -out-of-memory handling code. - -This patch introduces GRUB_MM_MGMT_OVERHEAD to address the region -management overhead (e.g. metadata, padding). The value of this new -constant must be large enough to make sure grub_memalign(align, size) -always succeeds after a successful call to - grub_mm_init_region(addr, size + align + GRUB_MM_MGMT_OVERHEAD), -for any given addr and size (assuming no integer overflow). - -The size passed to grub_mm_add_region_fn() is now correctly adjusted, -thus if grub_mm_add_region_fn() succeeded, current allocation request -can always succeed. - -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit 2282cbfe5aa1ff6c1bbcbdcd2003089ad7c03ba3) ---- - grub-core/kern/mm.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++--- - 1 file changed, 61 insertions(+), 3 deletions(-) - -diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index da1ac9427c..f29a3e5cbd 100644 ---- a/grub-core/kern/mm.c -+++ b/grub-core/kern/mm.c -@@ -83,6 +83,46 @@ - - - -+/* -+ * GRUB_MM_MGMT_OVERHEAD is an upper bound of management overhead of -+ * each region, with any possible padding taken into account. -+ * -+ * The value must be large enough to make sure grub_memalign(align, size) -+ * always succeeds after a successful call to -+ * grub_mm_init_region(addr, size + align + GRUB_MM_MGMT_OVERHEAD), -+ * for any given addr, align and size (assuming no interger overflow). -+ * -+ * The worst case which has maximum overhead is shown in the figure below: -+ * -+ * +-- addr -+ * v |<- size + align ->| -+ * +---------+----------------+----------------+------------------+---------+ -+ * | padding | grub_mm_region | grub_mm_header | usable bytes | padding | -+ * +---------+----------------+----------------+------------------+---------+ -+ * |<- a ->|<- b ->|<- c ->|<- d ->|<- e ->| -+ * ^ -+ * b == sizeof (struct grub_mm_region) | / Assuming no other suitable -+ * c == sizeof (struct grub_mm_header) | | block is available, then: -+ * d == size + align +-| If align == 0, this will be -+ * | the pointer returned by next -+ * Assuming addr % GRUB_MM_ALIGN == 1, then: | grub_memalign(align, size). -+ * a == GRUB_MM_ALIGN - 1 | If align > 0, this chunk may -+ * | need to be split to fulfill -+ * Assuming d % GRUB_MM_ALIGN == 1, then: | alignment requirements, and -+ * e == GRUB_MM_ALIGN - 1 | the returned pointer may be -+ * \ inside these usable bytes. -+ * Therefore, the maximum overhead is: -+ * a + b + c + e == (GRUB_MM_ALIGN - 1) + sizeof (struct grub_mm_region) -+ * + sizeof (struct grub_mm_header) + (GRUB_MM_ALIGN - 1) -+ */ -+#define GRUB_MM_MGMT_OVERHEAD ((GRUB_MM_ALIGN - 1) \ -+ + sizeof (struct grub_mm_region) \ -+ + sizeof (struct grub_mm_header) \ -+ + (GRUB_MM_ALIGN - 1)) -+ -+/* The size passed to grub_mm_add_region_fn() is aligned up by this value. */ -+#define GRUB_MM_HEAP_GROW_ALIGN 4096 -+ - grub_mm_region_t grub_mm_base; - grub_mm_add_region_func_t grub_mm_add_region_fn; - -@@ -230,6 +270,11 @@ grub_mm_init_region (void *addr, grub_size_t size) - - grub_dprintf ("regions", "No: considering a new region at %p of size %" PRIxGRUB_SIZE "\n", - addr, size); -+ /* -+ * If you want to modify the code below, please also take a look at -+ * GRUB_MM_MGMT_OVERHEAD and make sure it is synchronized with the code. -+ */ -+ - /* Allocate a region from the head. */ - r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN); - -@@ -410,6 +455,7 @@ grub_memalign (grub_size_t align, grub_size_t size) - { - grub_mm_region_t r; - grub_size_t n = ((size + GRUB_MM_ALIGN - 1) >> GRUB_MM_ALIGN_LOG2) + 1; -+ grub_size_t grow; - int count = 0; - - if (!grub_mm_base) -@@ -418,10 +464,22 @@ grub_memalign (grub_size_t align, grub_size_t size) - if (size > ~(grub_size_t) align) - goto fail; - -+ /* -+ * Pre-calculate the necessary size of heap growth (if applicable), -+ * with region management overhead taken into account. -+ */ -+ if (grub_add (size + align, GRUB_MM_MGMT_OVERHEAD, &grow)) -+ goto fail; -+ -+ /* Align up heap growth to make it friendly to CPU/MMU. */ -+ if (grow > ~(grub_size_t) (GRUB_MM_HEAP_GROW_ALIGN - 1)) -+ goto fail; -+ grow = ALIGN_UP (grow, GRUB_MM_HEAP_GROW_ALIGN); -+ - /* We currently assume at least a 32-bit grub_size_t, - so limiting allocations to - 1MiB - in name of sanity is beneficial. */ -- if ((size + align) > ~(grub_size_t) 0x100000) -+ if (grow > ~(grub_size_t) 0x100000) - goto fail; - - align = (align >> GRUB_MM_ALIGN_LOG2); -@@ -447,7 +505,7 @@ grub_memalign (grub_size_t align, grub_size_t size) - count++; - - if (grub_mm_add_region_fn != NULL && -- grub_mm_add_region_fn (size, GRUB_MM_ADD_REGION_CONSECUTIVE) == GRUB_ERR_NONE) -+ grub_mm_add_region_fn (grow, GRUB_MM_ADD_REGION_CONSECUTIVE) == GRUB_ERR_NONE) - goto again; - - /* fallthrough */ -@@ -462,7 +520,7 @@ grub_memalign (grub_size_t align, grub_size_t size) - * Try again even if this fails, in case it was able to partially - * satisfy the request - */ -- grub_mm_add_region_fn (size, GRUB_MM_ADD_REGION_NONE); -+ grub_mm_add_region_fn (grow, GRUB_MM_ADD_REGION_NONE); - goto again; - } - diff --git a/0321-mm-Preallocate-some-space-when-adding-new-regions.patch b/0321-mm-Preallocate-some-space-when-adding-new-regions.patch deleted file mode 100644 index 291092d..0000000 --- a/0321-mm-Preallocate-some-space-when-adding-new-regions.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Sun, 29 Jan 2023 19:49:32 +0800 -Subject: [PATCH] mm: Preallocate some space when adding new regions - -When grub_memalign() encounters out-of-memory, it will try -grub_mm_add_region_fn() to request more memory from system firmware. -However, it doesn't preallocate memory space for future allocation -requests. In extreme cases, it requires one call to -grub_mm_add_region_fn() for each memory allocation request. This can -be very slow. - -This patch introduces GRUB_MM_HEAP_GROW_EXTRA, the minimal heap growth -granularity. The new region size is now set to the bigger one of its -original value and GRUB_MM_HEAP_GROW_EXTRA. Thus, it will result in some -memory space preallocated if current allocations request is small. - -The value of GRUB_MM_HEAP_GROW_EXTRA is set to 1MB. If this value is -smaller, the cost of small memory allocations will be higher. If this -value is larger, more memory will be wasted and it might cause -out-of-memory on machines with small amount of RAM. - -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit 21869baec15239b6d99122b32b14a778af4c754f) ---- - grub-core/kern/mm.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index f29a3e5cbd..cc8a4703bc 100644 ---- a/grub-core/kern/mm.c -+++ b/grub-core/kern/mm.c -@@ -123,6 +123,9 @@ - /* The size passed to grub_mm_add_region_fn() is aligned up by this value. */ - #define GRUB_MM_HEAP_GROW_ALIGN 4096 - -+/* Minimal heap growth granularity when existing heap space is exhausted. */ -+#define GRUB_MM_HEAP_GROW_EXTRA 0x100000 -+ - grub_mm_region_t grub_mm_base; - grub_mm_add_region_func_t grub_mm_add_region_fn; - -@@ -471,6 +474,9 @@ grub_memalign (grub_size_t align, grub_size_t size) - if (grub_add (size + align, GRUB_MM_MGMT_OVERHEAD, &grow)) - goto fail; - -+ /* Preallocate some extra space if heap growth is small. */ -+ grow = grub_max (grow, GRUB_MM_HEAP_GROW_EXTRA); -+ - /* Align up heap growth to make it friendly to CPU/MMU. */ - if (grow > ~(grub_size_t) (GRUB_MM_HEAP_GROW_ALIGN - 1)) - goto fail; diff --git a/0322-mm-Avoid-complex-heap-growth-math-in-hot-path.patch b/0322-mm-Avoid-complex-heap-growth-math-in-hot-path.patch deleted file mode 100644 index fe6b3e1..0000000 --- a/0322-mm-Avoid-complex-heap-growth-math-in-hot-path.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Zhang Boyang -Date: Sun, 29 Jan 2023 19:49:33 +0800 -Subject: [PATCH] mm: Avoid complex heap growth math in hot path - -We do a lot of math about heap growth in hot path of grub_memalign(). -However, the result is only used if out of memory is encountered, which -is seldom. - -This patch moves these calculations away from hot path. These -calculations are now only done if out of memory is encountered. This -change can also help compiler to optimize integer overflow checks away. - -Signed-off-by: Zhang Boyang -Reviewed-by: Daniel Kiper -(cherry picked from commit 65bc45963014773e2062ccc63ff34a089d2e352e) ---- - grub-core/kern/mm.c | 34 ++++++++++++++++++++-------------- - 1 file changed, 20 insertions(+), 14 deletions(-) - -diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c -index cc8a4703bc..630d7be0e2 100644 ---- a/grub-core/kern/mm.c -+++ b/grub-core/kern/mm.c -@@ -467,20 +467,7 @@ grub_memalign (grub_size_t align, grub_size_t size) - if (size > ~(grub_size_t) align) - goto fail; - -- /* -- * Pre-calculate the necessary size of heap growth (if applicable), -- * with region management overhead taken into account. -- */ -- if (grub_add (size + align, GRUB_MM_MGMT_OVERHEAD, &grow)) -- goto fail; -- -- /* Preallocate some extra space if heap growth is small. */ -- grow = grub_max (grow, GRUB_MM_HEAP_GROW_EXTRA); -- -- /* Align up heap growth to make it friendly to CPU/MMU. */ -- if (grow > ~(grub_size_t) (GRUB_MM_HEAP_GROW_ALIGN - 1)) -- goto fail; -- grow = ALIGN_UP (grow, GRUB_MM_HEAP_GROW_ALIGN); -+ grow = size + align; - - /* We currently assume at least a 32-bit grub_size_t, - so limiting allocations to - 1MiB -@@ -510,6 +497,25 @@ grub_memalign (grub_size_t align, grub_size_t size) - /* Request additional pages, contiguous */ - count++; - -+ /* -+ * Calculate the necessary size of heap growth (if applicable), -+ * with region management overhead taken into account. -+ */ -+ if (grub_add (grow, GRUB_MM_MGMT_OVERHEAD, &grow)) -+ goto fail; -+ -+ /* Preallocate some extra space if heap growth is small. */ -+ grow = grub_max (grow, GRUB_MM_HEAP_GROW_EXTRA); -+ -+ /* Align up heap growth to make it friendly to CPU/MMU. */ -+ if (grow > ~(grub_size_t) (GRUB_MM_HEAP_GROW_ALIGN - 1)) -+ goto fail; -+ grow = ALIGN_UP (grow, GRUB_MM_HEAP_GROW_ALIGN); -+ -+ /* Do the same sanity check again. */ -+ if (grow > ~(grub_size_t) 0x100000) -+ goto fail; -+ - if (grub_mm_add_region_fn != NULL && - grub_mm_add_region_fn (grow, GRUB_MM_ADD_REGION_CONSECUTIVE) == GRUB_ERR_NONE) - goto again; diff --git a/0325-emu-linux-work-around-systemctl-kexec-returning.patch b/0325-emu-linux-work-around-systemctl-kexec-returning.patch deleted file mode 100644 index eaef5ff..0000000 --- a/0325-emu-linux-work-around-systemctl-kexec-returning.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Robbie Harwood -Date: Wed, 22 Mar 2023 14:19:43 -0400 -Subject: [PATCH] emu/linux: work around systemctl kexec returning - -Per systemctl(1), it "is asynchronous; it will return after the reboot -operation is enqueued, without waiting for it to complete". This -differs from kexec(8), which calls reboot(2) and therefore does not -return. - -When not using fallback, this results in the confusing-but-harmless: - - error trying to perform 'systemctl kexec': 0 - Aborted. Press any key to exit. - -on screen for a bit, followed by successful kexec. - -To reduce the liklihood of hitting this case, add a delay on succesful -return. Ultimately, the systemd interface is racy: we can't avoid it -entirely unless we never fallback on success. - -Signed-off-by: Robbie Harwood ---- - grub-core/loader/emu/linux.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/grub-core/loader/emu/linux.c b/grub-core/loader/emu/linux.c -index 0cf378a376..7de3f7f861 100644 ---- a/grub-core/loader/emu/linux.c -+++ b/grub-core/loader/emu/linux.c -@@ -74,6 +74,10 @@ grub_linux_boot (void) - (kexecute==1) ? "do-or-die" : "just-in-case"); - rc = grub_util_exec (systemctl); - -+ /* `systemctl kexec` is "asynchronous" and will return even on success. */ -+ if (rc == 0) -+ grub_sleep (10); -+ - if (kexecute == 1) - grub_fatal (N_("error trying to perform 'systemctl kexec': %d"), rc); - diff --git a/0326-kern-ieee1275-init-Convert-plain-numbers-to-constant.patch b/0326-kern-ieee1275-init-Convert-plain-numbers-to-constant.patch deleted file mode 100644 index ca82e33..0000000 --- a/0326-kern-ieee1275-init-Convert-plain-numbers-to-constant.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Avnish Chouhan -Date: Mon, 27 Mar 2023 12:25:39 +0530 -Subject: [PATCH] kern/ieee1275/init: Convert plain numbers to constants in - Vec5 - -This patch converts the plain numbers used in Vec5 properties to constants. - -1. LPAR: Client program supports logical partitioning and - associated hcall()s. -2. SPLPAR: Client program supports the Shared - Processor LPAR Option. -3. CMO: Enables the Cooperative Memory Over-commitment Option. -4. MAX_CPU: Defines maximum number of CPUs supported. - -Signed-off-by: Avnish Chouhan -Reviewed-by: Daniel Kiper -(cherry picked from commit 8406cfe4774eb2da3db4bf0bc2b2ff6592ecbdaf) ---- - grub-core/kern/ieee1275/init.c | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 72d4fed312..5d79580341 100644 ---- a/grub-core/kern/ieee1275/init.c -+++ b/grub-core/kern/ieee1275/init.c -@@ -72,6 +72,12 @@ extern char _end[]; - grub_addr_t grub_ieee1275_original_stack; - #endif - -+#define LPAR 0x80 -+#define SPLPAR 0x40 -+#define BYTE2 (LPAR | SPLPAR) -+#define CMO 0x80 -+#define MAX_CPU 256 -+ - void - grub_exit (int rc __attribute__((unused))) - { -@@ -575,7 +581,7 @@ grub_ieee1275_ibm_cas (void) - .vec4 = 0x0001, /* set required minimum capacity % to the lowest value */ - .vec5_size = 1 + sizeof (struct option_vector5) - 2, - .vec5 = { -- 0, 192, 0, 128, 0, 0, 0, 0, 256 -+ 0, BYTE2, 0, CMO, 0, 0, 0, 0, MAX_CPU - } - }; - diff --git a/0327-kern-ieee1275-init-Extended-support-in-Vec5.patch b/0327-kern-ieee1275-init-Extended-support-in-Vec5.patch deleted file mode 100644 index b8b481f..0000000 --- a/0327-kern-ieee1275-init-Extended-support-in-Vec5.patch +++ /dev/null @@ -1,127 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Avnish Chouhan -Date: Mon, 27 Mar 2023 12:25:40 +0530 -Subject: [PATCH] kern/ieee1275/init: Extended support in Vec5 -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This patch enables multiple options in Vec5 which are required and -solves the boot issues seen on some machines which are looking for -these specific options. - -1. LPAR: Client program supports logical partitioning and - associated hcall()s. -2. SPLPAR: Client program supports the Shared - Processor LPAR Option. -3. DYN_RCON_MEM: Client program supports the - “ibm,dynamic-reconfiguration-memory” property and it may be - presented in the device tree. -4. LARGE_PAGES: Client supports pages larger than 4 KB. -5. DONATE_DCPU_CLS: Client supports donating dedicated processor cycles. -6. PCI_EXP: Client supports PCI Express implementations - utilizing Message Signaled Interrupts (MSIs). - -7. CMOC: Enables the Cooperative Memory Over-commitment Option. -8. EXT_CMO: Enables the Extended Cooperative Memory Over-commit Option. - -9. ASSOC_REF: Enables “ibm,associativity” and - “ibm,associativity-reference-points” properties. -10. AFFINITY: Enables Platform Resource Reassignment Notification. -11. NUMA: Supports NUMA Distance Lookup Table Option. - -12. HOTPLUG_INTRPT: Supports Hotplug Interrupts. -13. HPT_RESIZE: Enable Hash Page Table Resize Option. - -14. MAX_CPU: Defines maximum number of CPUs supported. - -15. PFO_HWRNG: Supports Random Number Generator. -16. PFO_HW_COMP: Supports Compression Engine. -17. PFO_ENCRYPT: Supports Encryption Engine. - -18. SUB_PROCESSORS: Supports Sub-Processors. - -19. DY_MEM_V2: Client program supports the “ibm,dynamic-memory-v2” property in the - “ibm,dynamic-reconfiguration-memory” node and it may be presented in the device tree. -20. DRC_INFO: Client program supports the “ibm,drc-info” property definition and it may be - presented in the device tree. - -Signed-off-by: Avnish Chouhan -Reviewed-by: Daniel Kiper -(cherry picked from commit 98d0df0351fbff7a4acc64c7594d538889a43e2d) ---- - grub-core/kern/ieee1275/init.c | 47 ++++++++++++++++++++++++++++++++++++------ - 1 file changed, 41 insertions(+), 6 deletions(-) - -diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 5d79580341..3d4ad9d1f1 100644 ---- a/grub-core/kern/ieee1275/init.c -+++ b/grub-core/kern/ieee1275/init.c -@@ -72,11 +72,41 @@ extern char _end[]; - grub_addr_t grub_ieee1275_original_stack; - #endif - --#define LPAR 0x80 --#define SPLPAR 0x40 --#define BYTE2 (LPAR | SPLPAR) --#define CMO 0x80 --#define MAX_CPU 256 -+/* Options vector5 properties. */ -+ -+#define LPAR 0x80 -+#define SPLPAR 0x40 -+#define DYN_RCON_MEM 0x20 -+#define LARGE_PAGES 0x10 -+#define DONATE_DCPU_CLS 0x02 -+#define PCI_EXP 0x01 -+#define BYTE2 (LPAR | SPLPAR | DYN_RCON_MEM | LARGE_PAGES | DONATE_DCPU_CLS | PCI_EXP) -+ -+#define CMOC 0x80 -+#define EXT_CMO 0x40 -+#define CMO (CMOC | EXT_CMO) -+ -+#define ASSOC_REF 0x80 -+#define AFFINITY 0x40 -+#define NUMA 0x20 -+#define ASSOCIATIVITY (ASSOC_REF | AFFINITY | NUMA) -+ -+#define HOTPLUG_INTRPT 0x04 -+#define HPT_RESIZE 0x01 -+#define BIN_OPTS (HOTPLUG_INTRPT | HPT_RESIZE) -+ -+#define MAX_CPU 256 -+ -+#define PFO_HWRNG 0x80000000 -+#define PFO_HW_COMP 0x40000000 -+#define PFO_ENCRYPT 0x20000000 -+#define PLATFORM_FACILITIES (PFO_HWRNG | PFO_HW_COMP | PFO_ENCRYPT) -+ -+#define SUB_PROCESSORS 1 -+ -+#define DY_MEM_V2 0x80 -+#define DRC_INFO 0x40 -+#define BYTE22 (DY_MEM_V2 | DRC_INFO) - - void - grub_exit (int rc __attribute__((unused))) -@@ -519,6 +549,11 @@ struct option_vector5 - grub_uint8_t micro_checkpoint; - grub_uint8_t reserved0; - grub_uint32_t max_cpus; -+ grub_uint16_t base_papr; -+ grub_uint16_t mem_reference; -+ grub_uint32_t platform_facilities; -+ grub_uint8_t sub_processors; -+ grub_uint8_t byte22; - } GRUB_PACKED; - - struct pvr_entry -@@ -581,7 +616,7 @@ grub_ieee1275_ibm_cas (void) - .vec4 = 0x0001, /* set required minimum capacity % to the lowest value */ - .vec5_size = 1 + sizeof (struct option_vector5) - 2, - .vec5 = { -- 0, BYTE2, 0, CMO, 0, 0, 0, 0, MAX_CPU -+ 0, BYTE2, 0, CMO, ASSOCIATIVITY, BIN_OPTS, 0, 0, MAX_CPU, 0, 0, PLATFORM_FACILITIES, SUB_PROCESSORS, BYTE22 - } - }; - diff --git a/0328-tpm-Disable-the-tpm-verifier-if-the-TPM-device-is-no.patch b/0328-tpm-Disable-the-tpm-verifier-if-the-TPM-device-is-no.patch deleted file mode 100644 index 9c2522c..0000000 --- a/0328-tpm-Disable-the-tpm-verifier-if-the-TPM-device-is-no.patch +++ /dev/null @@ -1,156 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Michael Chang -Date: Wed, 22 Mar 2023 12:25:43 +0800 -Subject: [PATCH] tpm: Disable the tpm verifier if the TPM device is not - present - -When the tpm module is loaded, the verifier reads entire file into -memory, measures it and uses verified content as a backing buffer for -file accesses. However, this process may result in high memory -utilization for file operations, sometimes causing a system to run out -of memory which may finally lead to boot failure. To address this issue, -among others, the commit 887f98f0d (mm: Allow dynamically requesting -additional memory regions) have optimized memory management by -dynamically allocating heap space to maximize memory usage and reduce -threat of memory exhaustion. But in some cases problems may still arise, -e.g., when large ISO images are mounted using loopback or when dealing -with embedded systems with limited memory resources. - -Unfortunately current implementation of the tpm module doesn't allow -elimination of the back buffer once it is loaded. Even if the TPM device -is not present or it has been explicitly disabled. This may unnecessary -allocate a lot memory. To solve this issue, a patch has been developed -to detect the TPM status at module load and skip verifier registration -if the device is missing or deactivated. This prevents allocation of -memory for the back buffer, avoiding wasting memory when no real measure -boot functionality is performed. Disabling the TPM device in the system -can reduce memory usage in the GRUB. It is useful in scenarios where -high memory utilization is a concern and measurements of loaded -artifacts are not necessary. - -Signed-off-by: Michael Chang -Signed-off-by: Stefan Berger -Reviewed-by: Daniel Kiper -(cherry picked from commit 30708dfe3bebd62a5487437554da8a24253f519f) ---- - grub-core/commands/efi/tpm.c | 37 +++++++++++++++++++++++++++++++++++ - grub-core/commands/ieee1275/ibmvtpm.c | 20 +++++++++---------- - grub-core/commands/tpm.c | 10 ++++++++++ - include/grub/tpm.h | 1 + - 4 files changed, 58 insertions(+), 10 deletions(-) - -diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c -index ae09c1bf8b..e1f343fea3 100644 ---- a/grub-core/commands/efi/tpm.c -+++ b/grub-core/commands/efi/tpm.c -@@ -287,3 +287,40 @@ grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, - else - return grub_tpm2_log_event (tpm_handle, buf, size, pcr, description); - } -+ -+int -+grub_tpm_present (void) -+{ -+ 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) -+ { -+ grub_efi_tpm_protocol_t *tpm; -+ -+ tpm = grub_efi_open_protocol (tpm_handle, &tpm_guid, -+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); -+ if (!tpm) -+ { -+ grub_dprintf ("tpm", "Cannot open TPM protocol\n"); -+ return 0; -+ } -+ return grub_tpm1_present (tpm); -+ } -+ else -+ { -+ grub_efi_tpm2_protocol_t *tpm; -+ -+ tpm = grub_efi_open_protocol (tpm_handle, &tpm2_guid, -+ GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); -+ if (!tpm) -+ { -+ grub_dprintf ("tpm", "Cannot open TPM protocol\n"); -+ return 0; -+ } -+ return grub_tpm2_present (tpm); -+ } -+} -diff --git a/grub-core/commands/ieee1275/ibmvtpm.c b/grub-core/commands/ieee1275/ibmvtpm.c -index 239942d27e..a6fee5c516 100644 ---- a/grub-core/commands/ieee1275/ibmvtpm.c -+++ b/grub-core/commands/ieee1275/ibmvtpm.c -@@ -135,16 +135,6 @@ grub_err_t - grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, - const char *description) - { -- /* -- * Call tpm_init() 'late' rather than from GRUB_MOD_INIT() so that device nodes -- * can be found. -- */ -- grub_err_t err = tpm_init (); -- -- /* Absence of a TPM isn't a failure. */ -- if (err != GRUB_ERR_NONE) -- return GRUB_ERR_NONE; -- - grub_dprintf ("tpm", "log_event, pcr = %d, size = 0x%" PRIxGRUB_SIZE ", %s\n", - pcr, size, description); - -@@ -153,3 +143,13 @@ grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr, - - return GRUB_ERR_NONE; - } -+ -+int -+grub_tpm_present (void) -+{ -+ /* -+ * Call tpm_init() "late" rather than from GRUB_MOD_INIT() so that device nodes -+ * can be found. -+ */ -+ return tpm_init() == GRUB_ERR_NONE; -+} -diff --git a/grub-core/commands/tpm.c b/grub-core/commands/tpm.c -index e287d042e6..5839053d3d 100644 ---- a/grub-core/commands/tpm.c -+++ b/grub-core/commands/tpm.c -@@ -86,10 +86,20 @@ struct grub_file_verifier grub_tpm_verifier = { - - GRUB_MOD_INIT (tpm) - { -+ /* -+ * Even though this now calls ibmvtpm's grub_tpm_present() from GRUB_MOD_INIT(), -+ * it does seem to call it late enough in the initialization sequence so -+ * that whatever discovered "device nodes" before this GRUB_MOD_INIT() is -+ * called, enables the ibmvtpm driver to see the device nodes. -+ */ -+ if (!grub_tpm_present()) -+ return; - grub_verifier_register (&grub_tpm_verifier); - } - - GRUB_MOD_FINI (tpm) - { -+ if (!grub_tpm_present()) -+ return; - grub_verifier_unregister (&grub_tpm_verifier); - } -diff --git a/include/grub/tpm.h b/include/grub/tpm.h -index 5c285cbc52..c19fcbd0a6 100644 ---- a/include/grub/tpm.h -+++ b/include/grub/tpm.h -@@ -36,4 +36,5 @@ - - grub_err_t grub_tpm_measure (unsigned char *buf, grub_size_t size, - grub_uint8_t pcr, const char *description); -+int grub_tpm_present (void); - #endif diff --git a/0338-kern-ieee1275-init-ppc64-Restrict-high-memory-in-pre.patch b/0338-kern-ieee1275-init-ppc64-Restrict-high-memory-in-pre.patch deleted file mode 100644 index 5c7e1a3..0000000 --- a/0338-kern-ieee1275-init-ppc64-Restrict-high-memory-in-pre.patch +++ /dev/null @@ -1,226 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Stefan Berger -Date: Tue, 25 Jul 2023 13:23:10 -0400 -Subject: [PATCH] kern/ieee1275/init: ppc64: Restrict high memory in presence - of fadump - -When a kernel dump is present then restrict the high memory regions to -avoid allocating memory where the kernel dump resides. Use the -ibm,kernel-dump node under /rtas to determine whether a kernel dump exists -and up to which limit grub can use available memory. Set the -upper_mem_limit to the size of the kernel dump section of type -'REAL_MODE_REGION' and therefore only allow grub's memory usage for high -addresses from RMO_ADDR_MAX to 'upper_mem_limit'. This means that grub can -use high memory in the range of RMO_ADDR_MAX (768MB) to upper_mem_limit and -the kernel-dump memory regions above 'upper_mem_limit' remain untouched. -This change has no effect on memory allocations below 'linux_rmo_save' -(typically at 640MB). - -Also, fall back to allocating below rmo_linux_save in case the chunk of -memory there would be larger than the chunk of memory above RMO_ADDR_MAX. -This can for example occur if a free memory area is found starting at 300MB -extending up to 1GB but a kernel dump is located at 768MB and therefore -does not allow the allocation of the high memory area but requiring to use -the chunk starting at 300MB to avoid an unnecessary out-of-memory -condition. - -Signed-off-by: Stefan Berger -Reviewed-by: Hari Bathini -Cc: Pavithra Prakash -Cc: Michael Ellerman -Cc: Carolyn Scherrer -Cc: Mahesh Salgaonkar -Cc: Sourabh Jain ---- - grub-core/kern/ieee1275/init.c | 144 ++++++++++++++++++++++++++++++++++++++++- - 1 file changed, 142 insertions(+), 2 deletions(-) - -diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c -index 3d4ad9d1f162..8e7f742fad46 100644 ---- a/grub-core/kern/ieee1275/init.c -+++ b/grub-core/kern/ieee1275/init.c -@@ -17,6 +17,8 @@ - * along with GRUB. If not, see . - */ - -+#include /* offsetof() */ -+ - #include - #include - #include -@@ -198,6 +200,96 @@ grub_claim_heap (void) - #else - /* Helpers for mm on powerpc. */ - -+/* ibm,kernel-dump data structures */ -+struct kd_section -+{ -+ grub_uint32_t flags; -+ grub_uint16_t src_datatype; -+#define KD_SRC_DATATYPE_REAL_MODE_REGION 0x0011 -+ grub_uint16_t error_flags; -+ grub_uint64_t src_address; -+ grub_uint64_t num_bytes; -+ grub_uint64_t act_bytes; -+ grub_uint64_t dst_address; -+} GRUB_PACKED; -+ -+#define MAX_KD_SECTIONS 10 -+ -+struct kernel_dump -+{ -+ grub_uint32_t format; -+ grub_uint16_t num_sections; -+ grub_uint16_t status_flags; -+ grub_uint32_t offset_1st_section; -+ grub_uint32_t num_blocks; -+ grub_uint64_t start_block; -+ grub_uint64_t num_blocks_avail; -+ grub_uint32_t offet_path_string; -+ grub_uint32_t max_time_allowed; -+ struct kd_section kds[MAX_KD_SECTIONS]; /* offset_1st_section should point to kds[0] */ -+} GRUB_PACKED; -+ -+/* -+ * Determine if a kernel dump exists and if it does, then determine the highest -+ * address that grub can use for memory allocations. -+ * The caller must have initialized *highest to rmo_top. *highest will not -+ * be modified if no kernel dump is found. -+ */ -+static void -+check_kernel_dump (grub_uint64_t *highest) -+{ -+ struct kernel_dump kernel_dump; -+ grub_ssize_t kernel_dump_size; -+ grub_ieee1275_phandle_t rtas; -+ struct kd_section *kds; -+ grub_size_t i; -+ -+ /* If there's a kernel-dump it must have at least one section */ -+ if (grub_ieee1275_finddevice ("/rtas", &rtas) || -+ grub_ieee1275_get_property (rtas, "ibm,kernel-dump", &kernel_dump, -+ sizeof (kernel_dump), &kernel_dump_size) || -+ kernel_dump_size <= (grub_ssize_t) offsetof (struct kernel_dump, kds[1])) -+ return; -+ -+ kernel_dump_size = grub_min (kernel_dump_size, (grub_ssize_t) sizeof (kernel_dump)); -+ -+ if (grub_be_to_cpu32 (kernel_dump.format) != 1) -+ { -+ grub_printf (_("Error: ibm,kernel-dump has an unexpected format version '%u'\n"), -+ grub_be_to_cpu32 (kernel_dump.format)); -+ return; -+ } -+ -+ if (grub_be_to_cpu16 (kernel_dump.num_sections) > MAX_KD_SECTIONS) -+ { -+ grub_printf (_("Error: Too many kernel dump sections: %d\n"), -+ grub_be_to_cpu32 (kernel_dump.num_sections)); -+ return; -+ } -+ -+ for (i = 0; i < grub_be_to_cpu16 (kernel_dump.num_sections); i++) -+ { -+ kds = (struct kd_section *) ((grub_addr_t) &kernel_dump + -+ grub_be_to_cpu32 (kernel_dump.offset_1st_section) + -+ i * sizeof (struct kd_section)); -+ /* sanity check the address is within the 'kernel_dump' struct */ -+ if ((grub_addr_t) kds > (grub_addr_t) &kernel_dump + kernel_dump_size + sizeof (*kds)) -+ { -+ grub_printf (_("Error: 'kds' address beyond last available section\n")); -+ return; -+ } -+ -+ if ((grub_be_to_cpu16 (kds->src_datatype) == KD_SRC_DATATYPE_REAL_MODE_REGION) && -+ (grub_be_to_cpu64 (kds->src_address) == 0)) -+ { -+ *highest = grub_min (*highest, grub_be_to_cpu64 (kds->num_bytes)); -+ break; -+ } -+ } -+ -+ return; -+} -+ - /* - * How much memory does OF believe exists in total? - * -@@ -277,10 +369,31 @@ regions_claim (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, - * - * Finally, we also want to make sure that when grub loads the kernel, - * it isn't going to use up all the memory we're trying to reserve! So -- * enforce our entire RUNTIME_MIN_SPACE here: -+ * enforce our entire RUNTIME_MIN_SPACE here (no fadump): -+ * -+ * | Top of memory == upper_mem_limit -| -+ * | | -+ * | available | -+ * | | -+ * |---------- 768 MB ----------| -+ * | | -+ * | reserved | -+ * | | -+ * |--- 768 MB - runtime min space ---| -+ * | | -+ * | available | -+ * | | -+ * |---------- 0 MB ----------| -+ * -+ * In case fadump is used, we allow the following: - * - * |---------- Top of memory ----------| - * | | -+ * | unavailable | -+ * | (kernel dump area) | -+ * | | -+ * |--------- upper_mem_limit ---------| -+ * | | - * | available | - * | | - * |---------- 768 MB ----------| -@@ -335,17 +448,44 @@ regions_claim (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, - } - else - { -+ grub_uint64_t upper_mem_limit = rmo_top; -+ grub_uint64_t orig_addr = addr; -+ -+ check_kernel_dump (&upper_mem_limit); -+ - /* - * we order these cases to prefer higher addresses and avoid some - * splitting issues -+ * The following shows the order of variables: -+ * no kernel dump: linux_rmo_save < RMO_ADDR_MAX <= upper_mem_limit == rmo_top -+ * with kernel dump: liuxx_rmo_save < RMO_ADDR_MAX <= upper_mem_limit <= rmo_top - */ -- if (addr < RMO_ADDR_MAX && (addr + len) > RMO_ADDR_MAX) -+ if (addr < RMO_ADDR_MAX && (addr + len) > RMO_ADDR_MAX && upper_mem_limit >= RMO_ADDR_MAX) - { - grub_dprintf ("ieee1275", - "adjusting region for RUNTIME_MIN_SPACE: (%llx -> %llx) -> (%llx -> %llx)\n", - addr, addr + len, RMO_ADDR_MAX, addr + len); - len = (addr + len) - RMO_ADDR_MAX; - addr = RMO_ADDR_MAX; -+ -+ /* We must not exceed the upper_mem_limit (assuming it's >= RMO_ADDR_MAX) */ -+ if (addr + len > upper_mem_limit) -+ { -+ /* take the bigger chunk from either below linux_rmo_save or above upper_mem_limit */ -+ len = upper_mem_limit - addr; -+ if (orig_addr < linux_rmo_save && linux_rmo_save - orig_addr > len) -+ { -+ /* lower part is bigger */ -+ addr = orig_addr; -+ len = linux_rmo_save - addr; -+ } -+ -+ grub_dprintf ("ieee1275", "re-adjusted region to: (%llx -> %llx)\n", -+ addr, addr + len); -+ -+ if (len == 0) -+ return 0; -+ } - } - else if ((addr < linux_rmo_save) && ((addr + len) > linux_rmo_save)) - { diff --git a/0341-fs-Remove-trailing-whitespaces.patch b/0341-fs-Remove-trailing-whitespaces.patch deleted file mode 100644 index a876f6b..0000000 --- a/0341-fs-Remove-trailing-whitespaces.patch +++ /dev/null @@ -1,1681 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Elyes Haouas -Date: Fri, 4 Mar 2022 07:41:59 +0100 -Subject: [PATCH] fs: Remove trailing whitespaces - -Signed-off-by: Elyes Haouas -Reviewed-by: Daniel Kiper ---- - grub-core/fs/affs.c | 4 +- - grub-core/fs/archelp.c | 4 +- - grub-core/fs/bfs.c | 10 +- - grub-core/fs/cpio_common.c | 2 +- - grub-core/fs/fat.c | 6 +- - grub-core/fs/fshelp.c | 6 +- - grub-core/fs/hfs.c | 14 +-- - grub-core/fs/hfsplus.c | 8 +- - grub-core/fs/hfspluscomp.c | 6 +- - grub-core/fs/iso9660.c | 12 +-- - grub-core/fs/minix.c | 6 +- - grub-core/fs/nilfs2.c | 8 +- - grub-core/fs/ntfs.c | 8 +- - grub-core/fs/reiserfs.c | 2 +- - grub-core/fs/romfs.c | 8 +- - grub-core/fs/squash4.c | 26 ++--- - grub-core/fs/udf.c | 2 +- - grub-core/fs/ufs.c | 4 +- - grub-core/fs/xfs.c | 2 +- - grub-core/fs/zfs/zfs.c | 224 ++++++++++++++++++++-------------------- - grub-core/fs/zfs/zfs_fletcher.c | 12 +-- - grub-core/fs/zfs/zfs_sha256.c | 14 +-- - grub-core/fs/zfs/zfscrypt.c | 14 +-- - 23 files changed, 201 insertions(+), 201 deletions(-) - -diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c -index cafcd0fba916..0d90e9d1a895 100644 ---- a/grub-core/fs/affs.c -+++ b/grub-core/fs/affs.c -@@ -345,7 +345,7 @@ grub_affs_create_node (grub_fshelp_node_t dir, - if (len > sizeof (fil->name)) - len = sizeof (fil->name); - *grub_latin1_to_utf8 (name_u8, fil->name, len) = '\0'; -- -+ - (*node)->di = *fil; - for (nest = 0; nest < 8; nest++) - { -@@ -408,7 +408,7 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir, - node = orig_node = grub_zalloc (sizeof (*node)); - if (!node) - return 1; -- -+ - *node = *dir; - if (hook (".", GRUB_FSHELP_DIR, node, hook_data)) - return 1; -diff --git a/grub-core/fs/archelp.c b/grub-core/fs/archelp.c -index 0cf544f6fdfe..998de88b865c 100644 ---- a/grub-core/fs/archelp.c -+++ b/grub-core/fs/archelp.c -@@ -75,7 +75,7 @@ handle_symlink (struct grub_archelp_data *data, - || !arcops->get_link_target) - return GRUB_ERR_NONE; - flen = grub_strlen (fn); -- if (grub_memcmp (*name, fn, flen) != 0 -+ if (grub_memcmp (*name, fn, flen) != 0 - || ((*name)[flen] != 0 && (*name)[flen] != '/')) - return GRUB_ERR_NONE; - rest = *name + flen; -@@ -251,7 +251,7 @@ grub_archelp_open (struct grub_archelp_data *data, - grub_uint32_t mode; - grub_int32_t mtime; - int restart; -- -+ - if (arcops->find_file (data, &fn, &mtime, &mode)) - goto fail; - -diff --git a/grub-core/fs/bfs.c b/grub-core/fs/bfs.c -index 47dbe2011a14..a75876010d30 100644 ---- a/grub-core/fs/bfs.c -+++ b/grub-core/fs/bfs.c -@@ -530,13 +530,13 @@ iterate_in_b_tree (grub_disk_t disk, - err = read_b_node (disk, sb, ino, - node_off, - &node, -- &key_data, -+ &key_data, - &keylen_idx, - &key_values); - - if (err) - return 0; -- -+ - for (i = 0; i < grub_bfs_to_cpu_treehead (node->count_keys); i++) - { - char c; -@@ -682,7 +682,7 @@ find_in_b_tree (grub_disk_t disk, - level--; - grub_free (node); - continue; -- } -+ } - } - else if (level != 0 - && i + 1 < grub_bfs_to_cpu_treehead (node->count_keys)) -@@ -827,7 +827,7 @@ mount (grub_disk_t disk, struct grub_bfs_superblock *sb) - grub_err_t err; - err = grub_disk_read (disk, SUPERBLOCK, 0, sizeof (*sb), sb); - if (err == GRUB_ERR_OUT_OF_RANGE) -- return grub_error (GRUB_ERR_BAD_FS, -+ return grub_error (GRUB_ERR_BAD_FS, - #ifdef MODE_AFS - "not an AFS filesystem" - #else -@@ -843,7 +843,7 @@ mount (grub_disk_t disk, struct grub_bfs_superblock *sb) - || (grub_bfs_to_cpu32 (sb->bsize) - != (1U << grub_bfs_to_cpu32 (sb->log2_bsize))) - || grub_bfs_to_cpu32 (sb->log2_bsize) < GRUB_DISK_SECTOR_BITS) -- return grub_error (GRUB_ERR_BAD_FS, -+ return grub_error (GRUB_ERR_BAD_FS, - #ifdef MODE_AFS - "not an AFS filesystem" - #else -diff --git a/grub-core/fs/cpio_common.c b/grub-core/fs/cpio_common.c -index 4e885d62313e..5d41b6fdbe1c 100644 ---- a/grub-core/fs/cpio_common.c -+++ b/grub-core/fs/cpio_common.c -@@ -117,7 +117,7 @@ grub_cpio_get_link_target (struct grub_archelp_data *data) - if (!ret) - return NULL; - -- err = grub_disk_read (data->disk, 0, data->dofs, data->size, -+ err = grub_disk_read (data->disk, 0, data->dofs, data->size, - ret); - if (err) - { -diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c -index ff6200c5be5d..c5efed724124 100644 ---- a/grub-core/fs/fat.c -+++ b/grub-core/fs/fat.c -@@ -246,7 +246,7 @@ grub_fat_mount (grub_disk_t disk) - #ifdef MODE_EXFAT - if (grub_memcmp ((const char *) bpb.oem_name, "EXFAT ", - sizeof (bpb.oem_name)) != 0) -- goto fail; -+ goto fail; - #endif - - /* Get the sizes of logical sectors and clusters. */ -@@ -321,7 +321,7 @@ grub_fat_mount (grub_disk_t disk) - #endif - - #ifdef MODE_EXFAT -- data->cluster_sector = (grub_le_to_cpu32 (bpb.cluster_offset) -+ data->cluster_sector = (grub_le_to_cpu32 (bpb.cluster_offset) - << data->logical_sector_bits); - data->num_clusters = (grub_le_to_cpu32 (bpb.cluster_count) - << data->logical_sector_bits); -@@ -694,7 +694,7 @@ grub_fat_iterate_dir_next (grub_fshelp_node_t node, - { - int j; - for (j = 0; j < 15; j++) -- ctxt->unibuf[slots * 15 + j] -+ ctxt->unibuf[slots * 15 + j] - = grub_le_to_cpu16 (sec.type_specific.file_name.str[j]); - slots++; - } -diff --git a/grub-core/fs/fshelp.c b/grub-core/fs/fshelp.c -index a2d0d297a520..cb41934b4fec 100644 ---- a/grub-core/fs/fshelp.c -+++ b/grub-core/fs/fshelp.c -@@ -215,7 +215,7 @@ find_file (char *currpath, - break; - - push_node (ctx, foundnode, foundtype); -- -+ - /* Read in the symlink and follow it. */ - if (ctx->currnode->type == GRUB_FSHELP_SYMLINK) - { -@@ -326,7 +326,7 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode, - enum grub_fshelp_filetype expecttype) - { - return grub_fshelp_find_file_real (path, rootnode, foundnode, -- iterate_dir, NULL, -+ iterate_dir, NULL, - read_symlink, expecttype); - - } -@@ -339,7 +339,7 @@ grub_fshelp_find_file_lookup (const char *path, grub_fshelp_node_t rootnode, - enum grub_fshelp_filetype expecttype) - { - return grub_fshelp_find_file_real (path, rootnode, foundnode, -- NULL, lookup_file, -+ NULL, lookup_file, - read_symlink, expecttype); - - } -diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c -index f419965d154f..91dc0e69c3de 100644 ---- a/grub-core/fs/hfs.c -+++ b/grub-core/fs/hfs.c -@@ -883,7 +883,7 @@ grub_hfs_iterate_dir_it_dir (struct grub_hfs_node *hnd __attribute ((unused)), - { - struct grub_hfs_catalog_key *ckey = rec->key; - struct grub_hfs_iterate_dir_node_found_ctx *ctx = hook_arg; -- -+ - /* Stop when the entries do not match anymore. */ - if (ckey->parent_dir != ctx->dir_be) - return 1; -@@ -1077,7 +1077,7 @@ macroman_to_utf8 (char *to, const grub_uint8_t *from, grub_size_t len, - { - *optr++ = ':'; - continue; -- } -+ } - if (!(*iptr & 0x80)) - { - *optr++ = *iptr; -@@ -1094,7 +1094,7 @@ utf8_to_macroman (grub_uint8_t *to, const char *from) - grub_uint8_t *end = to + 31; - grub_uint8_t *optr = to; - const char *iptr = from; -- -+ - while (*iptr && optr < end) - { - int i, clen; -@@ -1104,7 +1104,7 @@ utf8_to_macroman (grub_uint8_t *to, const char *from) - *optr++ = '/'; - iptr++; - continue; -- } -+ } - if (!(*iptr & 0x80)) - { - *optr++ = *iptr++; -@@ -1165,7 +1165,7 @@ lookup_file (grub_fshelp_node_t dir, - *foundnode = grub_malloc (sizeof (struct grub_fshelp_node)); - if (!*foundnode) - return grub_errno; -- -+ - (*foundnode)->inode = grub_be_to_cpu32 (fdrec.dir.dirid); - (*foundnode)->fdrec = fdrec; - (*foundnode)->data = dir->data; -@@ -1266,7 +1266,7 @@ grub_hfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook, - .hook_data = hook_data - }; - grub_fshelp_node_t found = NULL; -- -+ - grub_dl_ref (my_mod); - - data = grub_hfs_mount (device->disk); -@@ -1295,7 +1295,7 @@ grub_hfs_open (struct grub_file *file, const char *name) - { - struct grub_hfs_data *data; - grub_fshelp_node_t found = NULL; -- -+ - grub_dl_ref (my_mod); - - data = grub_hfs_mount (file->device->disk); -diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c -index 19c7b3367987..6337cbfcbec6 100644 ---- a/grub-core/fs/hfsplus.c -+++ b/grub-core/fs/hfsplus.c -@@ -19,7 +19,7 @@ - - /* HFS+ is documented at http://developer.apple.com/technotes/tn/tn1150.html */ - --#define grub_fshelp_node grub_hfsplus_file -+#define grub_fshelp_node grub_hfsplus_file - #include - #include - #include -@@ -146,7 +146,7 @@ grub_hfsplus_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) - { - struct grub_hfsplus_btnode *nnode = 0; - grub_disk_addr_t blksleft = fileblock; -- struct grub_hfsplus_extent *extents = node->compressed -+ struct grub_hfsplus_extent *extents = node->compressed - ? &node->resource_extents[0] : &node->extents[0]; - - while (1) -@@ -477,7 +477,7 @@ grub_hfsplus_cmp_extkey (struct grub_hfsplus_key *keya, - - if (extkey_a->type < extkey_b->type) - return -1; -- -+ - akey = grub_be_to_cpu32 (extkey_a->start); - if (akey > extkey_b->start) - return 1; -@@ -568,7 +568,7 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree, - struct grub_hfsplus_key_internal *key, - int (*compare_keys) (struct grub_hfsplus_key *keya, - struct grub_hfsplus_key_internal *keyb), -- struct grub_hfsplus_btnode **matchnode, -+ struct grub_hfsplus_btnode **matchnode, - grub_off_t *keyoffset) - { - grub_uint64_t currnode; -diff --git a/grub-core/fs/hfspluscomp.c b/grub-core/fs/hfspluscomp.c -index d76f3f137a92..095ea48c9a62 100644 ---- a/grub-core/fs/hfspluscomp.c -+++ b/grub-core/fs/hfspluscomp.c -@@ -179,7 +179,7 @@ hfsplus_read_compressed_real (struct grub_hfsplus_file *node, - return len0; - } - --static grub_err_t -+static grub_err_t - hfsplus_open_compressed_real (struct grub_hfsplus_file *node) - { - grub_err_t err; -@@ -306,8 +306,8 @@ hfsplus_open_compressed_real (struct grub_hfsplus_file *node) - - GRUB_MOD_INIT(hfspluscomp) - { -- grub_hfsplus_open_compressed = hfsplus_open_compressed_real; -- grub_hfsplus_read_compressed = hfsplus_read_compressed_real; -+ grub_hfsplus_open_compressed = hfsplus_open_compressed_real; -+ grub_hfsplus_read_compressed = hfsplus_read_compressed_real; - } - - GRUB_MOD_FINI(hfspluscomp) -diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c -index ac011950a64f..91817ec1f5ad 100644 ---- a/grub-core/fs/iso9660.c -+++ b/grub-core/fs/iso9660.c -@@ -181,7 +181,7 @@ static grub_err_t - iso9660_to_unixtime (const struct grub_iso9660_date *i, grub_int64_t *nix) - { - struct grub_datetime datetime; -- -+ - if (! i->year[0] && ! i->year[1] - && ! i->year[2] && ! i->year[3] - && ! i->month[0] && ! i->month[1] -@@ -198,7 +198,7 @@ iso9660_to_unixtime (const struct grub_iso9660_date *i, grub_int64_t *nix) - datetime.hour = (i->hour[0] - '0') * 10 + (i->hour[1] - '0'); - datetime.minute = (i->minute[0] - '0') * 10 + (i->minute[1] - '0'); - datetime.second = (i->second[0] - '0') * 10 + (i->second[1] - '0'); -- -+ - if (!grub_datetime2unixtime (&datetime, nix)) - return grub_error (GRUB_ERR_BAD_NUMBER, "incorrect date"); - *nix -= i->offset * 60 * 15; -@@ -216,7 +216,7 @@ iso9660_to_unixtime2 (const struct grub_iso9660_date2 *i, grub_int64_t *nix) - datetime.hour = i->hour; - datetime.minute = i->minute; - datetime.second = i->second; -- -+ - if (!grub_datetime2unixtime (&datetime, nix)) - return 0; - *nix -= i->offset * 60 * 15; -@@ -499,7 +499,7 @@ grub_iso9660_mount (grub_disk_t disk) - static char * - grub_iso9660_read_symlink (grub_fshelp_node_t node) - { -- return node->have_symlink -+ return node->have_symlink - ? grub_strdup (node->symlink - + (node->have_dirents) * sizeof (node->dirents[0]) - - sizeof (node->dirents)) : grub_strdup (""); -@@ -549,7 +549,7 @@ add_part (struct iterate_dir_ctx *ctx, - ctx->symlink = new; - - grub_memcpy (ctx->symlink + size, part, len2); -- ctx->symlink[size + len2] = 0; -+ ctx->symlink[size + len2] = 0; - } - - static grub_err_t -@@ -1106,7 +1106,7 @@ grub_iso9660_uuid (grub_device_t device, char **uuid) - } - - /* Get writing time of filesystem. */ --static grub_err_t -+static grub_err_t - grub_iso9660_mtime (grub_device_t device, grub_int64_t *timebuf) - { - struct grub_iso9660_data *data; -diff --git a/grub-core/fs/minix.c b/grub-core/fs/minix.c -index 3cd18c85b302..953df11916b8 100644 ---- a/grub-core/fs/minix.c -+++ b/grub-core/fs/minix.c -@@ -98,10 +98,10 @@ struct grub_minix_sblock - grub_uint32_t max_file_size; - grub_uint32_t zones; - grub_uint16_t magic; -- -+ - grub_uint16_t pad2; - grub_uint16_t block_size; -- grub_uint8_t disk_version; -+ grub_uint8_t disk_version; - }; - #else - struct grub_minix_sblock -@@ -351,7 +351,7 @@ grub_minix_read_inode (struct grub_minix_data *data, grub_minix_ino_t ino) - int offs = (ino % (GRUB_DISK_SECTOR_SIZE - / sizeof (struct grub_minix_inode)) - * sizeof (struct grub_minix_inode)); -- -+ - grub_disk_read (data->disk, block, offs, - sizeof (struct grub_minix_inode), &data->inode); - -diff --git a/grub-core/fs/nilfs2.c b/grub-core/fs/nilfs2.c -index 3c248a910b42..fc7374ead490 100644 ---- a/grub-core/fs/nilfs2.c -+++ b/grub-core/fs/nilfs2.c -@@ -1,5 +1,5 @@ --/* -- * nilfs2.c - New Implementation of Log filesystem -+/* -+ * nilfs2.c - New Implementation of Log filesystem - * - * Written by Jiro SEKIBA - * -@@ -680,12 +680,12 @@ grub_nilfs2_read_checkpoint (struct grub_nilfs2_data *data, - grub_disk_t disk = data->disk; - unsigned int nilfs2_block_count = (1 << LOG2_NILFS2_BLOCK_SIZE (data)); - -- /* Assume sizeof(struct grub_nilfs2_cpfile_header) < -+ /* Assume sizeof(struct grub_nilfs2_cpfile_header) < - sizeof(struct grub_nilfs2_checkpoint). - */ - blockno = grub_divmod64 (cpno, NILFS2_BLOCK_SIZE (data) / - sizeof (struct grub_nilfs2_checkpoint), &offset); -- -+ - pptr = grub_nilfs2_bmap_lookup (data, &data->sroot.sr_cpfile, blockno, 1); - if (pptr == (grub_uint64_t) - 1) - { -diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c -index 2f34f76da88c..3511e4e2cb6f 100644 ---- a/grub-core/fs/ntfs.c -+++ b/grub-core/fs/ntfs.c -@@ -17,7 +17,7 @@ - * along with this program. If not, see . - */ - --#define grub_fshelp_node grub_ntfs_file -+#define grub_fshelp_node grub_ntfs_file - - #include - #include -@@ -32,7 +32,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); - - static grub_dl_t my_mod; - --#define grub_fshelp_node grub_ntfs_file -+#define grub_fshelp_node grub_ntfs_file - - static inline grub_uint16_t - u16at (void *ptr, grub_size_t ofs) -@@ -725,7 +725,7 @@ grub_ntfs_read_symlink (grub_fshelp_node_t node) - && grub_isalpha (buf[4])) - { - grub_memmove (buf, buf + 6, end - buf + 1 - 6); -- end -= 6; -+ end -= 6; - } - return buf; - } -@@ -992,7 +992,7 @@ grub_ntfs_dir_iter (const char *filename, enum grub_fshelp_filetype filetype, - grub_memset (&info, 0, sizeof (info)); - info.dir = ((filetype & GRUB_FSHELP_TYPE_MASK) == GRUB_FSHELP_DIR); - info.mtimeset = 1; -- info.mtime = grub_divmod64 (node->mtime, 10000000, 0) -+ info.mtime = grub_divmod64 (node->mtime, 10000000, 0) - - 86400ULL * 365 * (1970 - 1601) - - 86400ULL * ((1970 - 1601) / 4) + 86400ULL * ((1970 - 1601) / 100); - grub_free (node); -diff --git a/grub-core/fs/reiserfs.c b/grub-core/fs/reiserfs.c -index b8253da7fed2..42818c376229 100644 ---- a/grub-core/fs/reiserfs.c -+++ b/grub-core/fs/reiserfs.c -@@ -775,7 +775,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, - char *entry_name; - char *entry_name_end = 0; - char c; -- -+ - if (!(entry_state & GRUB_REISERFS_VISIBLE_MASK)) - continue; - -diff --git a/grub-core/fs/romfs.c b/grub-core/fs/romfs.c -index d97b8fbb8c36..1f7dcfca1d3a 100644 ---- a/grub-core/fs/romfs.c -+++ b/grub-core/fs/romfs.c -@@ -112,7 +112,7 @@ grub_romfs_mount (grub_device_t dev) - { - grub_error (GRUB_ERR_BAD_FS, "not romfs"); - return NULL; -- } -+ } - err = do_checksum (&sb, sizeof (sb) < grub_be_to_cpu32 (sb.sb.total_size) ? - sizeof (sb) : grub_be_to_cpu32 (sb.sb.total_size)); - if (err) -@@ -271,7 +271,7 @@ grub_romfs_iterate_dir (grub_fshelp_node_t dir, - while (1) - { - char buf[16]; -- err = grub_disk_read (dir->data->disk, -+ err = grub_disk_read (dir->data->disk, - laddr >> GRUB_DISK_SECTOR_BITS, - laddr & (GRUB_DISK_SECTOR_SIZE - 1), - 16, buf); -@@ -298,7 +298,7 @@ grub_romfs_iterate_dir (grub_fshelp_node_t dir, - node->data_addr = grub_be_to_cpu32 (node->file.spec); - filetype = GRUB_FSHELP_DIR; - } -- -+ - break; - } - } -@@ -402,7 +402,7 @@ grub_romfs_read (grub_file_t file, char *buf, grub_size_t len) - data->data->disk->read_hook_data = file->read_hook_data; - grub_disk_read (data->data->disk, - (data->data_addr + file->offset) >> GRUB_DISK_SECTOR_BITS, -- (data->data_addr + file->offset) & (GRUB_DISK_SECTOR_SIZE - 1), -+ (data->data_addr + file->offset) & (GRUB_DISK_SECTOR_SIZE - 1), - len, buf); - data->data->disk->read_hook = NULL; - -diff --git a/grub-core/fs/squash4.c b/grub-core/fs/squash4.c -index 6dd731e231ee..02b1f9b6d101 100644 ---- a/grub-core/fs/squash4.c -+++ b/grub-core/fs/squash4.c -@@ -210,7 +210,7 @@ struct grub_fshelp_node - struct grub_squash_data *data; - struct grub_squash_inode ino; - grub_size_t stsize; -- struct -+ struct - { - grub_disk_addr_t ino_chunk; - grub_uint16_t ino_offset; -@@ -243,7 +243,7 @@ read_chunk (struct grub_squash_data *data, void *buf, grub_size_t len, - csize = SQUASH_CHUNK_SIZE - offset; - if (csize > len) - csize = len; -- -+ - if (grub_le_to_cpu16 (d) & SQUASH_CHUNK_UNCOMPRESSED) - { - grub_disk_addr_t a = chunk_start + 2 + offset; -@@ -256,7 +256,7 @@ read_chunk (struct grub_squash_data *data, void *buf, grub_size_t len, - else - { - char *tmp; -- grub_size_t bsize = grub_le_to_cpu16 (d) & ~SQUASH_CHUNK_FLAGS; -+ grub_size_t bsize = grub_le_to_cpu16 (d) & ~SQUASH_CHUNK_FLAGS; - grub_disk_addr_t a = chunk_start + 2; - tmp = grub_malloc (bsize); - if (!tmp) -@@ -339,7 +339,7 @@ xz_decompress (char *inbuf, grub_size_t insize, grub_off_t off, - while (len) - { - enum xz_ret xzret; -- -+ - buf.out_pos = 0; - - xzret = xz_dec_run (data->xzdec, &buf); -@@ -399,9 +399,9 @@ squash_mount (grub_disk_t disk) - return NULL; - } - -- err = grub_disk_read (disk, -+ err = grub_disk_read (disk, - grub_le_to_cpu64 (sb.unk1offset) -- >> GRUB_DISK_SECTOR_BITS, -+ >> GRUB_DISK_SECTOR_BITS, - grub_le_to_cpu64 (sb.unk1offset) - & (GRUB_DISK_SECTOR_SIZE - 1), sizeof (frag), &frag); - if (grub_errno == GRUB_ERR_OUT_OF_RANGE) -@@ -448,7 +448,7 @@ squash_mount (grub_disk_t disk) - } - - data->blksz = grub_le_to_cpu32 (data->sb.block_size); -- for (data->log2_blksz = 0; -+ for (data->log2_blksz = 0; - (1U << data->log2_blksz) < data->blksz; - data->log2_blksz++); - -@@ -643,7 +643,7 @@ make_root_node (struct grub_squash_data *data, struct grub_fshelp_node *root) - root->stack[0].ino_chunk = grub_le_to_cpu32 (data->sb.root_ino_chunk); - root->stack[0].ino_offset = grub_cpu_to_le16 (data->sb.root_ino_offset); - return read_chunk (data, &root->ino, sizeof (root->ino), -- grub_le_to_cpu64 (data->sb.inodeoffset) -+ grub_le_to_cpu64 (data->sb.inodeoffset) - + root->stack[0].ino_chunk, - root->stack[0].ino_offset); - } -@@ -765,7 +765,7 @@ grub_squash_open (struct grub_file *file, const char *name) - } - - static grub_ssize_t --direct_read (struct grub_squash_data *data, -+direct_read (struct grub_squash_data *data, - struct grub_squash_cache_inode *ino, - grub_off_t off, char *buf, grub_size_t len) - { -@@ -882,7 +882,7 @@ direct_read (struct grub_squash_data *data, - grub_free (block); - } - else -- err = grub_disk_read (data->disk, -+ err = grub_disk_read (data->disk, - (ino->cumulated_block_sizes[i] + a + boff) - >> GRUB_DISK_SECTOR_BITS, - (ino->cumulated_block_sizes[i] + a + boff) -@@ -946,7 +946,7 @@ grub_squash_read (grub_file_t file, char *buf, grub_size_t len) - } - else - off -= direct_len; -- -+ - err = read_chunk (data, &frag, sizeof (frag), - data->fragments, sizeof (frag) * fragment); - if (err) -@@ -957,7 +957,7 @@ grub_squash_read (grub_file_t file, char *buf, grub_size_t len) - b = grub_le_to_cpu32 (ino->ino.long_file.offset) + off; - else - b = grub_le_to_cpu32 (ino->ino.file.offset) + off; -- -+ - /* FIXME: cache uncompressed chunks. */ - if (compressed) - { -@@ -1013,7 +1013,7 @@ grub_squash_mtime (grub_device_t dev, grub_int64_t *tm) - *tm = grub_le_to_cpu32 (data->sb.creation_time); - squash_unmount (data); - return GRUB_ERR_NONE; --} -+} - - static struct grub_fs grub_squash_fs = - { -diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c -index 2ac5c1d0048f..5a665093ed77 100644 ---- a/grub-core/fs/udf.c -+++ b/grub-core/fs/udf.c -@@ -567,7 +567,7 @@ grub_udf_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) - (buf + sizeof (struct grub_udf_aed)); - continue; - } -- -+ - if (filebytes < adlen) - { - grub_uint32_t ad_block_num = ad->block.block_num; -diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c -index 34a698b71b8d..a354c92d936a 100644 ---- a/grub-core/fs/ufs.c -+++ b/grub-core/fs/ufs.c -@@ -568,7 +568,7 @@ grub_ufs_find_file (struct grub_ufs_data *data, const char *path) - { - dirino = data->ino; - grub_ufs_read_inode (data, grub_ufs_to_cpu32 (dirent.ino), 0); -- -+ - if ((INODE_MODE(data) & GRUB_UFS_ATTR_TYPE) - == GRUB_UFS_ATTR_LNK) - { -@@ -613,7 +613,7 @@ grub_ufs_mount (grub_disk_t disk) - && ((data->sblock.bsize & (data->sblock.bsize - 1)) == 0) - && data->sblock.ino_per_group != 0) - { -- for (data->log2_blksz = 0; -+ for (data->log2_blksz = 0; - (1U << data->log2_blksz) < grub_ufs_to_cpu32 (data->sblock.bsize); - data->log2_blksz++); - -diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c -index e3816d1ec4a9..d6de7f1a2dd2 100644 ---- a/grub-core/fs/xfs.c -+++ b/grub-core/fs/xfs.c -@@ -894,7 +894,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - tag, which is not used by GRUB. So it can be overwritten. */ - filename[direntry->len] = '\0'; - -- if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode), -+ if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode), - filename, &ctx)) - { - grub_free (dirblock); -diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c -index cf4d2ab189a5..5961818abc9a 100644 ---- a/grub-core/fs/zfs/zfs.c -+++ b/grub-core/fs/zfs/zfs.c -@@ -176,7 +176,7 @@ typedef struct decomp_entry - /* - * Signature for checksum functions. - */ --typedef void zio_checksum_t(const void *data, grub_uint64_t size, -+typedef void zio_checksum_t(const void *data, grub_uint64_t size, - grub_zfs_endian_t endian, zio_cksum_t *zcp); - - /* -@@ -297,7 +297,7 @@ check_feature(const char *name, grub_uint64_t val, struct grub_zfs_dir_ctx *ctx) - static grub_err_t - check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data ); - --static grub_err_t -+static grub_err_t - zlib_decompress (void *s, void *d, - grub_size_t slen, grub_size_t dlen) - { -@@ -310,7 +310,7 @@ zlib_decompress (void *s, void *d, - return grub_errno; - } - --static grub_err_t -+static grub_err_t - zle_decompress (void *s, void *d, - grub_size_t slen, grub_size_t dlen) - { -@@ -415,7 +415,7 @@ static zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS] = { - */ - static grub_err_t - zio_checksum_verify (zio_cksum_t zc, grub_uint32_t checksum, -- grub_zfs_endian_t endian, -+ grub_zfs_endian_t endian, - char *buf, grub_size_t size) - { - zio_eck_t *zec = (zio_eck_t *) (buf + size) - 1; -@@ -425,14 +425,14 @@ zio_checksum_verify (zio_cksum_t zc, grub_uint32_t checksum, - if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func == NULL) - { - grub_dprintf ("zfs", "unknown checksum function %d\n", checksum); -- return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, -+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "unknown checksum function %d", checksum); - } - - if (ci->ci_eck) - { -- expected_cksum = zec->zec_cksum; -- zec->zec_cksum = zc; -+ expected_cksum = zec->zec_cksum; -+ zec->zec_cksum = zc; - ci->ci_func (buf, size, endian, &actual_cksum); - zec->zec_cksum = expected_cksum; - zc = expected_cksum; -@@ -445,14 +445,14 @@ zio_checksum_verify (zio_cksum_t zc, grub_uint32_t checksum, - { - grub_dprintf ("zfs", "checksum %s verification failed\n", ci->ci_name); - grub_dprintf ("zfs", "actual checksum %016llx %016llx %016llx %016llx\n", -- (unsigned long long) actual_cksum.zc_word[0], -+ (unsigned long long) actual_cksum.zc_word[0], - (unsigned long long) actual_cksum.zc_word[1], -- (unsigned long long) actual_cksum.zc_word[2], -+ (unsigned long long) actual_cksum.zc_word[2], - (unsigned long long) actual_cksum.zc_word[3]); - grub_dprintf ("zfs", "expected checksum %016llx %016llx %016llx %016llx\n", -- (unsigned long long) zc.zc_word[0], -+ (unsigned long long) zc.zc_word[0], - (unsigned long long) zc.zc_word[1], -- (unsigned long long) zc.zc_word[2], -+ (unsigned long long) zc.zc_word[2], - (unsigned long long) zc.zc_word[3]); - return grub_error (GRUB_ERR_BAD_FS, N_("checksum verification failed")); - } -@@ -485,17 +485,17 @@ vdev_uberblock_compare (uberblock_t * ub1, uberblock_t * ub2) - else - ub2_endian = GRUB_ZFS_BIG_ENDIAN; - -- if (grub_zfs_to_cpu64 (ub1->ub_txg, ub1_endian) -+ if (grub_zfs_to_cpu64 (ub1->ub_txg, ub1_endian) - < grub_zfs_to_cpu64 (ub2->ub_txg, ub2_endian)) - return -1; -- if (grub_zfs_to_cpu64 (ub1->ub_txg, ub1_endian) -+ if (grub_zfs_to_cpu64 (ub1->ub_txg, ub1_endian) - > grub_zfs_to_cpu64 (ub2->ub_txg, ub2_endian)) - return 1; - -- if (grub_zfs_to_cpu64 (ub1->ub_timestamp, ub1_endian) -+ if (grub_zfs_to_cpu64 (ub1->ub_timestamp, ub1_endian) - < grub_zfs_to_cpu64 (ub2->ub_timestamp, ub2_endian)) - return -1; -- if (grub_zfs_to_cpu64 (ub1->ub_timestamp, ub1_endian) -+ if (grub_zfs_to_cpu64 (ub1->ub_timestamp, ub1_endian) - > grub_zfs_to_cpu64 (ub2->ub_timestamp, ub2_endian)) - return 1; - -@@ -573,7 +573,7 @@ find_bestub (uberblock_phys_t * ub_array, - grub_errno = GRUB_ERR_NONE; - continue; - } -- if (ubbest == NULL -+ if (ubbest == NULL - || vdev_uberblock_compare (&(ubptr->ubp_uberblock), - &(ubbest->ubp_uberblock)) > 0) - ubbest = ubptr; -@@ -594,10 +594,10 @@ get_psize (blkptr_t * bp, grub_zfs_endian_t endian) - static grub_uint64_t - dva_get_offset (const dva_t *dva, grub_zfs_endian_t endian) - { -- grub_dprintf ("zfs", "dva=%llx, %llx\n", -- (unsigned long long) dva->dva_word[0], -+ grub_dprintf ("zfs", "dva=%llx, %llx\n", -+ (unsigned long long) dva->dva_word[0], - (unsigned long long) dva->dva_word[1]); -- return grub_zfs_to_cpu64 ((dva)->dva_word[1], -+ return grub_zfs_to_cpu64 ((dva)->dva_word[1], - endian) << SPA_MINBLOCKSHIFT; - } - -@@ -720,7 +720,7 @@ fill_vdev_info_real (struct grub_zfs_data *data, - if (!fill->children) - { - fill->n_children = nelm; -- -+ - fill->children = grub_zalloc (fill->n_children - * sizeof (fill->children[0])); - } -@@ -839,7 +839,7 @@ nvlist_next_nvpair (const char *nvl, const char *nvpair) - { - /* skip over header, nvl_version and nvl_nvflag */ - nvpair = nvl + 4 * 3; -- } -+ } - else - { - /* skip to the next nvpair */ -@@ -873,10 +873,10 @@ nvlist_next_nvpair (const char *nvl, const char *nvpair) - name_len = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); - nvp += 4; - -- nvp = nvp + ((name_len + 3) & ~3); // align -- if (nvp + 4 >= nvl + VDEV_PHYS_SIZE -+ nvp = nvp + ((name_len + 3) & ~3); // align -+ if (nvp + 4 >= nvl + VDEV_PHYS_SIZE - || encode_size < 0 -- || nvp + 4 + encode_size > nvl + VDEV_PHYS_SIZE) -+ || nvp + 4 + encode_size > nvl + VDEV_PHYS_SIZE) - { - grub_dprintf ("zfs", "nvlist overflow\n"); - grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist"); -@@ -896,7 +896,7 @@ nvpair_name (const char *nvp, char **buf, grub_size_t *buflen) - { - /* skip over encode/decode size */ - nvp += 4 * 2; -- -+ - *buf = (char *) (nvp + 4); - *buflen = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); - -@@ -943,7 +943,7 @@ nvpair_value (const char *nvp,char **val, - - /* skip over name */ - nvp = nvp + ((name_len + 3) & ~3); /* align */ -- -+ - /* skip over type */ - nvp += 4; - nelm = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); -@@ -957,7 +957,7 @@ nvpair_value (const char *nvp,char **val, - *size_out = encode_size; - if (nelm_out) - *nelm_out = nelm; -- -+ - return 1; - } - -@@ -1183,7 +1183,7 @@ scan_disk (grub_device_t dev, struct grub_zfs_data *data, - desc.vdev_phys_sector - = label * (sizeof (vdev_label_t) >> SPA_MINBLOCKSHIFT) - + ((VDEV_SKIP_SIZE + VDEV_BOOT_HEADER_SIZE) >> SPA_MINBLOCKSHIFT) -- + (label < VDEV_LABELS / 2 ? 0 : -+ + (label < VDEV_LABELS / 2 ? 0 : - ALIGN_DOWN (grub_disk_native_sectors (dev->disk), sizeof (vdev_label_t)) - - VDEV_LABELS * (sizeof (vdev_label_t) >> SPA_MINBLOCKSHIFT)); - -@@ -1229,7 +1229,7 @@ scan_disk (grub_device_t dev, struct grub_zfs_data *data, - grub_free (bh); - return GRUB_ERR_NONE; - } -- -+ - grub_free (ub_array); - grub_free (bh); - -@@ -1269,7 +1269,7 @@ scan_devices_iter (const char *name, void *hook_data) - - if (!inserted) - grub_device_close (dev); -- -+ - return 0; - } - -@@ -1386,7 +1386,7 @@ recovery (grub_uint8_t *bufs[4], grub_size_t s, const int nbufs, - for (i = 0; i < nbufs; i++) - { - grub_uint8_t mul; -- for (j = i; j < nbufs; j++) -+ for (j = i; j < nbufs; j++) - if (matrix1[i][j]) - break; - if (j == nbufs) -@@ -1453,7 +1453,7 @@ recovery (grub_uint8_t *bufs[4], grub_size_t s, const int nbufs, - } - default: - return grub_error (GRUB_ERR_BUG, "too big matrix"); -- } -+ } - } - - static grub_err_t -@@ -1510,7 +1510,7 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc, - int idx, orig_idx; - - if (desc->nparity < 1 || desc->nparity > 3) -- return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, -+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "raidz%d is not supported", desc->nparity); - - if (desc->n_children <= desc->nparity || desc->n_children < 1) -@@ -1659,7 +1659,7 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc, - len -= csize; - idx--; - } -- for (i = 0; i < failed_devices -+ for (i = 0; i < failed_devices - && recovery_len[i] == recovery_len[0]; - i++); - /* Since the chunks have variable length handle the last block -@@ -1782,7 +1782,7 @@ zio_read_gang (blkptr_t * bp, grub_zfs_endian_t endian, dva_t * dva, void *buf, - * Read in a block of raw data to buf. - */ - static grub_err_t --zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian, void *buf, -+zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian, void *buf, - struct grub_zfs_data *data) - { - int i, psize; -@@ -1850,7 +1850,7 @@ decode_embedded_bp_compressed(const blkptr_t *bp, void *buf) - * and put the uncompressed data in buf. - */ - static grub_err_t --zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf, -+zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf, - grub_size_t *size, struct grub_zfs_data *data) - { - grub_size_t lsize, psize; -@@ -1936,7 +1936,7 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf, - if (encrypted) - { - if (!grub_zfs_decrypt) -- err = grub_error (GRUB_ERR_BAD_FS, -+ err = grub_error (GRUB_ERR_BAD_FS, - N_("module `%s' isn't loaded"), - "zfscrypt"); - else -@@ -1960,7 +1960,7 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf, - endian)); - return grub_error (GRUB_ERR_BAD_FS, "no key found in keychain"); - } -- grub_dprintf ("zfs", "using key %u (%" PRIxGRUB_UINT64_T -+ grub_dprintf ("zfs", "using key %u (%" PRIxGRUB_UINT64_T - ", %p) for txg %" PRIxGRUB_UINT64_T "\n", - besti, data->subvol.keyring[besti].txg, - data->subvol.keyring[besti].cipher, -@@ -2008,7 +2008,7 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf, - * - */ - static grub_err_t --dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, -+dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, - grub_zfs_endian_t *endian_out, struct grub_zfs_data *data) - { - int level; -@@ -2038,8 +2038,8 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, - - if (BP_IS_HOLE (bp)) - { -- grub_size_t size = grub_zfs_to_cpu16 (dn->dn.dn_datablkszsec, -- dn->endian) -+ grub_size_t size = grub_zfs_to_cpu16 (dn->dn.dn_datablkszsec, -+ dn->endian) - << SPA_MINBLOCKSHIFT; - *buf = grub_malloc (size); - if (!*buf) -@@ -2103,7 +2103,7 @@ mzap_lookup (mzap_phys_t * zapobj, grub_zfs_endian_t endian, - } - - static int --mzap_iterate (mzap_phys_t * zapobj, grub_zfs_endian_t endian, int objsize, -+mzap_iterate (mzap_phys_t * zapobj, grub_zfs_endian_t endian, int objsize, - int (*hook) (const char *name, grub_uint64_t val, - struct grub_zfs_dir_ctx *ctx), - struct grub_zfs_dir_ctx *ctx) -@@ -2117,7 +2117,7 @@ mzap_iterate (mzap_phys_t * zapobj, grub_zfs_endian_t endian, int objsize, - grub_dprintf ("zfs", "zap: name = %s, value = %llx, cd = %x\n", - mzap_ent[i].mze_name, (long long)mzap_ent[i].mze_value, - (int)mzap_ent[i].mze_cd); -- if (hook (mzap_ent[i].mze_name, -+ if (hook (mzap_ent[i].mze_name, - grub_zfs_to_cpu64 (mzap_ent[i].mze_value, endian), ctx)) - return 1; - } -@@ -2178,12 +2178,12 @@ name_cmp (const char *s1, const char *s2, grub_size_t n, - - if (!case_insensitive) - return grub_memcmp (t1, t2, n); -- -+ - while (n--) - { - if (grub_toupper (*t1) != grub_toupper (*t2)) - return (int) grub_toupper (*t1) - (int) grub_toupper (*t2); -- -+ - t1++; - t2++; - } -@@ -2221,7 +2221,7 @@ zap_leaf_array_equal (zap_leaf_phys_t * l, grub_zfs_endian_t endian, - - /* XXX */ - static grub_err_t --zap_leaf_array_get (zap_leaf_phys_t * l, grub_zfs_endian_t endian, int blksft, -+zap_leaf_array_get (zap_leaf_phys_t * l, grub_zfs_endian_t endian, int blksft, - int chunk, grub_size_t array_len, char *buf) - { - grub_size_t bseen = 0; -@@ -2285,7 +2285,7 @@ zap_leaf_lookup (zap_leaf_phys_t * l, grub_zfs_endian_t endian, - - grub_dprintf ("zfs", "fzap: length %d\n", (int) le->le_name_length); - -- if (zap_leaf_array_equal (l, endian, blksft, -+ if (zap_leaf_array_equal (l, endian, blksft, - grub_zfs_to_cpu16 (le->le_name_chunk,endian), - grub_zfs_to_cpu16 (le->le_name_length, endian), - name, case_insensitive)) -@@ -2334,7 +2334,7 @@ fzap_lookup (dnode_end_t * zap_dnode, zap_phys_t * zap, - { - void *l; - grub_uint64_t hash, idx, blkid; -- int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, -+ int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, - zap_dnode->endian) << DNODE_SHIFT); - grub_err_t err; - grub_zfs_endian_t leafendian; -@@ -2347,7 +2347,7 @@ fzap_lookup (dnode_end_t * zap_dnode, zap_phys_t * zap, - - /* get block id from index */ - if (zap->zap_ptrtbl.zt_numblks != 0) -- return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, -+ return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "external pointer tables not supported"); - idx = ZAP_HASH_IDX (hash, zap->zap_ptrtbl.zt_shift); - blkid = grub_zfs_to_cpu64 (((grub_uint64_t *) zap)[idx + (1 << (blksft - 3 - 1))], zap_dnode->endian); -@@ -2379,7 +2379,7 @@ fzap_iterate (dnode_end_t * zap_dnode, zap_phys_t * zap, - void *l_in; - grub_uint64_t idx, idx2, blkid; - grub_uint16_t chunk; -- int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, -+ int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, - zap_dnode->endian) << DNODE_SHIFT); - grub_err_t err; - grub_zfs_endian_t endian; -@@ -2390,7 +2390,7 @@ fzap_iterate (dnode_end_t * zap_dnode, zap_phys_t * zap, - /* get block id from index */ - if (zap->zap_ptrtbl.zt_numblks != 0) - { -- grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, -+ grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "external pointer tables not supported"); - return 0; - } -@@ -2517,7 +2517,7 @@ zap_lookup (dnode_end_t * zap_dnode, const char *name, grub_uint64_t *val, - grub_dprintf ("zfs", "micro zap\n"); - err = mzap_lookup (zapbuf, endian, size, name, val, - case_insensitive); -- grub_dprintf ("zfs", "returned %d\n", err); -+ grub_dprintf ("zfs", "returned %d\n", err); - grub_free (zapbuf); - return err; - } -@@ -2527,7 +2527,7 @@ zap_lookup (dnode_end_t * zap_dnode, const char *name, grub_uint64_t *val, - /* this is a fat zap */ - err = fzap_lookup (zap_dnode, zapbuf, name, val, data, - case_insensitive); -- grub_dprintf ("zfs", "returned %d\n", err); -+ grub_dprintf ("zfs", "returned %d\n", err); - grub_free (zapbuf); - return err; - } -@@ -2560,7 +2560,7 @@ zap_iterate_u64_transform (const void *name, - } - - static int --zap_iterate_u64 (dnode_end_t * zap_dnode, -+zap_iterate_u64 (dnode_end_t * zap_dnode, - int (*hook) (const char *name, grub_uint64_t val, - struct grub_zfs_dir_ctx *ctx), - struct grub_zfs_data *data, struct grub_zfs_dir_ctx *ctx) -@@ -2607,7 +2607,7 @@ zap_iterate_u64 (dnode_end_t * zap_dnode, - } - - static int --zap_iterate (dnode_end_t * zap_dnode, -+zap_iterate (dnode_end_t * zap_dnode, - grub_size_t nameelemlen, - int (*hook) (const void *name, grub_size_t namelen, - const void *val_in, -@@ -2667,7 +2667,7 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type, - grub_err_t err; - grub_zfs_endian_t endian; - -- blksz = grub_zfs_to_cpu16 (mdn->dn.dn_datablkszsec, -+ blksz = grub_zfs_to_cpu16 (mdn->dn.dn_datablkszsec, - mdn->endian) << SPA_MINBLOCKSHIFT; - epbs = zfs_log2 (blksz) - DNODE_SHIFT; - -@@ -2678,18 +2678,18 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type, - blkid = objnum >> epbs; - idx = objnum & ((1 << epbs) - 1); - -- if (data->dnode_buf != NULL && grub_memcmp (data->dnode_mdn, mdn, -- sizeof (*mdn)) == 0 -+ if (data->dnode_buf != NULL && grub_memcmp (data->dnode_mdn, mdn, -+ sizeof (*mdn)) == 0 - && objnum >= data->dnode_start && objnum < data->dnode_end) - { - grub_memmove (&(buf->dn), &(data->dnode_buf)[idx], DNODE_SIZE); - buf->endian = data->dnode_endian; -- if (type && buf->dn.dn_type != type) -- return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type"); -+ if (type && buf->dn.dn_type != type) -+ return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type"); - return GRUB_ERR_NONE; - } - -- grub_dprintf ("zfs", "endian = %d, blkid=%llx\n", mdn->endian, -+ grub_dprintf ("zfs", "endian = %d, blkid=%llx\n", mdn->endian, - (unsigned long long) blkid); - err = dmu_read (mdn, blkid, &dnbuf, &endian, data); - if (err) -@@ -2715,8 +2715,8 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type, - - grub_memmove (&(buf->dn), (dnode_phys_t *) dnbuf + idx, DNODE_SIZE); - buf->endian = endian; -- if (type && buf->dn.dn_type != type) -- return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type"); -+ if (type && buf->dn.dn_type != type) -+ return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type"); - - return GRUB_ERR_NONE; - } -@@ -2740,7 +2740,7 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, - struct dnode_chain - { - struct dnode_chain *next; -- dnode_end_t dn; -+ dnode_end_t dn; - }; - struct dnode_chain *dnode_path = 0, *dn_new, *root; - -@@ -2750,7 +2750,7 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, - dn_new->next = 0; - dnode_path = root = dn_new; - -- err = dnode_get (&subvol->mdn, MASTER_NODE_OBJ, DMU_OT_MASTER_NODE, -+ err = dnode_get (&subvol->mdn, MASTER_NODE_OBJ, DMU_OT_MASTER_NODE, - &(dnode_path->dn), data); - if (err) - { -@@ -2801,7 +2801,7 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, - grub_free (dn_new); - return grub_errno; - } -- -+ - while (1) - { - /* skip leading slashes */ -@@ -2827,7 +2827,7 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, - } - else - { -- err = grub_error (GRUB_ERR_FILE_NOT_FOUND, -+ err = grub_error (GRUB_ERR_FILE_NOT_FOUND, - "can't resolve .."); - break; - } -@@ -2877,7 +2877,7 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, - { - grub_size_t block; - grub_size_t blksz; -- blksz = (grub_zfs_to_cpu16 (dnode_path->dn.dn.dn_datablkszsec, -+ blksz = (grub_zfs_to_cpu16 (dnode_path->dn.dn.dn_datablkszsec, - dnode_path->dn.endian) - << SPA_MINBLOCKSHIFT); - -@@ -2916,7 +2916,7 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, - if (err) - break; - free_symval = 1; -- } -+ } - path = path_buf = grub_malloc (sym_sz + grub_strlen (oldpath) + 1); - if (!path_buf) - { -@@ -2930,9 +2930,9 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, - if (free_symval) - grub_free (sym_value); - path [sym_sz] = 0; -- grub_memcpy (path + grub_strlen (path), oldpath, -+ grub_memcpy (path + grub_strlen (path), oldpath, - grub_strlen (oldpath) + 1); -- -+ - grub_free (oldpathbuf); - if (path[0] != '/') - { -@@ -2951,7 +2951,7 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, - { - void *sahdrp; - int hdrsize; -- -+ - if (dnode_path->dn.dn.dn_bonuslen != 0) - { - sahdrp = DN_BONUS (&dnode_path->dn.dn); -@@ -2959,7 +2959,7 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, - else if (dnode_path->dn.dn.dn_flags & DNODE_FLAG_SPILL_BLKPTR) - { - blkptr_t *bp = &dnode_path->dn.dn.dn_spill; -- -+ - err = zio_read (bp, dnode_path->dn.endian, &sahdrp, NULL, data); - if (err) - break; -@@ -2978,7 +2978,7 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, - dnode_path->dn.endian) >> 12) & 0xf) == 0xa) - { - char *sym_value = (char *) sahdrp + hdrsize + SA_SYMLINK_OFFSET; -- grub_size_t sym_sz = -+ grub_size_t sym_sz = - grub_zfs_to_cpu64 (grub_get_unaligned64 ((char *) sahdrp - + hdrsize - + SA_SIZE_OFFSET), -@@ -2993,9 +2993,9 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, - } - grub_memcpy (path, sym_value, sym_sz); - path [sym_sz] = 0; -- grub_memcpy (path + grub_strlen (path), oldpath, -+ grub_memcpy (path + grub_strlen (path), oldpath, - grub_strlen (oldpath) + 1); -- -+ - grub_free (oldpathbuf); - if (path[0] != '/') - { -@@ -3096,7 +3096,7 @@ get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname, - - grub_dprintf ("zfs", "endian = %d\n", mosmdn->endian); - -- err = dnode_get (mosmdn, DMU_POOL_DIRECTORY_OBJECT, -+ err = dnode_get (mosmdn, DMU_POOL_DIRECTORY_OBJECT, - DMU_OT_OBJECT_DIRECTORY, mdn, data); - if (err) - return err; -@@ -3119,7 +3119,7 @@ get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname, - { - grub_uint64_t childobj; - char *cname, ch; -- -+ - while (*fsname == '/') - fsname++; - -@@ -3279,7 +3279,7 @@ dnode_get_fullpath (const char *fullpath, struct subvolume *subvol, - filename = ptr_slash; - else - filename = "/"; -- grub_dprintf ("zfs", "fsname = '%s' snapname='%s' filename = '%s'\n", -+ grub_dprintf ("zfs", "fsname = '%s' snapname='%s' filename = '%s'\n", - fsname, snapname, filename); - } - grub_dprintf ("zfs", "alive\n"); -@@ -3365,7 +3365,7 @@ dnode_get_fullpath (const char *fullpath, struct subvolume *subvol, - - snapobj = grub_zfs_to_cpu64 (((dsl_dataset_phys_t *) DN_BONUS (&subvol->mdn.dn))->ds_snapnames_zapobj, subvol->mdn.endian); - -- err = dnode_get (&(data->mos), snapobj, -+ err = dnode_get (&(data->mos), snapobj, - DMU_OT_DSL_DS_SNAP_MAP, &subvol->mdn, data); - if (!err) - err = zap_lookup (&subvol->mdn, snapname, &headobj, data, 0); -@@ -3383,13 +3383,13 @@ dnode_get_fullpath (const char *fullpath, struct subvolume *subvol, - subvol->obj = headobj; - - make_mdn (&subvol->mdn, data); -- -+ - grub_dprintf ("zfs", "endian = %d\n", subvol->mdn.endian); - - if (*isfs) - { - grub_free (fsname); -- grub_free (snapname); -+ grub_free (snapname); - return GRUB_ERR_NONE; - } - err = dnode_get_path (subvol, filename, dn, data); -@@ -3409,9 +3409,9 @@ nvlist_find_value (const char *nvlist_in, const char *name, - char *nvp_name; - - /* Verify if the 1st and 2nd byte in the nvlist are valid. */ -- /* NOTE: independently of what endianness header announces all -+ /* NOTE: independently of what endianness header announces all - subsequent values are big-endian. */ -- if (nvlist[0] != NV_ENCODE_XDR || (nvlist[1] != NV_LITTLE_ENDIAN -+ if (nvlist[0] != NV_ENCODE_XDR || (nvlist[1] != NV_LITTLE_ENDIAN - && nvlist[1] != NV_BIG_ENDIAN)) - { - grub_dprintf ("zfs", "incorrect nvlist header\n"); -@@ -3532,13 +3532,13 @@ get_nvlist_size (const char *beg, const char *limit) - { - const char *ptr; - grub_uint32_t encode_size; -- -+ - ptr = beg + 8; - - while (ptr < limit - && (encode_size = grub_be_to_cpu32 (grub_get_unaligned32 (ptr)))) - ptr += encode_size; /* goto the next nvpair */ -- ptr += 8; -+ ptr += 8; - return (ptr > limit) ? -1 : (ptr - beg); - } - -@@ -3674,8 +3674,8 @@ zfs_mount (grub_device_t dev) - } - - ub = &(data->current_uberblock); -- ub_endian = (grub_zfs_to_cpu64 (ub->ub_magic, -- GRUB_ZFS_LITTLE_ENDIAN) == UBERBLOCK_MAGIC -+ ub_endian = (grub_zfs_to_cpu64 (ub->ub_magic, -+ GRUB_ZFS_LITTLE_ENDIAN) == UBERBLOCK_MAGIC - ? GRUB_ZFS_LITTLE_ENDIAN : GRUB_ZFS_BIG_ENDIAN); - - err = zio_read (&ub->ub_rootbp, ub_endian, -@@ -3728,7 +3728,7 @@ grub_zfs_fetch_nvlist (grub_device_t dev, char **nvlist) - return err; - } - --static grub_err_t -+static grub_err_t - zfs_label (grub_device_t device, char **label) - { - char *nvlist; -@@ -3740,7 +3740,7 @@ zfs_label (grub_device_t device, char **label) - return grub_errno; - - err = zfs_fetch_nvlist (data->device_original, &nvlist); -- if (err) -+ if (err) - { - zfs_unmount (data); - return err; -@@ -3752,7 +3752,7 @@ zfs_label (grub_device_t device, char **label) - return grub_errno; - } - --static grub_err_t -+static grub_err_t - zfs_uuid (grub_device_t device, char **uuid) - { - struct grub_zfs_data *data; -@@ -3770,7 +3770,7 @@ zfs_uuid (grub_device_t device, char **uuid) - return GRUB_ERR_NONE; - } - --static grub_err_t -+static grub_err_t - zfs_mtime (grub_device_t device, grub_int64_t *mt) - { - struct grub_zfs_data *data; -@@ -3784,8 +3784,8 @@ zfs_mtime (grub_device_t device, grub_int64_t *mt) - return grub_errno; - - ub = &(data->current_uberblock); -- ub_endian = (grub_zfs_to_cpu64 (ub->ub_magic, -- GRUB_ZFS_LITTLE_ENDIAN) == UBERBLOCK_MAGIC -+ ub_endian = (grub_zfs_to_cpu64 (ub->ub_magic, -+ GRUB_ZFS_LITTLE_ENDIAN) == UBERBLOCK_MAGIC - ? GRUB_ZFS_LITTLE_ENDIAN : GRUB_ZFS_BIG_ENDIAN); - - *mt = grub_zfs_to_cpu64 (ub->ub_timestamp, ub_endian); -@@ -3823,7 +3823,7 @@ grub_zfs_open (struct grub_file *file, const char *fsfilename) - } - - /* We found the dnode for this file. Verify if it is a plain file. */ -- if (data->dnode.dn.dn_type != DMU_OT_PLAIN_FILE_CONTENTS) -+ if (data->dnode.dn.dn_type != DMU_OT_PLAIN_FILE_CONTENTS) - { - zfs_unmount (data); - return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file")); -@@ -3898,7 +3898,7 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len) - return len; - } - -- blksz = grub_zfs_to_cpu16 (data->dnode.dn.dn_datablkszsec, -+ blksz = grub_zfs_to_cpu16 (data->dnode.dn.dn_datablkszsec, - data->dnode.endian) << SPA_MINBLOCKSHIFT; - - if (blksz == 0) -@@ -3991,11 +3991,11 @@ fill_fs_info (struct grub_dirhook_info *info, - dnode_end_t dn; - grub_uint64_t objnum; - grub_uint64_t headobj; -- -+ - grub_memset (info, 0, sizeof (*info)); -- -+ - info->dir = 1; -- -+ - if (mdn.dn.dn_type == DMU_OT_DSL_DIR) - { - headobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&mdn.dn))->dd_head_dataset_obj, mdn.endian); -@@ -4010,28 +4010,28 @@ fill_fs_info (struct grub_dirhook_info *info, - err = make_mdn (&mdn, data); - if (err) - return err; -- err = dnode_get (&mdn, MASTER_NODE_OBJ, DMU_OT_MASTER_NODE, -+ err = dnode_get (&mdn, MASTER_NODE_OBJ, DMU_OT_MASTER_NODE, - &dn, data); - if (err) - { - grub_dprintf ("zfs", "failed here\n"); - return err; - } -- -+ - err = zap_lookup (&dn, ZFS_ROOT_OBJ, &objnum, data, 0); - if (err) - { - grub_dprintf ("zfs", "failed here\n"); - return err; - } -- -+ - err = dnode_get (&mdn, objnum, 0, &dn, data); - if (err) - { - grub_dprintf ("zfs", "failed here\n"); - return err; - } -- -+ - if (dn.dn.dn_bonustype == DMU_OT_SA) - { - void *sahdrp; -@@ -4117,15 +4117,15 @@ iterate_zap (const char *name, grub_uint64_t val, struct grub_zfs_dir_ctx *ctx) - info.mtime = grub_zfs_to_cpu64 (grub_get_unaligned64 ((char *) sahdrp + hdrsize + SA_MTIME_OFFSET), dn.endian); - info.case_insensitive = ctx->data->subvol.case_insensitive; - } -- -+ - if (dn.dn.dn_bonustype == DMU_OT_ZNODE) -- { -+ { - info.mtimeset = 1; - info.mtime = grub_zfs_to_cpu64 (((znode_phys_t *) DN_BONUS (&dn.dn))->zp_mtime[0], - dn.endian); - } - info.dir = (dn.dn.dn_type == DMU_OT_DIRECTORY_CONTENTS); -- grub_dprintf ("zfs", "type=%d, name=%s\n", -+ grub_dprintf ("zfs", "type=%d, name=%s\n", - (int)dn.dn.dn_type, (char *)name); - return ctx->hook (name, &info, ctx->hook_data); - } -@@ -4219,7 +4219,7 @@ grub_zfs_dir (grub_device_t device, const char *path, - - if (isfs) - { -- grub_uint64_t childobj, headobj; -+ grub_uint64_t childobj, headobj; - grub_uint64_t snapobj; - dnode_end_t dn; - struct grub_dirhook_info info; -@@ -4247,7 +4247,7 @@ grub_zfs_dir (grub_device_t device, const char *path, - } - - zap_iterate_u64 (&dn, iterate_zap_fs, data, &ctx); -- -+ - err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, &dn, data); - if (err) - { -@@ -4289,8 +4289,8 @@ check_feature (const char *name, grub_uint64_t val, - return 0; - if (name[0] == 0) - return 0; -- for (i = 0; spa_feature_names[i] != NULL; i++) -- if (grub_strcmp (name, spa_feature_names[i]) == 0) -+ for (i = 0; spa_feature_names[i] != NULL; i++) -+ if (grub_strcmp (name, spa_feature_names[i]) == 0) - return 0; - return 1; - } -@@ -4303,7 +4303,7 @@ check_feature (const char *name, grub_uint64_t val, - * 0: Success. - * errnum: Failure. - */ -- -+ - static grub_err_t - check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data ) - { -@@ -4328,7 +4328,7 @@ check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct gru - errnum = zap_lookup(&dn, DMU_POOL_FEATURES_FOR_READ, &objnum, data,0); - if (errnum != 0) - return errnum; -- -+ - errnum = dnode_get(&mosmdn, objnum, DMU_OTN_ZAP_METADATA, &dn, data); - if (errnum != 0) - return errnum; -diff --git a/grub-core/fs/zfs/zfs_fletcher.c b/grub-core/fs/zfs/zfs_fletcher.c -index 7d27b053dc7a..ad3be6705479 100644 ---- a/grub-core/fs/zfs/zfs_fletcher.c -+++ b/grub-core/fs/zfs/zfs_fletcher.c -@@ -39,14 +39,14 @@ - #include - - void --fletcher_2(const void *buf, grub_uint64_t size, grub_zfs_endian_t endian, -+fletcher_2(const void *buf, grub_uint64_t size, grub_zfs_endian_t endian, - zio_cksum_t *zcp) - { - const grub_uint64_t *ip = buf; - const grub_uint64_t *ipend = ip + (size / sizeof (grub_uint64_t)); - grub_uint64_t a0, b0, a1, b1; -- -- for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) -+ -+ for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) - { - a0 += grub_zfs_to_cpu64 (ip[0], endian); - a1 += grub_zfs_to_cpu64 (ip[1], endian); -@@ -61,14 +61,14 @@ fletcher_2(const void *buf, grub_uint64_t size, grub_zfs_endian_t endian, - } - - void --fletcher_4 (const void *buf, grub_uint64_t size, grub_zfs_endian_t endian, -+fletcher_4 (const void *buf, grub_uint64_t size, grub_zfs_endian_t endian, - zio_cksum_t *zcp) - { - const grub_uint32_t *ip = buf; - const grub_uint32_t *ipend = ip + (size / sizeof (grub_uint32_t)); - grub_uint64_t a, b, c, d; -- -- for (a = b = c = d = 0; ip < ipend; ip++) -+ -+ for (a = b = c = d = 0; ip < ipend; ip++) - { - a += grub_zfs_to_cpu32 (ip[0], endian);; - b += a; -diff --git a/grub-core/fs/zfs/zfs_sha256.c b/grub-core/fs/zfs/zfs_sha256.c -index a181f076c54c..f042fa61ab89 100644 ---- a/grub-core/fs/zfs/zfs_sha256.c -+++ b/grub-core/fs/zfs/zfs_sha256.c -@@ -116,23 +116,23 @@ zio_checksum_SHA256(const void *buf, grub_uint64_t size, - grub_uint8_t pad[128]; - unsigned padsize = size & 63; - unsigned i; -- -+ - for (i = 0; i < size - padsize; i += 64) - SHA256Transform(H, (grub_uint8_t *)buf + i); -- -+ - for (i = 0; i < padsize; i++) - pad[i] = ((grub_uint8_t *)buf)[i]; -- -+ - for (pad[padsize++] = 0x80; (padsize & 63) != 56; padsize++) - pad[padsize] = 0; -- -+ - for (i = 0; i < 8; i++) - pad[padsize++] = (size << 3) >> (56 - 8 * i); -- -+ - for (i = 0; i < padsize && i <= 64; i += 64) - SHA256Transform(H, pad + i); -- -- zcp->zc_word[0] = grub_cpu_to_zfs64 ((grub_uint64_t)H[0] << 32 | H[1], -+ -+ zcp->zc_word[0] = grub_cpu_to_zfs64 ((grub_uint64_t)H[0] << 32 | H[1], - endian); - zcp->zc_word[1] = grub_cpu_to_zfs64 ((grub_uint64_t)H[2] << 32 | H[3], - endian); -diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c -index de3b015f5827..da30e9ab33dd 100644 ---- a/grub-core/fs/zfs/zfscrypt.c -+++ b/grub-core/fs/zfs/zfscrypt.c -@@ -46,7 +46,7 @@ - GRUB_MOD_LICENSE ("GPLv3+"); - - /* -- Mostly based on following article: -+ Mostly based on following article: - https://blogs.oracle.com/darren/entry/zfs_encryption_what_is_on - */ - -@@ -179,7 +179,7 @@ grub_gcm_mul (grub_uint8_t *a, const grub_uint8_t *b) - grub_crypto_xor (res, res, bs, 16); - grub_gcm_mul_x (bs); - } -- -+ - grub_memcpy (a, res, 16); - } - -@@ -275,7 +275,7 @@ algo_decrypt (grub_crypto_cipher_handle_t cipher, grub_uint64_t algo, - } - - static grub_err_t --grub_zfs_decrypt_real (grub_crypto_cipher_handle_t cipher, -+grub_zfs_decrypt_real (grub_crypto_cipher_handle_t cipher, - grub_uint64_t algo, - void *nonce, - char *buf, grub_size_t size, -@@ -286,7 +286,7 @@ grub_zfs_decrypt_real (grub_crypto_cipher_handle_t cipher, - unsigned i; - grub_uint32_t sw[4]; - gcry_err_code_t err; -- -+ - grub_memcpy (sw, nonce, 16); - if (endian != GRUB_ZFS_BIG_ENDIAN) - for (i = 0; i < 4; i++) -@@ -302,7 +302,7 @@ grub_zfs_decrypt_real (grub_crypto_cipher_handle_t cipher, - sw + 1, 3, 12); - if (err) - return grub_crypto_gcry_error (err); -- -+ - for (i = 0; i < 3; i++) - if (grub_zfs_to_cpu32 (expected_mac[i], endian) - != grub_be_to_cpu32 (mac[i])) -@@ -362,7 +362,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key, - grub_crypto_cipher_close (cipher); - continue; - } -- -+ - err = grub_crypto_cipher_set_key (cipher, wrap_key_real, - keylen); - if (err) -@@ -371,7 +371,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key, - grub_crypto_cipher_close (cipher); - continue; - } -- -+ - err = algo_decrypt (cipher, algo, decrypted, key->unknown_purpose_key, 32, - mac, key->unknown_purpose_nonce, 2, 16); - if (err || (grub_crypto_memcmp (mac, key->unknown_purpose_key + 32, 16) diff --git a/0342-fs-xfs-Fix-memory-leaks-in-XFS-module.patch b/0342-fs-xfs-Fix-memory-leaks-in-XFS-module.patch deleted file mode 100644 index f5421ce..0000000 --- a/0342-fs-xfs-Fix-memory-leaks-in-XFS-module.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: "t.feng" -Date: Tue, 29 Nov 2022 17:14:15 +0800 -Subject: [PATCH] fs/xfs: Fix memory leaks in XFS module - -Signed-off-by: t.feng -Reviewed-by: Daniel Kiper ---- - grub-core/fs/xfs.c | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c -index d6de7f1a2dd2..b67407690c1a 100644 ---- a/grub-core/fs/xfs.c -+++ b/grub-core/fs/xfs.c -@@ -585,7 +585,10 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) - if (grub_disk_read (node->data->disk, - GRUB_XFS_FSB_TO_BLOCK (node->data, get_fsb (keys, i - 1 + recoffset)) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS), - 0, node->data->bsize, leaf)) -- return 0; -+ { -+ grub_free (leaf); -+ return 0; -+ } - - if ((!node->data->hascrc && - grub_strncmp ((char *) leaf->magic, "BMAP", 4)) || -@@ -751,6 +754,7 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename, - if (err) - { - grub_print_error (); -+ grub_free (fdiro); - return 0; - } - -@@ -861,7 +865,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - blk << dirblk_log2, - dirblk_size, dirblock, 0); - if (numread != dirblk_size) -- return 0; -+ { -+ grub_free (dirblock); -+ return 0; -+ } - - entries = (grub_be_to_cpu32 (tail->leaf_count) - - grub_be_to_cpu32 (tail->leaf_stale)); diff --git a/0343-fs-xfs-Fix-issues-found-while-fuzzing-the-XFS-filesy.patch b/0343-fs-xfs-Fix-issues-found-while-fuzzing-the-XFS-filesy.patch deleted file mode 100644 index 7083a57..0000000 --- a/0343-fs-xfs-Fix-issues-found-while-fuzzing-the-XFS-filesy.patch +++ /dev/null @@ -1,106 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Darren Kenny -Date: Fri, 2 Jun 2023 18:08:44 +0000 -Subject: [PATCH] fs/xfs: Fix issues found while fuzzing the XFS filesystem - -While performing fuzz testing with XFS filesystem images with ASAN -enabled, several issues were found where the memory accesses are made -beyond the data that is allocated into the struct grub_xfs_data -structure's data field. - -The existing structure didn't store the size of the memory allocated into -the buffer in the data field and had no way to check it. To resolve these -issues, the data size is stored to enable checks into the data buffer. - -With these checks in place, the fuzzing corpus no longer cause any crashes. - -Signed-off-by: Darren Kenny -Signed-off-by: Robbie Harwood -Signed-off-by: Marta Lewandowska -Signed-off-by: Lidong Chen -Reviewed-by: Daniel Kiper ---- - grub-core/fs/xfs.c | 26 ++++++++++++++++++++++++++ - 1 file changed, 26 insertions(+) - -diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c -index b67407690c1a..b91cd32b49ab 100644 ---- a/grub-core/fs/xfs.c -+++ b/grub-core/fs/xfs.c -@@ -239,6 +239,7 @@ struct grub_fshelp_node - - struct grub_xfs_data - { -+ grub_size_t data_size; - struct grub_xfs_sblock sblock; - grub_disk_t disk; - int pos; -@@ -611,8 +612,20 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) - } - else if (node->inode.format == XFS_INODE_FORMAT_EXT) - { -+ grub_addr_t exts_end = 0; -+ grub_addr_t data_end = 0; -+ - nrec = grub_be_to_cpu32 (node->inode.nextents); - exts = (struct grub_xfs_extent *) grub_xfs_inode_data(&node->inode); -+ -+ if (grub_mul (sizeof (struct grub_xfs_extent), nrec, &exts_end) || -+ grub_add ((grub_addr_t) node->data, exts_end, &exts_end) || -+ grub_add ((grub_addr_t) node->data, node->data->data_size, &data_end) || -+ exts_end > data_end) -+ { -+ grub_error (GRUB_ERR_BAD_FS, "invalid number of XFS extents"); -+ return 0; -+ } - } - else - { -@@ -803,6 +816,9 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - grub_uint8_t *inopos = grub_xfs_inline_de_inopos(dir->data, de); - grub_uint8_t c; - -+ if ((inopos + (smallino ? 4 : 8)) > (grub_uint8_t *) dir + grub_xfs_fshelp_size (dir->data)) -+ return grub_error (GRUB_ERR_BAD_FS, "not a correct XFS inode"); -+ - /* inopos might be unaligned. */ - if (smallino) - ino = (((grub_uint32_t) inopos[0]) << 24) -@@ -829,6 +845,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - de->name[de->len] = c; - - de = grub_xfs_inline_next_de(dir->data, head, de); -+ -+ if ((grub_uint8_t *) de >= (grub_uint8_t *) dir + grub_xfs_fshelp_size (dir->data)) -+ return grub_error (GRUB_ERR_BAD_FS, "invalid XFS directory entry"); -+ - } - break; - } -@@ -897,6 +917,9 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - } - - filename = (char *)(direntry + 1); -+ if (filename + direntry->len - 1 > (char *) tail) -+ return grub_error (GRUB_ERR_BAD_FS, "invalid XFS directory entry"); -+ - /* The byte after the filename is for the filetype, padding, or - tag, which is not used by GRUB. So it can be overwritten. */ - filename[direntry->len] = '\0'; -@@ -941,6 +964,8 @@ grub_xfs_mount (grub_disk_t disk) - if (!data) - return 0; - -+ data->data_size = sizeof (struct grub_xfs_data); -+ - grub_dprintf("xfs", "Reading sb\n"); - /* Read the superblock. */ - if (grub_disk_read (disk, 0, 0, -@@ -962,6 +987,7 @@ grub_xfs_mount (grub_disk_t disk) - if (! data) - goto fail; - -+ data->data_size = sz; - data->diropen.data = data; - data->diropen.ino = grub_be_to_cpu64(data->sblock.rootino); - data->diropen.inode_read = 1; diff --git a/0344-fs-xfs-Incorrect-short-form-directory-data-boundary-.patch b/0344-fs-xfs-Incorrect-short-form-directory-data-boundary-.patch deleted file mode 100644 index d70ec5a..0000000 --- a/0344-fs-xfs-Incorrect-short-form-directory-data-boundary-.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Lidong Chen -Date: Thu, 28 Sep 2023 22:33:44 +0000 -Subject: [PATCH] fs/xfs: Incorrect short form directory data boundary check - -After parsing of the current entry, the entry pointer is advanced -to the next entry at the end of the "for" loop. In case where the -last entry is at the end of the data boundary, the advanced entry -pointer can point off the data boundary. The subsequent boundary -check for the advanced entry pointer can cause a failure. - -The fix is to include the boundary check into the "for" loop -condition. - -Signed-off-by: Lidong Chen -Reviewed-by: Daniel Kiper -Tested-by: Sebastian Andrzej Siewior -Tested-by: Marta Lewandowska ---- - grub-core/fs/xfs.c | 7 ++----- - 1 file changed, 2 insertions(+), 5 deletions(-) - -diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c -index b91cd32b49ab..ebf962793fa7 100644 ---- a/grub-core/fs/xfs.c -+++ b/grub-core/fs/xfs.c -@@ -810,7 +810,8 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - if (iterate_dir_call_hook (parent, "..", &ctx)) - return 1; - -- for (i = 0; i < head->count; i++) -+ for (i = 0; i < head->count && -+ (grub_uint8_t *) de < ((grub_uint8_t *) dir + grub_xfs_fshelp_size (dir->data)); i++) - { - grub_uint64_t ino; - grub_uint8_t *inopos = grub_xfs_inline_de_inopos(dir->data, de); -@@ -845,10 +846,6 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - de->name[de->len] = c; - - de = grub_xfs_inline_next_de(dir->data, head, de); -- -- if ((grub_uint8_t *) de >= (grub_uint8_t *) dir + grub_xfs_fshelp_size (dir->data)) -- return grub_error (GRUB_ERR_BAD_FS, "invalid XFS directory entry"); -- - } - break; - } diff --git a/0345-fs-xfs-Add-large-extent-counters-incompat-feature-su.patch b/0345-fs-xfs-Add-large-extent-counters-incompat-feature-su.patch deleted file mode 100644 index 8c414a8..0000000 --- a/0345-fs-xfs-Add-large-extent-counters-incompat-feature-su.patch +++ /dev/null @@ -1,115 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Anthony Iliopoulos -Date: Thu, 26 Oct 2023 11:53:39 +0200 -Subject: [PATCH] fs/xfs: Add large extent counters incompat feature support - -XFS introduced 64-bit extent counters for inodes via a series of -upstream commits and the feature was marked as stable in v6.5 via -commit 61d7e8274cd8 (xfs: drop EXPERIMENTAL tag for large extent -counts). - -Further, xfsprogs release v6.5.0 switched this feature on by default -in mkfs.xfs via commit e5b18d7d1d96 (mkfs: enable large extent counts -by default). - -Filesystems formatted with large extent count support, nrext64=1, are -thus currently not recognizable by GRUB, since this is an incompat -feature. Add the required support so that those filesystems and inodes -with large extent counters can be read by GRUB. - -Signed-off-by: Anthony Iliopoulos -Reviewed-by: Andrey Albershteyn -Reviewed-by: Daniel Kiper -Tested-by: Marta Lewandowska -Tested-by: Sebastian Andrzej Siewior ---- - grub-core/fs/xfs.c | 30 +++++++++++++++++++++++++----- - 1 file changed, 25 insertions(+), 5 deletions(-) - -diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c -index 18edfcff486c..bc2224dbb463 100644 ---- a/grub-core/fs/xfs.c -+++ b/grub-core/fs/xfs.c -@@ -79,6 +79,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); - /* Inode flags2 flags */ - #define XFS_DIFLAG2_BIGTIME_BIT 3 - #define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_BIT) -+#define XFS_DIFLAG2_NREXT64_BIT 4 -+#define XFS_DIFLAG2_NREXT64 (1 << XFS_DIFLAG2_NREXT64_BIT) - - /* incompat feature flags */ - #define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */ -@@ -86,6 +88,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); - #define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */ - #define XFS_SB_FEAT_INCOMPAT_BIGTIME (1 << 3) /* large timestamps */ - #define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4) /* needs xfs_repair */ -+#define XFS_SB_FEAT_INCOMPAT_NREXT64 (1 << 5) /* large extent counters */ - - /* - * Directory entries with ftype are explicitly handled by GRUB code. -@@ -101,7 +104,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); - XFS_SB_FEAT_INCOMPAT_SPINODES | \ - XFS_SB_FEAT_INCOMPAT_META_UUID | \ - XFS_SB_FEAT_INCOMPAT_BIGTIME | \ -- XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR) -+ XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR | \ -+ XFS_SB_FEAT_INCOMPAT_NREXT64) - - struct grub_xfs_sblock - { -@@ -203,7 +207,8 @@ struct grub_xfs_inode - grub_uint16_t mode; - grub_uint8_t version; - grub_uint8_t format; -- grub_uint8_t unused2[26]; -+ grub_uint8_t unused2[18]; -+ grub_uint64_t nextents_big; - grub_uint64_t atime; - grub_uint64_t mtime; - grub_uint64_t ctime; -@@ -545,11 +550,26 @@ get_fsb (const void *keys, int idx) - return grub_be_to_cpu64 (grub_get_unaligned64 (p)); - } - -+static int -+grub_xfs_inode_has_large_extent_counts (const struct grub_xfs_inode *inode) -+{ -+ return inode->version >= 3 && -+ (inode->flags2 & grub_cpu_to_be64_compile_time (XFS_DIFLAG2_NREXT64)); -+} -+ -+static grub_uint64_t -+grub_xfs_get_inode_nextents (struct grub_xfs_inode *inode) -+{ -+ return (grub_xfs_inode_has_large_extent_counts (inode)) ? -+ grub_be_to_cpu64 (inode->nextents_big) : -+ grub_be_to_cpu32 (inode->nextents); -+} -+ - static grub_disk_addr_t - grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) - { - struct grub_xfs_btree_node *leaf = 0; -- int ex, nrec; -+ grub_uint64_t ex, nrec; - struct grub_xfs_extent *exts; - grub_uint64_t ret = 0; - -@@ -574,7 +594,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) - / (2 * sizeof (grub_uint64_t)); - do - { -- int i; -+ grub_uint64_t i; - - for (i = 0; i < nrec; i++) - { -@@ -621,7 +641,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) - grub_addr_t exts_end = 0; - grub_addr_t data_end = 0; - -- nrec = grub_be_to_cpu32 (node->inode.nextents); -+ nrec = grub_xfs_get_inode_nextents (&node->inode); - exts = (struct grub_xfs_extent *) grub_xfs_inode_data(&node->inode); - - if (grub_mul (sizeof (struct grub_xfs_extent), nrec, &exts_end) || diff --git a/0350-fs-xfs-Fix-XFS-directory-extent-parsing.patch b/0350-fs-xfs-Fix-XFS-directory-extent-parsing.patch deleted file mode 100644 index c005731..0000000 --- a/0350-fs-xfs-Fix-XFS-directory-extent-parsing.patch +++ /dev/null @@ -1,168 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jon DeVree -Date: Tue, 17 Oct 2023 23:03:47 -0400 -Subject: [PATCH] fs/xfs: Fix XFS directory extent parsing - -The XFS directory entry parsing code has never been completely correct -for extent based directories. The parser correctly handles the case -where the directory is contained in a single extent, but then mistakenly -assumes the data blocks for the multiple extent case are each identical -to the single extent case. The difference in the format of the data -blocks between the two cases is tiny enough that its gone unnoticed for -a very long time. - -A recent change introduced some additional bounds checking into the XFS -parser. Like GRUB's existing parser, it is correct for the single extent -case but incorrect for the multiple extent case. When parsing a directory -with multiple extents, this new bounds checking is sometimes (but not -always) tripped and triggers an "invalid XFS directory entry" error. This -probably would have continued to go unnoticed but the /boot/grub/ -directory is large enough that it often has multiple extents. - -The difference between the two cases is that when there are multiple -extents, the data blocks do not contain a trailer nor do they contain -any leaf information. That information is stored in a separate set of -extents dedicated to just the leaf information. These extents come after -the directory entry extents and are not included in the inode size. So -the existing parser already ignores the leaf extents. - -The only reason to read the trailer/leaf information at all is so that -the parser can avoid misinterpreting that data as directory entries. So -this updates the parser as follows: - -For the single extent case the parser doesn't change much: -1. Read the size of the leaf information from the trailer -2. Set the end pointer for the parser to the start of the leaf - information. (The previous bounds checking set the end pointer to the - start of the trailer, so this is actually a small improvement.) -3. Set the entries variable to the expected number of directory entries. - -For the multiple extent case: -1. Set the end pointer to the end of the block. -2. Do not set up the entries variable. Figuring out how many entries are - in each individual block is complex and does not seem worth it when - it appears to be safe to just iterate over the entire block. - -The bounds check itself was also dependent upon the faulty XFS parser -because it accidentally used "filename + length - 1". Presumably this -was able to pass the fuzzer because in the old parser there was always -8 bytes of slack space between the tail pointer and the actual end of -the block. Since this is no longer the case the bounds check needs to be -updated to "filename + length + 1" in order to prevent a regression in -the handling of corrupt fliesystems. - -Notes: -* When there is only one extent there will only ever be one block. If - more than one block is required then XFS will always switch to holding - leaf information in a separate extent. -* B-tree based directories seems to be parsed properly by the same code - that handles multiple extents. This is unlikely to ever occur within - /boot though because its only used when there are an extremely large - number of directory entries. - -Fixes: ef7850c75 (fs/xfs: Fix issues found while fuzzing the XFS filesystem) -Fixes: b2499b29c (Adds support for the XFS filesystem.) -Fixes: https://savannah.gnu.org/bugs/?64376 - -Signed-off-by: Jon DeVree -Reviewed-by: Daniel Kiper -Tested-by: Sebastian Andrzej Siewior -Tested-by: Marta Lewandowska ---- - grub-core/fs/xfs.c | 52 ++++++++++++++++++++++++++++++++++++++-------------- - 1 file changed, 38 insertions(+), 14 deletions(-) - -diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c -index ebf962793fa7..18edfcff486c 100644 ---- a/grub-core/fs/xfs.c -+++ b/grub-core/fs/xfs.c -@@ -223,6 +223,12 @@ struct grub_xfs_inode - /* Size of struct grub_xfs_inode v2, up to unused4 member included. */ - #define XFS_V2_INODE_SIZE (XFS_V3_INODE_SIZE - 76) - -+struct grub_xfs_dir_leaf_entry -+{ -+ grub_uint32_t hashval; -+ grub_uint32_t address; -+} GRUB_PACKED; -+ - struct grub_xfs_dirblock_tail - { - grub_uint32_t leaf_count; -@@ -874,9 +880,8 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - { - struct grub_xfs_dir2_entry *direntry = - grub_xfs_first_de(dir->data, dirblock); -- int entries; -- struct grub_xfs_dirblock_tail *tail = -- grub_xfs_dir_tail(dir->data, dirblock); -+ int entries = -1; -+ char *end = dirblock + dirblk_size; - - numread = grub_xfs_read_file (dir, 0, 0, - blk << dirblk_log2, -@@ -887,14 +892,27 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - return 0; - } - -- entries = (grub_be_to_cpu32 (tail->leaf_count) -- - grub_be_to_cpu32 (tail->leaf_stale)); -+ /* -+ * Leaf and tail information are only in the data block if the number -+ * of extents is 1. -+ */ -+ if (dir->inode.nextents == grub_cpu_to_be32_compile_time (1)) -+ { -+ struct grub_xfs_dirblock_tail *tail = grub_xfs_dir_tail (dir->data, dirblock); - -- if (!entries) -- continue; -+ end = (char *) tail; -+ -+ /* Subtract the space used by leaf nodes. */ -+ end -= grub_be_to_cpu32 (tail->leaf_count) * sizeof (struct grub_xfs_dir_leaf_entry); -+ -+ 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) -+ while ((char *) direntry < (char *) end) - { - grub_uint8_t *freetag; - char *filename; -@@ -914,7 +932,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - } - - filename = (char *)(direntry + 1); -- if (filename + direntry->len - 1 > (char *) tail) -+ if (filename + direntry->len + 1 > (char *) end) - return grub_error (GRUB_ERR_BAD_FS, "invalid XFS directory entry"); - - /* The byte after the filename is for the filetype, padding, or -@@ -928,11 +946,17 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - return 1; - } - -- /* Check if last direntry in this block is -- reached. */ -- entries--; -- if (!entries) -- break; -+ /* -+ * The expected number of directory entries is only tracked for the -+ * single extent case. -+ */ -+ if (dir->inode.nextents == grub_cpu_to_be32_compile_time (1)) -+ { -+ /* Check if last direntry in this block is reached. */ -+ entries--; -+ if (!entries) -+ break; -+ } - - /* Select the next directory entry. */ - direntry = grub_xfs_next_de(dir->data, direntry); diff --git a/0359-fs-ntfs-Fix-an-OOB-write-when-parsing-the-ATTRIBUTE_.patch b/0359-fs-ntfs-Fix-an-OOB-write-when-parsing-the-ATTRIBUTE_.patch deleted file mode 100644 index ea38989..0000000 --- a/0359-fs-ntfs-Fix-an-OOB-write-when-parsing-the-ATTRIBUTE_.patch +++ /dev/null @@ -1,90 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Maxim Suhanov -Date: Mon, 28 Aug 2023 16:31:57 +0300 -Subject: [PATCH] fs/ntfs: Fix an OOB write when parsing the $ATTRIBUTE_LIST - attribute for the $MFT file - -When parsing an extremely fragmented $MFT file, i.e., the file described -using the $ATTRIBUTE_LIST attribute, current NTFS code will reuse a buffer -containing bytes read from the underlying drive to store sector numbers, -which are consumed later to read data from these sectors into another buffer. - -These sectors numbers, two 32-bit integers, are always stored at predefined -offsets, 0x10 and 0x14, relative to first byte of the selected entry within -the $ATTRIBUTE_LIST attribute. Usually, this won't cause any problem. - -However, when parsing a specially-crafted file system image, this may cause -the NTFS code to write these integers beyond the buffer boundary, likely -causing the GRUB memory allocator to misbehave or fail. These integers contain -values which are controlled by on-disk structures of the NTFS file system. - -Such modification and resulting misbehavior may touch a memory range not -assigned to the GRUB and owned by firmware or another EFI application/driver. - -This fix introduces checks to ensure that these sector numbers are never -written beyond the boundary. - -Fixes: CVE-2023-4692 - -Reported-by: Maxim Suhanov -Signed-off-by: Maxim Suhanov -Reviewed-by: Daniel Kiper ---- - grub-core/fs/ntfs.c | 18 +++++++++++++++++- - 1 file changed, 17 insertions(+), 1 deletion(-) - -diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c -index 3511e4e2cb6f..4681c7ac32a8 100644 ---- a/grub-core/fs/ntfs.c -+++ b/grub-core/fs/ntfs.c -@@ -184,7 +184,7 @@ find_attr (struct grub_ntfs_attr *at, grub_uint8_t attr) - } - if (at->attr_end) - { -- grub_uint8_t *pa; -+ grub_uint8_t *pa, *pa_end; - - at->emft_buf = grub_malloc (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR); - if (at->emft_buf == NULL) -@@ -209,11 +209,13 @@ find_attr (struct grub_ntfs_attr *at, grub_uint8_t attr) - } - at->attr_nxt = at->edat_buf; - at->attr_end = at->edat_buf + u32at (pa, 0x30); -+ pa_end = at->edat_buf + n; - } - else - { - at->attr_nxt = at->attr_end + u16at (pa, 0x14); - at->attr_end = at->attr_end + u32at (pa, 4); -+ pa_end = at->mft->buf + (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR); - } - at->flags |= GRUB_NTFS_AF_ALST; - while (at->attr_nxt < at->attr_end) -@@ -230,6 +232,13 @@ find_attr (struct grub_ntfs_attr *at, grub_uint8_t attr) - at->flags |= GRUB_NTFS_AF_GPOS; - at->attr_cur = at->attr_nxt; - pa = at->attr_cur; -+ -+ if ((pa >= pa_end) || (pa_end - pa < 0x18)) -+ { -+ grub_error (GRUB_ERR_BAD_FS, "can\'t parse attribute list"); -+ return NULL; -+ } -+ - grub_set_unaligned32 ((char *) pa + 0x10, - grub_cpu_to_le32 (at->mft->data->mft_start)); - grub_set_unaligned32 ((char *) pa + 0x14, -@@ -240,6 +249,13 @@ find_attr (struct grub_ntfs_attr *at, grub_uint8_t attr) - { - if (*pa != attr) - break; -+ -+ if ((pa >= pa_end) || (pa_end - pa < 0x18)) -+ { -+ grub_error (GRUB_ERR_BAD_FS, "can\'t parse attribute list"); -+ return NULL; -+ } -+ - if (read_attr - (at, pa + 0x10, - u32at (pa, 0x10) * (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR), diff --git a/0360-fs-ntfs-Fix-an-OOB-read-when-reading-data-from-the-r.patch b/0360-fs-ntfs-Fix-an-OOB-read-when-reading-data-from-the-r.patch deleted file mode 100644 index a7da68c..0000000 --- a/0360-fs-ntfs-Fix-an-OOB-read-when-reading-data-from-the-r.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Maxim Suhanov -Date: Mon, 28 Aug 2023 16:32:33 +0300 -Subject: [PATCH] fs/ntfs: Fix an OOB read when reading data from the resident - $DATA attribute - -When reading a file containing resident data, i.e., the file data is stored in -the $DATA attribute within the NTFS file record, not in external clusters, -there are no checks that this resident data actually fits the corresponding -file record segment. - -When parsing a specially-crafted file system image, the current NTFS code will -read the file data from an arbitrary, attacker-chosen memory offset and of -arbitrary, attacker-chosen length. - -This allows an attacker to display arbitrary chunks of memory, which could -contain sensitive information like password hashes or even plain-text, -obfuscated passwords from BS EFI variables. - -This fix implements a check to ensure that resident data is read from the -corresponding file record segment only. - -Fixes: CVE-2023-4693 - -Reported-by: Maxim Suhanov -Signed-off-by: Maxim Suhanov -Reviewed-by: Daniel Kiper ---- - grub-core/fs/ntfs.c | 13 ++++++++++++- - 1 file changed, 12 insertions(+), 1 deletion(-) - -diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c -index 4681c7ac32a8..1949d48a494f 100644 ---- a/grub-core/fs/ntfs.c -+++ b/grub-core/fs/ntfs.c -@@ -401,7 +401,18 @@ read_data (struct grub_ntfs_attr *at, grub_uint8_t *pa, grub_uint8_t *dest, - { - if (ofs + len > u32at (pa, 0x10)) - return grub_error (GRUB_ERR_BAD_FS, "read out of range"); -- grub_memcpy (dest, pa + u32at (pa, 0x14) + ofs, len); -+ -+ if (u32at (pa, 0x10) > (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR)) -+ return grub_error (GRUB_ERR_BAD_FS, "resident attribute too large"); -+ -+ if (pa >= at->mft->buf + (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR)) -+ return grub_error (GRUB_ERR_BAD_FS, "resident attribute out of range"); -+ -+ if (u16at (pa, 0x14) + u32at (pa, 0x10) > -+ (grub_addr_t) at->mft->buf + (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR) - (grub_addr_t) pa) -+ return grub_error (GRUB_ERR_BAD_FS, "resident attribute out of range"); -+ -+ grub_memcpy (dest, pa + u16at (pa, 0x14) + ofs, len); - return 0; - } - diff --git a/0361-fs-ntfs-Fix-an-OOB-read-when-parsing-directory-entri.patch b/0361-fs-ntfs-Fix-an-OOB-read-when-parsing-directory-entri.patch deleted file mode 100644 index 8f478f7..0000000 --- a/0361-fs-ntfs-Fix-an-OOB-read-when-parsing-directory-entri.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Maxim Suhanov -Date: Mon, 28 Aug 2023 16:33:17 +0300 -Subject: [PATCH] fs/ntfs: Fix an OOB read when parsing directory entries from - resident and non-resident index attributes - -This fix introduces checks to ensure that index entries are never read -beyond the corresponding directory index. - -The lack of this check is a minor issue, likely not exploitable in any way. - -Reported-by: Maxim Suhanov -Signed-off-by: Maxim Suhanov -Reviewed-by: Daniel Kiper ---- - grub-core/fs/ntfs.c | 13 +++++++++++-- - 1 file changed, 11 insertions(+), 2 deletions(-) - -diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c -index 1949d48a494f..72302033281a 100644 ---- a/grub-core/fs/ntfs.c -+++ b/grub-core/fs/ntfs.c -@@ -599,7 +599,7 @@ get_utf8 (grub_uint8_t *in, grub_size_t len) - } - - static int --list_file (struct grub_ntfs_file *diro, grub_uint8_t *pos, -+list_file (struct grub_ntfs_file *diro, grub_uint8_t *pos, grub_uint8_t *end_pos, - grub_fshelp_iterate_dir_hook_t hook, void *hook_data) - { - grub_uint8_t *np; -@@ -610,6 +610,9 @@ list_file (struct grub_ntfs_file *diro, grub_uint8_t *pos, - grub_uint8_t namespace; - char *ustr; - -+ if ((pos >= end_pos) || (end_pos - pos < 0x52)) -+ break; -+ - if (pos[0xC] & 2) /* end signature */ - break; - -@@ -617,6 +620,9 @@ list_file (struct grub_ntfs_file *diro, grub_uint8_t *pos, - ns = *(np++); - namespace = *(np++); - -+ if (2 * ns > end_pos - pos - 0x52) -+ break; -+ - /* - * Ignore files in DOS namespace, as they will reappear as Win32 - * names. -@@ -802,7 +808,9 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir, - } - - cur_pos += 0x10; /* Skip index root */ -- ret = list_file (mft, cur_pos + u16at (cur_pos, 0), hook, hook_data); -+ ret = list_file (mft, cur_pos + u16at (cur_pos, 0), -+ at->mft->buf + (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR), -+ hook, hook_data); - if (ret) - goto done; - -@@ -889,6 +897,7 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir, - (const grub_uint8_t *) "INDX"))) - goto done; - ret = list_file (mft, &indx[0x18 + u16at (indx, 0x18)], -+ indx + (mft->data->idx_size << GRUB_NTFS_BLK_SHR), - hook, hook_data); - if (ret) - goto done; diff --git a/0362-fs-ntfs-Fix-an-OOB-read-when-parsing-bitmaps-for-ind.patch b/0362-fs-ntfs-Fix-an-OOB-read-when-parsing-bitmaps-for-ind.patch deleted file mode 100644 index 9d636c6..0000000 --- a/0362-fs-ntfs-Fix-an-OOB-read-when-parsing-bitmaps-for-ind.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Maxim Suhanov -Date: Mon, 28 Aug 2023 16:33:44 +0300 -Subject: [PATCH] fs/ntfs: Fix an OOB read when parsing bitmaps for index - attributes - -This fix introduces checks to ensure that bitmaps for directory indices -are never read beyond their actual sizes. - -The lack of this check is a minor issue, likely not exploitable in any way. - -Reported-by: Maxim Suhanov -Signed-off-by: Maxim Suhanov -Reviewed-by: Daniel Kiper ---- - grub-core/fs/ntfs.c | 19 +++++++++++++++++++ - 1 file changed, 19 insertions(+) - -diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c -index 72302033281a..74515114287f 100644 ---- a/grub-core/fs/ntfs.c -+++ b/grub-core/fs/ntfs.c -@@ -839,6 +839,25 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir, - - if (is_resident) - { -+ if (bitmap_len > (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR)) -+ { -+ grub_error (GRUB_ERR_BAD_FS, "resident bitmap too large"); -+ goto done; -+ } -+ -+ if (cur_pos >= at->mft->buf + (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR)) -+ { -+ grub_error (GRUB_ERR_BAD_FS, "resident bitmap out of range"); -+ goto done; -+ } -+ -+ if (u16at (cur_pos, 0x14) + u32at (cur_pos, 0x10) > -+ (grub_addr_t) at->mft->buf + (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR) - (grub_addr_t) cur_pos) -+ { -+ grub_error (GRUB_ERR_BAD_FS, "resident bitmap out of range"); -+ goto done; -+ } -+ - grub_memcpy (bmp, cur_pos + u16at (cur_pos, 0x14), - bitmap_len); - } diff --git a/0363-fs-ntfs-Fix-an-OOB-read-when-parsing-a-volume-label.patch b/0363-fs-ntfs-Fix-an-OOB-read-when-parsing-a-volume-label.patch deleted file mode 100644 index 60b36f5..0000000 --- a/0363-fs-ntfs-Fix-an-OOB-read-when-parsing-a-volume-label.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Maxim Suhanov -Date: Mon, 28 Aug 2023 16:38:19 +0300 -Subject: [PATCH] fs/ntfs: Fix an OOB read when parsing a volume label - -This fix introduces checks to ensure that an NTFS volume label is always -read from the corresponding file record segment. - -The current NTFS code allows the volume label string to be read from an -arbitrary, attacker-chosen memory location. However, the bytes read are -always treated as UTF-16LE. So, the final string displayed is mostly -unreadable and it can't be easily converted back to raw bytes. - -The lack of this check is a minor issue, likely not causing a significant -data leak. - -Reported-by: Maxim Suhanov -Signed-off-by: Maxim Suhanov -Reviewed-by: Daniel Kiper ---- - grub-core/fs/ntfs.c | 18 +++++++++++++++++- - 1 file changed, 17 insertions(+), 1 deletion(-) - -diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c -index 74515114287f..32ba8276dd8d 100644 ---- a/grub-core/fs/ntfs.c -+++ b/grub-core/fs/ntfs.c -@@ -1209,13 +1209,29 @@ grub_ntfs_label (grub_device_t device, char **label) - - init_attr (&mft->attr, mft); - pa = find_attr (&mft->attr, GRUB_NTFS_AT_VOLUME_NAME); -+ -+ if (pa >= mft->buf + (mft->data->mft_size << GRUB_NTFS_BLK_SHR)) -+ { -+ grub_error (GRUB_ERR_BAD_FS, "can\'t parse volume label"); -+ goto fail; -+ } -+ -+ if (mft->buf + (mft->data->mft_size << GRUB_NTFS_BLK_SHR) - pa < 0x16) -+ { -+ grub_error (GRUB_ERR_BAD_FS, "can\'t parse volume label"); -+ goto fail; -+ } -+ - if ((pa) && (pa[8] == 0) && (u32at (pa, 0x10))) - { - int len; - - len = u32at (pa, 0x10) / 2; - pa += u16at (pa, 0x14); -- *label = get_utf8 (pa, len); -+ if (mft->buf + (mft->data->mft_size << GRUB_NTFS_BLK_SHR) - pa >= 2 * len) -+ *label = get_utf8 (pa, len); -+ else -+ grub_error (GRUB_ERR_BAD_FS, "can\'t parse volume label"); - } - - fail: diff --git a/0364-fs-ntfs-Make-code-more-readable.patch b/0364-fs-ntfs-Make-code-more-readable.patch deleted file mode 100644 index 81dc8ef..0000000 --- a/0364-fs-ntfs-Make-code-more-readable.patch +++ /dev/null @@ -1,156 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Maxim Suhanov -Date: Mon, 28 Aug 2023 16:40:07 +0300 -Subject: [PATCH] fs/ntfs: Make code more readable - -Move some calls used to access NTFS attribute header fields into -functions with human-readable names. - -Suggested-by: Daniel Kiper -Signed-off-by: Maxim Suhanov -Reviewed-by: Daniel Kiper ---- - grub-core/fs/ntfs.c | 48 +++++++++++++++++++++++++++++++++--------------- - 1 file changed, 33 insertions(+), 15 deletions(-) - -diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c -index 32ba8276dd8d..991b1c2094f5 100644 ---- a/grub-core/fs/ntfs.c -+++ b/grub-core/fs/ntfs.c -@@ -52,6 +52,24 @@ u64at (void *ptr, grub_size_t ofs) - return grub_le_to_cpu64 (grub_get_unaligned64 ((char *) ptr + ofs)); - } - -+static grub_uint16_t -+first_attr_off (void *mft_buf_ptr) -+{ -+ return u16at (mft_buf_ptr, 0x14); -+} -+ -+static grub_uint16_t -+res_attr_data_off (void *res_attr_ptr) -+{ -+ return u16at (res_attr_ptr, 0x14); -+} -+ -+static grub_uint32_t -+res_attr_data_len (void *res_attr_ptr) -+{ -+ return u32at (res_attr_ptr, 0x10); -+} -+ - grub_ntfscomp_func_t grub_ntfscomp_func; - - static grub_err_t -@@ -106,7 +124,7 @@ init_attr (struct grub_ntfs_attr *at, struct grub_ntfs_file *mft) - { - at->mft = mft; - at->flags = (mft == &mft->data->mmft) ? GRUB_NTFS_AF_MMFT : 0; -- at->attr_nxt = mft->buf + u16at (mft->buf, 0x14); -+ at->attr_nxt = mft->buf + first_attr_off (mft->buf); - at->attr_end = at->emft_buf = at->edat_buf = at->sbuf = NULL; - } - -@@ -154,7 +172,7 @@ find_attr (struct grub_ntfs_attr *at, grub_uint8_t attr) - return NULL; - } - -- new_pos = &at->emft_buf[u16at (at->emft_buf, 0x14)]; -+ new_pos = &at->emft_buf[first_attr_off (at->emft_buf)]; - while (*new_pos != 0xFF) - { - if ((*new_pos == *at->attr_cur) -@@ -213,7 +231,7 @@ find_attr (struct grub_ntfs_attr *at, grub_uint8_t attr) - } - else - { -- at->attr_nxt = at->attr_end + u16at (pa, 0x14); -+ at->attr_nxt = at->attr_end + res_attr_data_off (pa); - at->attr_end = at->attr_end + u32at (pa, 4); - pa_end = at->mft->buf + (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR); - } -@@ -399,20 +417,20 @@ read_data (struct grub_ntfs_attr *at, grub_uint8_t *pa, grub_uint8_t *dest, - - if (pa[8] == 0) - { -- if (ofs + len > u32at (pa, 0x10)) -+ if (ofs + len > res_attr_data_len (pa)) - return grub_error (GRUB_ERR_BAD_FS, "read out of range"); - -- if (u32at (pa, 0x10) > (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR)) -+ if (res_attr_data_len (pa) > (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR)) - return grub_error (GRUB_ERR_BAD_FS, "resident attribute too large"); - - if (pa >= at->mft->buf + (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR)) - return grub_error (GRUB_ERR_BAD_FS, "resident attribute out of range"); - -- if (u16at (pa, 0x14) + u32at (pa, 0x10) > -+ if (res_attr_data_off (pa) + res_attr_data_len (pa) > - (grub_addr_t) at->mft->buf + (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR) - (grub_addr_t) pa) - return grub_error (GRUB_ERR_BAD_FS, "resident attribute out of range"); - -- grub_memcpy (dest, pa + u16at (pa, 0x14) + ofs, len); -+ grub_memcpy (dest, pa + res_attr_data_off (pa) + ofs, len); - return 0; - } - -@@ -556,7 +574,7 @@ init_file (struct grub_ntfs_file *mft, grub_uint64_t mftno) - (unsigned long long) mftno); - - if (!pa[8]) -- mft->size = u32at (pa, 0x10); -+ mft->size = res_attr_data_len (pa); - else - mft->size = u64at (pa, 0x30); - -@@ -801,7 +819,7 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir, - (u32at (cur_pos, 0x18) != 0x490024) || - (u32at (cur_pos, 0x1C) != 0x300033)) - continue; -- cur_pos += u16at (cur_pos, 0x14); -+ cur_pos += res_attr_data_off (cur_pos); - if (*cur_pos != 0x30) /* Not filename index */ - continue; - break; -@@ -830,7 +848,7 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir, - { - int is_resident = (cur_pos[8] == 0); - -- bitmap_len = ((is_resident) ? u32at (cur_pos, 0x10) : -+ bitmap_len = ((is_resident) ? res_attr_data_len (cur_pos) : - u32at (cur_pos, 0x28)); - - bmp = grub_malloc (bitmap_len); -@@ -851,14 +869,14 @@ grub_ntfs_iterate_dir (grub_fshelp_node_t dir, - goto done; - } - -- if (u16at (cur_pos, 0x14) + u32at (cur_pos, 0x10) > -+ if (res_attr_data_off (cur_pos) + res_attr_data_len (cur_pos) > - (grub_addr_t) at->mft->buf + (at->mft->data->mft_size << GRUB_NTFS_BLK_SHR) - (grub_addr_t) cur_pos) - { - grub_error (GRUB_ERR_BAD_FS, "resident bitmap out of range"); - goto done; - } - -- grub_memcpy (bmp, cur_pos + u16at (cur_pos, 0x14), -+ grub_memcpy (bmp, cur_pos + res_attr_data_off (cur_pos), - bitmap_len); - } - else -@@ -1222,12 +1240,12 @@ grub_ntfs_label (grub_device_t device, char **label) - goto fail; - } - -- if ((pa) && (pa[8] == 0) && (u32at (pa, 0x10))) -+ if ((pa) && (pa[8] == 0) && (res_attr_data_len (pa))) - { - int len; - -- len = u32at (pa, 0x10) / 2; -- pa += u16at (pa, 0x14); -+ len = res_attr_data_len (pa) / 2; -+ pa += res_attr_data_off (pa); - if (mft->buf + (mft->data->mft_size << GRUB_NTFS_BLK_SHR) - pa >= 2 * len) - *label = get_utf8 (pa, len); - else diff --git a/bootstrap b/bootstrap index 5b08e7e..dc2238f 100755 --- a/bootstrap +++ b/bootstrap @@ -1,10 +1,10 @@ #! /bin/sh # Print a version string. -scriptversion=2019-01-04.17; # UTC +scriptversion=2022-01-26.05; # UTC # Bootstrap this package from checked-out sources. -# Copyright (C) 2003-2019 Free Software Foundation, Inc. +# Copyright (C) 2003-2022 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 @@ -47,7 +47,7 @@ PERL="${PERL-perl}" me=$0 -default_gnulib_url=git://git.sv.gnu.org/gnulib +default_gnulib_url=https://git.savannah.gnu.org/git/gnulib.git usage() { cat </dev/null) +if test -z "$package"; then + package=$(sed -n "$extract_package_name" configure.ac) \ + || die 'cannot find package name in configure.ac' +fi gnulib_name=lib$package build_aux=build-aux @@ -290,62 +313,6 @@ find_tool () eval "export $find_tool_envvar" } -# Override the default configuration, if necessary. -# Make sure that bootstrap.conf is sourced from the current directory -# if we were invoked as "sh bootstrap". -case "$0" in - */*) test -r "$0.conf" && . "$0.conf" ;; - *) test -r "$0.conf" && . ./"$0.conf" ;; -esac - -if test "$vc_ignore" = auto; then - vc_ignore= - test -d .git && vc_ignore=.gitignore - test -d CVS && vc_ignore="$vc_ignore .cvsignore" -fi - -if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" = x; then - use_gnulib=false -else - use_gnulib=true -fi - -# Translate configuration into internal form. - -# Parse options. - -for option -do - case $option in - --help) - usage - exit;; - --gnulib-srcdir=*) - GNULIB_SRCDIR=${option#--gnulib-srcdir=};; - --skip-po) - SKIP_PO=t;; - --force) - checkout_only_file=;; - --copy) - copy=true;; - --bootstrap-sync) - bootstrap_sync=true;; - --no-bootstrap-sync) - bootstrap_sync=false;; - --no-git) - use_git=false;; - *) - die "$option: unknown option";; - esac -done - -$use_git || test -d "$GNULIB_SRCDIR" \ - || die "Error: --no-git requires --gnulib-srcdir" - -if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then - die "Bootstrapping from a non-checked-out distribution is risky." -fi - # Strip blank and comment lines to leave significant entries. gitignore_entries() { sed '/^#/d; /^$/d' "$@" @@ -387,6 +354,137 @@ insert_vc_ignore() { insert_if_absent "$vc_ignore_file" "$pattern" } +symlink_to_dir() +{ + src=$1/$2 + dst=${3-$2} + + test -f "$src" && { + + # If the destination directory doesn't exist, create it. + # This is required at least for "lib/uniwidth/cjk.h". + dst_dir=$(dirname "$dst") + if ! test -d "$dst_dir"; then + mkdir -p "$dst_dir" + + # If we've just created a directory like lib/uniwidth, + # tell version control system(s) it's ignorable. + # FIXME: for now, this does only one level + parent=$(dirname "$dst_dir") + for dot_ig in x $vc_ignore; do + test $dot_ig = x && continue + ig=$parent/$dot_ig + insert_vc_ignore $ig "${dst_dir##*/}" + done + fi + + if $copy; then + { + test ! -h "$dst" || { + echo "$me: rm -f $dst" && + rm -f "$dst" + } + } && + test -f "$dst" && + cmp -s "$src" "$dst" || { + echo "$me: cp -fp $src $dst" && + cp -fp "$src" "$dst" + } + else + # Leave any existing symlink alone, if it already points to the source, + # so that broken build tools that care about symlink times + # aren't confused into doing unnecessary builds. Conversely, if the + # existing symlink's timestamp is older than the source, make it afresh, + # so that broken tools aren't confused into skipping needed builds. See + # . + test -h "$dst" && + src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 && + dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 && + test "$src_i" = "$dst_i" && + both_ls=$(ls -dt "$src" "$dst") && + test "X$both_ls" = "X$dst$nl$src" || { + dot_dots= + case $src in + /*) ;; + *) + case /$dst/ in + *//* | */../* | */./* | /*/*/*/*/*/) + die "invalid symlink calculation: $src -> $dst";; + /*/*/*/*/) dot_dots=../../../;; + /*/*/*/) dot_dots=../../;; + /*/*/) dot_dots=../;; + esac;; + esac + + echo "$me: ln -fs $dot_dots$src $dst" && + ln -fs "$dot_dots$src" "$dst" + } + fi + } +} + +# Override the default configuration, if necessary. +# Make sure that bootstrap.conf is sourced from the current directory +# if we were invoked as "sh bootstrap". +case "$0" in + */*) test -r "$0.conf" && . "$0.conf" ;; + *) test -r "$0.conf" && . ./"$0.conf" ;; +esac + +if test "$vc_ignore" = auto; then + vc_ignore= + test -d .git && vc_ignore=.gitignore + test -d CVS && vc_ignore="$vc_ignore .cvsignore" +fi + +if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" = x; then + use_gnulib=false +else + use_gnulib=true +fi + +# Translate configuration into internal form. + +# Parse options. + +for option +do + case $option in + --help) + usage + exit;; + --version) + set -e + echo "bootstrap $scriptversion" + echo "$copyright" + exit 0 + ;; + --gnulib-srcdir=*) + GNULIB_SRCDIR=${option#--gnulib-srcdir=};; + --skip-po) + SKIP_PO=t;; + --force) + checkout_only_file=;; + --copy) + copy=true;; + --bootstrap-sync) + bootstrap_sync=true;; + --no-bootstrap-sync) + bootstrap_sync=false;; + --no-git) + use_git=false;; + *) + bootstrap_option_hook $option || die "$option: unknown option";; + esac +done + +$use_git || test -d "$GNULIB_SRCDIR" \ + || die "Error: --no-git requires --gnulib-srcdir" + +if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then + die "Bootstrapping from a non-checked-out distribution is risky." +fi + # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac. found_aux_dir=no grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \ @@ -665,9 +763,25 @@ if $use_gnulib; then shallow= if test -z "$GNULIB_REVISION"; then git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2' + git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \ + || cleanup_gnulib + else + git fetch -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2' + mkdir -p "$gnulib_path" + # Only want a shallow checkout of $GNULIB_REVISION, but git does not + # support cloning by commit hash. So attempt a shallow fetch by commit + # hash to minimize the amount of data downloaded and changes needed to + # be processed, which can drastically reduce download and processing + # time for checkout. If the fetch by commit fails, a shallow fetch can + # not be performed because we do not know what the depth of the commit + # is without fetching all commits. So fallback to fetching all commits. + git -C "$gnulib_path" init + git -C "$gnulib_path" remote add origin ${GNULIB_URL:-$default_gnulib_url} + git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \ + || git -C "$gnulib_path" fetch origin \ + || cleanup_gnulib + git -C "$gnulib_path" reset --hard FETCH_HEAD fi - git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \ - || cleanup_gnulib trap - 1 2 13 15 fi @@ -784,75 +898,6 @@ case $SKIP_PO in fi;; esac -symlink_to_dir() -{ - src=$1/$2 - dst=${3-$2} - - test -f "$src" && { - - # If the destination directory doesn't exist, create it. - # This is required at least for "lib/uniwidth/cjk.h". - dst_dir=$(dirname "$dst") - if ! test -d "$dst_dir"; then - mkdir -p "$dst_dir" - - # If we've just created a directory like lib/uniwidth, - # tell version control system(s) it's ignorable. - # FIXME: for now, this does only one level - parent=$(dirname "$dst_dir") - for dot_ig in x $vc_ignore; do - test $dot_ig = x && continue - ig=$parent/$dot_ig - insert_vc_ignore $ig "${dst_dir##*/}" - done - fi - - if $copy; then - { - test ! -h "$dst" || { - echo "$me: rm -f $dst" && - rm -f "$dst" - } - } && - test -f "$dst" && - cmp -s "$src" "$dst" || { - echo "$me: cp -fp $src $dst" && - cp -fp "$src" "$dst" - } - else - # Leave any existing symlink alone, if it already points to the source, - # so that broken build tools that care about symlink times - # aren't confused into doing unnecessary builds. Conversely, if the - # existing symlink's timestamp is older than the source, make it afresh, - # so that broken tools aren't confused into skipping needed builds. See - # . - test -h "$dst" && - src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 && - dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 && - test "$src_i" = "$dst_i" && - both_ls=$(ls -dt "$src" "$dst") && - test "X$both_ls" = "X$dst$nl$src" || { - dot_dots= - case $src in - /*) ;; - *) - case /$dst/ in - *//* | */../* | */./* | /*/*/*/*/*/) - die "invalid symlink calculation: $src -> $dst";; - /*/*/*/*/) dot_dots=../../../;; - /*/*/*/) dot_dots=../../;; - /*/*/) dot_dots=../;; - esac;; - esac - - echo "$me: ln -fs $dot_dots$src $dst" && - ln -fs "$dot_dots$src" "$dst" - } - fi - } -} - version_controlled_file() { parent=$1 file=$2 @@ -970,7 +1015,7 @@ bootstrap_post_import_hook \ # Uninitialized submodules are listed with an initial dash. if $use_git && git submodule | grep '^-' >/dev/null; then die "some git submodules are not initialized. " \ - "Run 'git submodule init' and bootstrap again." + "Run 'git submodule update --init' and bootstrap again." fi # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some @@ -1064,7 +1109,7 @@ bootstrap_epilogue echo "$0: done. Now you can run './configure'." -# Local variables: +# Local Variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" diff --git a/bootstrap.conf b/bootstrap.conf index 6b043fc..7a7813d 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -1,6 +1,6 @@ # Bootstrap configuration. -# Copyright (C) 2006-2019 Free Software Foundation, Inc. +# Copyright (C) 2006-2022 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 @@ -16,11 +16,10 @@ # along with this program. If not, see . -GNULIB_REVISION=d271f868a8df9bbec29049d01e056481b7a1a263 +GNULIB_REVISION=9f48fb992a3d7e96610c4ce8be969cff2d61a01b # gnulib modules used by this package. -# mbswidth is used by gnulib-fix-width.diff's changes to argp rather than -# directly. +# mbswidth is used by fix-width.diff's changes to argp rather than directly. gnulib_modules=" argp base64 @@ -35,6 +34,7 @@ gnulib_modules=" realloc-gnu regex save-cwd + stdbool " gnulib_tool_option_extras="\ @@ -66,10 +66,11 @@ SKIP_PO=t # Build prerequisites buildreq="\ -autoconf 2.63 -automake 1.11 -gettext 0.18.3 +autoconf 2.64 +automake 1.14 +gettext - git 1.5.5 +patch - tar - " @@ -79,11 +80,12 @@ cp -a INSTALL INSTALL.grub bootstrap_post_import_hook () { set -e - for patchname in fix-base64 fix-null-deref fix-null-state-deref fix-regcomp-uninit-token \ - fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width no-abort; do - patch -d grub-core/lib/gnulib -p2 \ - < "grub-core/lib/gnulib-patches/$patchname.patch" - done + + # Instead of patching our gnulib and therefore maintaining a fork, submit + # changes to gnulib and update the hash above when they've merged. Do not + # add new patches here. + patch -d grub-core/lib/gnulib -p2 < grub-core/lib/gnulib-patches/fix-width.patch + for patchname in \ 0001-Support-POTFILES-shell \ 0002-Handle-gettext_printf-shell-function \ diff --git a/gitignore b/gitignore index f6a1bd0..4d0dfb7 100644 --- a/gitignore +++ b/gitignore @@ -11,11 +11,13 @@ *.img *.log *.lst +!/grub-core/extra_deps.lst *.marker *.mod *.o *.pf2 *.pp +*.pyc *.trs *~ .deps-core/ @@ -230,6 +232,8 @@ widthspec.bin /lib/libgcrypt-grub /libgrub_a_init.c /lzocompress_test +/luks1_test +/luks2_test /m4/ /minixfs_test /missing diff --git a/grub.patches b/grub.patches index 0da3904..303e447 100644 --- a/grub.patches +++ b/grub.patches @@ -1,366 +1,280 @@ Patch0001: 0001-Revert-templates-Fix-user-facing-typo-with-an-incorr.patch Patch0002: 0002-Revert-templates-Properly-disable-the-os-prober-by-d.patch Patch0003: 0003-Revert-templates-Disable-the-os-prober-by-default.patch -Patch0004: 0004-Add-support-for-Linux-EFI-stub-loading.patch -Patch0005: 0005-Rework-linux-command.patch -Patch0006: 0006-Rework-linux16-command.patch -Patch0007: 0007-Add-secureboot-support-on-efi-chainloader.patch -Patch0008: 0008-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch -Patch0009: 0009-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch -Patch0010: 0010-re-write-.gitignore.patch -Patch0011: 0011-IBM-client-architecture-CAS-reboot-support.patch -Patch0012: 0012-for-ppc-reset-console-display-attr-when-clear-screen.patch -Patch0013: 0013-Disable-GRUB-video-support-for-IBM-power-machines.patch -Patch0014: 0014-Move-bash-completion-script-922997.patch -Patch0015: 0015-Allow-fallback-to-include-entries-by-title-not-just-.patch -Patch0016: 0016-Make-exit-take-a-return-code.patch -Patch0017: 0017-Make-efi-machines-load-an-env-block-from-a-variable.patch -Patch0018: 0018-Migrate-PPC-from-Yaboot-to-Grub2.patch -Patch0019: 0019-Add-fw_path-variable-revised.patch -Patch0020: 0020-Pass-x-hex-hex-straight-through-unmolested.patch -Patch0021: 0021-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch -Patch0022: 0022-Add-devicetree-loading.patch -Patch0023: 0023-Enable-pager-by-default.-985860.patch -Patch0024: 0024-Don-t-say-GNU-Linux-in-generated-menus.patch -Patch0025: 0025-Add-.eh_frame-to-list-of-relocations-stripped.patch -Patch0026: 0026-Don-t-require-a-password-to-boot-entries-generated-b.patch -Patch0027: 0027-use-fw_path-prefix-when-fallback-searching-for-grub-.patch -Patch0028: 0028-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch -Patch0029: 0029-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch -Patch0030: 0030-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch -Patch0031: 0031-Try-prefix-if-fw_path-doesn-t-work.patch -Patch0032: 0032-Make-grub2-mkconfig-construct-titles-that-look-like-.patch -Patch0033: 0033-Add-friendly-grub2-password-config-tool-985962.patch -Patch0034: 0034-tcp-add-window-scaling-support.patch -Patch0035: 0035-efinet-and-bootp-add-support-for-dhcpv6.patch -Patch0036: 0036-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch -Patch0037: 0037-bz1374141-fix-incorrect-mask-for-ppc64.patch -Patch0038: 0038-Make-grub_fatal-also-backtrace.patch -Patch0039: 0039-Make-our-info-pages-say-grub2-where-appropriate.patch -Patch0040: 0040-macos-just-build-chainloader-entries-don-t-try-any-x.patch -Patch0041: 0041-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch -Patch0042: 0042-export-btrfs_subvol-and-btrfs_subvolid.patch -Patch0043: 0043-grub2-btrfs-03-follow_default.patch -Patch0044: 0044-grub2-btrfs-04-grub2-install.patch -Patch0045: 0045-grub2-btrfs-05-grub2-mkconfig.patch -Patch0046: 0046-grub2-btrfs-06-subvol-mount.patch -Patch0047: 0047-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch -Patch0048: 0048-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch -Patch0049: 0049-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch -Patch0050: 0050-Use-grub_efi_.-memory-helpers-where-reasonable.patch -Patch0051: 0051-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch -Patch0052: 0052-don-t-use-int-for-efi-status.patch -Patch0053: 0053-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch -Patch0054: 0054-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch -Patch0055: 0055-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch -Patch0056: 0056-Make-pmtimer-tsc-calibration-not-take-51-seconds-to-.patch -Patch0057: 0057-align-struct-efi_variable-better.patch -Patch0058: 0058-Add-BLS-support-to-grub-mkconfig.patch -Patch0059: 0059-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch -Patch0060: 0060-Add-grub2-switch-to-blscfg.patch -Patch0061: 0061-make-better-backtraces.patch -Patch0062: 0062-normal-don-t-draw-our-startup-message-if-debug-is-se.patch -Patch0063: 0063-Work-around-some-minor-include-path-weirdnesses.patch -Patch0064: 0064-Make-it-possible-to-enabled-build-id-sha1.patch -Patch0065: 0065-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch -Patch0066: 0066-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch -Patch0067: 0067-Fixup-for-newer-compiler.patch -Patch0068: 0068-Don-t-attempt-to-export-the-start-and-_start-symbols.patch -Patch0069: 0069-Fixup-for-newer-compiler.patch -Patch0070: 0070-Add-support-for-non-Ethernet-network-cards.patch -Patch0071: 0071-net-read-bracketed-ipv6-addrs-and-port-numbers.patch -Patch0072: 0072-bootp-New-net_bootp6-command.patch -Patch0073: 0073-efinet-UEFI-IPv6-PXE-support.patch -Patch0074: 0074-grub.texi-Add-net_bootp6-doument.patch -Patch0075: 0075-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch -Patch0076: 0076-efinet-Setting-network-from-UEFI-device-path.patch -Patch0077: 0077-efinet-Setting-DNS-server-from-UEFI-protocol.patch -Patch0078: 0078-Support-UEFI-networking-protocols.patch -Patch0079: 0079-AUDIT-0-http-boot-tracker-bug.patch -Patch0080: 0080-grub-editenv-Add-incr-command-to-increment-integer-v.patch -Patch0081: 0081-Add-auto-hide-menu-support.patch -Patch0082: 0082-Add-grub-set-bootflag-utility.patch -Patch0083: 0083-docs-Add-grub-boot-indeterminate.service-example.patch -Patch0084: 0084-gentpl-add-disable-support.patch -Patch0085: 0085-gentpl-add-pc-firmware-type.patch -Patch0086: 0086-efinet-also-use-the-firmware-acceleration-for-http.patch -Patch0087: 0087-efi-http-Make-root_url-reflect-the-protocol-hostname.patch -Patch0088: 0088-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch -Patch0089: 0089-module-verifier-make-it-possible-to-run-checkers-on-.patch -Patch0090: 0090-Rework-how-the-fdt-command-builds.patch -Patch0091: 0091-Disable-non-wordsize-allocations-on-arm.patch -Patch0092: 0092-Prepend-prefix-when-HTTP-path-is-relative.patch -Patch0093: 0093-Make-grub_error-more-verbose.patch -Patch0094: 0094-Make-reset-an-alias-for-the-reboot-command.patch -Patch0095: 0095-Add-a-version-command.patch -Patch0096: 0096-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch -Patch0097: 0097-arm-arm64-loader-Better-memory-allocation-and-error-.patch -Patch0098: 0098-Try-to-pick-better-locations-for-kernel-and-initrd.patch -Patch0099: 0099-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch -Patch0100: 0100-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch -Patch0101: 0101-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch -Patch0102: 0102-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch -Patch0103: 0103-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch -Patch0104: 0104-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch -Patch0105: 0105-Fix-getroot.c-s-trampolines.patch -Patch0106: 0106-Do-not-allow-stack-trampolines-anywhere.patch -Patch0107: 0107-Reimplement-boot_counter.patch -Patch0108: 0108-Fix-menu-entry-selection-based-on-ID-and-title.patch -Patch0109: 0109-Make-the-menu-entry-users-option-argument-to-be-opti.patch -Patch0110: 0110-Add-efi-export-env-and-efi-load-env-commands.patch -Patch0111: 0111-Make-it-possible-to-subtract-conditions-from-debug.patch -Patch0112: 0112-Export-all-variables-from-the-initial-context-when-c.patch -Patch0113: 0113-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch -Patch0114: 0114-Don-t-assume-that-boot-commands-will-only-return-on-.patch -Patch0115: 0115-grub-set-bootflag-Update-comment-about-running-as-ro.patch -Patch0116: 0116-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch -Patch0117: 0117-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch -Patch0118: 0118-Add-start-symbol-for-RISC-V.patch -Patch0119: 0119-bootstrap.conf-Force-autogen.sh-to-use-python3.patch -Patch0120: 0120-efi-http-Export-fw-http-_path-variables-to-make-them.patch -Patch0121: 0121-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch -Patch0122: 0122-efi-net-Allow-to-specify-a-port-number-in-addresses.patch -Patch0123: 0123-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch -Patch0124: 0124-efi-net-Print-a-debug-message-if-parsing-the-address.patch -Patch0125: 0125-kern-term-Also-accept-F8-as-a-user-interrupt-key.patch -Patch0126: 0126-efi-Set-image-base-address-before-jumping-to-the-PE-.patch -Patch0127: 0127-tpm-Don-t-propagate-TPM-measurement-errors-to-the-ve.patch -Patch0128: 0128-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch -Patch0129: 0129-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch -Patch0130: 0130-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch -Patch0131: 0131-efi-dhcp-fix-some-allocation-error-checking.patch -Patch0132: 0132-efi-http-fix-some-allocation-error-checking.patch -Patch0133: 0133-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch -Patch0134: 0134-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch -Patch0135: 0135-linuxefi-fail-kernel-validation-without-shim-protoco.patch -Patch0136: 0136-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch -Patch0137: 0137-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch -Patch0138: 0138-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch -Patch0139: 0139-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch -Patch0140: 0140-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch -Patch0141: 0141-Add-systemd-integration-scripts-to-make-systemctl-re.patch -Patch0142: 0142-systemd-integration.sh-Also-set-old-menu_show_once-g.patch -Patch0143: 0143-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch -Patch0144: 0144-grub-install-disable-support-for-EFI-platforms.patch -Patch0145: 0145-New-with-debug-timestamps-configure-flag-to-prepend-.patch -Patch0146: 0146-Added-debug-statements-to-grub_disk_open-and-grub_di.patch -Patch0147: 0147-Introduce-function-grub_debug_is_enabled-void-return.patch -Patch0148: 0148-Don-t-clear-screen-when-debugging-is-enabled.patch -Patch0149: 0149-kern-file-Fix-error-handling-in-grub_file_open.patch -Patch0150: 0150-grub_file_-instrumentation-new-file-debug-tag.patch -Patch0151: 0151-ieee1275-Avoiding-many-unecessary-open-close.patch -Patch0152: 0152-ieee1275-powerpc-implements-fibre-channel-discovery-.patch -Patch0153: 0153-ieee1275-powerpc-enables-device-mapper-discovery.patch -Patch0154: 0154-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch -Patch0155: 0155-Add-suport-for-signing-grub-with-an-appended-signatu.patch -Patch0156: 0156-docs-grub-Document-signing-grub-under-UEFI.patch -Patch0157: 0157-docs-grub-Document-signing-grub-with-an-appended-sig.patch -Patch0158: 0158-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch -Patch0159: 0159-pgp-factor-out-rsa_pad.patch -Patch0160: 0160-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch -Patch0161: 0161-posix_wrap-tweaks-in-preparation-for-libtasn1.patch -Patch0162: 0162-libtasn1-import-libtasn1-4.16.0.patch -Patch0163: 0163-libtasn1-disable-code-not-needed-in-grub.patch -Patch0164: 0164-libtasn1-changes-for-grub-compatibility.patch -Patch0165: 0165-libtasn1-compile-into-asn1-module.patch -Patch0166: 0166-test_asn1-test-module-for-libtasn1.patch -Patch0167: 0167-grub-install-support-embedding-x509-certificates.patch -Patch0168: 0168-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch -Patch0169: 0169-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch -Patch0170: 0170-appended-signatures-support-verifying-appended-signa.patch -Patch0171: 0171-appended-signatures-verification-tests.patch -Patch0172: 0172-appended-signatures-documentation.patch -Patch0173: 0173-ieee1275-enter-lockdown-based-on-ibm-secure-boot.patch -Patch0174: 0174-ieee1275-drop-HEAP_MAX_ADDR-HEAP_MIN_SIZE.patch -Patch0175: 0175-appendedsig-x509-Also-handle-the-Extended-Key-Usage-.patch -Patch0176: 0176-ieee1275-ofdisk-retry-on-open-failure.patch -Patch0177: 0177-Allow-chainloading-EFI-apps-from-loop-mounts.patch -Patch0178: 0178-efinet-Add-DHCP-proxy-support.patch -Patch0179: 0179-fs-ext2-Ignore-checksum-seed-incompat-feature.patch -Patch0180: 0180-Don-t-update-the-cmdline-when-generating-legacy-menu.patch -Patch0181: 0181-Suppress-gettext-error-message.patch -Patch0182: 0182-grub-set-password-Always-use-boot-grub2-user.cfg-as-.patch -Patch0183: 0183-templates-Check-for-EFI-at-runtime-instead-of-config.patch -Patch0184: 0184-efi-Print-an-error-if-boot-to-firmware-setup-is-not-.patch -Patch0185: 0185-arm64-Fix-EFI-loader-kernel-image-allocation.patch -Patch0186: 0186-normal-main-Discover-the-device-to-read-the-config-f.patch -Patch0187: 0187-powerpc-adjust-setting-of-prefix-for-signed-binary-c.patch -Patch0188: 0188-fs-xfs-Fix-unreadable-filesystem-with-v4-superblock.patch -Patch0189: 0189-Print-module-name-on-license-check-failure.patch -Patch0190: 0190-powerpc-ieee1275-load-grub-at-4MB-not-2MB.patch -Patch0191: 0191-grub-mkconfig-restore-umask-for-grub.cfg.patch -Patch0192: 0192-fs-btrfs-Use-full-btrfs-bootloader-area.patch -Patch0193: 0193-Add-Fedora-location-of-DejaVu-SANS-font.patch -Patch0194: 0194-normal-menu-Don-t-show-Booting-s-msg-when-auto-booti.patch -Patch0195: 0195-EFI-suppress-the-Welcome-to-GRUB-message-in-EFI-buil.patch -Patch0196: 0196-EFI-console-Do-not-set-colorstate-until-the-first-te.patch -Patch0197: 0197-EFI-console-Do-not-set-cursor-until-the-first-text-o.patch -Patch0198: 0198-Use-visual-indentation-in-config.h.in.patch -Patch0199: 0199-Where-present-ensure-config-util.h-precedes-config.h.patch -Patch0200: 0200-Drop-gnulib-fix-base64.patch.patch -Patch0201: 0201-Drop-gnulib-no-abort.patch.patch -Patch0202: 0202-Update-gnulib-version-and-drop-most-gnulib-patches.patch -Patch0203: 0203-commands-search-Fix-bug-stopping-iteration-when-no-f.patch -Patch0204: 0204-search-new-efidisk-only-option-on-EFI-systems.patch -Patch0205: 0205-efi-new-connectefi-command.patch -Patch0206: 0206-grub-core-loader-i386-efi-linux.c-do-not-validate-ke.patch -Patch0207: 0207-grub-core-loader-arm64-linux.c-do-not-validate-kerne.patch -Patch0208: 0208-grub-core-loader-efi-chainloader.c-do-not-validate-c.patch -Patch0209: 0209-grub-core-loader-efi-linux.c-drop-now-unused-grub_li.patch -Patch0210: 0210-powerpc-prefix-detection-support-device-names-with-c.patch -Patch0211: 0211-make-ofdisk_retries-optional.patch -Patch0212: 0212-loader-efi-chainloader-grub_load_and_start_image-doe.patch -Patch0213: 0213-loader-efi-chainloader-simplify-the-loader-state.patch -Patch0214: 0214-commands-boot-Add-API-to-pass-context-to-loader.patch -Patch0215: 0215-loader-efi-chainloader-Use-grub_loader_set_ex.patch -Patch0216: 0216-loader-i386-efi-linux-Avoid-a-use-after-free-in-the-.patch -Patch0217: 0217-loader-i386-efi-linux-Use-grub_loader_set_ex.patch -Patch0218: 0218-loader-i386-efi-linux-Fix-a-memory-leak-in-the-initr.patch -Patch0219: 0219-kern-efi-sb-Reject-non-kernel-files-in-the-shim_lock.patch -Patch0220: 0220-kern-file-Do-not-leak-device_name-on-error-in-grub_f.patch -Patch0221: 0221-video-readers-png-Abort-sooner-if-a-read-operation-f.patch -Patch0222: 0222-video-readers-png-Refuse-to-handle-multiple-image-he.patch -Patch0223: 0223-video-readers-png-Drop-greyscale-support-to-fix-heap.patch -Patch0224: 0224-video-readers-png-Avoid-heap-OOB-R-W-inserting-huff-.patch -Patch0225: 0225-video-readers-png-Sanity-check-some-huffman-codes.patch -Patch0226: 0226-video-readers-jpeg-Abort-sooner-if-a-read-operation-.patch -Patch0227: 0227-video-readers-jpeg-Do-not-reallocate-a-given-huff-ta.patch -Patch0228: 0228-video-readers-jpeg-Refuse-to-handle-multiple-start-o.patch -Patch0229: 0229-video-readers-jpeg-Block-int-underflow-wild-pointer-.patch -Patch0230: 0230-normal-charset-Fix-array-out-of-bounds-formatting-un.patch -Patch0231: 0231-net-netbuff-Block-overly-large-netbuff-allocs.patch -Patch0232: 0232-net-ip-Do-IP-fragment-maths-safely.patch -Patch0233: 0233-net-dns-Fix-double-free-addresses-on-corrupt-DNS-res.patch -Patch0234: 0234-net-dns-Don-t-read-past-the-end-of-the-string-we-re-.patch -Patch0235: 0235-net-tftp-Prevent-a-UAF-and-double-free-from-a-failed.patch -Patch0236: 0236-net-tftp-Avoid-a-trivial-UAF.patch -Patch0237: 0237-net-http-Do-not-tear-down-socket-if-it-s-already-bee.patch -Patch0238: 0238-net-http-Fix-OOB-write-for-split-http-headers.patch -Patch0239: 0239-net-http-Error-out-on-headers-with-LF-without-CR.patch -Patch0240: 0240-fs-f2fs-Do-not-read-past-the-end-of-nat-journal-entr.patch -Patch0241: 0241-fs-f2fs-Do-not-read-past-the-end-of-nat-bitmap.patch -Patch0242: 0242-fs-f2fs-Do-not-copy-file-names-that-are-too-long.patch -Patch0243: 0243-fs-btrfs-Fix-several-fuzz-issues-with-invalid-dir-it.patch -Patch0244: 0244-fs-btrfs-Fix-more-ASAN-and-SEGV-issues-found-with-fu.patch -Patch0245: 0245-fs-btrfs-Fix-more-fuzz-issues-related-to-chunks.patch -Patch0246: 0246-misc-Make-grub_min-and-grub_max-more-resilient.patch -Patch0247: 0247-ReiserFS-switch-to-using-grub_min-grub_max.patch -Patch0248: 0248-misc-make-grub_boot_time-also-call-grub_dprintf-boot.patch -Patch0249: 0249-modules-make-.module_license-read-only.patch -Patch0250: 0250-modules-strip-.llvm_addrsig-sections-and-similar.patch -Patch0251: 0251-modules-Don-t-allocate-space-for-non-allocable-secti.patch -Patch0252: 0252-pe-add-the-DOS-header-struct-and-fix-some-bad-naming.patch -Patch0253: 0253-EFI-allocate-kernel-in-EFI_RUNTIME_SERVICES_CODE-ins.patch -Patch0254: 0254-modules-load-module-sections-at-page-aligned-address.patch -Patch0255: 0255-nx-add-memory-attribute-get-set-API.patch -Patch0256: 0256-nx-set-page-permissions-for-loaded-modules.patch -Patch0257: 0257-nx-set-attrs-in-our-kernel-loaders.patch -Patch0258: 0258-nx-set-the-nx-compatible-flag-in-EFI-grub-images.patch -Patch0259: 0259-grub-probe-document-the-behavior-of-multiple-v.patch -Patch0260: 0260-grub_fs_probe-dprint-errors-from-filesystems.patch -Patch0261: 0261-fs-fat-don-t-error-when-mtime-is-0.patch -Patch0262: 0262-Make-debug-file-show-which-file-filters-get-run.patch -Patch0263: 0263-efi-use-enumerated-array-positions-for-our-allocatio.patch -Patch0264: 0264-efi-split-allocation-policy-for-kernel-vs-initrd-mem.patch -Patch0265: 0265-efi-allocate-the-initrd-within-the-bounds-expressed-.patch -Patch0266: 0266-efi-use-EFI_LOADER_-CODE-DATA-for-kernel-and-initrd-.patch -Patch0267: 0267-BLS-create-etc-kernel-cmdline-during-mkconfig.patch -Patch0268: 0268-squish-don-t-dup-rhgb-quiet-check-mtimes.patch -Patch0269: 0269-squish-give-up-on-rhgb-quiet.patch -Patch0270: 0270-squish-BLS-only-write-etc-kernel-cmdline-if-writable.patch -Patch0271: 0271-blscfg-Don-t-root-device-in-emu-builds.patch -Patch0272: 0272-loader-arm64-linux-Remove-magic-number-header-field-.patch -Patch0273: 0273-Correct-BSS-zeroing-on-aarch64.patch -Patch0274: 0274-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch -Patch0275: 0275-x86-efi-Fix-an-incorrect-array-size-in-kernel-alloca.patch -Patch0276: 0276-commands-efi-tpm-Refine-the-status-of-log-event.patch -Patch0277: 0277-commands-efi-tpm-Use-grub_strcpy-instead-of-grub_mem.patch -Patch0278: 0278-efi-tpm-Add-EFI_CC_MEASUREMENT_PROTOCOL-support.patch -Patch0279: 0279-font-Reject-glyphs-exceeds-font-max_glyph_width-or-f.patch -Patch0280: 0280-font-Fix-size-overflow-in-grub_font_get_glyph_intern.patch -Patch0281: 0281-font-Fix-several-integer-overflows-in-grub_font_cons.patch -Patch0282: 0282-font-Remove-grub_font_dup_glyph.patch -Patch0283: 0283-font-Fix-integer-overflow-in-ensure_comb_space.patch -Patch0284: 0284-font-Fix-integer-overflow-in-BMP-index.patch -Patch0285: 0285-font-Fix-integer-underflow-in-binary-search-of-char-.patch -Patch0286: 0286-kern-efi-sb-Enforce-verification-of-font-files.patch -Patch0287: 0287-fbutil-Fix-integer-overflow.patch -Patch0288: 0288-font-Fix-an-integer-underflow-in-blit_comb.patch -Patch0289: 0289-font-Harden-grub_font_blit_glyph-and-grub_font_blit_.patch -Patch0290: 0290-font-Assign-null_font-to-glyphs-in-ascii_font_glyph.patch -Patch0291: 0291-normal-charset-Fix-an-integer-overflow-in-grub_unico.patch -Patch0292: 0292-font-Try-opening-fonts-from-the-bundled-memdisk.patch -Patch0293: 0293-mm-Clarify-grub_real_malloc.patch -Patch0294: 0294-mm-grub_real_malloc-Make-small-allocs-comment-match-.patch -Patch0295: 0295-mm-Document-grub_free.patch -Patch0296: 0296-mm-Document-grub_mm_init_region.patch -Patch0297: 0297-mm-Document-GRUB-internal-memory-management-structur.patch -Patch0298: 0298-mm-Assert-that-we-preserve-header-vs-region-alignmen.patch -Patch0299: 0299-mm-When-adding-a-region-merge-with-region-after-as-w.patch -Patch0300: 0300-mm-Debug-support-for-region-operations.patch -Patch0301: 0301-mm-Drop-unused-unloading-of-modules-on-OOM.patch -Patch0302: 0302-mm-Allow-dynamically-requesting-additional-memory-re.patch -Patch0303: 0303-kern-efi-mm-Always-request-a-fixed-number-of-pages-o.patch -Patch0304: 0304-kern-efi-mm-Extract-function-to-add-memory-regions.patch -Patch0305: 0305-kern-efi-mm-Pass-up-errors-from-add_memory_regions.patch -Patch0306: 0306-kern-efi-mm-Implement-runtime-addition-of-pages.patch -Patch0307: 0307-efi-Increase-default-memory-allocation-to-32-MiB.patch -Patch0308: 0308-mm-Try-invalidate-disk-caches-last-when-out-of-memor.patch -Patch0309: 0309-ppc64le-signed-boot-media-changes.patch -Patch0310: 0310-core-Fix-several-implicit-function-declarations.patch -Patch0311: 0311-loader-Add-support-for-grub-emu-to-kexec-Linux-menu-.patch -Patch0312: 0312-powerpc-Drop-Open-Hack-Ware-remove-GRUB_IEEE1275_FLA.patch -Patch0313: 0313-ieee1275-request-memory-with-ibm-client-architecture.patch -Patch0314: 0314-ieee1275-drop-len-1-quirk-in-heap_init.patch -Patch0315: 0315-ieee1275-support-runtime-memory-claiming.patch -Patch0316: 0316-ieee1275-implement-vec5-for-cas-negotiation.patch -Patch0317: 0317-ibmvtpm-Add-support-for-trusted-boot-using-a-vTPM-2..patch -Patch0318: 0318-powerpc-Drop-Open-Hack-Ware.patch -Patch0319: 0319-osdep-linux-hostdisk-Modify-sector-by-sysfs-as-disk-.patch -Patch0320: 0320-mm-Adjust-new-region-size-to-take-management-overhea.patch -Patch0321: 0321-mm-Preallocate-some-space-when-adding-new-regions.patch -Patch0322: 0322-mm-Avoid-complex-heap-growth-math-in-hot-path.patch -Patch0323: 0323-hostdisk-work-around-proc-not-reporting-size.patch -Patch0324: 0324-blscfg-check-for-mounted-boot-in-emu.patch -Patch0325: 0325-emu-linux-work-around-systemctl-kexec-returning.patch -Patch0326: 0326-kern-ieee1275-init-Convert-plain-numbers-to-constant.patch -Patch0327: 0327-kern-ieee1275-init-Extended-support-in-Vec5.patch -Patch0328: 0328-tpm-Disable-the-tpm-verifier-if-the-TPM-device-is-no.patch -Patch0329: 0329-grub_dl_set_mem_attrs-fix-format-string.patch -Patch0330: 0330-grub_dl_set_mem_attrs-add-self-check-for-the-tramp-G.patch -Patch0331: 0331-grub_dl_load_segments-page-align-the-tramp-GOT-areas.patch -Patch0332: 0332-emu-Add-switch-root-to-grub-emu.patch -Patch0333: 0333-util-Enable-default-kernel-for-updates.patch -Patch0334: 0334-efi-http-change-uint32_t-to-uintn_t.patch -Patch0335: 0335-Add-Install-section-to-aux-systemd-units.patch -Patch0336: 0336-arm64-Use-proper-memory-type-for-kernel-allocation.patch -Patch0337: 0337-Fix-missing-include-in-ofdisk.c.patch -Patch0338: 0338-kern-ieee1275-init-ppc64-Restrict-high-memory-in-pre.patch -Patch0339: 0339-grub-install-on-EFI-if-forced.patch -Patch0340: 0340-Remove-Install-section-from-aux-systemd-units.patch -Patch0341: 0341-fs-Remove-trailing-whitespaces.patch -Patch0342: 0342-fs-xfs-Fix-memory-leaks-in-XFS-module.patch -Patch0343: 0343-fs-xfs-Fix-issues-found-while-fuzzing-the-XFS-filesy.patch -Patch0344: 0344-fs-xfs-Incorrect-short-form-directory-data-boundary-.patch -Patch0345: 0345-fs-xfs-Add-large-extent-counters-incompat-feature-su.patch -Patch0346: 0346-chainloader-remove-device-path-debug-message.patch -Patch0347: 0347-normal-Remove-grub_env_set-prefix-in-grub_try_normal.patch -Patch0348: 0348-add-flag-to-only-search-root-dev.patch -Patch0349: 0349-Ignore-warnings-for-incompatible-types.patch -Patch0350: 0350-fs-xfs-Fix-XFS-directory-extent-parsing.patch -Patch0351: 0351-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch -Patch0352: 0352-grub2-mkconfig-Simplify-os_name-detection.patch -Patch0353: 0353-grub-mkconfig-Remove-check-for-mount-point-for-grub-.patch -Patch0354: 0354-grub-mkconfig-dont-overwrite-BLS-cmdline-if-BLSCFG.patch -Patch0355: 0355-grub2-mkconfig-Pass-all-boot-params-when-used-by-ana.patch -Patch0356: 0356-grub-set-bootflag-Conservative-partial-fix-for-CVE-2.patch -Patch0357: 0357-grub-set-bootflag-More-complete-fix-for-CVE-2024-104.patch -Patch0358: 0358-grub-set-bootflag-Exit-calmly-when-not-running-as-ro.patch -Patch0359: 0359-fs-ntfs-Fix-an-OOB-write-when-parsing-the-ATTRIBUTE_.patch -Patch0360: 0360-fs-ntfs-Fix-an-OOB-read-when-reading-data-from-the-r.patch -Patch0361: 0361-fs-ntfs-Fix-an-OOB-read-when-parsing-directory-entri.patch -Patch0362: 0362-fs-ntfs-Fix-an-OOB-read-when-parsing-bitmaps-for-ind.patch -Patch0363: 0363-fs-ntfs-Fix-an-OOB-read-when-parsing-a-volume-label.patch -Patch0364: 0364-fs-ntfs-Make-code-more-readable.patch -Patch0365: 0365-cmd-search-Rework-of-CVE-2023-4001-fix.patch -Patch0366: 0366-grub-mkconfig.in-turn-off-executable-owner-bit.patch +Patch0004: 0004-Rework-linux-command.patch +Patch0005: 0005-Rework-linux16-command.patch +Patch0006: 0006-re-write-.gitignore.patch +Patch0007: 0007-IBM-client-architecture-CAS-reboot-support.patch +Patch0008: 0008-for-ppc-reset-console-display-attr-when-clear-screen.patch +Patch0009: 0009-Disable-GRUB-video-support-for-IBM-power-machines.patch +Patch0010: 0010-Move-bash-completion-script-922997.patch +Patch0011: 0011-Allow-fallback-to-include-entries-by-title-not-just-.patch +Patch0012: 0012-Make-exit-take-a-return-code.patch +Patch0013: 0013-Make-efi-machines-load-an-env-block-from-a-variable.patch +Patch0014: 0014-Migrate-PPC-from-Yaboot-to-Grub2.patch +Patch0015: 0015-Add-fw_path-variable-revised.patch +Patch0016: 0016-Pass-x-hex-hex-straight-through-unmolested.patch +Patch0017: 0017-blscfg-add-blscfg-module-to-parse-Boot-Loader-Specif.patch +Patch0018: 0018-Add-devicetree-loading.patch +Patch0019: 0019-Enable-pager-by-default.-985860.patch +Patch0020: 0020-Don-t-say-GNU-Linux-in-generated-menus.patch +Patch0021: 0021-Add-.eh_frame-to-list-of-relocations-stripped.patch +Patch0022: 0022-Don-t-require-a-password-to-boot-entries-generated-b.patch +Patch0023: 0023-use-fw_path-prefix-when-fallback-searching-for-grub-.patch +Patch0024: 0024-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch +Patch0025: 0025-Generate-OS-and-CLASS-in-10_linux-from-etc-os-releas.patch +Patch0026: 0026-Try-prefix-if-fw_path-doesn-t-work.patch +Patch0027: 0027-Make-grub2-mkconfig-construct-titles-that-look-like-.patch +Patch0028: 0028-Add-friendly-grub2-password-config-tool-985962.patch +Patch0029: 0029-tcp-add-window-scaling-support.patch +Patch0030: 0030-efinet-and-bootp-add-support-for-dhcpv6.patch +Patch0031: 0031-bootp-New-net_bootp6-command.patch +Patch0032: 0032-Add-grub-get-kernel-settings-and-use-it-in-10_linux.patch +Patch0033: 0033-Make-grub_fatal-also-backtrace.patch +Patch0034: 0034-Make-our-info-pages-say-grub2-where-appropriate.patch +Patch0035: 0035-macos-just-build-chainloader-entries-don-t-try-any-x.patch +Patch0036: 0036-grub2-btrfs-Add-ability-to-boot-from-subvolumes.patch +Patch0037: 0037-btrfs-fix-a-bad-null-check.patch +Patch0038: 0038-export-btrfs_subvol-and-btrfs_subvolid.patch +Patch0039: 0039-grub2-btrfs-03-follow_default.patch +Patch0040: 0040-grub2-btrfs-04-grub2-install.patch +Patch0041: 0041-grub2-btrfs-05-grub2-mkconfig.patch +Patch0042: 0042-grub2-btrfs-06-subvol-mount.patch +Patch0043: 0043-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch +Patch0044: 0044-Grub-not-working-correctly-with-btrfs-snapshots-bsc-.patch +Patch0045: 0045-Add-grub_efi_allocate_pool-and-grub_efi_free_pool-wr.patch +Patch0046: 0046-Use-grub_efi_.-memory-helpers-where-reasonable.patch +Patch0047: 0047-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch +Patch0048: 0048-don-t-use-int-for-efi-status.patch +Patch0049: 0049-make-GRUB_MOD_INIT-declare-its-function-prototypes.patch +Patch0050: 0050-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch +Patch0051: 0051-20_linux_xen-load-xen-or-multiboot-2-modules-as-need.patch +Patch0052: 0052-align-struct-efi_variable-better.patch +Patch0053: 0053-Add-BLS-support-to-grub-mkconfig.patch +Patch0054: 0054-Don-t-attempt-to-backtrace-on-grub_abort-for-grub-em.patch +Patch0055: 0055-Add-grub2-switch-to-blscfg.patch +Patch0056: 0056-normal-don-t-draw-our-startup-message-if-debug-is-se.patch +Patch0057: 0057-Work-around-some-minor-include-path-weirdnesses.patch +Patch0058: 0058-Make-it-possible-to-enabled-build-id-sha1.patch +Patch0059: 0059-make-better-backtraces.patch +Patch0060: 0060-Fixup-for-newer-compiler.patch +Patch0061: 0061-Don-t-attempt-to-export-the-start-and-_start-symbols.patch +Patch0062: 0062-Fixup-for-newer-compiler.patch +Patch0063: 0063-Add-support-for-non-Ethernet-network-cards.patch +Patch0064: 0064-efinet-UEFI-IPv6-PXE-support.patch +Patch0065: 0065-grub.texi-Add-net_bootp6-doument.patch +Patch0066: 0066-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch +Patch0067: 0067-Fix-const-char-pointers-in-grub-core-net-bootp.c.patch +Patch0068: 0068-efinet-Setting-network-from-UEFI-device-path.patch +Patch0069: 0069-efinet-Setting-DNS-server-from-UEFI-protocol.patch +Patch0070: 0070-Support-UEFI-networking-protocols.patch +Patch0071: 0071-AUDIT-0-http-boot-tracker-bug.patch +Patch0072: 0072-grub-editenv-Add-incr-command-to-increment-integer-v.patch +Patch0073: 0073-Add-auto-hide-menu-support.patch +Patch0074: 0074-Add-grub-set-bootflag-utility.patch +Patch0075: 0075-docs-Add-grub-boot-indeterminate.service-example.patch +Patch0076: 0076-gentpl-add-disable-support.patch +Patch0077: 0077-gentpl-add-pc-firmware-type.patch +Patch0078: 0078-efinet-also-use-the-firmware-acceleration-for-http.patch +Patch0079: 0079-efi-http-Make-root_url-reflect-the-protocol-hostname.patch +Patch0080: 0080-Make-it-so-we-can-tell-configure-which-cflags-utils-.patch +Patch0081: 0081-Rework-how-the-fdt-command-builds.patch +Patch0082: 0082-Disable-non-wordsize-allocations-on-arm.patch +Patch0083: 0083-Prepend-prefix-when-HTTP-path-is-relative.patch +Patch0084: 0084-Make-grub_error-more-verbose.patch +Patch0085: 0085-Make-reset-an-alias-for-the-reboot-command.patch +Patch0086: 0086-Add-a-version-command.patch +Patch0087: 0087-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch +Patch0088: 0088-Attempt-to-fix-up-all-the-places-Wsign-compare-error.patch +Patch0089: 0089-Don-t-use-Wno-sign-compare-Wno-conversion-Wno-error-.patch +Patch0090: 0090-Fix-getroot.c-s-trampolines.patch +Patch0091: 0091-Do-not-allow-stack-trampolines-anywhere.patch +Patch0092: 0092-Reimplement-boot_counter.patch +Patch0093: 0093-Fix-menu-entry-selection-based-on-ID-and-title.patch +Patch0094: 0094-Make-the-menu-entry-users-option-argument-to-be-opti.patch +Patch0095: 0095-Add-efi-export-env-and-efi-load-env-commands.patch +Patch0096: 0096-Export-all-variables-from-the-initial-context-when-c.patch +Patch0097: 0097-grub.d-Split-out-boot-success-reset-from-menu-auto-h.patch +Patch0098: 0098-Don-t-assume-that-boot-commands-will-only-return-on-.patch +Patch0099: 0099-grub-set-bootflag-Update-comment-about-running-as-ro.patch +Patch0100: 0100-grub-set-bootflag-Write-new-env-to-tmpfile-and-then-.patch +Patch0101: 0101-grub.d-Fix-boot_indeterminate-getting-set-on-boot_su.patch +Patch0102: 0102-Add-start-symbol-for-RISC-V.patch +Patch0103: 0103-bootstrap.conf-Force-autogen.sh-to-use-python3.patch +Patch0104: 0104-efi-http-Export-fw-http-_path-variables-to-make-them.patch +Patch0105: 0105-efi-http-Enclose-literal-IPv6-addresses-in-square-br.patch +Patch0106: 0106-efi-net-Allow-to-specify-a-port-number-in-addresses.patch +Patch0107: 0107-efi-ip4_config-Improve-check-to-detect-literal-IPv6-.patch +Patch0108: 0108-efi-net-Print-a-debug-message-if-parsing-the-address.patch +Patch0109: 0109-kern-term-Also-accept-F8-as-a-user-interrupt-key.patch +Patch0110: 0110-http-Prepend-prefix-when-the-HTTP-path-is-relative-a.patch +Patch0111: 0111-Fix-a-missing-return-in-efi-export-env-and-efi-load-.patch +Patch0112: 0112-efi-dhcp-fix-some-allocation-error-checking.patch +Patch0113: 0113-efi-http-fix-some-allocation-error-checking.patch +Patch0114: 0114-efi-ip-46-_config.c-fix-some-potential-allocation-ov.patch +Patch0115: 0115-Fix-const-char-pointers-in-grub-core-net-efi-ip4_con.patch +Patch0116: 0116-Fix-const-char-pointers-in-grub-core-net-efi-ip6_con.patch +Patch0117: 0117-Fix-const-char-pointers-in-grub-core-net-efi-net.c.patch +Patch0118: 0118-Fix-const-char-pointers-in-grub-core-net-efi-pxe.c.patch +Patch0119: 0119-Add-systemd-integration-scripts-to-make-systemctl-re.patch +Patch0120: 0120-systemd-integration.sh-Also-set-old-menu_show_once-g.patch +Patch0121: 0121-at_keyboard-use-set-1-when-keyboard-is-in-Translate-.patch +Patch0122: 0122-grub-install-disable-support-for-EFI-platforms.patch +Patch0123: 0123-New-with-debug-timestamps-configure-flag-to-prepend-.patch +Patch0124: 0124-Added-debug-statements-to-grub_disk_open-and-grub_di.patch +Patch0125: 0125-Introduce-function-grub_debug_is_enabled-void-return.patch +Patch0126: 0126-Don-t-clear-screen-when-debugging-is-enabled.patch +Patch0127: 0127-grub_file_-instrumentation-new-file-debug-tag.patch +Patch0128: 0128-ieee1275-Avoiding-many-unecessary-open-close.patch +Patch0129: 0129-ieee1275-powerpc-implements-fibre-channel-discovery-.patch +Patch0130: 0130-ieee1275-powerpc-enables-device-mapper-discovery.patch +Patch0131: 0131-Add-at_keyboard_fallback_set-var-to-force-the-set-ma.patch +Patch0132: 0132-Add-suport-for-signing-grub-with-an-appended-signatu.patch +Patch0133: 0133-docs-grub-Document-signing-grub-under-UEFI.patch +Patch0134: 0134-docs-grub-Document-signing-grub-with-an-appended-sig.patch +Patch0135: 0135-dl-provide-a-fake-grub_dl_set_persistent-for-the-emu.patch +Patch0136: 0136-pgp-factor-out-rsa_pad.patch +Patch0137: 0137-crypto-move-storage-for-grub_crypto_pk_-to-crypto.c.patch +Patch0138: 0138-posix_wrap-tweaks-in-preparation-for-libtasn1.patch +Patch0139: 0139-libtasn1-import-libtasn1-4.16.0.patch +Patch0140: 0140-libtasn1-disable-code-not-needed-in-grub.patch +Patch0141: 0141-libtasn1-changes-for-grub-compatibility.patch +Patch0142: 0142-libtasn1-compile-into-asn1-module.patch +Patch0143: 0143-test_asn1-test-module-for-libtasn1.patch +Patch0144: 0144-grub-install-support-embedding-x509-certificates.patch +Patch0145: 0145-appended-signatures-import-GNUTLS-s-ASN.1-descriptio.patch +Patch0146: 0146-appended-signatures-parse-PKCS-7-signedData-and-X.50.patch +Patch0147: 0147-appended-signatures-support-verifying-appended-signa.patch +Patch0148: 0148-appended-signatures-verification-tests.patch +Patch0149: 0149-appended-signatures-documentation.patch +Patch0150: 0150-ieee1275-enter-lockdown-based-on-ibm-secure-boot.patch +Patch0151: 0151-ieee1275-drop-HEAP_MAX_ADDR-HEAP_MIN_SIZE.patch +Patch0152: 0152-appendedsig-x509-Also-handle-the-Extended-Key-Usage-.patch +Patch0153: 0153-ieee1275-ofdisk-retry-on-open-failure.patch +Patch0154: 0154-efinet-Add-DHCP-proxy-support.patch +Patch0155: 0155-Don-t-update-the-cmdline-when-generating-legacy-menu.patch +Patch0156: 0156-Suppress-gettext-error-message.patch +Patch0157: 0157-grub-set-password-Always-use-boot-grub2-user.cfg-as-.patch +Patch0158: 0158-normal-main-Discover-the-device-to-read-the-config-f.patch +Patch0159: 0159-powerpc-adjust-setting-of-prefix-for-signed-binary-c.patch +Patch0160: 0160-powerpc-ieee1275-load-grub-at-4MB-not-2MB.patch +Patch0161: 0161-Add-Fedora-location-of-DejaVu-SANS-font.patch +Patch0162: 0162-efi-new-connectefi-command.patch +Patch0163: 0163-powerpc-prefix-detection-support-device-names-with-c.patch +Patch0164: 0164-make-ofdisk_retries-optional.patch +Patch0165: 0165-misc-Make-grub_min-and-grub_max-more-resilient.patch +Patch0166: 0166-ReiserFS-switch-to-using-grub_min-grub_max.patch +Patch0167: 0167-misc-make-grub_boot_time-also-call-grub_dprintf-boot.patch +Patch0168: 0168-modules-make-.module_license-read-only.patch +Patch0169: 0169-modules-strip-.llvm_addrsig-sections-and-similar.patch +Patch0170: 0170-modules-Don-t-allocate-space-for-non-allocable-secti.patch +Patch0171: 0171-modules-load-module-sections-at-page-aligned-address.patch +Patch0172: 0172-nx-add-memory-attribute-get-set-API.patch +Patch0173: 0173-nx-set-page-permissions-for-loaded-modules.patch +Patch0174: 0174-nx-set-the-nx-compatible-flag-in-EFI-grub-images.patch +Patch0175: 0175-grub_fs_probe-dprint-errors-from-filesystems.patch +Patch0176: 0176-Make-debug-file-show-which-file-filters-get-run.patch +Patch0177: 0177-BLS-create-etc-kernel-cmdline-during-mkconfig.patch +Patch0178: 0178-squish-don-t-dup-rhgb-quiet-check-mtimes.patch +Patch0179: 0179-squish-give-up-on-rhgb-quiet.patch +Patch0180: 0180-squish-BLS-only-write-etc-kernel-cmdline-if-writable.patch +Patch0181: 0181-blscfg-Don-t-root-device-in-emu-builds.patch +Patch0182: 0182-ppc64le-signed-boot-media-changes.patch +Patch0183: 0183-core-Fix-several-implicit-function-declarations.patch +Patch0184: 0184-ieee1275-request-memory-with-ibm-client-architecture.patch +Patch0185: 0185-hostdisk-work-around-proc-not-reporting-size.patch +Patch0186: 0186-blscfg-check-for-mounted-boot-in-emu.patch +Patch0187: 0187-grub_dl_set_mem_attrs-fix-format-string.patch +Patch0188: 0188-grub_dl_set_mem_attrs-add-self-check-for-the-tramp-G.patch +Patch0189: 0189-grub_dl_load_segments-page-align-the-tramp-GOT-areas.patch +Patch0190: 0190-emu-Add-switch-root-to-grub-emu.patch +Patch0191: 0191-util-Enable-default-kernel-for-updates.patch +Patch0192: 0192-efi-http-change-uint32_t-to-uintn_t.patch +Patch0193: 0193-Add-Install-section-to-aux-systemd-units.patch +Patch0194: 0194-Fix-missing-include-in-ofdisk.c.patch +Patch0195: 0195-add-flag-to-only-search-root-dev.patch +Patch0196: 0196-cryptdisk-fix-incorrect-sign-comparison.patch +Patch0197: 0197-grub-install-fix-a-sign-comparison-error.patch +Patch0198: 0198-grub-mount-work-around-bad-integer-comparison.patch +Patch0199: 0199-power-Fix-use-after-free-in-get_slave_from_dm.patch +Patch0200: 0200-Fix-some-sign-comparison-errors.patch +Patch0201: 0201-normal-Fix-a-discarded-const.patch +Patch0202: 0202-at_keyboard-mark-grub_keyboard_controller_write-unus.patch +Patch0203: 0203-Fix-another-minor-sign-comparison-error.patch +Patch0204: 0204-Track-explicit-module-dependencies-in-Makefile.core..patch +Patch0205: 0205-Revert-mm-Assert-that-we-preserve-header-vs-region-a.patch +Patch0206: 0206-make-use-the-_CPU-variety-of-build-flags-for-PROGRAM.patch +Patch0207: 0207-Work-around-extra_deps.lst-issue.patch +Patch0208: 0208-include-proper-attribute-for-an-EFI-API-call-definit.patch +Patch0209: 0209-cast-grub_error-status-parameter.patch +Patch0210: 0210-remove-unused-varible.patch +Patch0211: 0211-cast-grub_net_bootp_packet-pointer.patch +Patch0212: 0212-libtasn1-fix-string-overflow-warning.patch +Patch0213: 0213-Add-support-for-Linux-EFI-stub-loading.patch +Patch0214: 0214-fix-i386_pc-on-legacycfg-module.patch +Patch0215: 0215-Add-secureboot-support-on-efi-chainloader.patch +Patch0216: 0216-Make-any-of-the-loaders-that-link-in-efi-mode-honor-.patch +Patch0217: 0217-Minimize-the-sort-ordering-for-.debug-and-rescue-ker.patch +Patch0218: 0218-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch +Patch0219: 0219-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch +Patch0220: 0220-Handle-multi-arch-64-on-32-boot-in-linuxefi-loader.patch +Patch0221: 0221-Try-to-pick-better-locations-for-kernel-and-initrd.patch +Patch0222: 0222-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch +Patch0223: 0223-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch +Patch0224: 0224-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch +Patch0225: 0225-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch +Patch0226: 0226-efi-Set-image-base-address-before-jumping-to-the-PE-.patch +Patch0227: 0227-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch +Patch0228: 0228-efilinux-Fix-integer-overflows-in-grub_cmd_initrd.patch +Patch0229: 0229-linuxefi-fail-kernel-validation-without-shim-protoco.patch +Patch0230: 0230-Allow-chainloading-EFI-apps-from-loop-mounts.patch +Patch0231: 0231-grub-core-loader-i386-efi-linux.c-do-not-validate-ke.patch +Patch0232: 0232-grub-core-loader-efi-chainloader.c-do-not-validate-c.patch +Patch0233: 0233-grub-core-loader-efi-linux.c-drop-now-unused-grub_li.patch +Patch0234: 0234-loader-efi-chainloader-grub_load_and_start_image-doe.patch +Patch0235: 0235-loader-efi-chainloader-simplify-the-loader-state.patch +Patch0236: 0236-loader-efi-chainloader-Use-grub_loader_set_ex.patch +Patch0237: 0237-loader-i386-efi-linux-Avoid-a-use-after-free-in-the-.patch +Patch0238: 0238-loader-i386-efi-linux-Use-grub_loader_set_ex.patch +Patch0239: 0239-loader-i386-efi-linux-Fix-a-memory-leak-in-the-initr.patch +Patch0240: 0240-EFI-allocate-kernel-in-EFI_RUNTIME_SERVICES_CODE-ins.patch +Patch0241: 0241-efi-use-enumerated-array-positions-for-our-allocatio.patch +Patch0242: 0242-efi-split-allocation-policy-for-kernel-vs-initrd-mem.patch +Patch0243: 0243-efi-allocate-the-initrd-within-the-bounds-expressed-.patch +Patch0244: 0244-efi-use-EFI_LOADER_-CODE-DATA-for-kernel-and-initrd-.patch +Patch0245: 0245-x86-efi-Fix-an-incorrect-array-size-in-kernel-alloca.patch +Patch0246: 0246-grub-install-on-EFI-if-forced.patch +Patch0247: 0247-Remove-Install-section-from-aux-systemd-units.patch +Patch0248: 0248-chainloader-remove-device-path-debug-message.patch +Patch0249: 0249-grub-set-bootflag-Conservative-partial-fix-for-CVE-2.patch +Patch0250: 0250-grub-set-bootflag-More-complete-fix-for-CVE-2024-104.patch +Patch0251: 0251-grub-set-bootflag-Exit-calmly-when-not-running-as-ro.patch +Patch0252: 0252-Makefile.core.def-fix-linux-module.patch +Patch0253: 0253-Add-support-for-Linux-EFI-stub-loading-on-arm-archit.patch +Patch0254: 0254-arm-arm64-loader-Better-memory-allocation-and-error-.patch +Patch0255: 0255-arm64-Fix-EFI-loader-kernel-image-allocation.patch +Patch0256: 0256-pe-add-the-DOS-header-struct-and-fix-some-bad-naming.patch +Patch0257: 0257-Correct-BSS-zeroing-on-aarch64.patch +Patch0258: 0258-arm64-Use-proper-memory-type-for-kernel-allocation.patch +Patch0259: 0259-normal-Remove-grub_env_set-prefix-in-grub_try_normal.patch +Patch0260: 0260-fs-xfs-Handle-non-continuous-data-blocks-in-director.patch +Patch0261: 0261-Ignore-warnings-for-incompatible-types.patch +Patch0262: 0262-cmd-search-Rework-of-CVE-2023-4001-fix.patch +Patch0263: 0263-loader-efi-linux.c-read-the-kernel-image-before-head.patch +Patch0264: 0264-nx-set-attrs-in-our-kernel-loaders.patch +Patch0265: 0265-efi-Provide-wrappers-for-load_image-start_image.patch +Patch0266: 0266-efi-Disallow-fallback-to-legacy-Linux-loader-when-sh.patch +Patch0267: 0267-Set-non-executable-stack-sections-on-EFI-assembly-fi.patch +Patch0268: 0268-grub-mkconfig.in-turn-off-executable-owner-bit.patch +Patch0269: 0269-kern-ieee1275-init-Add-IEEE-1275-Radix-support-for-K.patch +Patch0270: 0270-grub2-mkconfig-Ensure-grub-cfg-stub-is-not-overwritt.patch +Patch0271: 0271-grub2-mkconfig-Simplify-os_name-detection.patch +Patch0272: 0272-grub-mkconfig-Remove-check-for-mount-point-for-grub-.patch +Patch0273: 0273-efi-api.h-include-missing-__grub_efi_api-macros-on-E.patch +Patch0274: 0274-grub-core-net-arp.c-fix-variable-name.patch +Patch0275: 0275-load-EFI-commands-inside-test-expressions.patch +Patch0276: 0276-efi-loader-Check-if-NX-is-required-in-grub_efi_linux.patch +Patch0277: 0277-Stop-grub.efi-from-always-printing-dynamic_load_symb.patch +Patch0278: 0278-linuxefi-Invalidate-i-cache-before-starting-the-kern.patch +Patch0279: 0279-grub-mkconfig-dont-overwrite-BLS-cmdline-if-BLSCFG.patch +Patch0280: 0280-grub2-mkconfig-Pass-all-boot-params-when-used-by-ana.patch diff --git a/grub2.spec b/grub2.spec index 2ed1c13..48b3526 100644 --- a/grub2.spec +++ b/grub2.spec @@ -6,7 +6,7 @@ %undefine _hardened_build %undefine _package_note_file -%global tarversion 2.06 +%global tarversion 2.12 %undefine _missing_build_ids_terminate_build %global _configure_gnuconfig_hack 0 @@ -16,8 +16,8 @@ Name: grub2 Epoch: 1 -Version: 2.06 -Release: 134%{?dist} +Version: 2.12 +Release: 1%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPL-3.0-or-later URL: http://www.gnu.org/software/grub/ @@ -583,6 +583,10 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog +* Wed Nov 6 2024 Leo Sandoval - 2.12-1 +- Rebased to release grub-2.12 +- Resolves: #RHEL-15032 + * Tue Oct 29 2024 Troy Dawson - Bump release for October 2024 mass rebuild: Resolves: RHEL-64018 diff --git a/sources b/sources index 5f2ba31..d510fb5 100644 --- a/sources +++ b/sources @@ -1,4 +1,4 @@ SHA512 (unifont-13.0.06.pcf.gz) = 25f1ea4e316cd77b65cf4f60aa10ed054db6df2195be7344216673dee6628ab055ebcdeea186996d931fd1e9e4f519f4a2e4b4544b8a9ad2fe410aadc4eecd2d SHA512 (theme.tar.bz2) = 0f6f914d5f801509403094b28b8cfe5169cb56ae9bdd808ae21a6780a8236b434161a068351508dd78729c25ee2fed066c124c1eef9e15102750b409b4576a5c -SHA512 (grub-2.06.tar.xz) = 4f11c648f3078567e53fc0c74d5026fdc6da4be27d188975e79d9a4df817ade0fe5ad2ddd694238a07edc45adfa02943d83c57767dd51548102b375e529e8efe +SHA512 (grub-2.12.tar.xz) = 761c060a4c3da9c0e810b0ea967e3ebc66baa4ddd682a503ae3d30a83707626bccaf49359304a16b3a26fc4435fe6bea1ee90be910c84de3c2b5485a31a15be3 SHA512 (gnulib-9f48fb992a3d7e96610c4ce8be969cff2d61a01b.tar.gz) = 6887dede2d4a403422ea045329ee9bd7ca4c1561bcaf39e805e1d1ce8f4c050a65ce286e7d8362fb8e815b5fab0b405730a3f93194e343e2aedcf9b4411a285e