Fix UEFI booting in a different way.

Related: rhbz#1626844
Related: rhbz#1624532
Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2018-09-10 17:02:06 -04:00
parent 1b51084aaa
commit 0c72748086
4 changed files with 64 additions and 66 deletions

View File

@ -1,63 +0,0 @@
From d2332fd171c4ed22aa4f226bdbc5aec24589144f Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 3 Sep 2018 10:44:40 +0200
Subject: [PATCH] Fix "Try to pick better locations for kernel and initrd"
causing boot to fail on some UEFI x86_64 systems
The "Try to pick better locations for kernel and initrd" commit causes boot
to fail on some UEFI x86_64 systems (Sandy Bridge) with these errors:
grub-core/loader/i386/efi/linux.c:217:cannot allocate kernel parameters.
grub-core/loader/i386/efi/linux.c:94:you need to load the kernel first.
This commit fixes this by retrying the memory allocations changed by
the "Try to pick better locations for kernel and initrd" commit with
the old memory limit of 0x3fffffff.
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1624525
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
grub-core/loader/i386/efi/linux.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
index fddf547..15f6b40 100644
--- a/grub-core/loader/i386/efi/linux.c
+++ b/grub-core/loader/i386/efi/linux.c
@@ -110,6 +110,10 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
}
initrd_mem = grub_efi_allocate_pages_max (GRUB_EFI_MAX_USABLE_ADDRESS, BYTES_TO_PAGES(size));
+
+ if (!initrd_mem)
+ initrd_mem = grub_efi_allocate_pages_max (0x3fffffff, BYTES_TO_PAGES(size));
+
if (!initrd_mem)
{
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate initrd"));
@@ -212,6 +216,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_USABLE_ADDRESS,
BYTES_TO_PAGES(sizeof(*params)));
+
+ if (! params)
+ params = grub_efi_allocate_pages_max (0x3fffffff,
+ BYTES_TO_PAGES(sizeof(*params)));
+
if (! params)
{
grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate kernel parameters");
@@ -313,6 +322,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
kernel_mem = grub_efi_allocate_pages_max(GRUB_EFI_MAX_USABLE_ADDRESS,
BYTES_TO_PAGES(lh->init_size));
+ if (!kernel_mem)
+ kernel_mem = grub_efi_allocate_pages_max(0x3fffffff,
+ BYTES_TO_PAGES(lh->init_size));
+
if (!kernel_mem)
{
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate kernel"));
--
2.19.0.rc1

View File

@ -0,0 +1,56 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 30 Aug 2018 11:10:18 -0400
Subject: [PATCH] Try (again) to pick better locations for kernel and initrd
- Don't limit allocations on 64-bit platforms to < 0x3fffffff if we're using
the "large" code model ; use __UINTPTR_MAX__.
- Get the comparison right to check the address we've allocated.
- Fix the allocation for the command line as well.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
grub-core/kern/efi/mm.c | 2 +-
grub-core/loader/i386/efi/linux.c | 2 +-
include/grub/x86_64/efi/memory.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
index 4c00f4cc9d3..5d898613232 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,
grub_efi_boot_services_t *b;
grub_efi_physical_address_t address = max;
- if (max >= GRUB_EFI_MAX_USABLE_ADDRESS)
+ if (max > GRUB_EFI_MAX_USABLE_ADDRESS)
return 0;
b = grub_efi_system_table->boot_services;
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
index fddf54762a7..5727f7fce80 100644
--- a/grub-core/loader/i386/efi/linux.c
+++ b/grub-core/loader/i386/efi/linux.c
@@ -281,7 +281,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
#endif
grub_dprintf ("linux", "setting up cmdline\n");
- linux_cmdline = grub_efi_allocate_pages_max(0x3fffffff,
+ linux_cmdline = grub_efi_allocate_pages_max(GRUB_EFI_MAX_USABLE_ADDRESS,
BYTES_TO_PAGES(lh->cmdline_size + 1));
if (!linux_cmdline)
{
diff --git a/include/grub/x86_64/efi/memory.h b/include/grub/x86_64/efi/memory.h
index 70bce170850..18bb6c67162 100644
--- a/include/grub/x86_64/efi/memory.h
+++ b/include/grub/x86_64/efi/memory.h
@@ -4,7 +4,7 @@
#if defined (__code_model_large__)
#define GRUB_EFI_MAX_USABLE_ADDRESS __UINTPTR_MAX__
#else
-#define GRUB_EFI_MAX_USABLE_ADDRESS __INTPTR_MAX__
+#define GRUB_EFI_MAX_USABLE_ADDRESS 0x7fffffff
#endif
#endif /* ! GRUB_MEMORY_CPU_HEADER */

View File

@ -234,4 +234,4 @@ Patch0233: 0233-Make-grub_error-more-verbose.patch
Patch0234: 0234-arm-arm64-loader-Better-memory-allocation-and-error-.patch
Patch0235: 0235-Fix-GRUB_EFI_MAX_USABLE_ADDRESS-to-be-64-bit-on-x86_.patch
Patch0236: 0236-Try-to-pick-better-locations-for-kernel-and-initrd.patch
Patch0237: 0237-Fix-Try-to-pick-better-locations-for-kernel-and-init.patch
Patch0237: 0237-Try-again-to-pick-better-locations-for-kernel-and-in.patch

View File

@ -7,7 +7,7 @@
Name: grub2
Epoch: 1
Version: 2.02
Release: 54%{?dist}
Release: 55%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
Group: System Environment/Base
License: GPLv3+
@ -498,9 +498,14 @@ fi
%endif
%changelog
* Mon Sep 10 2018 Peter Jones <pjones@redhat.com> - 2.02-55
- Fix UEFI booting in a different way.
Related: rhbz#1626844
Related: rhbz#1624532
* Fri Sep 07 2018 Kevin Fenzi <kevin@scrye.com> - 2.02-54
- Add patch from https://github.com/rhboot/grub2/pull/30 to fix uefi booting
- Resolves: rhbz#1624532
Resolves: rhbz#1624532
* Thu Aug 30 2018 Peter Jones <pjones@redhat.com> - 2.02-53
- Fix AArch64 machines with no RAM latched lower than 1GB