Skip to contentSkip to conversation

grub efi initrd image memory allocation 4K alignment

PATCH In review bibo,mao 1 participant 2 messages Oct 24, 2006 – Oct 25, 2006

lore
Share & tools
lore

bibo,mao

author
#0 lore raw

PATCH 2/3 grub efi initrd image memory allocation 4K alignment

Hi,
On grub efi platform, initrd image memory allocation start
address must be 4K alignment, else it will fail to alloc memory for initrd image.

thanks
bibo,mao

loader/i386/efi/linux.c +0 -1
diff -Nruap grub2.org/loader/i386/efi/linux.c grub2/loader/i386/efi/linux.c
@@ -587,7 +587,6 @@ grub_rescue_cmd_initrd (int argc, char *
       desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
    {
      if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
-	  && desc->physical_start >= addr_min
	  && desc->physical_start + size < addr_max
	  && desc->num_pages >= initrd_pages)
	{
@@ -598,7 +597,7 @@ grub_rescue_cmd_initrd (int argc, char *
	    physical_end = addr_max;

	  if (physical_end > addr)
-	    addr = physical_end - page_align (size);
+	    addr = PAGE_DOWN(physical_end - page_align (size));
	}
    }
author
#1 lore raw

This patch is sent for second time.

thanks
bibo,mao

loader/i386/efi/linux.c +0 -1
diff -Nrup grub2.org/loader/i386/efi/linux.c grub2/loader/i386/efi/linux.c
@@ -587,7 +587,6 @@ grub_rescue_cmd_initrd (int argc, char *
       desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
    {
      if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
-	  && desc->physical_start >= addr_min
	  && desc->physical_start + size < addr_max
	  && desc->num_pages >= initrd_pages)
	{
@@ -598,7 +597,7 @@ grub_rescue_cmd_initrd (int argc, char *
	    physical_end = addr_max;

	  if (physical_end > addr)
-	    addr = physical_end - page_align (size);
+	    addr = GRUB_EFI_PAGE_TRUNC (physical_end - page_align (size));
	}
    }
Quoted 28 lines · Bibo

Hi,
On grub efi platform, initrd image memory allocation start
address must be 4K alignment, else it will fail to alloc memory for initrd image.

thanks
bibo,mao

diff -Nruap grub2.org/loader/i386/efi/linux.c grub2/loader/i386/efi/linux.c

loader/i386/efi/linux.c 2006-10-24 13:25:35.000000000 +0800 renamed from loader/i386/efi/linux.c 2006-10-24 13:24:46.000000000 +0800 +1 -2
@@ -587,7 +587,6 @@ grub_rescue_cmd_initrd (int argc, char *
        desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
     {
       if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
-         && desc->physical_start >= addr_min
          && desc->physical_start + size < addr_max
          && desc->num_pages >= initrd_pages)
        {
@@ -598,7 +597,7 @@ grub_rescue_cmd_initrd (int argc, char *
            physical_end = addr_max;
 
          if (physical_end > addr)
-           addr = physical_end - page_align (size);
+           addr = PAGE_DOWN(physical_end - page_align (size));
        }
     }