import grub2-2.02-122.el8
This commit is contained in:
parent
9a1ac4ad66
commit
3e7ee9ce38
|
@ -1,4 +1,4 @@
|
|||
From fe8b1f619fafcd2438e3d86fb07c6a5e9280423c Mon Sep 17 00:00:00 2001
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ian Page Hands <iphands@gmail.com>
|
||||
Date: Tue, 8 Jun 2021 13:48:56 -0400
|
||||
Subject: [PATCH] efinet: Add DHCP proxy support
|
||||
|
@ -51,6 +51,3 @@ index df7760ad2..25809050b 100644
|
|||
1, device, path);
|
||||
grub_dprintf ("efinet", "device: `%s' path: `%s'\n", *device, *path);
|
||||
}
|
||||
--
|
||||
2.34.1
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich@redhat.com>
|
||||
Date: Tue, 8 Feb 2022 08:39:10 +0100
|
||||
Subject: [PATCH] search: fixed bug stopping iteration when --no-floppy is used
|
||||
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
|
||||
|
@ -10,8 +11,11 @@ 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 <rmetrich@redhat.com>
|
||||
(cherry picked from commit e784b4b3367341b0468dd2a83b265d49383f48ae)
|
||||
(cherry picked from commit 8f4688fd61dcf35de3d7ebbc2b237cfa2f202930)
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
(cherry picked from commit 68ba54c2298604146be83cae144dafd1cfd1fe2d)
|
||||
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
|
||||
(cherry picked from commit 7ada55e3fcd16e00773d3918955b2b945b7f063a)
|
||||
(cherry picked from commit 44a58e304fd06155a56b650927728af01bbc647d)
|
||||
---
|
||||
grub-core/commands/search.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
@ -17,8 +17,10 @@ effective EFI device behind.
|
|||
This commit also refactors handling of --no-floppy option.
|
||||
|
||||
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
|
||||
(cherry picked from commit aedb45f32106dd2a64f906b0db6a76ee09f1b930)
|
||||
(cherry picked from commit 4fef28d5405f7f986dba6e503e48d6a408588382)
|
||||
[rharwood: apply rmetrich's flags initialization fix]
|
||||
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
|
||||
(cherry picked from commit fdd8396f4fa750bbbabd4298f2593942f2b84710)
|
||||
(cherry picked from commit bea473b58726705bb83a3db88f52d46fdcc6150e)
|
||||
---
|
||||
grub-core/commands/search.c | 27 +++++++++++++++++++++++----
|
||||
grub-core/commands/search_wrap.c | 18 ++++++++++++------
|
||||
|
@ -86,7 +88,7 @@ index d3180bf66..2036a756b 100644
|
|||
.nhints = nhints,
|
||||
.count = 0,
|
||||
diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c
|
||||
index 47fc8eb99..464e6ebb1 100644
|
||||
index 47fc8eb99..0b62acf85 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[] =
|
||||
|
@ -109,7 +111,7 @@ index 47fc8eb99..464e6ebb1 100644
|
|||
const char *id = 0;
|
||||
int i = 0, j = 0, nhints = 0;
|
||||
char **hints = NULL;
|
||||
+ enum search_flags flags;
|
||||
+ enum search_flags flags = 0;
|
||||
|
||||
if (state[SEARCH_HINT].set)
|
||||
for (i = 0; state[SEARCH_HINT].args[i]; i++)
|
||||
|
|
|
@ -50,10 +50,10 @@ The code is easily extensible to handle other arguments in the future if
|
|||
needed.
|
||||
|
||||
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
|
||||
(cherry picked from commit 73e183ce1e42bd97ae91a9254f8d4acd4d0b1cbc)
|
||||
(cherry picked from commit 174c3efcf17b1f5ad466f9c5fb83cd9554edb5f9)
|
||||
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
|
||||
(cherry picked from commit cc972c27314c841f80ab0fe8318fae06f078c680)
|
||||
(cherry picked from commit 84b0c3f965a3918be64ca850139bea7c32d23ae9)
|
||||
---
|
||||
NEWS | 2 +-
|
||||
grub-core/Makefile.core.def | 6 ++
|
||||
grub-core/commands/efi/connectefi.c | 205 ++++++++++++++++++++++++++++++++++++
|
||||
grub-core/commands/efi/lsefi.c | 1 +
|
||||
|
@ -61,22 +61,10 @@ Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
|
|||
grub-core/kern/efi/efi.c | 13 +++
|
||||
include/grub/efi/disk.h | 2 +
|
||||
include/grub/efi/efi.h | 5 +
|
||||
NEWS | 2 +-
|
||||
8 files changed, 246 insertions(+), 1 deletion(-)
|
||||
create mode 100644 grub-core/commands/efi/connectefi.c
|
||||
|
||||
diff --git a/NEWS b/NEWS
|
||||
index 2ebd54e78..b04041507 100644
|
||||
--- a/NEWS
|
||||
+++ b/NEWS
|
||||
@@ -66,7 +66,7 @@ New in 2.02:
|
||||
* Prefer pmtimer for TSC calibration.
|
||||
|
||||
* New/improved platform support:
|
||||
- * New `efifwsetup' and `lsefi' commands on EFI platforms.
|
||||
+ * New `efifwsetup', `lsefi' and `connectefi` commands on EFI platforms.
|
||||
* New `cmosdump' and `cmosset' commands on platforms with CMOS support.
|
||||
* New command `pcidump' for PCI platforms.
|
||||
* Improve opcode parsing in ACPI halt implementation.
|
||||
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
||||
index 612df2e9c..ef06f8c95 100644
|
||||
--- a/grub-core/Makefile.core.def
|
||||
|
@ -394,3 +382,16 @@ index 570a69361..4411ffa16 100644
|
|||
void *EXPORT_FUNC(grub_efi_open_protocol) (grub_efi_handle_t handle,
|
||||
grub_efi_guid_t *protocol,
|
||||
grub_efi_uint32_t attributes);
|
||||
diff --git a/NEWS b/NEWS
|
||||
index 2ebd54e78..b04041507 100644
|
||||
--- a/NEWS
|
||||
+++ b/NEWS
|
||||
@@ -66,7 +66,7 @@ New in 2.02:
|
||||
* Prefer pmtimer for TSC calibration.
|
||||
|
||||
* New/improved platform support:
|
||||
- * New `efifwsetup' and `lsefi' commands on EFI platforms.
|
||||
+ * New `efifwsetup', `lsefi' and `connectefi` commands on EFI platforms.
|
||||
* New `cmosdump' and `cmosset' commands on platforms with CMOS support.
|
||||
* New command `pcidump' for PCI platforms.
|
||||
* Improve opcode parsing in ACPI halt implementation.
|
||||
|
|
|
@ -0,0 +1,203 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Thu, 11 Jul 2019 17:17:02 +0200
|
||||
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>
|
||||
(cherry picked from commit 9035d4f9ea2f26a9d4412a0918d597ceb5365442)
|
||||
|
||||
Conflicts:
|
||||
grub-core/loader/i386/efi/linux.c
|
||||
Context diffs in includes.
|
||||
|
||||
Signed-off-by: Lenny Szubowicz <lszubowi@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 2d9c9032b..9e76f23e5 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;
|
||||
@@ -472,7 +472,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)
|
||||
@@ -490,9 +490,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 576f8c07e..c5fdf522b 100644
|
||||
--- a/grub-core/loader/i386/efi/linux.c
|
||||
+++ b/grub-core/loader/i386/efi/linux.c
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <grub/lib/cmdline.h>
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/efi/linux.h>
|
||||
+#include <grub/cpu/efi/memory.h>
|
||||
#include <grub/tpm.h>
|
||||
#include <grub/safemath.h>
|
||||
|
||||
@@ -113,7 +114,9 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
||||
}
|
||||
}
|
||||
|
||||
- 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"));
|
||||
@@ -217,8 +220,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
}
|
||||
}
|
||||
|
||||
- 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");
|
||||
@@ -288,8 +294,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"));
|
||||
@@ -316,11 +325,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 2c64918e3..a4c2ec835 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 c6cb32417..acb61dca4 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 2c64918e3..a4c2ec835 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 2c64918e3..a4c2ec835 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 46e9145a3..e81cfb322 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 */
|
|
@ -0,0 +1,109 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Fri, 12 Jul 2019 09:53:32 +0200
|
||||
Subject: [PATCH] x86-efi: Use bounce buffers for reading to addresses > 4GB
|
||||
|
||||
Lots of machines apparently can't DMA correctly above 4GB during UEFI,
|
||||
so use bounce buffers for the initramfs read.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
(cherry picked from commit 7765a790dee00f2e0d414cf3a3d016c493cf0d9b)
|
||||
|
||||
Conflicts:
|
||||
grub-core/loader/i386/efi/linux.c
|
||||
git cherry-pick thought delete of prior def of MIN was a
|
||||
conflict.
|
||||
|
||||
Signed-off-by: Lenny Szubowicz <lszubowi@redhat.com>
|
||||
---
|
||||
grub-core/loader/i386/efi/linux.c | 52 +++++++++++++++++++++++++++++++++------
|
||||
1 file changed, 45 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
|
||||
index c5fdf522b..73cd838e9 100644
|
||||
--- a/grub-core/loader/i386/efi/linux.c
|
||||
+++ b/grub-core/loader/i386/efi/linux.c
|
||||
@@ -37,11 +37,16 @@ static grub_dl_t my_mod;
|
||||
static int loaded;
|
||||
static void *kernel_mem;
|
||||
static grub_uint64_t kernel_size;
|
||||
-static grub_uint8_t *initrd_mem;
|
||||
+static void *initrd_mem;
|
||||
static grub_uint32_t handover_offset;
|
||||
struct linux_kernel_params *params;
|
||||
static char *linux_cmdline;
|
||||
|
||||
+#define MIN(a, b) \
|
||||
+ ({ typeof (a) _a = (a); \
|
||||
+ typeof (b) _b = (b); \
|
||||
+ _a < _b ? _a : _b; })
|
||||
+
|
||||
#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12)
|
||||
|
||||
static grub_err_t
|
||||
@@ -75,6 +80,44 @@ grub_linuxefi_unload (void)
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
+#define BOUNCE_BUFFER_MAX 0x10000000ull
|
||||
+
|
||||
+static grub_ssize_t
|
||||
+read(grub_file_t file, grub_uint8_t *bufp, grub_size_t len)
|
||||
+{
|
||||
+ grub_ssize_t bufpos = 0;
|
||||
+ static grub_size_t bbufsz = 0;
|
||||
+ static char *bbuf = NULL;
|
||||
+
|
||||
+ if (bbufsz == 0)
|
||||
+ bbufsz = MIN(BOUNCE_BUFFER_MAX, len);
|
||||
+
|
||||
+ while (!bbuf && bbufsz)
|
||||
+ {
|
||||
+ bbuf = grub_malloc(bbufsz);
|
||||
+ if (!bbuf)
|
||||
+ bbufsz >>= 1;
|
||||
+ }
|
||||
+ if (!bbuf)
|
||||
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate bounce buffer"));
|
||||
+
|
||||
+ while (bufpos < (long long)len)
|
||||
+ {
|
||||
+ grub_ssize_t sz;
|
||||
+
|
||||
+ sz = grub_file_read (file, bbuf, MIN(bbufsz, len - bufpos));
|
||||
+ if (sz < 0)
|
||||
+ return sz;
|
||||
+ if (sz == 0)
|
||||
+ break;
|
||||
+
|
||||
+ grub_memcpy(bufp + bufpos, bbuf, sz);
|
||||
+ bufpos += sz;
|
||||
+ }
|
||||
+
|
||||
+ return bufpos;
|
||||
+}
|
||||
+
|
||||
static grub_err_t
|
||||
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
||||
@@ -133,7 +176,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
||||
for (i = 0; i < nfiles; i++)
|
||||
{
|
||||
grub_ssize_t cursize = grub_file_size (files[i]);
|
||||
- if (grub_file_read (files[i], ptr, cursize) != cursize)
|
||||
+ if (read (files[i], ptr, cursize) != cursize)
|
||||
{
|
||||
if (!grub_errno)
|
||||
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
|
||||
@@ -161,11 +204,6 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
-#define MIN(a, b) \
|
||||
- ({ typeof (a) _a = (a); \
|
||||
- typeof (b) _b = (b); \
|
||||
- _a < _b ? _a : _b; })
|
||||
-
|
||||
static grub_err_t
|
||||
grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
|
@ -0,0 +1,134 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Thu, 13 Sep 2018 14:42:34 -0400
|
||||
Subject: [PATCH] x86-efi: Re-arrange grub_cmd_linux() a little bit.
|
||||
|
||||
This just helps the next patch be easier to read.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
(cherry picked from commit 486cdd48889b30b03143c393e59a75ea040b5c40)
|
||||
---
|
||||
grub-core/loader/i386/efi/linux.c | 75 +++++++++++++++++++++------------------
|
||||
1 file changed, 41 insertions(+), 34 deletions(-)
|
||||
|
||||
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
|
||||
index 73cd838e9..c9650561f 100644
|
||||
--- a/grub-core/loader/i386/efi/linux.c
|
||||
+++ b/grub-core/loader/i386/efi/linux.c
|
||||
@@ -258,32 +258,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
}
|
||||
}
|
||||
|
||||
- params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_ALLOCATION_ADDRESS,
|
||||
- BYTES_TO_PAGES(sizeof(*params)));
|
||||
- if (!params)
|
||||
- params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_USABLE_ADDRESS,
|
||||
- BYTES_TO_PAGES(sizeof(*params)));
|
||||
- if (! params)
|
||||
- {
|
||||
- grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate kernel parameters");
|
||||
- goto fail;
|
||||
- }
|
||||
+ lh = (struct linux_i386_kernel_header *)kernel;
|
||||
+ grub_dprintf ("linux", "original lh is at %p\n", kernel);
|
||||
|
||||
- grub_dprintf ("linux", "params = %p\n", params);
|
||||
-
|
||||
- grub_memset (params, 0, sizeof(*params));
|
||||
-
|
||||
- setup_header_end_offset = *((grub_uint8_t *)kernel + 0x201);
|
||||
- grub_dprintf ("linux", "copying %lu bytes from %p to %p\n",
|
||||
- MIN((grub_size_t)0x202+setup_header_end_offset,
|
||||
- sizeof (*params)) - 0x1f1,
|
||||
- (grub_uint8_t *)kernel + 0x1f1,
|
||||
- (grub_uint8_t *)params + 0x1f1);
|
||||
- grub_memcpy ((grub_uint8_t *)params + 0x1f1,
|
||||
- (grub_uint8_t *)kernel + 0x1f1,
|
||||
- MIN((grub_size_t)0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1);
|
||||
- lh = (struct linux_i386_kernel_header *)params;
|
||||
- grub_dprintf ("linux", "lh is at %p\n", lh);
|
||||
grub_dprintf ("linux", "checking lh->boot_flag\n");
|
||||
if (lh->boot_flag != grub_cpu_to_le16 (0xaa55))
|
||||
{
|
||||
@@ -331,6 +308,34 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
}
|
||||
#endif
|
||||
|
||||
+ params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_ALLOCATION_ADDRESS,
|
||||
+ BYTES_TO_PAGES(sizeof(*params)));
|
||||
+ if (!params)
|
||||
+ params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_USABLE_ADDRESS,
|
||||
+ BYTES_TO_PAGES(sizeof(*params)));
|
||||
+ if (! params)
|
||||
+ {
|
||||
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate kernel parameters");
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
+ grub_dprintf ("linux", "params = %p\n", params);
|
||||
+
|
||||
+ grub_memset (params, 0, sizeof(*params));
|
||||
+
|
||||
+ setup_header_end_offset = *((grub_uint8_t *)kernel + 0x201);
|
||||
+ grub_dprintf ("linux", "copying %lu bytes from %p to %p\n",
|
||||
+ MIN((grub_size_t)0x202+setup_header_end_offset,
|
||||
+ sizeof (*params)) - 0x1f1,
|
||||
+ (grub_uint8_t *)kernel + 0x1f1,
|
||||
+ (grub_uint8_t *)params + 0x1f1);
|
||||
+ grub_memcpy ((grub_uint8_t *)params + 0x1f1,
|
||||
+ (grub_uint8_t *)kernel + 0x1f1,
|
||||
+ MIN((grub_size_t)0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1);
|
||||
+
|
||||
+ lh = (struct linux_i386_kernel_header *)params;
|
||||
+ grub_dprintf ("linux", "new lh is at %p\n", lh);
|
||||
+
|
||||
grub_dprintf ("linux", "setting up cmdline\n");
|
||||
linux_cmdline = grub_efi_allocate_pages_max(GRUB_EFI_MAX_ALLOCATION_ADDRESS,
|
||||
BYTES_TO_PAGES(lh->cmdline_size + 1));
|
||||
@@ -356,8 +361,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
grub_dprintf ("linux", "setting lh->cmd_line_ptr\n");
|
||||
lh->cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline;
|
||||
|
||||
- grub_dprintf ("linux", "computing handover offset\n");
|
||||
handover_offset = lh->handover_offset;
|
||||
+ grub_dprintf("linux", "handover_offset: %08x\n", handover_offset);
|
||||
|
||||
start = (lh->setup_sects + 1) * 512;
|
||||
|
||||
@@ -374,26 +379,28 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate kernel"));
|
||||
goto fail;
|
||||
}
|
||||
-
|
||||
- grub_dprintf ("linux", "kernel_mem = %lx\n", (unsigned long) kernel_mem);
|
||||
+ grub_dprintf("linux", "kernel_mem = %p\n", kernel_mem);
|
||||
|
||||
grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0);
|
||||
- loaded=1;
|
||||
+
|
||||
+ loaded = 1;
|
||||
+
|
||||
grub_dprintf ("linux", "setting lh->code32_start to %p\n", kernel_mem);
|
||||
lh->code32_start = (grub_uint32_t)(grub_addr_t) kernel_mem;
|
||||
|
||||
grub_memcpy (kernel_mem, (char *)kernel + start, filelen - start);
|
||||
|
||||
- grub_dprintf ("linux", "setting lh->type_of_loader\n");
|
||||
lh->type_of_loader = 0x6;
|
||||
+ grub_dprintf ("linux", "setting lh->type_of_loader = 0x%02x\n",
|
||||
+ lh->type_of_loader);
|
||||
|
||||
- grub_dprintf ("linux", "setting lh->ext_loader_{type,ver}\n");
|
||||
params->ext_loader_type = 0;
|
||||
params->ext_loader_ver = 2;
|
||||
- grub_dprintf("linux", "kernel_mem: %p handover_offset: %08x\n",
|
||||
- kernel_mem, handover_offset);
|
||||
+ grub_dprintf ("linux",
|
||||
+ "setting lh->ext_loader_{type,ver} = {0x%02x,0x%02x}\n",
|
||||
+ params->ext_loader_type, params->ext_loader_ver);
|
||||
|
||||
- fail:
|
||||
+fail:
|
||||
if (file)
|
||||
grub_file_close (file);
|
||||
|
|
@ -0,0 +1,259 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 12 Sep 2018 16:03:55 -0400
|
||||
Subject: [PATCH] x86-efi: Make our own allocator for kernel stuff
|
||||
|
||||
This helps enable allocations above 4GB.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
(cherry picked from commit cfea4ae780f8860d472cd2d5a9765ec2fe2adc83)
|
||||
---
|
||||
grub-core/loader/i386/efi/linux.c | 167 +++++++++++++++++++++-----------------
|
||||
1 file changed, 94 insertions(+), 73 deletions(-)
|
||||
|
||||
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
|
||||
index c9650561f..5eed2014c 100644
|
||||
--- a/grub-core/loader/i386/efi/linux.c
|
||||
+++ b/grub-core/loader/i386/efi/linux.c
|
||||
@@ -49,6 +49,65 @@ static char *linux_cmdline;
|
||||
|
||||
#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> 12)
|
||||
|
||||
+struct allocation_choice {
|
||||
+ grub_efi_physical_address_t addr;
|
||||
+ grub_efi_allocate_type_t alloc_type;
|
||||
+};
|
||||
+
|
||||
+static struct allocation_choice max_addresses[] =
|
||||
+ {
|
||||
+ { GRUB_EFI_MAX_ALLOCATION_ADDRESS, GRUB_EFI_ALLOCATE_MAX_ADDRESS },
|
||||
+ { GRUB_EFI_MAX_ALLOCATION_ADDRESS, GRUB_EFI_ALLOCATE_MAX_ADDRESS },
|
||||
+ { GRUB_EFI_MAX_ALLOCATION_ADDRESS, GRUB_EFI_ALLOCATE_MAX_ADDRESS },
|
||||
+ { 0, 0 }
|
||||
+ };
|
||||
+
|
||||
+static inline void
|
||||
+kernel_free(void *addr, grub_efi_uintn_t size)
|
||||
+{
|
||||
+ if (addr && size)
|
||||
+ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)addr,
|
||||
+ BYTES_TO_PAGES(size));
|
||||
+}
|
||||
+
|
||||
+static void *
|
||||
+kernel_alloc(grub_efi_uintn_t size, const char * const errmsg)
|
||||
+{
|
||||
+ void *addr = 0;
|
||||
+ unsigned int i;
|
||||
+ grub_efi_physical_address_t prev_max = 0;
|
||||
+
|
||||
+ for (i = 0; max_addresses[i].addr != 0 && addr == 0; i++)
|
||||
+ {
|
||||
+ grub_uint64_t max = max_addresses[i].addr;
|
||||
+ grub_efi_uintn_t pages;
|
||||
+
|
||||
+ if (max == prev_max)
|
||||
+ continue;
|
||||
+
|
||||
+ pages = BYTES_TO_PAGES(size);
|
||||
+ grub_dprintf ("linux", "Trying to allocate %lu pages from %p\n",
|
||||
+ pages, (void *)max);
|
||||
+
|
||||
+ prev_max = max;
|
||||
+ addr = grub_efi_allocate_pages_real (max, pages,
|
||||
+ max_addresses[i].alloc_type,
|
||||
+ GRUB_EFI_LOADER_DATA);
|
||||
+ if (addr)
|
||||
+ grub_dprintf ("linux", "Allocated at %p\n", addr);
|
||||
+ }
|
||||
+
|
||||
+ while (grub_error_pop ())
|
||||
+ {
|
||||
+ ;
|
||||
+ }
|
||||
+
|
||||
+ if (addr == NULL)
|
||||
+ grub_error (GRUB_ERR_OUT_OF_MEMORY, "%s", errmsg);
|
||||
+
|
||||
+ return addr;
|
||||
+}
|
||||
+
|
||||
static grub_err_t
|
||||
grub_linuxefi_boot (void)
|
||||
{
|
||||
@@ -64,19 +123,12 @@ grub_linuxefi_unload (void)
|
||||
{
|
||||
grub_dl_unref (my_mod);
|
||||
loaded = 0;
|
||||
- if (initrd_mem)
|
||||
- grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)initrd_mem,
|
||||
- BYTES_TO_PAGES(params->ramdisk_size));
|
||||
- if (linux_cmdline)
|
||||
- grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)
|
||||
- linux_cmdline,
|
||||
- BYTES_TO_PAGES(params->cmdline_size + 1));
|
||||
- if (kernel_mem)
|
||||
- grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)kernel_mem,
|
||||
- BYTES_TO_PAGES(kernel_size));
|
||||
- if (params)
|
||||
- grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)params,
|
||||
- BYTES_TO_PAGES(16384));
|
||||
+
|
||||
+ kernel_free(initrd_mem, params->ramdisk_size);
|
||||
+ kernel_free(linux_cmdline, params->cmdline_size + 1);
|
||||
+ kernel_free(kernel_mem, kernel_size);
|
||||
+ kernel_free(params, sizeof(*params));
|
||||
+
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -157,19 +209,13 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
||||
}
|
||||
}
|
||||
|
||||
- initrd_mem = grub_efi_allocate_pages_max (GRUB_EFI_MAX_ALLOCATION_ADDRESS, BYTES_TO_PAGES(size));
|
||||
- if (!initrd_mem)
|
||||
- initrd_mem = grub_efi_allocate_pages_max (GRUB_EFI_MAX_USABLE_ADDRESS, BYTES_TO_PAGES(size));
|
||||
- if (!initrd_mem)
|
||||
- {
|
||||
- grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate initrd"));
|
||||
- goto fail;
|
||||
- }
|
||||
-
|
||||
- grub_dprintf ("linux", "initrd_mem = %lx\n", (unsigned long) initrd_mem);
|
||||
+ initrd_mem = kernel_alloc(size, N_("can't allocate initrd"));
|
||||
+ if (initrd_mem == NULL)
|
||||
+ goto fail;
|
||||
+ grub_dprintf ("linux", "initrd_mem = %p\n", initrd_mem);
|
||||
|
||||
params->ramdisk_size = size;
|
||||
- params->ramdisk_image = (grub_uint32_t)(grub_addr_t) initrd_mem;
|
||||
+ params->ramdisk_image = initrd_mem;
|
||||
|
||||
ptr = initrd_mem;
|
||||
|
||||
@@ -230,7 +276,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
filelen = grub_file_size (file);
|
||||
|
||||
kernel = grub_malloc(filelen);
|
||||
-
|
||||
if (!kernel)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("cannot allocate kernel buffer"));
|
||||
@@ -289,7 +334,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
goto fail;
|
||||
}
|
||||
|
||||
-#if defined(__x86_64__) || defined(__aarch64__)
|
||||
+#if defined(__x86_64__)
|
||||
grub_dprintf ("linux", "checking lh->xloadflags\n");
|
||||
if (!(lh->xloadflags & LINUX_XLF_KERNEL_64))
|
||||
{
|
||||
@@ -308,17 +353,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
}
|
||||
#endif
|
||||
|
||||
- params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_ALLOCATION_ADDRESS,
|
||||
- BYTES_TO_PAGES(sizeof(*params)));
|
||||
+ params = kernel_alloc (sizeof(*params), "cannot allocate kernel parameters");
|
||||
if (!params)
|
||||
- params = grub_efi_allocate_pages_max (GRUB_EFI_MAX_USABLE_ADDRESS,
|
||||
- BYTES_TO_PAGES(sizeof(*params)));
|
||||
- if (! params)
|
||||
- {
|
||||
- grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate kernel parameters");
|
||||
- goto fail;
|
||||
- }
|
||||
-
|
||||
+ goto fail;
|
||||
grub_dprintf ("linux", "params = %p\n", params);
|
||||
|
||||
grub_memset (params, 0, sizeof(*params));
|
||||
@@ -337,19 +374,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
grub_dprintf ("linux", "new lh is at %p\n", lh);
|
||||
|
||||
grub_dprintf ("linux", "setting up cmdline\n");
|
||||
- linux_cmdline = grub_efi_allocate_pages_max(GRUB_EFI_MAX_ALLOCATION_ADDRESS,
|
||||
- BYTES_TO_PAGES(lh->cmdline_size + 1));
|
||||
+ linux_cmdline = kernel_alloc (lh->cmdline_size + 1, N_("can't allocate cmdline"));
|
||||
if (!linux_cmdline)
|
||||
- linux_cmdline = grub_efi_allocate_pages_max(GRUB_EFI_MAX_USABLE_ADDRESS,
|
||||
- BYTES_TO_PAGES(lh->cmdline_size + 1));
|
||||
- if (!linux_cmdline)
|
||||
- {
|
||||
- grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate cmdline"));
|
||||
- goto fail;
|
||||
- }
|
||||
-
|
||||
- grub_dprintf ("linux", "linux_cmdline = %lx\n",
|
||||
- (unsigned long)linux_cmdline);
|
||||
+ goto fail;
|
||||
+ grub_dprintf ("linux", "linux_cmdline = %p\n", linux_cmdline);
|
||||
|
||||
grub_memcpy (linux_cmdline, LINUX_IMAGE, sizeof (LINUX_IMAGE));
|
||||
grub_create_loader_cmdline (argc, argv,
|
||||
@@ -358,27 +386,24 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
GRUB_VERIFY_KERNEL_CMDLINE);
|
||||
|
||||
grub_dprintf ("linux", "cmdline:%s\n", linux_cmdline);
|
||||
- grub_dprintf ("linux", "setting lh->cmd_line_ptr\n");
|
||||
- lh->cmd_line_ptr = (grub_uint32_t)(grub_addr_t)linux_cmdline;
|
||||
+ grub_dprintf ("linux", "setting lh->cmd_line_ptr to 0x%08x\n",
|
||||
+ linux_cmdline);
|
||||
+ lh->cmd_line_ptr = linux_cmdline;
|
||||
|
||||
handover_offset = lh->handover_offset;
|
||||
- grub_dprintf("linux", "handover_offset: %08x\n", handover_offset);
|
||||
+ grub_dprintf("linux", "handover_offset: 0x%08x\n", handover_offset);
|
||||
|
||||
start = (lh->setup_sects + 1) * 512;
|
||||
|
||||
- kernel_mem = grub_efi_allocate_pages_max(lh->pref_address,
|
||||
- BYTES_TO_PAGES(lh->init_size));
|
||||
- if (!kernel_mem)
|
||||
- kernel_mem = grub_efi_allocate_pages_max(GRUB_EFI_MAX_ALLOCATION_ADDRESS,
|
||||
- BYTES_TO_PAGES(lh->init_size));
|
||||
- if (!kernel_mem)
|
||||
- kernel_mem = grub_efi_allocate_pages_max(GRUB_EFI_MAX_USABLE_ADDRESS,
|
||||
- BYTES_TO_PAGES(lh->init_size));
|
||||
- if (!kernel_mem)
|
||||
+ grub_dprintf ("linux", "lh->pref_address: %p\n", (void *)(grub_addr_t)lh->pref_address);
|
||||
+ if (lh->pref_address < (grub_uint64_t)GRUB_EFI_MAX_ALLOCATION_ADDRESS)
|
||||
{
|
||||
- grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("can't allocate kernel"));
|
||||
- goto fail;
|
||||
+ max_addresses[0].addr = lh->pref_address;
|
||||
+ max_addresses[0].alloc_type = GRUB_EFI_ALLOCATE_ADDRESS;
|
||||
}
|
||||
+ kernel_mem = kernel_alloc (lh->init_size, N_("can't allocate kernel"));
|
||||
+ if (!kernel_mem)
|
||||
+ goto fail;
|
||||
grub_dprintf("linux", "kernel_mem = %p\n", kernel_mem);
|
||||
|
||||
grub_loader_set (grub_linuxefi_boot, grub_linuxefi_unload, 0);
|
||||
@@ -413,18 +438,14 @@ fail:
|
||||
loaded = 0;
|
||||
}
|
||||
|
||||
- if (linux_cmdline && lh && !loaded)
|
||||
- grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)
|
||||
- linux_cmdline,
|
||||
- BYTES_TO_PAGES(lh->cmdline_size + 1));
|
||||
+ if (!loaded)
|
||||
+ {
|
||||
+ if (lh)
|
||||
+ kernel_free (linux_cmdline, lh->cmdline_size + 1);
|
||||
|
||||
- if (kernel_mem && !loaded)
|
||||
- grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)kernel_mem,
|
||||
- BYTES_TO_PAGES(kernel_size));
|
||||
-
|
||||
- if (params && !loaded)
|
||||
- grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)params,
|
||||
- BYTES_TO_PAGES(16384));
|
||||
+ kernel_free (kernel_mem, kernel_size);
|
||||
+ kernel_free (params, sizeof(*params));
|
||||
+ }
|
||||
|
||||
return grub_errno;
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Peter Jones <pjones@redhat.com>
|
||||
Date: Wed, 12 Sep 2018 16:12:27 -0400
|
||||
Subject: [PATCH] x86-efi: Allow initrd+params+cmdline allocations above 4GB.
|
||||
|
||||
This enables everything except the kernel itself to be above 4GB.
|
||||
Putting the kernel up there still doesn't work, because of the way
|
||||
params->code32_start is used.
|
||||
|
||||
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||||
(cherry picked from commit 2b636967018431b046b625ad4753c8de51f7f6b2)
|
||||
---
|
||||
grub-core/loader/i386/efi/linux.c | 67 +++++++++++++++++++++++++++++++++++----
|
||||
include/grub/i386/linux.h | 6 +++-
|
||||
2 files changed, 65 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
|
||||
index 5eed2014c..e9d2c85b3 100644
|
||||
--- a/grub-core/loader/i386/efi/linux.c
|
||||
+++ b/grub-core/loader/i386/efi/linux.c
|
||||
@@ -54,13 +54,22 @@ struct allocation_choice {
|
||||
grub_efi_allocate_type_t alloc_type;
|
||||
};
|
||||
|
||||
-static struct allocation_choice max_addresses[] =
|
||||
+static struct allocation_choice max_addresses[4] =
|
||||
{
|
||||
+ /* the kernel overrides this one with pref_address and
|
||||
+ * GRUB_EFI_ALLOCATE_ADDRESS */
|
||||
{ GRUB_EFI_MAX_ALLOCATION_ADDRESS, GRUB_EFI_ALLOCATE_MAX_ADDRESS },
|
||||
+ /* this one is always below 4GB, which we still *prefer* even if the flag
|
||||
+ * is set. */
|
||||
{ GRUB_EFI_MAX_ALLOCATION_ADDRESS, GRUB_EFI_ALLOCATE_MAX_ADDRESS },
|
||||
+ /* If the flag in params is set, this one gets changed to be above 4GB. */
|
||||
{ GRUB_EFI_MAX_ALLOCATION_ADDRESS, GRUB_EFI_ALLOCATE_MAX_ADDRESS },
|
||||
{ 0, 0 }
|
||||
};
|
||||
+static struct allocation_choice saved_addresses[4];
|
||||
+
|
||||
+#define save_addresses() grub_memcpy(saved_addresses, max_addresses, sizeof(max_addresses))
|
||||
+#define restore_addresses() grub_memcpy(max_addresses, saved_addresses, sizeof(max_addresses))
|
||||
|
||||
static inline void
|
||||
kernel_free(void *addr, grub_efi_uintn_t size)
|
||||
@@ -82,6 +91,11 @@ kernel_alloc(grub_efi_uintn_t size, const char * const errmsg)
|
||||
grub_uint64_t max = max_addresses[i].addr;
|
||||
grub_efi_uintn_t pages;
|
||||
|
||||
+ /*
|
||||
+ * When we're *not* loading the kernel, or >4GB allocations aren't
|
||||
+ * supported, these entries are basically all the same, so don't re-try
|
||||
+ * the same parameters.
|
||||
+ */
|
||||
if (max == prev_max)
|
||||
continue;
|
||||
|
||||
@@ -170,6 +184,9 @@ read(grub_file_t file, grub_uint8_t *bufp, grub_size_t len)
|
||||
return bufpos;
|
||||
}
|
||||
|
||||
+#define LOW_U32(val) ((grub_uint32_t)(((grub_addr_t)(val)) & 0xffffffffull))
|
||||
+#define HIGH_U32(val) ((grub_uint32_t)(((grub_addr_t)(val) >> 32) & 0xffffffffull))
|
||||
+
|
||||
static grub_err_t
|
||||
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc, char *argv[])
|
||||
@@ -214,8 +231,12 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
||||
goto fail;
|
||||
grub_dprintf ("linux", "initrd_mem = %p\n", initrd_mem);
|
||||
|
||||
- params->ramdisk_size = size;
|
||||
- params->ramdisk_image = initrd_mem;
|
||||
+ params->ramdisk_size = LOW_U32(size);
|
||||
+ params->ramdisk_image = LOW_U32(initrd_mem);
|
||||
+#if defined(__x86_64__)
|
||||
+ params->ext_ramdisk_size = HIGH_U32(size);
|
||||
+ params->ext_ramdisk_image = HIGH_U32(initrd_mem);
|
||||
+#endif
|
||||
|
||||
ptr = initrd_mem;
|
||||
|
||||
@@ -353,6 +374,18 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
}
|
||||
#endif
|
||||
|
||||
+#if defined(__x86_64__)
|
||||
+ if (lh->xloadflags & LINUX_XLF_CAN_BE_LOADED_ABOVE_4G)
|
||||
+ {
|
||||
+ grub_dprintf ("linux", "Loading kernel above 4GB is supported; enabling.\n");
|
||||
+ max_addresses[2].addr = GRUB_EFI_MAX_USABLE_ADDRESS;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ grub_dprintf ("linux", "Loading kernel above 4GB is not supported\n");
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
params = kernel_alloc (sizeof(*params), "cannot allocate kernel parameters");
|
||||
if (!params)
|
||||
goto fail;
|
||||
@@ -387,21 +420,40 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
||||
grub_dprintf ("linux", "cmdline:%s\n", linux_cmdline);
|
||||
grub_dprintf ("linux", "setting lh->cmd_line_ptr to 0x%08x\n",
|
||||
- linux_cmdline);
|
||||
- lh->cmd_line_ptr = linux_cmdline;
|
||||
+ LOW_U32(linux_cmdline));
|
||||
+ lh->cmd_line_ptr = LOW_U32(linux_cmdline);
|
||||
+#if defined(__x86_64__)
|
||||
+ if ((grub_efi_uintn_t)linux_cmdline > 0xffffffffull)
|
||||
+ {
|
||||
+ grub_dprintf ("linux", "setting params->ext_cmd_line_ptr to 0x%08x\n",
|
||||
+ HIGH_U32(linux_cmdline));
|
||||
+ params->ext_cmd_line_ptr = HIGH_U32(linux_cmdline);
|
||||
+ }
|
||||
+#endif
|
||||
|
||||
handover_offset = lh->handover_offset;
|
||||
grub_dprintf("linux", "handover_offset: 0x%08x\n", handover_offset);
|
||||
|
||||
start = (lh->setup_sects + 1) * 512;
|
||||
|
||||
+ /*
|
||||
+ * AFAICS >4GB for kernel *cannot* work because of params->code32_start being
|
||||
+ * 32-bit and getting called unconditionally in head_64.S from either entry
|
||||
+ * point.
|
||||
+ *
|
||||
+ * so nerf that out here...
|
||||
+ */
|
||||
+ save_addresses();
|
||||
grub_dprintf ("linux", "lh->pref_address: %p\n", (void *)(grub_addr_t)lh->pref_address);
|
||||
if (lh->pref_address < (grub_uint64_t)GRUB_EFI_MAX_ALLOCATION_ADDRESS)
|
||||
{
|
||||
max_addresses[0].addr = lh->pref_address;
|
||||
max_addresses[0].alloc_type = GRUB_EFI_ALLOCATE_ADDRESS;
|
||||
}
|
||||
+ max_addresses[1].addr = GRUB_EFI_MAX_ALLOCATION_ADDRESS;
|
||||
+ max_addresses[2].addr = GRUB_EFI_MAX_ALLOCATION_ADDRESS;
|
||||
kernel_mem = kernel_alloc (lh->init_size, N_("can't allocate kernel"));
|
||||
+ restore_addresses();
|
||||
if (!kernel_mem)
|
||||
goto fail;
|
||||
grub_dprintf("linux", "kernel_mem = %p\n", kernel_mem);
|
||||
@@ -410,8 +462,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
||||
loaded = 1;
|
||||
|
||||
- grub_dprintf ("linux", "setting lh->code32_start to %p\n", kernel_mem);
|
||||
- lh->code32_start = (grub_uint32_t)(grub_addr_t) kernel_mem;
|
||||
+ grub_dprintf ("linux", "setting lh->code32_start to 0x%08x\n",
|
||||
+ LOW_U32(kernel_mem));
|
||||
+ lh->code32_start = LOW_U32(kernel_mem);
|
||||
|
||||
grub_memcpy (kernel_mem, (char *)kernel + start, filelen - start);
|
||||
|
||||
diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h
|
||||
index 8474a857e..a4b37dcce 100644
|
||||
--- a/include/grub/i386/linux.h
|
||||
+++ b/include/grub/i386/linux.h
|
||||
@@ -230,7 +230,11 @@ struct linux_kernel_params
|
||||
grub_uint32_t ofw_cif_handler; /* b8 */
|
||||
grub_uint32_t ofw_idt; /* bc */
|
||||
|
||||
- grub_uint8_t padding7[0x1b8 - 0xc0];
|
||||
+ grub_uint32_t ext_ramdisk_image; /* 0xc0 */
|
||||
+ grub_uint32_t ext_ramdisk_size; /* 0xc4 */
|
||||
+ grub_uint32_t ext_cmd_line_ptr; /* 0xc8 */
|
||||
+
|
||||
+ grub_uint8_t padding7[0x1b8 - 0xcc];
|
||||
|
||||
union
|
||||
{
|
|
@ -0,0 +1,41 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Javier Martinez Canillas <javierm@redhat.com>
|
||||
Date: Tue, 26 May 2020 16:59:28 +0200
|
||||
Subject: [PATCH] x86-efi: Reduce maximum bounce buffer size to 16 MiB
|
||||
|
||||
The EFI linux loader allocates a bounce buffer to copy the initrd since in
|
||||
some machines doing DMA on addresses above 4GB is not possible during EFI.
|
||||
|
||||
But the verifiers framework also allocates a buffer to copy the initrd in
|
||||
its grub_file_open() handler. It does this since the data to verify has to
|
||||
be passed as a single chunk to modules that use the verifiers framework.
|
||||
|
||||
If the initrd image size is big there may not be enough memory in the heap
|
||||
to allocate two buffers of that size. This causes an allocation failure in
|
||||
the verifiers framework and leads to the initrd not being read.
|
||||
|
||||
To prevent these allocation failures, let's reduce the maximum size of the
|
||||
bounce buffer used in the EFI loader. Since the data read can be copied to
|
||||
the actual initrd address in multilple chunks.
|
||||
|
||||
Resolves: rhbz#1838633
|
||||
|
||||
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
||||
(cherry picked from commit 1c0d2ebdddf69962395f0fa4578446654512f3c4)
|
||||
---
|
||||
grub-core/loader/i386/efi/linux.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
|
||||
index e9d2c85b3..a043df891 100644
|
||||
--- a/grub-core/loader/i386/efi/linux.c
|
||||
+++ b/grub-core/loader/i386/efi/linux.c
|
||||
@@ -146,7 +146,7 @@ grub_linuxefi_unload (void)
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
-#define BOUNCE_BUFFER_MAX 0x10000000ull
|
||||
+#define BOUNCE_BUFFER_MAX 0x1000000ull
|
||||
|
||||
static grub_ssize_t
|
||||
read(grub_file_t file, grub_uint8_t *bufp, grub_size_t len)
|
|
@ -489,6 +489,12 @@ Patch0488: 0488-powerpc-fix-prefix-signed-grub-special-case-for-Powe.patch
|
|||
Patch0489: 0489-grub-mkconfig-restore-umask-for-grub.cfg.patch
|
||||
Patch0490: 0490-efinet-Add-DHCP-proxy-support.patch
|
||||
Patch0491: 0491-at_keyboard-Fix-unreliable-key-presses.patch
|
||||
Patch0492: 0492-search-fixed-bug-stopping-iteration-when-no-floppy-i.patch
|
||||
Patch0492: 0492-commands-search-Fix-bug-stopping-iteration-when-no-f.patch
|
||||
Patch0493: 0493-search-new-efidisk-only-option-on-EFI-systems.patch
|
||||
Patch0494: 0494-efi-new-connectefi-command.patch
|
||||
Patch0495: 0495-Try-to-pick-better-locations-for-kernel-and-initrd.patch
|
||||
Patch0496: 0496-x86-efi-Use-bounce-buffers-for-reading-to-addresses-.patch
|
||||
Patch0497: 0497-x86-efi-Re-arrange-grub_cmd_linux-a-little-bit.patch
|
||||
Patch0498: 0498-x86-efi-Make-our-own-allocator-for-kernel-stuff.patch
|
||||
Patch0499: 0499-x86-efi-Allow-initrd-params-cmdline-allocations-abov.patch
|
||||
Patch0500: 0500-x86-efi-Reduce-maximum-bounce-buffer-size-to-16-MiB.patch
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
Name: grub2
|
||||
Epoch: 1
|
||||
Version: 2.02
|
||||
Release: 120%{?dist}
|
||||
Release: 122%{?dist}
|
||||
Summary: Bootloader with support for Linux, Multiboot and more
|
||||
Group: System Environment/Base
|
||||
License: GPLv3+
|
||||
|
@ -510,11 +510,19 @@ fi
|
|||
%endif
|
||||
|
||||
%changelog
|
||||
* Fri Feb 28 2022 Robbie Harwood <rharwood@redhat.com> - 2.06-120
|
||||
* Wed Mar 09 2022 Robbie Harwood <rharwood@redhat.com> - 2.06-122
|
||||
- Fix initialization on efidisk patch
|
||||
- Resolves: #2061252
|
||||
|
||||
* Tue Mar 08 2022 Robbie Harwood <rharwood@redhat.com> - 2.06-121
|
||||
- Backport support for loading initrd above 4GB
|
||||
- Resolves: #2048433
|
||||
|
||||
* Mon Feb 28 2022 Robbie Harwood <rharwood@redhat.com> - 2.06-120
|
||||
- Bump signing
|
||||
- Resolves: #2032294
|
||||
|
||||
* Fri Feb 28 2022 Robbie Harwood <rharwood@redhat.com> - 2.06-119
|
||||
* Mon Feb 28 2022 Robbie Harwood <rharwood@redhat.com> - 2.06-119
|
||||
- Enable connectefi module
|
||||
- Resolves: #2032294
|
||||
|
||||
|
|
Loading…
Reference in New Issue