Blob Blame History Raw
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 */