|
|
28f7f8 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
27a4da |
From: Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
27a4da |
Date: Thu, 7 May 2015 16:23:39 +0200
|
|
|
28f7f8 |
Subject: [PATCH] linux.c: Ensure that initrd is page-aligned.
|
|
|
27a4da |
|
|
|
27a4da |
---
|
|
|
27a4da |
grub-core/loader/i386/linux.c | 11 +++++------
|
|
|
27a4da |
1 file changed, 5 insertions(+), 6 deletions(-)
|
|
|
27a4da |
|
|
|
27a4da |
diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
|
|
|
28f7f8 |
index 53f74ae0685..764cde20318 100644
|
|
|
27a4da |
--- a/grub-core/loader/i386/linux.c
|
|
|
27a4da |
+++ b/grub-core/loader/i386/linux.c
|
|
|
27a4da |
@@ -70,7 +70,6 @@ static grub_addr_t prot_mode_target;
|
|
|
27a4da |
static void *initrd_mem;
|
|
|
27a4da |
static grub_addr_t initrd_mem_target;
|
|
|
27a4da |
static grub_size_t prot_init_space;
|
|
|
27a4da |
-static grub_uint32_t initrd_pages;
|
|
|
27a4da |
static struct grub_relocator *relocator = NULL;
|
|
|
27a4da |
static void *efi_mmap_buf;
|
|
|
27a4da |
static grub_size_t maximal_cmdline_size;
|
|
|
27a4da |
@@ -1055,7 +1054,7 @@ static grub_err_t
|
|
|
27a4da |
grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|
|
27a4da |
int argc, char *argv[])
|
|
|
27a4da |
{
|
|
|
27a4da |
- grub_size_t size = 0;
|
|
|
27a4da |
+ grub_size_t size = 0, aligned_size = 0;
|
|
|
27a4da |
grub_addr_t addr_min, addr_max;
|
|
|
27a4da |
grub_addr_t addr;
|
|
|
27a4da |
grub_err_t err;
|
|
|
27a4da |
@@ -1077,8 +1076,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|
|
27a4da |
goto fail;
|
|
|
27a4da |
|
|
|
27a4da |
size = grub_get_initrd_size (&initrd_ctx);
|
|
|
27a4da |
-
|
|
|
27a4da |
- initrd_pages = (page_align (size) >> 12);
|
|
|
27a4da |
+ aligned_size = ALIGN_UP (size, 4096);
|
|
|
27a4da |
|
|
|
27a4da |
/* Get the highest address available for the initrd. */
|
|
|
27a4da |
if (grub_le_to_cpu16 (linux_params.version) >= 0x0203)
|
|
|
27a4da |
@@ -1106,7 +1104,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|
|
27a4da |
addr_min = (grub_addr_t) prot_mode_target + prot_init_space;
|
|
|
27a4da |
|
|
|
27a4da |
/* Put the initrd as high as possible, 4KiB aligned. */
|
|
|
27a4da |
- addr = (addr_max - size) & ~0xFFF;
|
|
|
27a4da |
+ addr = (addr_max - aligned_size) & ~0xFFF;
|
|
|
27a4da |
|
|
|
27a4da |
if (addr < addr_min)
|
|
|
27a4da |
{
|
|
|
27a4da |
@@ -1117,7 +1115,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|
|
27a4da |
{
|
|
|
27a4da |
grub_relocator_chunk_t ch;
|
|
|
27a4da |
err = grub_relocator_alloc_chunk_align (relocator, &ch,
|
|
|
27a4da |
- addr_min, addr, size, 0x1000,
|
|
|
27a4da |
+ addr_min, addr, aligned_size,
|
|
|
27a4da |
+ 0x1000,
|
|
|
27a4da |
GRUB_RELOCATOR_PREFERENCE_HIGH,
|
|
|
27a4da |
1);
|
|
|
27a4da |
if (err)
|