Once more into the breach, dear friends.
- Limit grub_malloc() on x86_64 to < 31bit addresses, as some devices seem to have a colossally broken storage controller (or UEFI driver) that can't do DMA to higher memory addresses, but fails silently. Resolves: rhbz#1626844 (possibly really resolving it this time.) - Also integrate Hans's attempt to fix the related error from -54, but do it the other way around: try the low addresses first and *then* the high one if the allocation fails. This way we'll get low regions by default, and if kernel/initramfs don't fit anywhere, it'll try the higher addresses. Related: rhbz#1624532 - Coalesce all the intermediate debugging junk from -54/-55/-56. Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
parent
371309b06e
commit
98536ecf37
@ -9,23 +9,35 @@ http_url: http://www.example.com/foo/bar
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
grub-core/kern/main.c | 2 +-
|
||||
grub-core/kern/main.c | 10 +++++-
|
||||
grub-core/net/efi/http.c | 82 ++++++++++++++++++++++++++++++++++++------------
|
||||
2 files changed, 63 insertions(+), 21 deletions(-)
|
||||
2 files changed, 71 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
|
||||
index da47b18b50e..fc8d8c6c9d4 100644
|
||||
index da47b18b50e..dcf48726d54 100644
|
||||
--- a/grub-core/kern/main.c
|
||||
+++ b/grub-core/kern/main.c
|
||||
@@ -131,7 +131,7 @@ grub_set_prefix_and_root (void)
|
||||
@@ -130,11 +130,19 @@ grub_set_prefix_and_root (void)
|
||||
if (fwdevice && fwpath)
|
||||
{
|
||||
char *fw_path;
|
||||
+ char separator[3] = ")";
|
||||
|
||||
- fw_path = grub_xasprintf ("(%s)/%s", fwdevice, fwpath);
|
||||
+ fw_path = grub_xasprintf ("(%s)%s%s", fwdevice, fwpath[0] == '/' ? "" : "/", fwpath);
|
||||
+ grub_dprintf ("fw_path", "\n");
|
||||
+ grub_dprintf ("fw_path", "fwdevice:\"%s\" fwpath:\"%s\"\n", fwdevice, fwpath);
|
||||
+
|
||||
+ if (!grub_strncmp(fwdevice, "http", 4) && fwpath[0] != '/')
|
||||
+ grub_strcpy(separator, ")/");
|
||||
+
|
||||
+ fw_path = grub_xasprintf ("(%s%s%s", fwdevice, separator, fwpath);
|
||||
if (fw_path)
|
||||
{
|
||||
grub_env_set ("fw_path", fw_path);
|
||||
+ grub_dprintf ("fw_path", "fw_path:\"%s\"\n", fw_path);
|
||||
grub_free (fw_path);
|
||||
}
|
||||
}
|
||||
diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c
|
||||
index 243acbaa35b..2a9624dacc4 100644
|
||||
--- a/grub-core/net/efi/http.c
|
||||
|
@ -1,27 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 27 Aug 2018 14:31:37 -0400
|
||||
Subject: [PATCH] Fix GRUB_EFI_MAX_USABLE_ADDRESS to be 64-bit on x86_64 EFI
|
||||
machines.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
include/grub/x86_64/efi/memory.h | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/include/grub/x86_64/efi/memory.h b/include/grub/x86_64/efi/memory.h
|
||||
index 46e9145a308..fb7437f7b5f 100644
|
||||
--- a/include/grub/x86_64/efi/memory.h
|
||||
+++ b/include/grub/x86_64/efi/memory.h
|
||||
@@ -2,9 +2,9 @@
|
||||
#include <grub/efi/memory.h>
|
||||
|
||||
#if defined (__code_model_large__)
|
||||
-#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff
|
||||
+#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffffffffffULL
|
||||
#else
|
||||
-#define GRUB_EFI_MAX_USABLE_ADDRESS 0x7fffffff
|
||||
+#define GRUB_EFI_MAX_USABLE_ADDRESS 0x7fffffffffffffffULL
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
132
0236-Add-a-version-command.patch
Normal file
132
0236-Add-a-version-command.patch
Normal file
@ -0,0 +1,132 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 11 Sep 2018 14:20:37 -0400
|
||||
Subject: [PATCH] Add a "version" command.
|
||||
|
||||
This adds a command that shows you info about grub's version, the grub target
|
||||
platform, the compiler version, and if you built with
|
||||
--with-rpm-version=<string>, the rpm package version.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
configure.ac | 13 ++++++++++
|
||||
grub-core/Makefile.core.def | 5 ++++
|
||||
grub-core/commands/version.c | 56 ++++++++++++++++++++++++++++++++++++++++++++
|
||||
config.h.in | 1 +
|
||||
4 files changed, 75 insertions(+)
|
||||
create mode 100644 grub-core/commands/version.c
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 9323c125469..61c4683cb76 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -287,6 +287,19 @@ AC_SUBST(target_cpu)
|
||||
AC_SUBST(platform)
|
||||
|
||||
# Define default variables
|
||||
+have_with_rpm_version=n
|
||||
+AC_ARG_WITH([rpm_version],
|
||||
+ AS_HELP_STRING([--with-rpm-version=VERSION],
|
||||
+ [set the rpm package version [[guessed]]]),
|
||||
+ [have_with_rpm_version=y],
|
||||
+ [have_with_rpm_version=n])
|
||||
+if test x$have_with_rpm_version = xy; then
|
||||
+ rpm_version="$with_rpm_version"
|
||||
+else
|
||||
+ rpm_version=""
|
||||
+fi
|
||||
+GRUB_RPM_VERSION="$rpm_version"
|
||||
+AC_SUBST(GRUB_RPM_VERSION)
|
||||
|
||||
have_with_bootdir=n
|
||||
AC_ARG_WITH([bootdir],
|
||||
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
||||
index 203584fb00b..701e5d32fa2 100644
|
||||
--- a/grub-core/Makefile.core.def
|
||||
+++ b/grub-core/Makefile.core.def
|
||||
@@ -537,6 +537,11 @@ image = {
|
||||
enable = mips_loongson;
|
||||
};
|
||||
|
||||
+module = {
|
||||
+ name = version;
|
||||
+ common = commands/version.c;
|
||||
+};
|
||||
+
|
||||
module = {
|
||||
name = disk;
|
||||
common = lib/disk.c;
|
||||
diff --git a/grub-core/commands/version.c b/grub-core/commands/version.c
|
||||
new file mode 100644
|
||||
index 00000000000..f0966a518f7
|
||||
--- /dev/null
|
||||
+++ b/grub-core/commands/version.c
|
||||
@@ -0,0 +1,56 @@
|
||||
+/* version.c - Command to print the grub version and build info. */
|
||||
+/*
|
||||
+ * GRUB -- GRand Unified Bootloader
|
||||
+ * Copyright (C) 2006,2007,2008 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 <http://www.gnu.org/licenses/>.
|
||||
+ */
|
||||
+
|
||||
+#include <grub/dl.h>
|
||||
+#include <grub/term.h>
|
||||
+#include <grub/time.h>
|
||||
+#include <grub/types.h>
|
||||
+#include <grub/misc.h>
|
||||
+#include <grub/extcmd.h>
|
||||
+#include <grub/i18n.h>
|
||||
+
|
||||
+GRUB_MOD_LICENSE ("GPLv3+");
|
||||
+
|
||||
+static grub_err_t
|
||||
+grub_cmd_version (grub_command_t cmd UNUSED, int argc, char **args UNUSED)
|
||||
+{
|
||||
+ if (argc != 0)
|
||||
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("no arguments expected"));
|
||||
+
|
||||
+ grub_printf (_("GNU GRUB version %s\n"), PACKAGE_VERSION);
|
||||
+ grub_printf (_("Platform %s-%s\n"), GRUB_TARGET_CPU, GRUB_PLATFORM);
|
||||
+ if (grub_strlen(GRUB_RPM_VERSION) != 0)
|
||||
+ grub_printf (_("RPM package version %s\n"), GRUB_RPM_VERSION);
|
||||
+ grub_printf (_("Compiler version %s\n"), __VERSION__);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static grub_command_t cmd;
|
||||
+
|
||||
+GRUB_MOD_INIT(version)
|
||||
+{
|
||||
+ cmd = grub_register_command ("version", grub_cmd_version, NULL,
|
||||
+ N_("Print version and build information."));
|
||||
+}
|
||||
+
|
||||
+GRUB_MOD_FINI(version)
|
||||
+{
|
||||
+ grub_unregister_command (cmd);
|
||||
+}
|
||||
diff --git a/config.h.in b/config.h.in
|
||||
index 9e8f9911b18..c7e316f0f1f 100644
|
||||
--- a/config.h.in
|
||||
+++ b/config.h.in
|
||||
@@ -59,6 +59,7 @@
|
||||
|
||||
#define GRUB_TARGET_CPU "@GRUB_TARGET_CPU@"
|
||||
#define GRUB_PLATFORM "@GRUB_PLATFORM@"
|
||||
+#define GRUB_RPM_VERSION "@GRUB_RPM_VERSION@"
|
||||
|
||||
#define RE_ENABLE_I18N 1
|
||||
|
@ -1,96 +0,0 @@
|
||||
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 to pick better locations for kernel and initrd
|
||||
|
||||
Don't limit allocations on 64-bit platforms to < 0x3fffffff; use
|
||||
__UINTPTR_MAX__ or __INTPTR_MAX__.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
grub-core/kern/efi/mm.c | 2 +-
|
||||
grub-core/loader/i386/efi/linux.c | 7 ++++---
|
||||
include/grub/arm64/efi/memory.h | 2 +-
|
||||
include/grub/x86_64/efi/memory.h | 4 ++--
|
||||
4 files changed, 8 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
|
||||
index 306924f73a4..4c00f4cc9d3 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 > 0xffffffff)
|
||||
+ 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 ea9f5134e67..fddf54762a7 100644
|
||||
--- a/grub-core/loader/i386/efi/linux.c
|
||||
+++ b/grub-core/loader/i386/efi/linux.c
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/efi/linux.h>
|
||||
#include <grub/tpm.h>
|
||||
+#include <grub/cpu/efi/memory.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
@@ -108,7 +109,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
||||
size += ALIGN_UP (grub_file_size (files[i]), 4);
|
||||
}
|
||||
|
||||
- initrd_mem = grub_efi_allocate_pages_max (0x3fffffff, BYTES_TO_PAGES(size));
|
||||
+ initrd_mem = grub_efi_allocate_pages_max (GRUB_EFI_MAX_USABLE_ADDRESS, BYTES_TO_PAGES(size));
|
||||
if (!initrd_mem)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate initrd"));
|
||||
@@ -209,7 +210,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- params = grub_efi_allocate_pages_max (0x3fffffff,
|
||||
+ params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_USABLE_ADDRESS,
|
||||
BYTES_TO_PAGES(sizeof(*params)));
|
||||
if (! params)
|
||||
{
|
||||
@@ -309,7 +310,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
BYTES_TO_PAGES(lh->init_size));
|
||||
|
||||
if (!kernel_mem)
|
||||
- kernel_mem = grub_efi_allocate_pages_max(0x3fffffff,
|
||||
+ kernel_mem = grub_efi_allocate_pages_max(GRUB_EFI_MAX_USABLE_ADDRESS,
|
||||
BYTES_TO_PAGES(lh->init_size));
|
||||
|
||||
if (!kernel_mem)
|
||||
diff --git a/include/grub/arm64/efi/memory.h b/include/grub/arm64/efi/memory.h
|
||||
index c6cb3241714..af62f56cf7e 100644
|
||||
--- a/include/grub/arm64/efi/memory.h
|
||||
+++ b/include/grub/arm64/efi/memory.h
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef GRUB_MEMORY_CPU_HEADER
|
||||
#include <grub/efi/memory.h>
|
||||
|
||||
-#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffffffULL
|
||||
+#define GRUB_EFI_MAX_USABLE_ADDRESS __UINTPTR_MAX__
|
||||
|
||||
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
||||
diff --git a/include/grub/x86_64/efi/memory.h b/include/grub/x86_64/efi/memory.h
|
||||
index fb7437f7b5f..70bce170850 100644
|
||||
--- a/include/grub/x86_64/efi/memory.h
|
||||
+++ b/include/grub/x86_64/efi/memory.h
|
||||
@@ -2,9 +2,9 @@
|
||||
#include <grub/efi/memory.h>
|
||||
|
||||
#if defined (__code_model_large__)
|
||||
-#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffffffffffULL
|
||||
+#define GRUB_EFI_MAX_USABLE_ADDRESS __UINTPTR_MAX__
|
||||
#else
|
||||
-#define GRUB_EFI_MAX_USABLE_ADDRESS 0x7fffffffffffffffULL
|
||||
+#define GRUB_EFI_MAX_USABLE_ADDRESS __INTPTR_MAX__
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
74
0237-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch
Normal file
74
0237-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch
Normal file
@ -0,0 +1,74 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Tue, 11 Sep 2018 15:58:29 -0400
|
||||
Subject: [PATCH] Add more dprintf, and nerf dprintf in script.c
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
grub-core/disk/diskfilter.c | 3 +++
|
||||
grub-core/disk/efi/efidisk.c | 1 +
|
||||
grub-core/kern/device.c | 1 +
|
||||
grub-core/script/script.c | 5 +++++
|
||||
4 files changed, 10 insertions(+)
|
||||
|
||||
diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c
|
||||
index 6f901c0adf7..66f6b992604 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)
|
||||
grub_disk_t disk;
|
||||
static int scan_depth = 0;
|
||||
|
||||
+ grub_dprintf ("diskfilter", "scanning %s\n", name);
|
||||
+
|
||||
if (!accept_diskfilter && is_valid_diskfilter_name (name))
|
||||
return 0;
|
||||
|
||||
@@ -1211,6 +1213,7 @@ insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id,
|
||||
the same. */
|
||||
if (pv->disk && grub_disk_get_size (disk) >= pv->part_size)
|
||||
return GRUB_ERR_NONE;
|
||||
+ grub_dprintf ("diskfilter", "checking %s\n", disk->name);
|
||||
pv->disk = grub_disk_open (disk->name);
|
||||
if (!pv->disk)
|
||||
return grub_errno;
|
||||
diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
|
||||
index 5d2400f66f2..4bc51877f04 100644
|
||||
--- a/grub-core/disk/efi/efidisk.c
|
||||
+++ b/grub-core/disk/efi/efidisk.c
|
||||
@@ -846,6 +846,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+ grub_dprintf ("efidisk", "getting disk for %s\n", device_name);
|
||||
parent = grub_disk_open (device_name);
|
||||
grub_free (dup_dp);
|
||||
|
||||
diff --git a/grub-core/kern/device.c b/grub-core/kern/device.c
|
||||
index 73b8ecc0c09..f58b58c89d5 100644
|
||||
--- a/grub-core/kern/device.c
|
||||
+++ b/grub-core/kern/device.c
|
||||
@@ -34,6 +34,7 @@ grub_device_open (const char *name)
|
||||
{
|
||||
grub_device_t dev = 0;
|
||||
|
||||
+ grub_dprintf ("device", "opening device %s\n", name);
|
||||
if (! name)
|
||||
{
|
||||
name = grub_env_get ("root");
|
||||
diff --git a/grub-core/script/script.c b/grub-core/script/script.c
|
||||
index ec4d4337c66..844e8343ca7 100644
|
||||
--- a/grub-core/script/script.c
|
||||
+++ b/grub-core/script/script.c
|
||||
@@ -22,6 +22,11 @@
|
||||
#include <grub/parser.h>
|
||||
#include <grub/mm.h>
|
||||
|
||||
+#ifdef grub_dprintf
|
||||
+#undef grub_dprintf
|
||||
+#endif
|
||||
+#define grub_dprintf(no, fmt, ...)
|
||||
+
|
||||
/* It is not possible to deallocate the memory when a syntax error was
|
||||
found. Because of that it is required to keep track of all memory
|
||||
allocations. The memory is freed in case of an error, or assigned
|
@ -1,56 +0,0 @@
|
||||
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 */
|
196
0239-Try-to-pick-better-locations-for-kernel-and-initrd.patch
Normal file
196
0239-Try-to-pick-better-locations-for-kernel-and-initrd.patch
Normal file
@ -0,0 +1,196 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 27 Aug 2018 14:31:37 -0400
|
||||
Subject: [PATCH] Try to pick better locations for kernel and initrd
|
||||
|
||||
- Don't limit allocations on 64-bit platforms to < 0x[37f]fffffff if
|
||||
we're using the "large" code model ; use __UINTPTR_MAX__.
|
||||
- Get the comparison right to check the address we've allocated.
|
||||
- Fix the allocation for the command line as well.
|
||||
|
||||
*But*, when we did this some systems started failing badly; coudln't
|
||||
parse partition tables, etc. What's going on here is the disk controller
|
||||
is silently failing DMAs to addresses above 4GB, so we're trying to parse
|
||||
uninitialized (or HW zeroed) ram when looking for the partition table,
|
||||
etc.
|
||||
|
||||
So to limit this, we make grub_malloc() pick addresses below 4GB on
|
||||
x86_64, but the direct EFI page allocation functions can get addresses
|
||||
above that.
|
||||
|
||||
Additionally, we now try to locate kernel+initrd+cmdline+etc below
|
||||
0x7fffffff, and if they're too big to fit any memory window there, then
|
||||
we try a higher address.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
grub-core/kern/efi/mm.c | 8 ++++----
|
||||
grub-core/loader/i386/efi/linux.c | 24 +++++++++++++++++-------
|
||||
include/grub/arm/efi/memory.h | 1 +
|
||||
include/grub/arm64/efi/memory.h | 1 +
|
||||
include/grub/i386/efi/memory.h | 1 +
|
||||
include/grub/ia64/efi/memory.h | 1 +
|
||||
include/grub/x86_64/efi/memory.h | 4 +++-
|
||||
7 files changed, 28 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
|
||||
index 306924f73a4..a553f817edb 100644
|
||||
--- 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 > 0xffffffff)
|
||||
+ if (max > GRUB_EFI_MAX_USABLE_ADDRESS)
|
||||
return 0;
|
||||
|
||||
b = grub_efi_system_table->boot_services;
|
||||
@@ -463,7 +463,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
||||
{
|
||||
if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
|
||||
#if 1
|
||||
- && desc->physical_start <= GRUB_EFI_MAX_USABLE_ADDRESS
|
||||
+ && desc->physical_start <= GRUB_EFI_MAX_ALLOCATION_ADDRESS
|
||||
#endif
|
||||
&& desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000
|
||||
&& desc->num_pages != 0)
|
||||
@@ -481,9 +481,9 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
||||
#if 1
|
||||
if (BYTES_TO_PAGES (filtered_desc->physical_start)
|
||||
+ filtered_desc->num_pages
|
||||
- > BYTES_TO_PAGES_DOWN (GRUB_EFI_MAX_USABLE_ADDRESS))
|
||||
+ > BYTES_TO_PAGES_DOWN (GRUB_EFI_MAX_ALLOCATION_ADDRESS))
|
||||
filtered_desc->num_pages
|
||||
- = (BYTES_TO_PAGES_DOWN (GRUB_EFI_MAX_USABLE_ADDRESS)
|
||||
+ = (BYTES_TO_PAGES_DOWN (GRUB_EFI_MAX_ALLOCATION_ADDRESS)
|
||||
- BYTES_TO_PAGES (filtered_desc->physical_start));
|
||||
#endif
|
||||
|
||||
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
|
||||
index ea9f5134e67..851bce77f12 100644
|
||||
--- a/grub-core/loader/i386/efi/linux.c
|
||||
+++ b/grub-core/loader/i386/efi/linux.c
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/efi/linux.h>
|
||||
#include <grub/tpm.h>
|
||||
+#include <grub/cpu/efi/memory.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
@@ -108,7 +109,9 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
||||
size += ALIGN_UP (grub_file_size (files[i]), 4);
|
||||
}
|
||||
|
||||
- initrd_mem = grub_efi_allocate_pages_max (0x3fffffff, BYTES_TO_PAGES(size));
|
||||
+ initrd_mem = grub_efi_allocate_pages_max (GRUB_EFI_MAX_ALLOCATION_ADDRESS, BYTES_TO_PAGES(size));
|
||||
+ if (!initrd_mem)
|
||||
+ initrd_mem = grub_efi_allocate_pages_max (GRUB_EFI_MAX_USABLE_ADDRESS, BYTES_TO_PAGES(size));
|
||||
if (!initrd_mem)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate initrd"));
|
||||
@@ -209,8 +212,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- params = grub_efi_allocate_pages_max (0x3fffffff,
|
||||
+ params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_ALLOCATION_ADDRESS,
|
||||
BYTES_TO_PAGES(sizeof(*params)));
|
||||
+ if (!params)
|
||||
+ params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_USABLE_ADDRESS,
|
||||
+ BYTES_TO_PAGES(sizeof(*params)));
|
||||
if (! params)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate kernel parameters");
|
||||
@@ -280,8 +286,11 @@ 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,
|
||||
- BYTES_TO_PAGES(lh->cmdline_size + 1));
|
||||
+ linux_cmdline = grub_efi_allocate_pages_max(GRUB_EFI_MAX_ALLOCATION_ADDRESS,
|
||||
+ BYTES_TO_PAGES(lh->cmdline_size + 1));
|
||||
+ if (!linux_cmdline)
|
||||
+ linux_cmdline = grub_efi_allocate_pages_max(GRUB_EFI_MAX_USABLE_ADDRESS,
|
||||
+ BYTES_TO_PAGES(lh->cmdline_size + 1));
|
||||
if (!linux_cmdline)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate cmdline"));
|
||||
@@ -307,11 +316,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
||||
kernel_mem = grub_efi_allocate_pages_max(lh->pref_address,
|
||||
BYTES_TO_PAGES(lh->init_size));
|
||||
-
|
||||
if (!kernel_mem)
|
||||
- kernel_mem = grub_efi_allocate_pages_max(0x3fffffff,
|
||||
+ kernel_mem = grub_efi_allocate_pages_max(GRUB_EFI_MAX_ALLOCATION_ADDRESS,
|
||||
+ BYTES_TO_PAGES(lh->init_size));
|
||||
+ if (!kernel_mem)
|
||||
+ kernel_mem = grub_efi_allocate_pages_max(GRUB_EFI_MAX_USABLE_ADDRESS,
|
||||
BYTES_TO_PAGES(lh->init_size));
|
||||
-
|
||||
if (!kernel_mem)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate kernel"));
|
||||
diff --git a/include/grub/arm/efi/memory.h b/include/grub/arm/efi/memory.h
|
||||
index 2c64918e3f7..a4c2ec83502 100644
|
||||
--- a/include/grub/arm/efi/memory.h
|
||||
+++ b/include/grub/arm/efi/memory.h
|
||||
@@ -2,5 +2,6 @@
|
||||
#include <grub/efi/memory.h>
|
||||
|
||||
#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff
|
||||
+#define GRUB_EFI_MAX_ALLOCATION_ADDRESS GRUB_EFI_MAX_USABLE_ADDRESS
|
||||
|
||||
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
||||
diff --git a/include/grub/arm64/efi/memory.h b/include/grub/arm64/efi/memory.h
|
||||
index c6cb3241714..acb61dca44b 100644
|
||||
--- a/include/grub/arm64/efi/memory.h
|
||||
+++ b/include/grub/arm64/efi/memory.h
|
||||
@@ -2,5 +2,6 @@
|
||||
#include <grub/efi/memory.h>
|
||||
|
||||
#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffffffULL
|
||||
+#define GRUB_EFI_MAX_ALLOCATION_ADDRESS GRUB_EFI_MAX_USABLE_ADDRESS
|
||||
|
||||
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
||||
diff --git a/include/grub/i386/efi/memory.h b/include/grub/i386/efi/memory.h
|
||||
index 2c64918e3f7..a4c2ec83502 100644
|
||||
--- a/include/grub/i386/efi/memory.h
|
||||
+++ b/include/grub/i386/efi/memory.h
|
||||
@@ -2,5 +2,6 @@
|
||||
#include <grub/efi/memory.h>
|
||||
|
||||
#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff
|
||||
+#define GRUB_EFI_MAX_ALLOCATION_ADDRESS GRUB_EFI_MAX_USABLE_ADDRESS
|
||||
|
||||
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
||||
diff --git a/include/grub/ia64/efi/memory.h b/include/grub/ia64/efi/memory.h
|
||||
index 2c64918e3f7..a4c2ec83502 100644
|
||||
--- a/include/grub/ia64/efi/memory.h
|
||||
+++ b/include/grub/ia64/efi/memory.h
|
||||
@@ -2,5 +2,6 @@
|
||||
#include <grub/efi/memory.h>
|
||||
|
||||
#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff
|
||||
+#define GRUB_EFI_MAX_ALLOCATION_ADDRESS GRUB_EFI_MAX_USABLE_ADDRESS
|
||||
|
||||
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
||||
diff --git a/include/grub/x86_64/efi/memory.h b/include/grub/x86_64/efi/memory.h
|
||||
index 46e9145a308..e81cfb32213 100644
|
||||
--- a/include/grub/x86_64/efi/memory.h
|
||||
+++ b/include/grub/x86_64/efi/memory.h
|
||||
@@ -2,9 +2,11 @@
|
||||
#include <grub/efi/memory.h>
|
||||
|
||||
#if defined (__code_model_large__)
|
||||
-#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff
|
||||
+#define GRUB_EFI_MAX_USABLE_ADDRESS __UINTPTR_MAX__
|
||||
+#define GRUB_EFI_MAX_ALLOCATION_ADDRESS 0x7fffffff
|
||||
#else
|
||||
#define GRUB_EFI_MAX_USABLE_ADDRESS 0x7fffffff
|
||||
+#define GRUB_EFI_MAX_ALLOCATION_ADDRESS GRUB_EFI_MAX_USABLE_ADDRESS
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
@ -1,35 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Mon, 10 Sep 2018 17:29:21 -0400
|
||||
Subject: [PATCH] fw_path: don't prepend / unless we're on http(s)
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
---
|
||||
grub-core/kern/main.c | 10 +++++++++-
|
||||
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
|
||||
index fc8d8c6c9d4..dcf48726d54 100644
|
||||
--- a/grub-core/kern/main.c
|
||||
+++ b/grub-core/kern/main.c
|
||||
@@ -130,11 +130,19 @@ grub_set_prefix_and_root (void)
|
||||
if (fwdevice && fwpath)
|
||||
{
|
||||
char *fw_path;
|
||||
+ char separator[3] = ")";
|
||||
|
||||
- fw_path = grub_xasprintf ("(%s)%s%s", fwdevice, fwpath[0] == '/' ? "" : "/", fwpath);
|
||||
+ grub_dprintf ("fw_path", "\n");
|
||||
+ grub_dprintf ("fw_path", "fwdevice:\"%s\" fwpath:\"%s\"\n", fwdevice, fwpath);
|
||||
+
|
||||
+ if (!grub_strncmp(fwdevice, "http", 4) && fwpath[0] != '/')
|
||||
+ grub_strcpy(separator, ")/");
|
||||
+
|
||||
+ fw_path = grub_xasprintf ("(%s%s%s", fwdevice, separator, fwpath);
|
||||
if (fw_path)
|
||||
{
|
||||
grub_env_set ("fw_path", fw_path);
|
||||
+ grub_dprintf ("fw_path", "fw_path:\"%s\"\n", fw_path);
|
||||
grub_free (fw_path);
|
||||
}
|
||||
}
|
@ -369,13 +369,13 @@ GRUB_MODULES=" all_video boot blscfg btrfs \\\
|
||||
echo efi_netfs efifwsetup efinet ext2 \\\
|
||||
fat font gfxmenu gfxterm gzio \\\
|
||||
halt hfsplus http iso9660 jpeg \\\
|
||||
loadenv loopback linux lvm lsefi \\\
|
||||
loadenv loopback linux lvm lsefi lsefimmap \\\
|
||||
mdraid09 mdraid1x minicmd net \\\
|
||||
normal part_apple part_msdos part_gpt \\\
|
||||
password_pbkdf2 png reboot \\\
|
||||
search search_fs_uuid search_fs_file \\\
|
||||
search_label serial sleep syslinuxcfg test tftp \\\
|
||||
video xfs" \
|
||||
version video xfs" \
|
||||
GRUB_MODULES+=%{efi_modules} \
|
||||
%{expand:%%{mkimage %{1} %{2} %{3} %{4}}} \
|
||||
%{nil}
|
||||
|
13
grub.patches
13
grub.patches
@ -231,10 +231,9 @@ Patch0230: 0230-Prepend-prefix-when-HTTP-path-is-relative.patch
|
||||
Patch0231: 0231-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch
|
||||
Patch0232: 0232-Mark-some-unused-stuff-unused.patch
|
||||
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-Try-again-to-pick-better-locations-for-kernel-and-in.patch
|
||||
Patch0238: 0238-Make-reset-an-alias-for-the-reboot-command.patch
|
||||
Patch0239: 0239-EFI-more-debug-output-on-GOP-and-UGA-probing.patch
|
||||
Patch0240: 0240-fw_path-don-t-prepend-unless-we-re-on-http-s.patch
|
||||
Patch0234: 0234-Make-reset-an-alias-for-the-reboot-command.patch
|
||||
Patch0235: 0235-EFI-more-debug-output-on-GOP-and-UGA-probing.patch
|
||||
Patch0236: 0236-Add-a-version-command.patch
|
||||
Patch0237: 0237-Add-more-dprintf-and-nerf-dprintf-in-script.c.patch
|
||||
Patch0238: 0238-arm-arm64-loader-Better-memory-allocation-and-error-.patch
|
||||
Patch0239: 0239-Try-to-pick-better-locations-for-kernel-and-initrd.patch
|
||||
|
14
grub2.spec
14
grub2.spec
@ -7,7 +7,7 @@
|
||||
Name: grub2
|
||||
Epoch: 1
|
||||
Version: 2.02
|
||||
Release: 56%{?dist}
|
||||
Release: 57%{?dist}
|
||||
Summary: Bootloader with support for Linux, Multiboot and more
|
||||
Group: System Environment/Base
|
||||
License: GPLv3+
|
||||
@ -498,6 +498,18 @@ fi
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Tue Sep 11 2018 Peter Jones <pjones@redhat.com> - 2.02-57
|
||||
- Limit grub_malloc() on x86_64 to < 31bit addresses, as some devices seem to
|
||||
have a colossally broken storage controller (or UEFI driver) that can't do
|
||||
DMA to higher memory addresses, but fails silently.
|
||||
Resolves: rhbz#1626844 (possibly really resolving it this time.)
|
||||
- Also integrate Hans's attempt to fix the related error from -54, but do it
|
||||
the other way around: try the low addresses first and *then* the high one if
|
||||
the allocation fails. This way we'll get low regions by default, and if
|
||||
kernel/initramfs don't fit anywhere, it'll try the higher addresses.
|
||||
Related: rhbz#1624532
|
||||
- Coalesce all the intermediate debugging junk from -54/-55/-56.
|
||||
|
||||
* Tue Sep 11 2018 Peter Jones <pjones@redhat.com> - 2.02-56
|
||||
- Don't mangle fw_path even harder.
|
||||
Resolves: rhbz#1626844
|
||||
|
Loading…
Reference in New Issue
Block a user