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